快乐的昕的电脑
2025-11-19 f13213d0a2d44443790e648896303ed93dc1bacd
pages/index.vue
@@ -553,27 +553,13 @@
            return str;
         },
            // 判断单条记录是否绑定刀具
            isCutterBound(row) {
                if (!row) return false;
                const idBound = typeof row.outToolId === 'number' ? row.outToolId > 0 : (
                    row.outToolId && row.outToolId.toString().trim() !== ''
                );
                const codeBound = !!(row.outToolCode && row.outToolCode.toString().trim() !== '');
                const nameBound = !!(row.outToolName && row.outToolName.toString().trim() !== '');
                return idBound || codeBound || nameBound;
            },
            // 旧的钩子替换为调用 isCutterBound(只看第一条或根据需要遍历)
            hasBindedCutter() {
                // 当前只允许一条正在操作的工单,取第一条
                return this.isCutterBound(this.isShowTableData[0]);
            },
            cancel() {
                if (!this.machineNo) return;
                // 后端数据判断
                if (this.hasBindedCutter()) {
                if (!this.machineNo) {
                    return;
                }
                // 直接用 flag 判断
                if (this.hasBindedCutterFlag) {
                    uni.showToast({
                        title: '当前工单已绑定刀具,不能清空重选',
                        icon: 'error',
@@ -581,11 +567,16 @@
                    });
                    return;
                }
                const editDate = this.formatDate(new Date());
                let editDate = this.formatDate(new Date());
                this.selectedIndexs = [];
                this.$post({
                    url: "/MesOrderSelect/Remove",
                    data: { machineNo: this.machineNo, editDate }
                    data: {
                        machineNo: this.machineNo,
                        editDate: editDate
                    },
                }).then(res => {
                    if (res.data.tbBillList > 0) {
                        this.isShowTableData = [];
@@ -651,23 +642,25 @@
            getWomdaaIsShow() {
                this.$post({
                    url: "/Womdaa/GetWomdaasByShow",
                    data: { machineNo: this.machineNo }
                }).then(res => {
                    const list = res.data.tbBillList || [];
                    // 统一映射并输出调试日志
                    this.isShowTableData = list.map(r => {
                        return {
                            ...r,
                            // 兼容大小写或下划线命名(若不存在则使用原值或空)
                            outToolId: r.outToolId ?? r.out_tool_id ?? r.outToolID ?? r.toolId ?? 0,
                            outToolCode: r.outToolCode ?? r.out_tool_code ?? r.toolCode ?? '',
                            outToolName: r.outToolName ?? r.out_tool_name ?? r.toolName ?? ''
                        };
                    });
                    if (this.isShowTableData.length > 0) {
                        console.log("GetWomdaasByShow 第一条记录:", this.isShowTableData[0]);
                    data: {
                        machineNo: this.machineNo,
                    }
                    if (this.isShowTableData.length === 1) {
                }).then(res => {
                    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() !== '');
                    }
                    // 存储到 data 变量
                    this.hasBindedCutterFlag = hasBindedCutter;
                    if (this.isShowTableData.length == 1) {
                        uni.setStorageSync('daa001', this.isShowTableData[0].daa001);
                        uni.setStorageSync('id', this.isShowTableData[0].id);
                    }