快乐的昕的电脑
2025-11-18 dc6741de2d3247e4d4870e42ebd8393c7c507494
pages/index.vue
@@ -553,25 +553,19 @@
            return str;
         },
                // 刀具绑定判断钩子
            // 刀具绑定判断钩子 (优化版)
                hasBindedCutter() {
                    const currentOrder = this.isShowTableData[0];
                    return (
                        currentOrder &&
                        (
                            (currentOrder.outToolId && currentOrder.outToolId.toString().trim() !== '') ||
                            (currentOrder.outToolCode && currentOrder.outToolCode.trim() !== '') ||
                            (currentOrder.outToolName && currentOrder.outToolName.trim() !== '')
                        )
                    );
                const o = this.isShowTableData[0];
                if (!o) return false;
                return ['outToolId', 'outToolCode', 'outToolName'].some(k => {
                    const v = o[k];
                    return v !== undefined && v !== null && v.toString().trim() !== '';
                });
            },
                cancel() {
                    if (!this.machineNo) {
                        return;
                    }
                if (!this.machineNo) return;
                    // 使用钩子判断
                    if (this.hasBindedCutter()) {
                        uni.showToast({
                            title: '当前工单已绑定刀具,不能清空重选',
@@ -583,7 +577,6 @@
                    let editDate = this.formatDate(new Date());
                    this.selectedIndexs = [];
                    this.$post({
                        url: "/MesOrderSelect/Remove",
                        data: {
@@ -659,12 +652,27 @@
                  machineNo: this.machineNo,
               }
            }).then(res => {
               this.isShowTableData = res.data.tbBillList;
               if (this.isShowTableData.length == 1) {
                    let list = res.data.tbBillList || [];
                    // 归一化刀具字段
                    this.isShowTableData = list.map(row => {
                        return {
                            ...row,
                            outToolId: row.outToolId ?? row.out_tool_id ?? row.outToolID ?? row.toolId ?? row.ToolId,
                            outToolCode: row.outToolCode ?? row.out_tool_code ?? row.toolCode ?? row.ToolCode,
                            outToolName: row.outToolName ?? row.out_tool_name ?? row.toolName ?? row.ToolName,
                        };
                    });
                    if (this.isShowTableData.length > 0) {
                        console.log("工单首条完整数据:", JSON.stringify(this.isShowTableData[0]));
                        console.log("刀具字段:",
                            this.isShowTableData[0].outToolId,
                            this.isShowTableData[0].outToolCode,
                            this.isShowTableData[0].outToolName
                        );
                    }
                    if (this.isShowTableData.length === 1) {
                  uni.setStorageSync('daa001', this.isShowTableData[0].daa001);
                  uni.setStorageSync('id', this.isShowTableData[0].id);
                  //this.toDetail(this.isShowTableData[0]);
               }
            });
         },