| | |
| | | <template> |
| | | <div class="page"> |
| | | <div class="top-right"> |
| | | <view class="page"> |
| | | <!--调机送检--> |
| | | <!-- 右上角刷新按钮 --> |
| | | <view class="top-right"> |
| | | <button class="refresh-btn" @click="refresh">刷新</button> |
| | | </div> |
| | | </view> |
| | | |
| | | <div class="middle-section"> |
| | | <div class="item" style="height:100px;"> |
| | | <h4>说明:先调机,再送检</h4> |
| | | </div> |
| | | |
| | | <!-- 调机开始 --> |
| | | <div class="item"> |
| | | <button :class="canStart ? 'btn-blue' : 'btn-disabled'" |
| | | :disabled="!canStart" |
| | | @click="onStartClick"> |
| | | <!-- 中间状态部分,上下结构,包含调机流程的三个步骤 --> |
| | | <view class="middle-section"> |
| | | <view class="item" style="height: 100px;"> |
| | | <h4> |
| | | <!--说明: |
| | | 1.点击'调机开始'、'送检呼叫'后再点击'保存生效'<br /> |
| | | 2.主界面首检合格后再点击'保存生效'<br /> |
| | | 3.首检不合格再点击'保存生效'会清空送检时间<br /> |
| | | 4.清空送检时间后点击‘检验不合格重新送检呼叫’再保存--> |
| | | </h4> |
| | | </view> |
| | | <view class="item"> |
| | | <!-- 调机开始按钮,maStartTime有值时禁用 --> |
| | | <button :class="maStartTime ? 'btn-disabled' : 'btn-blue'" |
| | | :disabled="!!maStartTime" |
| | | @click="handleMaStartTime"> |
| | | 调机开始 |
| | | </button> |
| | | <input class="txt-inp" v-model="maStartTime" placeholder="点击按钮带出时间" disabled /> |
| | | </div> |
| | | |
| | | <!-- 送检呼叫 --> |
| | | <div class="item"> |
| | | <button :class="canShout ? 'btn-blue' : 'btn-disabled'" |
| | | :disabled="!canShout" |
| | | @click="onShoutClick"> |
| | | <!-- 显示调机开始时间 --> |
| | | <input class="txt-inp" v-model="maStartTime" placeholder="点击按钮带出调机时间" disabled="true" /> |
| | | </view> |
| | | <view class="item"> |
| | | <!-- 送检呼叫按钮,maShoutTime有值时禁用 --> |
| | | <button :class="maShoutTime ? 'btn-disabled' : 'btn-blue'" |
| | | :disabled="!!maShoutTime" |
| | | @click="handleMaShoutTime"> |
| | | 送检呼叫 |
| | | </button> |
| | | <input class="txt-inp" v-model="maShoutTime" placeholder="点击按钮带出时间" disabled /> |
| | | </div> |
| | | <!-- 显示送检呼叫时间 --> |
| | | <input class="txt-inp" v-model="maShoutTime" placeholder="点击按钮带出送检时间" disabled="true" /> |
| | | </view> |
| | | <!--<view class="item">--> |
| | | <!-- 调机完成按钮,maEndTime有值时禁用 --> |
| | | <!--<button :class="maEndTime ? 'btn-disabled' : 'btn-blue'" |
| | | :disabled="!!maEndTime" |
| | | @click="handleMaEndTime"> |
| | | 调机完成(=检验通过) |
| | | </button>--> |
| | | <!-- 显示调机完成时间 --> |
| | | <!--<input class="txt-inp" v-model="maEndTime" placeholder="首次首检确认通过写入" disabled="true" /> |
| | | </view>--> |
| | | <view class="item"> |
| | | <button class="btn-disabled" disabled> |
| | | 调机完成(=检验通过=开工) |
| | | </button> |
| | | <input class="txt-inp" v-model="maEndTime" placeholder="首次首检确认通过写入" disabled="true" /> |
| | | </view> |
| | | |
| | | <!-- 调机完成(后端合格自动写) --> |
| | | <div class="item"> |
| | | <button class="btn-disabled" disabled>调机完成(=检验通过=开工)</button> |
| | | <input class="txt-inp" v-model="maEndTime" placeholder="首次首检合格后写入" disabled /> |
| | | </div> |
| | | <!--启用该功能--> |
| | | <!--新增:检验不合格送检呼叫 按钮(功能与送检呼叫一样,仅在特定 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> |
| | | |
| | | <!-- 首检结果与提示 --> |
| | | <div class="item" style="flex-direction:column;"> |
| | | <label>当前首检结果: {{ latestFirstResult || '未判定' }}</label> |
| | | <label v-if="remark" style="color:#00A2E9">{{ remark }}</label> |
| | | </div> |
| | | </div> |
| | | </view> |
| | | |
| | | <!-- 底部操作 --> |
| | | <div class="bottom-section"> |
| | | <button :class="hasUnsaved ? 'save-btn':'btn-disabled'" |
| | | :disabled="!hasUnsaved" |
| | | @click="save"> |
| | | 保存并生效 |
| | | </button> |
| | | <!-- 底部保存/取消按钮 --> |
| | | <view class="bottom-section"> |
| | | <!-- 只有调机完成未填写时才可保存 --> |
| | | <button class="save-btn" v-if="!maEndTime" @click="save">保存并生效</button> |
| | | <!-- 已完成时保存按钮禁用 --> |
| | | <button class="btn-disabled" v-else>保存并生效</button> |
| | | <button class="cancel-btn" @click="cancel">取消</button> |
| | | </div> |
| | | </div> |
| | | </view> |
| | | |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | export default { |
| | | props: { |
| | | orderNo: String, |
| | | orderId: Number, |
| | | machineNo: String |
| | | orderNo: String, // 工单号 |
| | | orderId: Number, // 工单ID |
| | | machineNo: String // 机台号 |
| | | }, |
| | | data() { |
| | | return { |
| | | statusForm: {}, |
| | | maStartTime: '', |
| | | maShoutTime: '', |
| | | maEndTime: '', |
| | | remark: '', |
| | | latestFirstResult: '', |
| | | // 原始快照 |
| | | origStart: '', |
| | | origShout: '', |
| | | origEnd: '', |
| | | submitting: false |
| | | }; |
| | | maShoutTime: '', // 送检呼叫时间 |
| | | maStartTime: '', // 调机开始时间 |
| | | maEndTime: '', // 调机完成时间 |
| | | statusForm: {}, // 工单状态表单数据(包含 remark 字段) |
| | | flag: -1, // 操作标记 |
| | | failedRemark: '首检不合格,送检时间已清空,请重新送检呼叫生成新的首检单' // 首检不合格后由后端返回的提示 |
| | | } |
| | | }, |
| | | computed: { |
| | | canStart() { |
| | | // 只在还没有开始时间时可点击 |
| | | return !this.maStartTime; |
| | | }, |
| | | canShout() { |
| | | // 有开始且目前没有送检时间时可呼叫 |
| | | return !!this.maStartTime && !this.maShoutTime; |
| | | }, |
| | | hasUnsaved() { |
| | | return (this.maStartTime !== this.origStart || |
| | | this.maShoutTime !== this.origShout); |
| | | // 满足首检不合格重新呼叫条件且当前尚未重新生成送检时间 => 按钮可用 |
| | | canFailResend() { |
| | | return this.statusForm && |
| | | this.statusForm.remark === this.failedRemark && |
| | | !this.maShoutTime; |
| | | } |
| | | }, |
| | | created() { |
| | | this.refresh(); |
| | | // 组件创建时自动加载工单数据 |
| | | if (!this.orderId && !this.orderNo) { |
| | | return; |
| | | } |
| | | this.findByOrderId(); |
| | | }, |
| | | methods: { |
| | | getNow() { |
| | | // 简易本地时间格式化,保持与后端需要的 yyyy-MM-dd HH:mm:ss 一致 |
| | | const pad = n => (n < 10 ? '0' + n : '' + n); |
| | | const d = new Date(); |
| | | return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`; |
| | | // 处理调机开始按钮点击 |
| | | handleMaStartTime() { |
| | | if (!this.maStartTime) { |
| | | this.setMaStartTime(); |
| | | this.flag = -1; // 调机开始按钮按下时回传的flag=-1 |
| | | } |
| | | }, |
| | | onStartClick() { |
| | | if (!this.canStart) return; |
| | | this.maStartTime = this.getNow(); |
| | | // 处理送检呼叫按钮点击(不含首检不合格重呼叫) |
| | | handleMaShoutTime() { |
| | | if (!this.maShoutTime) { |
| | | this.stateCheck(1); |
| | | } |
| | | }, |
| | | onShoutClick() { |
| | | if (!this.canShout) return; |
| | | this.maShoutTime = this.getNow(); |
| | | // 首检不合格重呼叫:flag = 2 |
| | | ReHandleMaShoutTime() { |
| | | if (!this.maShoutTime && this.canFailResend) { |
| | | this.stateCheck(2); |
| | | } |
| | | }, |
| | | // 处理调机完成按钮点击 |
| | | handleMaEndTime() { |
| | | if (!this.maEndTime) { |
| | | this.setMaEndTime(); |
| | | } |
| | | }, |
| | | // 设置调机开始时间为当前时间 |
| | | setMaStartTime() { |
| | | this.maStartTime = this.$getDate('yyyy-mm-dd hh24:mi:ss'); |
| | | }, |
| | | // 设置调机完成时间为当前时间 |
| | | setMaEndTime() { |
| | | console.log('调机完成按钮被点击'); |
| | | this.maEndTime = this.$getDate('yyyy-mm-dd hh24:mi:ss'); |
| | | }, |
| | | // 刷新工单数据(局部刷新当前组件) |
| | | refresh() { |
| | | if (!this.orderId) return; |
| | | this.findByOrderId(); |
| | | }, |
| | | // 保存并生效,将时间等信息提交到后端 |
| | | // 变更:返回 Promise;成功后局部刷新(调用 findByOrderId)而不是整页 reload |
| | | save() { |
| | | if (!this.statusForm.id) { |
| | | this.$showMessage("id为空,不允许推送"); |
| | | return Promise.resolve(); |
| | | } |
| | | return this.$post({ |
| | | url: "/MesOrderSta/ChangeMachineTime", |
| | | data: { |
| | | maStartTime: this.maStartTime, |
| | | maShoutTime: this.maShoutTime, |
| | | maEndTime: this.maEndTime, |
| | | id: this.statusForm.id, |
| | | orderId: this.orderId, |
| | | machineNo: this.machineNo, |
| | | flag: this.flag |
| | | } |
| | | }).then(res => { |
| | | if (res && res.data && res.data.tbBillList) { |
| | | this.$showMessage("呼叫成功"); |
| | | |
| | | // 关键修改:清空 flag 的值 |
| | | this.flag = -1; // 或者根据业务需求设置为其他初始值 |
| | | |
| | | // 方案1:使用uni-app的页面刷新方法 |
| | | // 方法1:触发下拉刷新(如果页面支持) |
| | | if (uni.startPullDownRefresh) { |
| | | uni.startPullDownRefresh(); |
| | | // 2秒后停止刷新 |
| | | setTimeout(() => { |
| | | uni.stopPullDownRefresh(); |
| | | }, 2000); |
| | | } |
| | | |
| | | // 方法2:重新调用页面的onLoad方法(推荐) |
| | | const pages = getCurrentPages(); |
| | | const currentPage = pages[pages.length - 1]; |
| | | if (currentPage && currentPage.onLoad) { |
| | | // 保存当前页面参数 |
| | | const pageOptions = currentPage.options || {}; |
| | | // 重新加载页面数据 |
| | | currentPage.onLoad(pageOptions); |
| | | } |
| | | |
| | | // 方法3:同时刷新组件数据 |
| | | this.findByOrderId(); |
| | | |
| | | } else { |
| | | this.$showMessage("呼叫失败"); |
| | | this.cancel(); |
| | | } |
| | | return res; |
| | | }).catch(err => { |
| | | console.error('保存失败:', err); |
| | | this.$showMessage("保存时发生错误"); |
| | | throw err; |
| | | }); |
| | | }, |
| | | // 取消操作,恢复为上次保存的数据 |
| | | 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.$post({ |
| | | url: "/MesOrderSta/FindByOrderNo", |
| | | data: { orderId: this.orderId, orderNo: this.orderNo } |
| | | }).then(res => { |
| | | const d = res.data; |
| | | if (!d) return; |
| | | const sta = d.tbBillList || {}; |
| | | this.statusForm = sta; |
| | | this.maStartTime = sta.maStartTime || ''; |
| | | this.maShoutTime = sta.maShoutTime || ''; |
| | | this.maEndTime = sta.maEndTime || ''; |
| | | this.remark = sta.remark || d.remark || ''; |
| | | this.latestFirstResult = sta.latestFirstResult || d.latestFirstResult || ''; |
| | | this.syncOrig(); |
| | | // 若后端因不合格清空送检时间,送检按钮会重新可用 |
| | | }); |
| | | }, |
| | | syncOrig() { |
| | | this.origStart = this.maStartTime; |
| | | this.origShout = this.maShoutTime; |
| | | this.origEnd = this.maEndTime; |
| | | }, |
| | | cancel() { |
| | | this.maStartTime = this.origStart; |
| | | this.maShoutTime = this.origShout; |
| | | this.maEndTime = this.origEnd; |
| | | }, |
| | | save() { |
| | | if (!this.statusForm.id) { |
| | | this.$showMessage("状态ID为空,不能保存"); |
| | | return; |
| | | } |
| | | if (!this.hasUnsaved) { |
| | | this.$showMessage("无变更"); |
| | | return; |
| | | } |
| | | if (this.submitting) return; |
| | | this.submitting = true; |
| | | this.$post({ |
| | | url: "/MesOrderSta/ChangeMachineTime", |
| | | data: { |
| | | id: this.statusForm.id, |
| | | // 按当前逻辑直接传已有时间,后端自行判定是开始还是送检 |
| | | maStartTime: this.maStartTime || null, |
| | | maShoutTime: this.maShoutTime || null, |
| | | maEndTime: null, // 前端不主动写完成 |
| | | orderId: this.orderId, |
| | | orderNo: this.orderNo, |
| | | machineNo: this.machineNo |
| | | orderNo: this.orderNo |
| | | } |
| | | }).then(res => { |
| | | this.submitting = false; |
| | | if (res.data) { |
| | | const sta = res.data.tbBillList || {}; |
| | | // 取回可能被后端清空或补写的字段 |
| | | this.maStartTime = sta.maStartTime || ''; |
| | | this.maShoutTime = sta.maShoutTime || ''; |
| | | this.maEndTime = sta.maEndTime || ''; |
| | | this.remark = sta.remark || res.data.remark || ''; |
| | | this.latestFirstResult = sta.latestFirstResult || res.data.latestFirstResult || ''; |
| | | this.syncOrig(); |
| | | this.$showMessage("保存成功"); |
| | | } else { |
| | | this.$showMessage("保存失败"); |
| | | } |
| | | }).catch(() => { |
| | | this.submitting = false; |
| | | this.$showMessage("网络异常"); |
| | | }); |
| | | this.statusForm = res.data.tbBillList; |
| | | this.maShoutTime = res.data.tbBillList.maShoutTime; |
| | | this.maStartTime = res.data.tbBillList.maStartTime; |
| | | this.maEndTime = res.data.tbBillList.maEndTime; |
| | | }) |
| | | } |
| | | } |
| | | }, |
| | | mounted() { |
| | | // 页面加载时,启动定时器,每隔30秒自动保存 |
| | | this.autoSaveTimer = setInterval(() => { |
| | | // 1. 调机完成时间有了就不自动保存 |
| | | if (this.maEndTime) { |
| | | return; |
| | | } |
| | | // 2. 送检时间为空也不自动保存 |
| | | if (!this.maShoutTime) { |
| | | return; |
| | | } |
| | | this.save(); // 满足条件才自动保存 |
| | | }, 1 * 30 * 1000); // 30秒 |
| | | }, |
| | | beforeDestroy() { |
| | | // 页面卸载时清理定时器 |
| | | clearInterval(this.autoSaveTimer); |
| | | }, |
| | | }; |
| | | </script> |
| | | |
| | | <style scoped> |
| | | .page { |
| | | padding: 2vh; |
| | | display: flex; |
| | | flex-direction: column; |
| | | height: 100%; |
| | | box-sizing: border-box; |
| | | } |
| | | /* 页面整体布局 */ |
| | | .page { |
| | | padding: 8px; |
| | | display: flex; |
| | | flex-direction: column; |
| | | justify-content: space-between; |
| | | box-sizing: border-box; |
| | | height: 100%; |
| | | } |
| | | |
| | | .top-right { |
| | | position: absolute; |
| | | top: 10px; |
| | | right: 50px; |
| | | } |
| | | /* 右上角刷新按钮 */ |
| | | .top-right { |
| | | position: absolute; |
| | | top: 8px; |
| | | right: 40px; |
| | | width: 200px; |
| | | z-index: 1000; |
| | | } |
| | | |
| | | .refresh-btn { |
| | | padding: 10px; |
| | | background: #00A2E9; |
| | | color: #fff; |
| | | border: none; |
| | | font-size: 1.5vw; |
| | | border-radius: 5px; |
| | | } |
| | | .refresh-btn { |
| | | padding: 8px 16px; |
| | | background-color: #00A2E9; |
| | | color: white; |
| | | border: none; |
| | | font-size: 24px; |
| | | border-radius: 5px; |
| | | } |
| | | |
| | | .middle-section { |
| | | display: flex; |
| | | flex-direction: column; |
| | | margin-bottom: 4vh; |
| | | } |
| | | label { |
| | | margin-right: 10px; |
| | | font-size: 24px; |
| | | } |
| | | |
| | | .item { |
| | | display: flex; |
| | | flex-direction: row; |
| | | align-items: flex-start; |
| | | margin-bottom: 2vh; |
| | | } |
| | | /* 中间状态部分布局 */ |
| | | .middle-section { |
| | | display: flex; |
| | | flex-direction: column; |
| | | margin-bottom: 8px; |
| | | } |
| | | |
| | | button { |
| | | width: 100%; |
| | | padding: 1.5vh; |
| | | font-size: 1.5vw; |
| | | border: none; |
| | | text-align: center; |
| | | } |
| | | .item { |
| | | display: flex; |
| | | flex-direction: row; |
| | | align-items: center; |
| | | margin-bottom: 10px; |
| | | gap: 10px; |
| | | } |
| | | |
| | | .btn-blue { |
| | | background: #00A2E9; |
| | | color: #fff; |
| | | } |
| | | .item h4 { |
| | | font-size: 24px; |
| | | line-height: 1.4; |
| | | margin: 0; |
| | | padding: 5px 0; |
| | | } |
| | | |
| | | .btn-disabled { |
| | | background: #ccc; |
| | | color: #fff; |
| | | } |
| | | button { |
| | | width: 50%; |
| | | flex-shrink: 0; |
| | | padding: 10px; |
| | | font-size: 24px; |
| | | border: none; |
| | | text-align: center; |
| | | min-height: 40px; |
| | | } |
| | | |
| | | .txt-inp { |
| | | height: 8vh; |
| | | padding: 1vh; |
| | | font-size: 1.5vw; |
| | | width: 100%; |
| | | box-sizing: border-box; |
| | | margin-left: 1vw; |
| | | } |
| | | .btn-disabled { |
| | | background-color: #ccc; |
| | | color: white; |
| | | } |
| | | |
| | | .bottom-section { |
| | | display: flex; |
| | | justify-content: space-between; |
| | | margin-top: 4vh; |
| | | } |
| | | .btn-blue { |
| | | background-color: #00A2E9; |
| | | color: white; |
| | | } |
| | | |
| | | .save-btn, .cancel-btn { |
| | | width: 48%; |
| | | padding: 1.5vh; |
| | | background: #00A2E9; |
| | | color: #fff; |
| | | font-size: 1.6vw; |
| | | border: none; |
| | | } |
| | | input { |
| | | margin-top: 0; |
| | | padding: 8px; |
| | | font-size: 24px; |
| | | border: 1px solid #ccc; |
| | | width: 50%; |
| | | flex-grow: 1; |
| | | box-sizing: border-box; |
| | | } |
| | | |
| | | .cancel-btn { |
| | | background: #0077A6; |
| | | } |
| | | /* 底部保存/取消按钮布局 */ |
| | | .bottom-section { |
| | | display: flex; |
| | | justify-content: space-between; |
| | | margin-top: 10px; |
| | | padding-top: 10px; |
| | | } |
| | | |
| | | .save-btn, |
| | | .cancel-btn { |
| | | width: 48%; |
| | | padding: 12px; |
| | | background-color: #00A2E9; |
| | | color: white; |
| | | font-size: 24px; |
| | | border: none; |
| | | text-align: center; |
| | | min-height: 45px; |
| | | } |
| | | |
| | | .txt-inp { |
| | | height: 80px; /* 增大高度 */ |
| | | padding: 12px; /* 增大内边距 */ |
| | | font-size: 24px; /* 增大字体 */ |
| | | width: 50%; |
| | | flex-grow: 1; |
| | | box-sizing: border-box; |
| | | margin-top: 0; |
| | | } |
| | | |
| | | /* 针对1280*717屏幕的特定优化 */ |
| | | @media screen and (max-width: 1280px) and (max-height: 800px) { |
| | | .page { |
| | | padding: 6px; |
| | | } |
| | | |
| | | .middle-section { |
| | | margin-bottom: 6px; |
| | | } |
| | | |
| | | .item { |
| | | margin-bottom: 8px; |
| | | } |
| | | |
| | | .item h4 { |
| | | font-size: 24px; |
| | | padding: 3px 0; |
| | | } |
| | | |
| | | button { |
| | | padding: 8px; |
| | | font-size: 24px; |
| | | min-height: 38px; |
| | | } |
| | | |
| | | .txt-inp { |
| | | height: 46px; |
| | | padding: 10px; |
| | | font-size: 24px; |
| | | } |
| | | |
| | | .bottom-section { |
| | | margin-top: 8px; |
| | | padding-top: 8px; |
| | | } |
| | | |
| | | .save-btn, |
| | | .cancel-btn { |
| | | padding: 10px; |
| | | font-size: 24px; |
| | | min-height: 42px; |
| | | } |
| | | |
| | | input { |
| | | font-size: 24px; |
| | | } |
| | | |
| | | .refresh-btn { |
| | | font-size: 24px; |
| | | } |
| | | |
| | | label { |
| | | font-size: 24px; |
| | | } |
| | | } |
| | | </style> |