快乐的昕的电脑
2025-11-19 f13213d0a2d44443790e648896303ed93dc1bacd
pages/index.vue
@@ -553,20 +553,13 @@
            return str;
         },
            // 刀具绑定判断钩子 (优化版)
            hasBindedCutter() {
                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()) {
                // 直接用 flag 判断
                if (this.hasBindedCutterFlag) {
                    uni.showToast({
                        title: '当前工单已绑定刀具,不能清空重选',
                        icon: 'error',
@@ -577,6 +570,7 @@
                let editDate = this.formatDate(new Date());
                this.selectedIndexs = [];
                this.$post({
                    url: "/MesOrderSelect/Remove",
                    data: {
@@ -652,25 +646,21 @@
                        machineNo: this.machineNo,
                    }
                }).then(res => {
                    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
                        );
                    this.isShowTableData = res.data.tbBillList;
                    // 只判断第一条(只允许一条工单)
                    const order = this.isShowTableData[0];
                    let hasBindedCutter = false;
                    if (order) {
                        hasBindedCutter =
                            (order.outToolId && order.outToolId.toString().trim() !== '') ||
                            (order.outToolCode && order.outToolCode.trim() !== '') ||
                            (order.outToolName && order.outToolName.trim() !== '');
                    }
                    if (this.isShowTableData.length === 1) {
                    // 存储到 data 变量
                    this.hasBindedCutterFlag = hasBindedCutter;
                    if (this.isShowTableData.length == 1) {
                        uni.setStorageSync('daa001', this.isShowTableData[0].daa001);
                        uni.setStorageSync('id', this.isShowTableData[0].id);
                    }