| | |
| | | } |
| | | |
| | | const staffNo = this.tiaojiStaffNo.split(':')[0]; |
| | | const totalQty = okQty + badQty; // 试产总数 = 良品数 + 不良品数 |
| | | const currentCjNum = this.order?.currentCjNum || 0; |
| | | |
| | | // 调用报试产数接口(使用报工界面的接口) |
| | | const payload = { |
| | | orderNo: this.workOrderNo, |
| | | orderId: this.orderId, // 需要从工单数据中获取 |
| | | bf: totalQty, // 试产总数 |
| | | bf: badQty, // bf传递不良品数 |
| | | staffNo: staffNo, |
| | | initCjNum: this.order?.initCjNum || 0, |
| | | currentCjNum: this.order?.currentCjNum || 0, |
| | | initCjNum: currentCjNum - badQty - okQty, // initCjNum = currentCjNum - bf - 良品数 |
| | | currentCjNum: currentCjNum, |
| | | type: 'tiaoji', // 标识为调机报工 |
| | | tiaojiOkQty: okQty, // 新增:良品数 |
| | | tiaojiBadQty: badQty // 新增:不良品数 |
| | |
| | | // 刷新数据 |
| | | await this.fetchFormData(); |
| | | await this.fetchDefaultToolFromWorkOrder(); |
| | | |
| | | // 新增:自动处理调机送检界面的按钮逻辑 |
| | | await this.autoHandleMachineInspection(); |
| | | } catch (err) { |
| | | console.error('调机报工错误:', err); |
| | | this.$showMessage('调机报工失败,请检查网络'); |
| | |
| | | } |
| | | }, |
| | | |
| | | // 新增:自动处理调机送检界面的按钮逻辑 |
| | | async autoHandleMachineInspection() { |
| | | try { |
| | | // 1. 使用 FindByOrderNo 获取调机送检界面的三个时间 |
| | | const statusRes = await this.$post({ |
| | | url: '/MesOrderSta/FindByOrderNo', |
| | | data: { |
| | | orderId: this.orderId, |
| | | orderNo: this.workOrderNo |
| | | } |
| | | }); |
| | | |
| | | if (!statusRes || !statusRes.data || !statusRes.data.tbBillList) { |
| | | console.error('获取工单状态失败'); |
| | | return; |
| | | } |
| | | |
| | | const statusForm = statusRes.data.tbBillList; |
| | | const maStartTime = statusForm.maStartTime; |
| | | const maShoutTime = statusForm.maShoutTime; |
| | | const maEndTime = statusForm.maEndTime; |
| | | |
| | | // 2. 准备需要更新的时间数据 |
| | | let needSave = false; |
| | | let updateData = { |
| | | id: statusForm.id, |
| | | orderId: this.orderId, |
| | | machineNo: this.machineNo, |
| | | flag: -1 |
| | | }; |
| | | |
| | | // 3. 从上到下根据显示框里是否有时间依次设置 |
| | | // 如果调机开始时间为空,设置调机开始时间 |
| | | if (!maStartTime) { |
| | | updateData.maStartTime = this.$getDate('yyyy-mm-dd hh24:mi:ss'); |
| | | updateData.flag = -1; // 调机开始的flag=-1 |
| | | needSave = true; |
| | | } else { |
| | | updateData.maStartTime = maStartTime; |
| | | } |
| | | |
| | | // 如果送检呼叫时间为空,设置送检呼叫时间 |
| | | if (!maShoutTime) { |
| | | updateData.maShoutTime = this.$getDate('yyyy-mm-dd hh24:mi:ss'); |
| | | updateData.flag = 1; // 首次送检呼叫的flag=1 |
| | | needSave = true; |
| | | } else { |
| | | updateData.maShoutTime = maShoutTime; |
| | | } |
| | | |
| | | // 调机完成时间保持不变 |
| | | updateData.maEndTime = maEndTime || ''; |
| | | |
| | | // 4. 如果有需要更新的时间,调用保存接口 |
| | | if (needSave) { |
| | | const saveRes = await this.$post({ |
| | | url: '/MesOrderSta/ChangeMachineTime', |
| | | data: updateData |
| | | }); |
| | | |
| | | if (saveRes && saveRes.data && saveRes.data.tbBillList) { |
| | | console.log('调机送检界面时间自动更新成功'); |
| | | } else { |
| | | console.error('调机送检界面时间自动更新失败'); |
| | | } |
| | | } |
| | | } catch (err) { |
| | | console.error('自动处理调机送检界面失败:', err); |
| | | // 不中断主流程,只记录错误 |
| | | } |
| | | }, |
| | | |
| | | // 新增:获取调机师傅列表 |
| | | async fetchTiaojiStaff() { |
| | | try { |