| | |
| | | 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() !== ''; |
| | | }); |
| | | }, |
| | | // 刀具绑定判断钩子 |
| | | hasBindedCutter() { |
| | | const currentOrder = this.isShowTableData[0]; |
| | | return ( |
| | | currentOrder && |
| | | ( |
| | | (currentOrder.outToolId && currentOrder.outToolId.toString().trim() !== '') || |
| | | (currentOrder.outToolCode && currentOrder.outToolCode.trim() !== '') || |
| | | (currentOrder.outToolName && currentOrder.outToolName.trim() !== '') |
| | | ) |
| | | ); |
| | | }, |
| | | |
| | | cancel() { |
| | | if (!this.machineNo) return; |
| | | |
| | | if (this.hasBindedCutter()) { |
| | | uni.showToast({ |
| | | title: '当前工单已绑定刀具,不能清空重选', |
| | | icon: 'error', |
| | | duration: 2000 |
| | | }); |
| | | return; |
| | | } |
| | | |
| | | let editDate = this.formatDate(new Date()); |
| | | this.selectedIndexs = []; |
| | | this.$post({ |
| | | url: "/MesOrderSelect/Remove", |
| | | data: { |
| | | machineNo: this.machineNo, |
| | | editDate: editDate |
| | | }, |
| | | }).then(res => { |
| | | if (res.data.tbBillList > 0) { |
| | | this.isShowTableData = []; |
| | | cancel() { |
| | | if (!this.machineNo) { |
| | | return; |
| | | } |
| | | }); |
| | | }, |
| | | |
| | | // 使用钩子判断 |
| | | if (this.hasBindedCutter()) { |
| | | uni.showToast({ |
| | | title: '当前工单已绑定刀具,不能清空重选', |
| | | icon: 'error', |
| | | duration: 2000 |
| | | }); |
| | | return; |
| | | } |
| | | |
| | | let editDate = this.formatDate(new Date()); |
| | | this.selectedIndexs = []; |
| | | |
| | | this.$post({ |
| | | url: "/MesOrderSelect/Remove", |
| | | data: { |
| | | machineNo: this.machineNo, |
| | | editDate: editDate |
| | | }, |
| | | }).then(res => { |
| | | if (res.data.tbBillList > 0) { |
| | | this.isShowTableData = []; |
| | | } |
| | | }); |
| | | }, |
| | | |
| | | formatDate(date) { |
| | | let year = date.getFullYear(); // 获取年份 |
| | |
| | | }) |
| | | }, |
| | | //获取表格的数据源 |
| | | getWomdaaIsShow() { |
| | | this.$post({ |
| | | url: "/Womdaa/GetWomdaasByShow", |
| | | data: { |
| | | 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 |
| | | ); |
| | | } |
| | | if (this.isShowTableData.length === 1) { |
| | | uni.setStorageSync('daa001', this.isShowTableData[0].daa001); |
| | | uni.setStorageSync('id', this.isShowTableData[0].id); |
| | | } |
| | | }); |
| | | }, |
| | | getWomdaaIsShow() { |
| | | this.$post({ |
| | | url: "/Womdaa/GetWomdaasByShow", |
| | | data: { |
| | | machineNo: this.machineNo, |
| | | } |
| | | }).then(res => { |
| | | this.isShowTableData = res.data.tbBillList; |
| | | |
| | | if (this.isShowTableData.length == 1) { |
| | | uni.setStorageSync('daa001', this.isShowTableData[0].daa001); |
| | | uni.setStorageSync('id', this.isShowTableData[0].id); |
| | | //this.toDetail(this.isShowTableData[0]); |
| | | } |
| | | }); |
| | | }, |
| | | |
| | | isShowTab() { |
| | | if (this.isShowTableData.length > 0) { |