| | |
| | | HDeptID: uni.getStorageSync('HDeptID'), |
| | | HEmpName: uni.getStorageSync('HEmpName'), |
| | | HEmpID: uni.getStorageSync('HEmpID'), |
| | | HMangerName: uni.getStorageSync('HEmpName'), |
| | | HMangerID: uni.getStorageSync('HEmpID'), |
| | | HMangerName: uni.getStorageSync('HMangerName'), |
| | | HMangerID: uni.getStorageSync('HMangerID'), |
| | | |
| | | |
| | | HSourceName: '', |
| | |
| | | HBillType: HBillType |
| | | }, |
| | | success: (res) => { |
| | | console.log(2, res.data); |
| | | if (res.data.code == 1) { |
| | | var data = res.data.data[0]; |
| | | console.log(3, data); |
| | | var num = data.Num; |
| | | console.log(4, num); |
| | | switch (num) { |
| | | case 1: |
| | | this.hform.HSourceID = data.HItemID; |
| | |
| | | }); |
| | | return; |
| | | } |
| | | // 根据组织条件决定是否进行校验 |
| | | const isSpecialOrg = uni.getStorageSync('OrganizationID') == "100007" && |
| | | uni.getStorageSync('Organization') == "事业一处"; |
| | | |
| | | // 先调用模具档案检查,校验通过后才添加数据 |
| | | this.getMould_FC().then(isValid => { |
| | | if (isValid) { |
| | | this.tabs = 1; |
| | | // 检查模具是否已存在于表格中 |
| | | const existingIndex = this.listData.findIndex(item => |
| | | item.HMouldID === data.hmainid |
| | | ); |
| | | if (uni.getStorageSync('OrganizationID') == "100007" && uni |
| | | .getStorageSync('Organization') == "事业一处") { |
| | | if (existingIndex === -1) { |
| | | // 如果不存在,添加到表格 |
| | | uni.showToast({ |
| | | title: '当前检具不在当前物料的检具清单中', |
| | | icon: 'none', |
| | | duration: 1500 |
| | | }); |
| | | this.refreshBarCodeState(); |
| | | } else { |
| | | // 如果已存在,检查器具数量 |
| | | if (this.listData[existingIndex].器具数量 === 0) { |
| | | // 器具数量为0,更新条码并将数量变为1 |
| | | this.listData[existingIndex].器具条码 = this.hform |
| | | .HBarCode; |
| | | this.listData[existingIndex].器具数量 = 1; |
| | | uni.showToast({ |
| | | title: '扫描成功', |
| | | icon: 'success', |
| | | duration: 1500 |
| | | }); |
| | | this.refreshBarCodeState(); |
| | | } else { |
| | | // 器具数量已为1,提示不允许重复扫描 |
| | | uni.showToast({ |
| | | title: '该模具已扫描,不允许重复扫描', |
| | | icon: 'none', |
| | | duration: 1500 |
| | | }); |
| | | this.refreshBarCodeState(); |
| | | } |
| | | } |
| | | if (isSpecialOrg) { |
| | | // 特殊组织:需要调用模具档案检查 |
| | | this.getMould_FC().then(isValid => { |
| | | if (isValid) { |
| | | this.handleMouldData(data); |
| | | } else { |
| | | if (existingIndex === -1) { |
| | | // 如果不存在,添加到表格 |
| | | const newRow = { |
| | | index: this.listData.length + 1, |
| | | HMouldID: data.hmainid, |
| | | 器具编码: data.模具编号, |
| | | 器具名称: data.模具名称, |
| | | 器具型号: data.模具型号, |
| | | 器具条码: this.hform.HBarCode, |
| | | 器具数量: 1, |
| | | checked: false // 默认不选中 |
| | | }; |
| | | this.listData.push(newRow); |
| | | this.refreshBarCodeState(); |
| | | } else { |
| | | // 如果已存在,提示用户 |
| | | uni.showToast({ |
| | | title: '该模具已扫描', |
| | | icon: 'none', |
| | | duration: 1500 |
| | | }); |
| | | this.refreshBarCodeState(); |
| | | } |
| | | // 校验不通过,清空条码但不添加数据 |
| | | this.refreshBarCodeState(); |
| | | } |
| | | |
| | | } else { |
| | | // 校验不通过,清空条码但不添加数据 |
| | | }).catch(error => { |
| | | console.log('校验失败:', error); |
| | | this.refreshBarCodeState(); |
| | | } |
| | | }).catch(error => { |
| | | console.log('校验失败:', error); |
| | | this.refreshBarCodeState(); |
| | | }); |
| | | }); |
| | | } else { |
| | | // 其他组织:直接处理模具数据 |
| | | this.handleMouldData(data); |
| | | } |
| | | break; |
| | | |
| | | case 4: |
| | | this.hform.HProcExchBillNo = data.单据号; |
| | | this.hform.HProcExchInterID = data.hmainid; |
| | |
| | | }, |
| | | }); |
| | | }, |
| | | handleMouldData(data) { |
| | | this.tabs = 1; |
| | | // 检查模具是否已存在于表格中 |
| | | const existingIndex = this.listData.findIndex(item => |
| | | item.HMouldID === data.hmainid |
| | | ); |
| | | |
| | | const isSpecialOrg = uni.getStorageSync('OrganizationID') == "100007" && |
| | | uni.getStorageSync('Organization') == "事业一处"; |
| | | |
| | | if (isSpecialOrg) { |
| | | // 特殊组织:检查物料器具清单 |
| | | if (existingIndex === -1) { |
| | | // 如果不存在,说明不在当前物料的检具清单中 |
| | | uni.showToast({ |
| | | title: '当前检具不在当前物料的检具清单中', |
| | | icon: 'none', |
| | | duration: 1500 |
| | | }); |
| | | this.refreshBarCodeState(); |
| | | } else { |
| | | // 如果已存在,检查器具数量 |
| | | if (this.listData[existingIndex].器具数量 === 0) { |
| | | // 器具数量为0,更新条码并将数量变为1 |
| | | this.listData[existingIndex].器具条码 = this.hform.HBarCode; |
| | | this.listData[existingIndex].器具数量 = 1; |
| | | uni.showToast({ |
| | | title: '扫描成功', |
| | | icon: 'success', |
| | | duration: 1500 |
| | | }); |
| | | this.refreshBarCodeState(); |
| | | } else { |
| | | // 器具数量已为1,提示不允许重复扫描 |
| | | uni.showToast({ |
| | | title: '该模具已扫描,不允许重复扫描', |
| | | icon: 'none', |
| | | duration: 1500 |
| | | }); |
| | | this.refreshBarCodeState(); |
| | | } |
| | | } |
| | | } else { |
| | | // 其他组织:直接处理 |
| | | if (existingIndex === -1) { |
| | | // 如果不存在,添加到表格 |
| | | const newRow = { |
| | | index: this.listData.length + 1, |
| | | HMouldID: data.hmainid, |
| | | 器具编码: data.模具编号, |
| | | 器具名称: data.模具名称, |
| | | 器具型号: data.模具型号, |
| | | 器具条码: this.hform.HBarCode, |
| | | 器具数量: 1, |
| | | checked: false // 默认不选中 |
| | | }; |
| | | this.listData.push(newRow); |
| | | uni.showToast({ |
| | | title: '扫描成功', |
| | | icon: 'success', |
| | | duration: 1500 |
| | | }); |
| | | this.refreshBarCodeState(); |
| | | } else { |
| | | // 如果已存在,提示用户 |
| | | uni.showToast({ |
| | | title: '该模具已扫描', |
| | | icon: 'none', |
| | | duration: 1500 |
| | | }); |
| | | this.refreshBarCodeState(); |
| | | } |
| | | } |
| | | }, |
| | | //获取使用部门数据 |
| | | getHDeptList() { |
| | | uni.request({ |