| | |
| | | <!-- 中间状态部分,上下结构,包含调机流程的三个步骤 --> |
| | | <view class="middle-section"> |
| | | <view class="item" style="height: 100px;"> |
| | | <h4>说明:先调机,再送检</h4> |
| | | <h4> |
| | | 说明:1.点击'调机开始'后再点击'保存生效' 2.点击'送检呼叫'后再点击'保存生效'<br /> |
| | | 3.主界面首检合格后再点击'保存生效'<br /> |
| | | 4.首检不合格再点击'保存生效'会清空送检时间 |
| | | </h4> |
| | | </view> |
| | | <view class="item"> |
| | | <!-- 调机开始按钮,maStartTime有值时禁用 --> |
| | |
| | | 调机开始 |
| | | </button> |
| | | <!-- 显示调机开始时间 --> |
| | | <input class="txt-inp" v-model="maStartTime" placeholder="点击按钮带出时间" disabled="true" /> |
| | | <input class="txt-inp" v-model="maStartTime" placeholder="点击按钮带出调机时间" disabled="true" /> |
| | | </view> |
| | | <view class="item"> |
| | | <!-- 送检呼叫按钮,maShoutTime有值时禁用 --> |
| | | <!-- 新增逻辑: 只有已填写调机开始时间且送检呼叫时间为空时才允许点击 --> |
| | | <button :class="canShout ? 'btn-blue' : 'btn-disabled'" |
| | | :disabled="!canShout" |
| | | <button :class="maShoutTime ? 'btn-disabled' : 'btn-blue'" |
| | | :disabled="!!maShoutTime" |
| | | @click="handleMaShoutTime"> |
| | | 送检呼叫 |
| | | </button> |
| | | <!-- 显示送检呼叫时间 --> |
| | | <input class="txt-inp" v-model="maShoutTime" placeholder="点击按钮带出时间" disabled="true" /> |
| | | <input class="txt-inp" v-model="maShoutTime" placeholder="点击按钮带出送检时间" disabled="true" /> |
| | | </view> |
| | | <!--<view class="item">--> |
| | | <!-- 调机完成按钮,maEndTime有值时禁用 --> |
| | |
| | | <input class="txt-inp" v-model="maEndTime" placeholder="首次首检确认通过写入" disabled="true" /> |
| | | </view> |
| | | |
| | | <!-- 新增: 首检结果与提示区域(不删除原有注释,仅新增) --> |
| | | <view class="item" style="flex-direction: column;"> |
| | | <label>当前首检结果: {{ latestFirstResult || '未判定' }}</label> |
| | | <label v-if="statusForm.remark" style="color:#00A2E9">{{ statusForm.remark }}</label> |
| | | <label v-if="showForceRebuild" style="color:#d9534f">首检不合格,系统已按后端策略可能自动重建,新单待检。</label> |
| | | <!--启用该功能--> |
| | | <!--新增:检验不合格送检呼叫 按钮(功能与送检呼叫一样,仅在特定 remark 下可以点击)--> |
| | | <view class="item"> |
| | | <!--检验不合格送检呼叫按钮,仅在 remark 为指定文本 且 当前无送检时间 时可点击--> |
| | | <button :class="canFailResend ? 'btn-blue' : 'btn-disabled'" |
| | | :disabled="!canFailResend" |
| | | @click="ReHandleMaShoutTime"> |
| | | <!--检验不合格重新送检呼叫--> |
| | | </button> |
| | | <!--仍复用同一送检时间字段,避免重复状态--> |
| | | <input class="txt-inp" |
| | | v-model="maShoutTime" |
| | | placeholder="首检不合格重新呼叫时点击按钮带出送检时间" |
| | | disabled="true" /> |
| | | </view> |
| | | |
| | | <!-- 新增: 强制重建按钮(可选,传 ForceRebuild=true) --> |
| | | <view class="item" v-if="showForceRebuild"> |
| | | <button :class="forceRebuilding ? 'btn-disabled':'btn-blue'" |
| | | :disabled="forceRebuilding" |
| | | @click="handleForceRebuild"> |
| | | {{ forceRebuilding ? '重建中...' : '强制重建首检单' }} |
| | | </button> |
| | | </view> |
| | | </view> |
| | | |
| | | <!-- 底部保存/取消按钮 --> |
| | |
| | | maShoutTime: '', // 送检呼叫时间 |
| | | maStartTime: '', // 调机开始时间 |
| | | maEndTime: '', // 调机完成时间 |
| | | statusForm: {}, // 工单状态表单数据 |
| | | statusForm: {}, // 工单状态表单数据(包含 remark 字段) |
| | | flag: -1, // 操作标记 |
| | | // 新增: 记录原始数据库时间用于对比避免无变化重复提交 |
| | | origMaStartTime: '', |
| | | origMaShoutTime: '', |
| | | origMaEndTime: '', |
| | | // 新增: 最新首检结果(后端需在 FindByOrderNo 返回) |
| | | latestFirstResult: '', |
| | | // 新增: 强制重建状态 |
| | | forceRebuilding: false |
| | | failedRemark: '首检不合格,送检时间已清空,请重新送检呼叫生成新的首检单' // 首检不合格后由后端返回的提示 |
| | | } |
| | | }, |
| | | computed: { |
| | | // 只有调机开始时间已填写且送检呼叫时间为空时允许呼叫 |
| | | canShout() { |
| | | return !!this.maStartTime && !this.maShoutTime; |
| | | }, |
| | | // 新增: 是否显示强制重建按钮 |
| | | showForceRebuild() { |
| | | return this.latestFirstResult === '不合格'; |
| | | // 满足首检不合格重新呼叫条件且当前尚未重新生成送检时间 => 按钮可用 |
| | | canFailResend() { |
| | | return this.statusForm && |
| | | this.statusForm.remark === this.failedRemark && |
| | | !this.maShoutTime; |
| | | } |
| | | }, |
| | | created() { |
| | |
| | | if (!this.maStartTime) { |
| | | this.setMaStartTime(); |
| | | this.flag = -1; // 调机开始按钮按下时回传的flag=-1 |
| | | // 新增: 调机开始后立即提交写入(仅当与原值不同) |
| | | this.autoSubmitIfChanged(); |
| | | } |
| | | }, |
| | | // 处理送检呼叫按钮点击 |
| | | // 处理送检呼叫按钮点击(不含首检不合格重呼叫) |
| | | handleMaShoutTime() { |
| | | // 增加前置校验:必须先有调机开始时间 |
| | | if (!this.maStartTime) { |
| | | this.$showMessage("请先点击调机开始"); |
| | | return; |
| | | } |
| | | if (!this.maShoutTime) { |
| | | this.stateCheck(1); |
| | | // 新增: 送检呼叫生成时间后立即提交(不合格会触发后端重建) |
| | | this.autoSubmitIfChanged(); |
| | | } |
| | | }, |
| | | // 首检不合格重呼叫:flag = 2 |
| | | ReHandleMaShoutTime() { |
| | | if (!this.maShoutTime && this.canFailResend) { |
| | | this.stateCheck(2); |
| | | } |
| | | }, |
| | | // 处理调机完成按钮点击 |
| | | handleMaEndTime() { |
| | | if (!this.maEndTime) { |
| | | this.setMaEndTime(); |
| | | // 新增: 完成时间写入后提交 |
| | | this.autoSubmitIfChanged(); |
| | | } |
| | | }, |
| | | // 设置调机开始时间为当前时间 |
| | |
| | | refresh() { |
| | | this.findByOrderId(); |
| | | }, |
| | | // 全界面刷新:清空本地状态后重新拉取(不删除任何原有注释) |
| | | fullReload() { |
| | | // 清空当前显示数据,避免旧数据短暂闪烁 |
| | | this.maShoutTime = ''; |
| | | this.maStartTime = ''; |
| | | this.maEndTime = ''; |
| | | this.statusForm = {}; |
| | | this.flag = -1; |
| | | // 下一帧重新获取 |
| | | this.$nextTick(() => { |
| | | this.findByOrderId(); |
| | | }); |
| | | }, |
| | | // 保存并生效,将时间等信息提交到后端 |
| | | save() { |
| | | if (!this.statusForm.id) { |
| | | this.$showMessage("id为空,不允许推送"); |
| | | return; |
| | | } |
| | | // 新增: 若无变化则不调用后端,避免重复重建 |
| | | if (!this.hasTimeChanged()) { |
| | | this.$showMessage("无时间变化,未提交"); |
| | | return; |
| | | } |
| | | this.postChangeMachineTime().then(ok => { |
| | | if (ok) { |
| | | this.$showMessage("保存成功"); |
| | | this.syncOriginalTimes(); |
| | | this.findByOrderId(); // 刷新显示 |
| | | } else { |
| | | this.$showMessage("呼叫失败"); |
| | | this.cancel(); |
| | | } |
| | | }); |
| | | }, |
| | | // 取消操作,恢复为上次保存的数据 |
| | | cancel() { |
| | | this.maShoutTime = this.origMaShoutTime; |
| | | this.maStartTime = this.origMaStartTime; |
| | | this.maEndTime = this.origMaEndTime; |
| | | }, |
| | | // 送检呼叫,item=1时设置送检呼叫时间 |
| | | stateCheck(item) { |
| | | switch (item) { |
| | | case 0: |
| | | break; |
| | | case 1: |
| | | this.maShoutTime = this.$getDate('yyyy-mm-dd hh24:mi:ss'); |
| | | this.flag = -1; // 送检呼叫有值后,flag始终为-1 |
| | | break; |
| | | case 2: |
| | | break; |
| | | } |
| | | this.flag = item; |
| | | }, |
| | | // 新增: 判断时间是否有变化 |
| | | hasTimeChanged() { |
| | | return this.maStartTime !== this.origMaStartTime || |
| | | this.maShoutTime !== this.origMaShoutTime || |
| | | this.maEndTime !== this.origMaEndTime; |
| | | }, |
| | | // 新增: 自动提交(按钮生成时间后调用)仅在有变化时 |
| | | autoSubmitIfChanged() { |
| | | if (!this.statusForm.id) return; |
| | | if (!this.hasTimeChanged()) return; |
| | | this.postChangeMachineTime().then(ok => { |
| | | if (ok) { |
| | | this.$showMessage("提交成功"); |
| | | this.syncOriginalTimes(); |
| | | this.findByOrderId(); |
| | | } |
| | | }); |
| | | }, |
| | | // 新增: 同步原始时间快照 |
| | | syncOriginalTimes() { |
| | | this.origMaStartTime = this.maStartTime; |
| | | this.origMaShoutTime = this.maShoutTime; |
| | | this.origMaEndTime = this.maEndTime; |
| | | }, |
| | | // 新增: 强制重建触发 |
| | | handleForceRebuild() { |
| | | if (!this.statusForm.id) { |
| | | this.$showMessage("id为空,不允许重建"); |
| | | return; |
| | | } |
| | | this.forceRebuilding = true; |
| | | // 强制重建前可以重新生成送检时间(确保首检单新快照) |
| | | this.maShoutTime = this.$getDate('yyyy-mm-dd hh24:mi:ss'); |
| | | this.postChangeMachineTime(true).then(ok => { |
| | | this.forceRebuilding = false; |
| | | if (ok) { |
| | | this.$showMessage("强制重建成功"); |
| | | this.syncOriginalTimes(); |
| | | this.findByOrderId(); |
| | | } else { |
| | | this.$showMessage("强制重建失败"); |
| | | } |
| | | }); |
| | | }, |
| | | // 新增: 封装后端请求(支持 ForceRebuild) |
| | | postChangeMachineTime(forceRebuild = false) { |
| | | return this.$post({ |
| | | this.$post({ |
| | | url: "/MesOrderSta/ChangeMachineTime", |
| | | data: { |
| | | maStartTime: this.maStartTime, |
| | |
| | | maEndTime: this.maEndTime, |
| | | id: this.statusForm.id, |
| | | orderId: this.orderId, |
| | | orderNo: this.orderNo, |
| | | machineNo: this.machineNo, |
| | | flag: this.flag, |
| | | // 可选扩展字段(后端方法中动态接收) |
| | | ForceRebuild: forceRebuild |
| | | flag: this.flag |
| | | } |
| | | }).then(res => { |
| | | // 后端返回结构假设:{ success:true/false, tbBillList: {...}, latestFirstResult:'合格/不合格' } |
| | | if (res.data) { |
| | | if (res.data.tbBillList) { |
| | | this.statusForm = res.data.tbBillList; |
| | | this.latestFirstResult = res.data.latestFirstResult || ''; |
| | | } |
| | | return res.data.success !== false; // 默认成功 |
| | | if (res.data.tbBillList) { |
| | | this.$showMessage("呼叫成功"); |
| | | this.findByOrderId(); |
| | | } else { |
| | | this.$showMessage("呼叫失败"); |
| | | this.cancel(); |
| | | } |
| | | return false; |
| | | }).catch(() => false); |
| | | }) |
| | | }, |
| | | // 取消操作,恢复为上次保存的数据 |
| | | cancel() { |
| | | this.maShoutTime = this.statusForm.maShoutTime; |
| | | this.maStartTime = this.statusForm.maStartTime; |
| | | this.maEndTime = this.statusForm.maEndTime; |
| | | }, |
| | | // 送检呼叫,item=1时设置送检呼叫时间 |
| | | // 送检呼叫与重新送检呼叫以及调机开始对应的 flag 值 |
| | | // flag 说明:-1 = 调机开始;1 = 首次送检呼叫;2 = 不合格重新送检呼叫 |
| | | stateCheck(item) { |
| | | switch (item) { |
| | | case 0: |
| | | break; |
| | | case 1:// 首次送检呼叫 |
| | | this.maShoutTime = this.$getDate('yyyy-mm-dd hh24:mi:ss'); |
| | | this.flag = -1; // 送检呼叫有值后,flag始终为-1 |
| | | break; |
| | | case 2:// 检验不合格重新送检呼叫 |
| | | this.maShoutTime = this.$getDate('yyyy-mm-dd hh24:mi:ss'); |
| | | //this.flag = -1; // 送检呼叫有值后,flag始终为-1 |
| | | break; |
| | | default: |
| | | // 其它值不处理 |
| | | break; |
| | | } |
| | | this.flag = item; |
| | | }, |
| | | // 根据工单号/ID获取工单状态数据 |
| | | findByOrderId() { |
| | |
| | | this.maShoutTime = res.data.tbBillList.maShoutTime; |
| | | this.maStartTime = res.data.tbBillList.maStartTime; |
| | | this.maEndTime = res.data.tbBillList.maEndTime; |
| | | // 新增: 同步首检结果、原始时间快照 |
| | | this.latestFirstResult = res.data.tbBillList.latestFirstResult || res.data.latestFirstResult || ''; |
| | | this.syncOriginalTimes(); |
| | | }) |
| | | } |
| | | } |