| | |
| | | confirmTool() { |
| | | this.showToolDialog = false; |
| | | }, |
| | | async handleUpTool() { |
| | | async handleUpTool() { |
| | | if (!this.workOrderNo) { |
| | | this.$showMessage('工单号不能为空'); |
| | | return; |
| | | } |
| | | if (!this.machineNo) { |
| | | this.$showMessage('机台号不能为空'); |
| | | return; |
| | | } |
| | | if (!this.selectedToolNo) { |
| | | this.$showMessage('刀具编号不能为空'); |
| | | return; |
| | | } |
| | | if (!this.useLimitInput) { |
| | | this.$showMessage('使用上限不能为空'); |
| | | return; |
| | | } |
| | | const useLimit = Number(this.useLimitInput); |
| | | if (isNaN(useLimit) || useLimit <= 0) { |
| | | this.$showMessage('请输入有效的使用上限'); |
| | | return; |
| | | } |
| | | const payload = { |
| | | workOrderNo: this.workOrderNo, // 工单号 |
| | | machineNo: this.machineNo, // 机台编号 |
| | |
| | | this.$showMessage(res.message || '上刀提交失败'); |
| | | } |
| | | }, |
| | | async handleDownTool() { |
| | | async handleDownTool() { |
| | | if (!this.workOrderNo) { |
| | | this.$showMessage('工单号不能为空'); |
| | | return; |
| | | } |
| | | if (!this.machineNo) { |
| | | this.$showMessage('机台号不能为空'); |
| | | return; |
| | | } |
| | | if (!this.selectedToolNo) { |
| | | this.$showMessage('刀具编号不能为空'); |
| | | return; |
| | | } |
| | | if (!this.useLimitInput) { |
| | | this.$showMessage('使用上限不能为空'); |
| | | return; |
| | | } |
| | | const useLimit = Number(this.useLimitInput); |
| | | if (isNaN(useLimit) || useLimit <= 0) { |
| | | this.$showMessage('请输入有效的使用上限'); |
| | | return; |
| | | } |
| | | const payload = { |
| | | workOrderNo: this.workOrderNo, |
| | | machineNo: this.machineNo, |
| | |
| | | this.toolName = ''; |
| | | this.toolModel = ''; |
| | | }, |
| | | setUseLimit() { |
| | | // 保存使用上限逻辑,实际应调用后端接口 |
| | | this.$showMessage('使用上限已保存(示例)'); |
| | | } |
| | | async fetchFormData() { |
| | | const payload = { |
| | | workOrderNo: this.workOrderNo && this.workOrderNo.trim() !== '' ? this.workOrderNo : null, |
| | | machineNo: this.machineNo && this.machineNo.trim() !== '' ? this.machineNo : null, |
| | | }; |
| | | const res = await this.$post({ |
| | | url: '/api/MesCutterLedger/GetFormData', // 加上 /api 前缀 |
| | | data: JSON.stringify(payload), |
| | | headers: { 'Content-Type': 'application/json' } |
| | | }); |
| | | if (res.status === 0) { |
| | | this.toolRecords = res.data; |
| | | } else { |
| | | this.$showMessage(res.message || '获取表单数据失败'); |
| | | } |
| | | } |
| | | }, |
| | | mounted() { |
| | | // 页面加载时拉取全部刀具 |
| | | this.fetchTools(''); |
| | | this.machineNo = uni.getStorageSync('machineNo') || '';// 读取本地缓存的机台编号 |
| | | this.workOrderNo = uni.getStorageSync('daa001') || ''; // 读取本地缓存的工单编号 |
| | | } |
| | | mounted() { |
| | | this.fetchTools(''); |
| | | this.machineNo = uni.getStorageSync('machineNo') || ''; |
| | | this.workOrderNo = uni.getStorageSync('daa001') || ''; |
| | | if (this.machineNo && this.workOrderNo) {this.fetchFormData();} |
| | | } |
| | | }; |
| | | </script> |
| | | |