快乐的昕的电脑
2025-10-11 614aa1e15c8ca6c5a3152716bd303f0bad01682c
components/mold.vue
@@ -175,7 +175,28 @@
         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,       // 机台编号
@@ -194,7 +215,28 @@
                    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,
@@ -223,11 +265,28 @@
            this.$showMessage('使用上限已保存(示例)');
         }
      },
        methods: {
            async fetchFormData() {
                const res = await this.$post({
                    url: '/MesCutterLedger/GetFormData',
                    data: JSON.stringify({
                        workOrderNo: this.workOrderNo,
                        machineNo: this.machineNo
                    }),
                    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') || ''; // 读取本地缓存的工单编号
         this.workOrderNo = uni.getStorageSync('daa001') || ''; // 读取本地缓存的工单编号
            this.fetchFormData(); // 页面加载时获取表单数据
      }
   };
</script>