diff --git a/src/views/material/repair/repairManage/component/edit.vue b/src/views/material/repair/repairManage/component/edit.vue index 87797dcf..e609ef18 100644 --- a/src/views/material/repair/repairManage/component/edit.vue +++ b/src/views/material/repair/repairManage/component/edit.vue @@ -1,121 +1,43 @@ + - -
- 保存 - 取消 +
+ 保存 + 取消
- + -
+
配件型号: - - + :normalizer="normalizer" + :searchable="true" + :disable-branch-nodes="true" + :show-count="false" + :expand-on-click-node="false" + placeholder="请选择配件型号" + style="width: 80%;" + @select="partChange" + />
- 重置 + 重置 - - - + + + - + -
- 保存 - 取消 +
+ 保存 + 取消
- - - + + + - + - - + - + - + - + -
- 保存 - 取消 +
+ 保存 + 取消
@@ -641,6 +331,8 @@ >
+ + - + @@ -724,10 +416,10 @@
+ @@ -1004,6 +697,7 @@ import "@riophae/vue-treeselect/dist/vue-treeselect.css"; export default { name: "", dicts: ["ma_machine_status"], + components: { Treeselect }, props: { repairRow: { type: [Object], @@ -1012,10 +706,8 @@ export default { data() { return { uploadKey: Date.now(), - partItems: [{ partType: "", partNum: "", isCharge: "" }], - partItemsMiddle: [ - { partName: "", partNum: "", partPrice: "0", isCharge: "" }, - ], + partItems: [{ partNum: "", partType: "", partId:null, storageNum:"" }], + partItemsMiddle: [{ partName: "", partNum: "", partPrice: "0", partType: "" }], // 遮罩层 loading: false, // 选中数组 @@ -1037,7 +729,7 @@ export default { repairCode: "", equipmentList: [], }, - equipmentList: [], + equipmentList: [], //编码维修 openCode: false, @@ -1053,15 +745,14 @@ export default { headers: { Authorization: "Bearer " + getToken() }, // 上传的地址 url: process.env.VUE_APP_BASE_API + "/file/upload", - }, - + }, //内部维修 openInner: false, innerRowData: {}, //配件表格数据 partTableList: [], - //选中的配件 - partType: null, + //选中的配件 + partTypeId: null, // 配件树结构数据 partTypeTree: [], @@ -1075,13 +766,13 @@ export default { }, propsKey: 1000, - //返场维修 + //返厂维修 openBack: false, backRowData: {}, //表格数据 backTableList: [], backForm: { - //返场厂家 + //返厂厂家 supplierId: null, //备注 remark: "", @@ -1268,12 +959,7 @@ export default { console.log(this.repairRow); this.GetViewByApply(); this.supplierInfoList(); - // getInfo().then((res) => { - // this.companyId = res.user.companyId - // this.createBy = res.user.userName - // }) }, - components: { Treeselect }, computed: { //图片上传1张后,隐藏上传框 uploadDisabled() { @@ -1303,6 +989,14 @@ export default { }); // this.GetDeviceTypeTreeFn(data.backApplyInfo.agreementId) }, + //是否可用勾选框 + selectable(row) { + if (row.disrepairNum != 0) { + return true; + } else { + return false + } + }, // 多选框选中数据 handleSelectionChange(selection) { this.queryParams.equipmentList = selection; @@ -1314,15 +1008,11 @@ export default { })) } }) - // this.idsTemp = selection.map((item) => item.ids); - // selection.forEach((item) => { - // this.idsList.push(item.id); - // }); this.single = selection.length != 1; - this.multiple = !selection.length; + this.multiple = !selection.length; }, /** 批量合格按钮操作 */ - handleAdd() { + handlePass() { if (this.idsTemp.length == 0) { this.$alert("请至少勾选一条数据", "提示", { type: "warning", @@ -1369,53 +1059,15 @@ export default { }) .catch(() => {}); }, - //是否可用勾选框 - selectable(row) { - console.log(row) - if (row.disrepairNum != 0) { - return true; - } else { - return false - } - }, - checkNum(row) { - // let maxNum = row.num - // if (row.preNum <= 1) { - // row.preNum = 1 - // } else if (row.preNum >= maxNum) { - // row.preNum = maxNum - // } - }, - /** 删除按钮操作 */ - // handleDelete(row) { - // this.$modal - // .confirm('是否确认删除所选择的数据项?') - // .then(() => { - // this.deviceType.forEach((e, index) => { - // if (e[3] === row.typeId) { - // this.deviceType.splice(index, 1) - // this.propsKey++ - // } - // }) - // this.equipmentList.forEach((item, index) => { - // if (item.id == row.id) { - // this.equipmentList.splice(index, 1) - // } - // }) - // }) - // .catch(() => {}) - // // this.equipmentList.splice(row.index, 1) - // }, - - //编码类型-弹窗 - /** 维修按钮操作 */ handleRepair(row) { - if (row.manageType == 0) {//编码 + ////编码 + if (row.manageType == 0) { this.repairRowData = row; this.repairDeviceList = []; this.openCode = true; - } else {//数量 + } else { + ////数量 this.innerRowData = row; this.partTableList = []; this.typeTemp = row.type; @@ -1423,30 +1075,24 @@ export default { this.disrepairNumTemp = row.typeRepairNum - row.typeRepairedNum - row.typeScrapNum; this.repairRowData = row; this.repairDeviceList = []; - const params = {}; - // const res = partTypeTreeList(params); + const params = {}; partTypeTreeList(params).then((res) => { this.partTypeTreeTwo = this.filterTree(res.data); this.resetForm("formLeft"); this.resetForm("formMiddle") this.resetForm("formRight") - this.partItems = [{ partType: "", partNum: "", isCharge: "" }], + this.partItems = [{ partNum: "", partType: "", partId:null, storageNum:"" }], this.partItemsMiddle= [ - { partName: "", partNum: "", partPrice: "0", isCharge: "" }, + { partName: "", partNum: "", partPrice: "0", partType: "" }, ], this.openNum = true; }); } - if ( - this.repairRowData.repairDeviceList && - this.repairRowData.repairDeviceList.length > 0 - ) { - this.repairDeviceList = this.repairRowData.repairDeviceList; - // this.repairDeviceList.forEach((item) => { - // item.isFinished = item.status == 1 ? 1 : 0; - // }); + if (this.repairRowData.repairDeviceList&&this.repairRowData.repairDeviceList.length > 0) { + this.repairDeviceList = this.repairRowData.repairDeviceList; } }, + //遍历树状数据 filterTree(nodes) { return nodes.map((node) => { if(node.level==3){ @@ -1458,14 +1104,14 @@ export default { return node; }); }, - //数量-内部-选中配件类型 - partTypeSelect(e){ - console.log(e) - }, + + + + // ********编码维修******** // 编码维修弹窗保存 - async saveCodeDialog() { + async saveCodeDialog() { this.repairRowData.repairDeviceList = this.repairDeviceList; - await saveCodeList(this.repairRowData.repairDeviceList).then((response) => { + await saveCodeList(this.repairRowData.repairDeviceList).then((response) => { if (response.code == 200) { this.$modal.msgSuccess("保存成功"); this.fileList = []; @@ -1484,8 +1130,7 @@ export default { }); this.openCode = false; // console.log(this.equipmentList) - }, - + }, // 编码维修弹窗取消 async cancelCodeDialog(){ let param = { @@ -1500,6 +1145,343 @@ export default { }); this.openCode = false; }, + + + + // ********编码--内部维修******** + //编码-内部维修 + openInnerDialog(row) { + console.log('111111111',row) + this.innerRowData = row; + this.partTableList = []; + if (this.innerRowData.partTableList && this.innerRowData.partTableList.length > 0) { + this.partTableList = this.innerRowData.partTableList; + } + this.getPartTypeTreeData(); + this.openInner = true; + }, + //编码-内部维修-配件树 + async getPartTypeTreeData() { + const params = {}; + const res = await partTypeTreeList(params); + console.log("treeData==========", res); + this.partTypeTree = res.data; + }, + //编码-内部维修- 反显 树结构数据获取父 -旧组件 + getSelectId(list, id) { + for (let i in list) { + if (list[i].id == id) { + //查询到就返回该数组对象的value + return [list[i].id]; + } + if (list[i].children) { + let node = this.getSelectId(list[i].children, id); + if (node !== undefined) { + //查询到把父节把父节点加到数组前面 + node.unshift(list[i].id); + return node; + } + } + } + }, + //编码-内部维修- 切换 设备类型树-旧组件 + async partTypeChange(val) { + const partTypeList = this.$refs.partTypeCascader.getCheckedNodes(); + console.log(partTypeList); + let tempList = []; + if (val.length > 0) { + const items = val.map((e) => { + return e[2]; + }); + for (let i of items) { + for (let z of partTypeList) { + if (z.data.id === i) { + const parent = z.parent; + console.log(parent); + const obj = JSON.parse(JSON.stringify(z.data)); + console.log(obj); + obj.typeCode = obj.label; + obj.typeName = parent.label; + obj.partType = "0"; + obj.partNum = 1; + console.log(obj); + tempList.push(obj); + break; + } + } + } + const newDataListNew = [...this.partTableList, ...tempList]; + const map = new Map(); + for (let item of newDataListNew) { + if (!map.has(item.id)) { + map.set(item.id, item); + } + } + const newArray = [...map.values()]; + let newArray_array = []; + items.forEach((e) => { + newArray.forEach((j) => { + if (e == j.id) { + newArray_array.push(j); + } + }); + }); + this.partTableList = newArray_array; + } else { + this.partTableList = []; + } + }, + //编码-内部维修- 切换 设备类型树-旧组件 + partChange(e){ + console.log(e) + let isHas = this.partTableList.findIndex(v=>v.partId==e.id) + let obj = {} + if(isHas>-1){ + this.$message.error("已存在所选配件"); + }else{ + let parentNode = this.findParentNode(this.partTypeTree, e); + // console.log(parentNode) + obj.typeName = parentNode.label; + obj.partId = e.id; + obj.typeCode = e.label; + obj.storageNum = e.storageNum; + obj.partType = "0"; + obj.partNum = 1; + this.partTableList.push(obj) + } + }, + /** 转换菜单数据结构 */ + normalizer(node) { + if (node.children && !node.children.length) { + delete node.children + } + return { + id: node.id, + label: node.storageNum>0?node.label+"("+ node.storageNum +")":node.label, + children: node.children + } + }, + //treeselect获取父节点 + findParentNode(nodes, targetNode) { + for (let node of nodes) { + if (node.children && node.children.includes(targetNode)) { + return node; // 返回父节点信息 + } else if (node.children) { + const parent = this.findParentNode(node.children, targetNode); // 递归查找子树中的父节点 + if (parent) return parent; // 如果找到,返回父节点信息并停止递归 + } + } + return null; // 未找到父节点时返回null + }, + //编码-内部维修- 重置按钮操作 + resetInner() { + this.partTypeId=null; + this.partTableList = []; + }, + //编码-内部维修- 删除 + handleDeletePart(row) { + this.partTableList.forEach((item, index) => { + if (item.id == row.id) { + this.partTableList.splice(index, 1); + } + }); + }, + //编码-内部维修- 弹窗保存 + saveInnerDialog() { + const isNum = this.partTableList.some( + (item) => item.partNum == 0 || item.partNum == undefined + ); + if (isNum) { + this.$message.error("配件数量不能为0!"); + return; + } + this.innerRowData.partTableList = this.partTableList; + this.innerRowData.repairType = 1; + this.innerRowData.partTableList.forEach((item) => { + this.innerRowData.codeInRepairPartList.push(item); + }); + if(this.partTableList.length==0) { + this.$message.error("请添加配件!"); + return; + }else{ + this.innerRowData.status = 1; + this.openInner = false; + } + // console.log(this.equipmentList) + }, + + + + // ********编码--返厂维修******** + // 返厂维修-打开 + openBackDialog(row) { + console.log('row',row) + this.backRowData = row; + this.backTableList = []; + this.resetForm("backForm") + if(row.backTableList){ + this.backForm = { + //返厂厂家 + supplierId: row.backTableList[0].supplierId, + //备注 + remark: row.backTableList[0].remark, + }; + } + if ( + this.backRowData.backTableList && + this.backRowData.backTableList.length > 0 + ) { + this.backTableList = this.backRowData.backTableList; + } else { + let obj = { + partName: "", + partType: "0", + partNum: 1, + backCost: 0, + supplier:this.backForm.supplierId, + remark:this.backForm.remark, + }; + this.backTableList.push(obj); + } + this.openBack = true; + }, + //返厂维修- 添加 + handleAddBack() { + let obj = { + partName: "", + partType: "0", + partNum: 1, + backCost: 0, + }; + this.backTableList.push(obj); + }, + //返厂维修- 删除 + handleDeleteBack(row) { + this.backTableList.splice(row.index, 1); + }, + //返厂维修- 弹窗保存 + saveBackDialog() { + if (this.backTableList.length > 0) { + this.$refs["backForm"].validate((valid) => { + if (valid) { + const isName = this.backTableList.some( + (item) => item.partName == "" || item.partName == undefined + ); + if (isName) { + this.$message.error("配件名称不能为空!"); + return; + } + const isNum = this.backTableList.some( + (item) => item.partNum == 0 || item.partNum == undefined + ); + if (isNum) { + this.$message.error("配件数量不能为0!"); + return; + } + const isCost = this.backTableList.some( + (item) => item.backCost == 0 || item.backCost == undefined + ); + if (isCost) { + this.$message.error("维修金额不能为0!"); + return; + } + this.backTableList.forEach(item=>{ + item.supplierId = this.backForm.supplierId + item.remark = this.backForm.remark + }) + this.backRowData.backTableList = this.backTableList; + this.backRowData.repairType = 2; + this.backRowData.backTableList.forEach((item) => { + this.backRowData.codeOutRepairPartList.push(item); + }); + this.backRowData.status = 1; + this.openBack = false; + } + }); + } else { + this.$modal.msgError("请添加配件!"); + } + }, + /** 返厂维修-物资厂家-下拉选 */ + supplierInfoList() { + let param = { + pageNum: 1, + pageSize: 1000, + keyWord: undefined, + }; + getListFacturer(param).then((response) => { + this.supplierList = response.rows; + }); + }, + + + + // ********编码--待报废******** + // 待报废-打开 + openScrapDialog(row) { + this.scrapRowData = row; + this.scrapForm = {}; + this.fileList = []; + this.openScrap = true; + }, + //编码-待报废保存按钮 + saveSubmit() { + this.uploadKey = Date.now(); + this.$refs["scrapForm"].validate(async(valid) => { + if(valid){ + if(this.fileList.length!=0){ + await this.getImaUpload(), + await this.addWaitRepairPic(this.scrapForm); + }else{ + await this.addWaitRepairPic(this.scrapForm); + } + this.scrapRowData.repairType = 3 + this.scrapRowData.codeScrapRepairPartList.push(this.scrapForm) + this.scrapRowData.status = 1 + this.openScrap = false; + } + }) + }, + //编码-待报废 + async addWaitRepairPic(scrapForm){ + this.scrapForm.fileList=this.fileListTemp + this.openScrap = false; + + }, + // 编码-待报废取消按钮 + saveCancel() { + this.uploadKey = Date.now(); + this.openScrap = false; + this.fileList = []; + this.fileListTemp = []; + this.resetForm("scrapForm"); + }, + //编码-待报废-上传文件库 + async getImaUpload(){ + this.fileListTemp = []; + const reqData = new FormData() + const {fileTwo} = await this.getFileData() + let res = await imgUpLoadThree(fileTwo); + console.log('res',res) + if (res.code === 200) { + res.data.forEach(item=>{ + let objTwo = { 'name': item.name, 'url': item.url,}; + this.fileListTemp.push(objTwo); + }) + } else { + this.$modal.msgError(res.msg); + } + }, + //编码-待报废-提交时循环fileList 获取raw文件 + async getFileData() { + const fileTwo = [] + this.fileList.forEach(item => { + if (item?.hasOwnProperty('raw')) { + fileTwo.push(item.raw) + } + }) + return { fileTwo } + }, //编码维修弹窗文件上传前 beforeFileUpload(row) { this.fileData = row; @@ -1575,312 +1557,6 @@ export default { }); this.fileList.splice(sum, 1); }, - // 待报废保存按钮 - saveSubmit() { - this.uploadKey = Date.now(); - this.$refs["scrapForm"].validate(async(valid) => { - if(valid){ - if(this.fileList.length!=0){ - await this.getImaUpload(), - await this.addWaitRepairPic(this.scrapForm); - }else{ - await this.addWaitRepairPic(this.scrapForm); - } - this.scrapRowData.repairType = 3 - this.scrapRowData.codeScrapRepairPartList.push(this.scrapForm) - this.scrapRowData.status = 1 - this.openScrap = false; - } - }) - // this.reset(); - }, - - //上传文件库 - async getImaUpload(){ - this.fileListTemp = []; - const reqData = new FormData() - const {fileTwo} = await this.getFileData() - let res = await imgUpLoadThree(fileTwo); - console.log('res',res) - if (res.code === 200) { - res.data.forEach(item=>{ - let objTwo = { 'name': item.name, 'url': item.url,}; - this.fileListTemp.push(objTwo); - }) - } else { - this.$modal.msgError(res.msg); - } - }, - - //提交时循环fileList 获取raw文件 - async getFileData() { - const fileTwo = [] - this.fileList.forEach(item => { - if (item?.hasOwnProperty('raw')) { - fileTwo.push(item.raw) - } - }) - return { fileTwo } - }, - - async addWaitRepairPic(scrapForm){ - this.scrapForm.fileList=this.fileListTemp - this.openScrap = false; - - }, - - // 待报废取消按钮 - saveCancel() { - this.uploadKey = Date.now(); - this.openScrap = false; - this.fileList = []; - this.fileListTemp = []; - this.resetForm("scrapForm"); - }, - - //内部维修 - openInnerDialog(row) { - console.log('111111111',row) - this.innerRowData = row; - this.partTableList = []; - if ( - this.innerRowData.partTableList && - this.innerRowData.partTableList.length > 0 - ) { - this.partTableList = this.innerRowData.partTableList; - } - this.getPartTypeTreeData(); - this.openInner = true; - }, - //内部维修-配件树 - async getPartTypeTreeData() { - const params = {}; - const res = await partTypeTreeList(params); - console.log("treeData==========", res); - this.partTypeTree = res.data; - //反显 - let selectList = []; - this.partTableList.forEach((e) => { - selectList.push(this.getSelectId(this.partTypeTree, e.id)); - }); - this.partType = selectList; - this.$forceUpdate(); - }, - //内部维修- 反显 树结构数据获取父 - getSelectId(list, id) { - for (let i in list) { - if (list[i].id == id) { - //查询到就返回该数组对象的value - return [list[i].id]; - } - if (list[i].children) { - let node = this.getSelectId(list[i].children, id); - if (node !== undefined) { - //查询到把父节把父节点加到数组前面 - node.unshift(list[i].id); - return node; - } - } - } - }, - //内部维修- 切换 设备类型树 - async partTypeChange(val) { - const partTypeList = this.$refs.partTypeCascader.getCheckedNodes(); - console.log(partTypeList); - let tempList = []; - if (val.length > 0) { - const items = val.map((e) => { - return e[2]; - }); - for (let i of items) { - for (let z of partTypeList) { - if (z.data.id === i) { - const parent = z.parent; - console.log(parent); - const obj = JSON.parse(JSON.stringify(z.data)); - console.log(obj); - obj.typeCode = obj.label; - obj.typeName = parent.label; - obj.isCharge = "0"; - obj.partNum = 1; - console.log(obj); - tempList.push(obj); - break; - } - } - } - const newDataListNew = [...this.partTableList, ...tempList]; - const map = new Map(); - for (let item of newDataListNew) { - if (!map.has(item.id)) { - map.set(item.id, item); - } - } - const newArray = [...map.values()]; - let newArray_array = []; - items.forEach((e) => { - newArray.forEach((j) => { - if (e == j.id) { - newArray_array.push(j); - } - }); - }); - this.partTableList = newArray_array; - } else { - this.partTableList = []; - } - }, - //内部维修- 重置按钮操作 - resetInner() { - this.partType = []; - this.partTableList = []; - }, - //内部维修- 删除 - handleDeletePart(row) { - this.partType.forEach((e, index) => { - if (e[2] === row.id) { - this.partType.splice(index, 1); - this.propsKey++; - } - }); - this.partTableList.forEach((item, index) => { - if (item.id == row.id) { - this.partTableList.splice(index, 1); - } - }); - }, - //内部维修- 弹窗保存 - saveInnerDialog() { - const isNum = this.partTableList.some( - (item) => item.partNum == 0 || item.partNum == undefined - ); - if (isNum) { - this.$message.error("配件数量不能为0!"); - return; - } - this.innerRowData.partTableList = this.partTableList; - this.innerRowData.repairType = 1; - this.innerRowData.partTableList.forEach((item) => { - this.innerRowData.codeInRepairPartList.push(item); - }); - if(this.partTableList.length==0) { - this.$message.error("请添加配件!"); - return; - }else{ - this.innerRowData.status = 1; - this.openInner = false; - } - // console.log(this.equipmentList) - }, - - // 返场维修-打开 - openBackDialog(row) { - console.log('row',row) - this.backRowData = row; - this.backTableList = []; - this.resetForm("backForm") - if(row.backTableList){ - this.backForm = { - //返场厂家 - supplierId: row.backTableList[0].supplierId, - //备注 - remark: row.backTableList[0].remark, - }; - } - if ( - this.backRowData.backTableList && - this.backRowData.backTableList.length > 0 - ) { - this.backTableList = this.backRowData.backTableList; - } else { - let obj = { - partName: "", - isCharge: "0", - partNum: 1, - backCost: 0, - supplier:this.backForm.supplierId, - remark:this.backForm.remark, - }; - this.backTableList.push(obj); - } - this.openBack = true; - }, - //返场维修- 添加 - handleAddBack() { - let obj = { - partName: "", - isCharge: "0", - partNum: 1, - backCost: 0, - }; - this.backTableList.push(obj); - }, - //返场维修- 删除 - handleDeleteBack(row) { - this.backTableList.splice(row.index, 1); - }, - //返场维修- 弹窗保存 - saveBackDialog() { - if (this.backTableList.length > 0) { - this.$refs["backForm"].validate((valid) => { - if (valid) { - const isName = this.backTableList.some( - (item) => item.partName == "" || item.partName == undefined - ); - if (isName) { - this.$message.error("配件名称不能为空!"); - return; - } - const isNum = this.backTableList.some( - (item) => item.partNum == 0 || item.partNum == undefined - ); - if (isNum) { - this.$message.error("配件数量不能为0!"); - return; - } - const isCost = this.backTableList.some( - (item) => item.backCost == 0 || item.backCost == undefined - ); - if (isCost) { - this.$message.error("维修金额不能为0!"); - return; - } - this.backTableList.forEach(item=>{ - item.supplierId = this.backForm.supplierId - item.remark = this.backForm.remark - }) - this.backRowData.backTableList = this.backTableList; - this.backRowData.repairType = 2; - this.backRowData.backTableList.forEach((item) => { - this.backRowData.codeOutRepairPartList.push(item); - }); - this.backRowData.status = 1; - this.openBack = false; - } - }); - } else { - this.$modal.msgError("请添加配件!"); - } - }, - /** 返场维修-物资厂家-下拉选 */ - supplierInfoList() { - let param = { - pageNum: 1, - pageSize: 1000, - keyWord: undefined, - }; - getListFacturer(param).then((response) => { - this.supplierList = response.rows; - }); - }, - - // 待报废-打开 - openScrapDialog(row) { - this.scrapRowData = row; - this.scrapForm = {}; - this.fileList = []; - this.openScrap = true; - }, // 待报废弹窗文件上传成功处理-编码弹窗上传 handleFileSuccess3(response, file, fileList) { if (response.code == 200) { @@ -1890,102 +1566,139 @@ export default { }; // this.scrapForm={} } - }, + }, - //数量管理左侧 + + + + + + // ********数量维修******** + //数量-内部-选中配件类型 + partTypeSelect(e){ + // console.log(e) + // console.log(this.partItems) + let index=-1; + let len = this.partItems.length; + if(this.partItems.length>0){ + index = this.partItems.findIndex(v=>v.partId==e.id) + // console.log(index) + if(index>-1){ + this.$message.error("已存在所选配件!"); + setTimeout(()=>{ + this.partItems[len-1].partId=null; + },500) + }else{ + this.partItems[len-1].storageNum=e.storageNum + } + }else{ + this.partItems[0].storageNum=e.storageNum + } + }, + //配件数量 + inputPartNum(item){ + // console.log(item) + if(item.partNum>item.storageNum){ + this.$message.error("配件数量不可大于配件领用库存!"); + item.partNum=item.storageNum + } + }, + //数量-左侧-内部维修-添加 addPartItem() { - this.partItems.push({ partType: "", partNum: "", isCharge: "" }); + this.partItems.push({ partNum: "", partType: "", partId:null, storageNum:"" }); this.dividerHeight += 200; // 每次增加配件时,竖线高度增加 }, + //数量-左侧-内部维修-删除 removePartItem(index) { if (this.partItems.length > 1) { this.partItems.splice(index, 1); this.dividerHeight -= 200; // 每次删除配件时,竖线高度减少 } - }, - - //数量管理中间 + }, + //数量管理中间-返厂维修-添加 addPartItemMiddle() { - this.partItemsMiddle.push({ partTypeName: "", partNum: "", isCharge: "" }); + this.partItemsMiddle.push({ partTypeName: "", partNum: "", partType: "" }); this.dividerHeight += 200; // 每次增加配件时,竖线高度增加 }, + //数量管理中间-返厂维修-删除 removePartItemMiddle(index) { if (this.partItemsMiddle.length > 1) { this.partItemsMiddle.splice(index, 1); this.dividerHeight -= 200; // 每次删除配件时,竖线高度减少 } }, - - async validateForms(refs){ - const validationResults = await Promise.all(refs.map(ref =>ref.validate())) - return validationResults.every(result=> result===true) - }, + //表单校验 + async validateForms(refs){ + const validationResults = await Promise.all(refs.map(ref =>ref.validate())) + return validationResults.every(result=> result===true) + }, //数量管理保存 - async saveNumAll() { - let refTemp = []; - if(this.formLeft.repairNum!=0){ - refTemp.push(this.$refs.formLeft) - } - if(this.formMiddle.repairNum!=0){ - refTemp.push(this.$refs.formMiddle) - } - if(this.formRight.scrapNum!=0){ - refTemp.push(this.$refs.formRight) - } - const valid = await this.validateForms(refTemp) + async saveNumAll() { + let refTemp = []; + if(this.formLeft.repairNum!=0){ + refTemp.push(this.$refs.formLeft) + } + if(this.formMiddle.repairNum!=0){ + refTemp.push(this.$refs.formMiddle) + } + if(this.formRight.scrapNum!=0){ + refTemp.push(this.$refs.formRight) + } + const valid = await this.validateForms(refTemp) if(valid){ - for (let i = 0; i < this.partItems.length; i++) { - this.innerRowData.repairDeviceList[0].numberInRepairPartList.push({ - isCharge: this.partItems[i].isCharge, - partId: this.partItems[i].partId, - partNum: this.partItems[i].partNum, - repairNum: this.formLeft.repairNum, - }); - } - for (let i = 0; i < this.partItemsMiddle.length; i++) { - this.innerRowData.repairDeviceList[0].numberOutRepairPartList.push({ - isCharge: this.partItemsMiddle[i].isCharge, - partPrice: this.partItemsMiddle[i].partPrice, - partNum: this.partItemsMiddle[i].partNum, - partName: this.partItemsMiddle[i].partName, - supplierId: this.formMiddle.supplierId, - repairNum: this.formMiddle.repairNum, - }); - } - this.uploadKey = Date.now(); - if(this.fileList.length!=0){ - await this.getImaUpload(), - this.formRight.fileList = this.fileListTemp; - }else{ - this.formRight.fileList = this.fileListTemp; - } - console.log('this.formRight',this.formRight) - this.innerRowData.repairDeviceList[0].numberScrapRepairPartList.push(this.formRight) - this.innerRowData.repairDeviceList[0].repairType = 1; - saveCodeList(this.innerRowData.repairDeviceList).then(async (response) => { - if (response.code == 200) { - this.$modal.msgSuccess("保存成功"); - this.fileList=[]; - this.fileListTemp=[]; - let param = { - taskId: this.repairRow.taskId, - keyword: "", - }; - this.taskIdTemp = this.repairRow.taskId; - const res = await getAppRepairMaTypeList(param); - this.equipmentList = res.data; - this.equipmentList.forEach((e) => { - e.disrepairNum = Number(e.typeRepairNum) - Number(e.typeRepairedNum)-Number(e.typeScrapNum); - }); - this.openNum=false; + for (let i = 0; i < this.partItems.length; i++) { + this.innerRowData.repairDeviceList[0].numberInRepairPartList.push({ + partType: this.partItems[i].partType, + partId: this.partItems[i].partId, + partNum: this.partItems[i].partNum, + storageNum: this.partItems[i].storageNum, + repairNum: this.formLeft.repairNum, + }); } - }); + for (let i = 0; i < this.partItemsMiddle.length; i++) { + this.innerRowData.repairDeviceList[0].numberOutRepairPartList.push({ + partType: this.partItemsMiddle[i].partType, + partPrice: this.partItemsMiddle[i].partPrice, + partNum: this.partItemsMiddle[i].partNum, + partName: this.partItemsMiddle[i].partName, + supplierId: this.formMiddle.supplierId, + repairNum: this.formMiddle.repairNum, + }); + } + this.uploadKey = Date.now(); + if(this.fileList.length!=0){ + await this.getImaUpload(), + this.formRight.fileList = this.fileListTemp; + }else{ + this.formRight.fileList = this.fileListTemp; + } + console.log('this.formRight',this.formRight) + this.innerRowData.repairDeviceList[0].numberScrapRepairPartList.push(this.formRight) + this.innerRowData.repairDeviceList[0].repairType = 1; + saveCodeList(this.innerRowData.repairDeviceList).then(async (response) => { + if (response.code == 200) { + this.$modal.msgSuccess("保存成功"); + this.fileList=[]; + this.fileListTemp=[]; + let param = { + taskId: this.repairRow.taskId, + keyword: "", + }; + this.taskIdTemp = this.repairRow.taskId; + const res = await getAppRepairMaTypeList(param); + this.equipmentList = res.data; + this.equipmentList.forEach((e) => { + e.disrepairNum = Number(e.typeRepairNum) - Number(e.typeRepairedNum)-Number(e.typeScrapNum); + }); + this.openNum=false; + } + }); } // this.$refs.refTemp.validate(async(valid)=>{ // if(valid){ // for (let i = 0; i < this.partItems.length; i++) { // this.innerRowData.repairDeviceList[0].numberInRepairPartList.push({ - // isCharge: this.partItems[i].isCharge, + // partType: this.partItems[i].partType, // partId: this.partItems[i].partId, // partNum: this.partItems[i].partNum, // repairNum: this.formLeft.repairNum, @@ -1999,7 +1712,7 @@ export default { // if(valid){ // for (let i = 0; i < this.partItems.length; i++) { // this.innerRowData.repairDeviceList[0].numberInRepairPartList.push({ - // isCharge: this.partItems[i].isCharge, + // partType: this.partItems[i].partType, // partId: this.partItems[i].partId, // partNum: this.partItems[i].partNum, // repairNum: this.formLeft.repairNum, @@ -2007,7 +1720,7 @@ export default { // } // for (let i = 0; i < this.partItemsMiddle.length; i++) { // this.innerRowData.repairDeviceList[0].numberOutRepairPartList.push({ - // isCharge: this.partItemsMiddle[i].isCharge, + // partType: this.partItemsMiddle[i].partType, // partPrice: this.partItemsMiddle[i].partPrice, // partNum: this.partItemsMiddle[i].partNum, // partName: this.partItemsMiddle[i].partName, @@ -2050,7 +1763,7 @@ export default { // if(valid){ // for (let i = 0; i < this.partItems.length; i++) { // this.innerRowData.repairDeviceList[0].numberInRepairPartList.push({ - // isCharge: this.partItems[i].isCharge, + // partType: this.partItems[i].partType, // partId: this.partItems[i].partId, // partNum: this.partItems[i].partNum, // repairNum: this.formLeft.repairNum, @@ -2058,7 +1771,7 @@ export default { // } // for (let i = 0; i < this.partItemsMiddle.length; i++) { // this.innerRowData.repairDeviceList[0].numberOutRepairPartList.push({ - // isCharge: this.partItemsMiddle[i].isCharge, + // partType: this.partItemsMiddle[i].partType, // partPrice: this.partItemsMiddle[i].partPrice, // partNum: this.partItemsMiddle[i].partNum, // partName: this.partItemsMiddle[i].partName, @@ -2100,20 +1813,17 @@ export default { // } }, - //数量管理取消 + //数量维修取消 saveCancelAll(){ this.fileList=[]; this.fileListTemp=[]; this.resetForm("formLeft"); this.resetForm("formMiddle") this.resetForm("formRight") - this.partItems = [{ partType: "", partNum: "", isCharge: "" }], - this.partItemsMiddle = [ - { partName: "", partNum: "", partPrice: "0", isCharge: "" }, - ], + this.partItems = [{ partNum: "", partType: "", partId:null, storageNum:"" }], + this.partItemsMiddle = [{ partName: "", partNum: "", partPrice: "0", partType: "" }], this.openNum=false; - }, - + }, //待维修数量限制统计 waitRepairCount(){ if((Number(this.formLeft.repairNum) + Number(this.formMiddle.repairNum)+ Number(this.formRight.scrapNum)) >this.disrepairNumTemp){ @@ -2131,8 +1841,7 @@ export default { if(Number(this.formRight.scrapNum)==0){ this.resetForm("formRight") } - }, - + }, }, };