diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesProductPlanController.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesProductPlanController.java index bc4eebc5..8826861a 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesProductPlanController.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesProductPlanController.java @@ -323,4 +323,28 @@ public class MesProductPlanController extends BaseController { return R.fail(e.getMessage()); } } + + /** + * 获取生产派工附件List列表 + * @param attachType + * @param dispatchCode + * @param processId + * @param userId + * @return + */ + @GetMapping(value = "/attachInfoList/{attachType}/{dispatchCode}/{processId}/{userId}") + public AjaxResult getAttachInfoList(@PathVariable("attachType") String attachType, @PathVariable("dispatchCode") String dispatchCode, + @PathVariable("processId") Long processId, @PathVariable("userId") Long userId) { + return success(mesProductPlanService.getAttachInfoList(dispatchCode, processId, userId, attachType)); + } + + /** + * 校验生产派工是否已绑定附件 + * @param attachId + * @return + */ + @GetMapping(value = "/checkMesProductPlanAttachInfo/{attachType}/{attachId}") + public AjaxResult checkMesProductPlanAttachInfo(@PathVariable("attachType") String attachType, @PathVariable("attachId") String attachId) { + return success(mesProductPlanService.checkMesProductPlanAttachInfo(attachType, attachId)); + } } diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesProductPlanService.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesProductPlanService.java index 4876d50a..fa53dc55 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesProductPlanService.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesProductPlanService.java @@ -5,14 +5,12 @@ import java.util.List; import java.util.Map; import com.hw.mes.domain.MesBaseAttachInfo; -import com.hw.mes.domain.MesMaterialBom; import com.hw.mes.domain.MesProductOrder; import com.hw.mes.domain.MesProductPlan; import com.hw.mes.domain.vo.MesAssignTaskVo; import com.hw.mes.domain.vo.MesMaterialScanVo; import com.hw.mes.domain.vo.MesProductPlanDeleteVo; import com.hw.mes.domain.vo.MesProductPlanEditVo; -import org.springframework.transaction.annotation.Transactional; /** * 生产派工Service接口 @@ -187,4 +185,21 @@ public interface IMesProductPlanService */ public List selectMesProductPlanJoinUserList(MesProductPlan mesProductPlan); + /** + * 获取生产派工附件List列表 + * @param attachType + * @param dispatchCode + * @param processId + * @param userId + * @return + */ + public List getAttachInfoList(String dispatchCode, Long processId, Long userId, String attachType); + + /** + * 校验生产派工是否已绑定附件 + * @param attachType + * @param attachId + * @return + */ + String checkMesProductPlanAttachInfo(String attachType, String attachId); } diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesMaterialBomServiceImpl.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesMaterialBomServiceImpl.java index d867c37f..d4b4e08f 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesMaterialBomServiceImpl.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesMaterialBomServiceImpl.java @@ -7,6 +7,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import com.hw.common.core.constant.CacheConstants; +import com.hw.common.core.constant.MesConstants; import com.hw.common.core.constant.SecurityConstants; import com.hw.common.core.domain.R; import com.hw.common.core.exception.ServiceException; @@ -15,6 +16,7 @@ import com.hw.common.core.utils.MailUtils; import com.hw.common.core.utils.StringUtils; import com.hw.common.redis.service.RedisService; import com.hw.mes.domain.MesBaseAttachInfo; +import com.hw.mes.mapper.MesProductPlanMapper; import com.hw.mes.service.IMesBaseAttachInfoService; import com.hw.system.api.RemoteUserService; import com.hw.system.api.domain.SysUser; @@ -46,6 +48,9 @@ public class MesMaterialBomServiceImpl implements IMesMaterialBomService { @Autowired private RedisService redisService; + @Autowired + private MesProductPlanMapper mesProductPlanMapper; + /** * 查询物料BOM信息 * @@ -290,23 +295,26 @@ public class MesMaterialBomServiceImpl implements IMesMaterialBomService { public List getBomAttachInfo(String attachType, Long[] materialBomIds) { List attachIdList = new ArrayList<>(); for (Long materialBomId : materialBomIds) { - if (attachType.equals("1")){ - MesMaterialBom materialBom = mesMaterialBomMapper.selectMesMaterialBomByMaterialBomId(materialBomId); - if (StringUtils.isNotEmpty(materialBom.getAttachId())){ - String[] split = materialBom.getAttachId().split(","); - List longList = Arrays.stream(split) - .map(Long::valueOf) // 转换每个字符串为 Long - .collect(Collectors.toList()); - attachIdList.addAll(longList); - } - } else { - MesMaterialBom materialBom = mesMaterialBomMapper.selectMesMaterialBomByMaterialBomId(materialBomId); - if (StringUtils.isNotEmpty(materialBom.getSopId())){ - String[] split = materialBom.getSopId().split(","); - List longList = Arrays.stream(split) - .map(Long::valueOf) // 转换每个字符串为 Long - .collect(Collectors.toList()); - attachIdList.addAll(longList); + MesMaterialBom mesMaterialBom = new MesMaterialBom(); + mesMaterialBom.setAncestors(materialBomId.toString()); + List materialBomList = mesMaterialBomMapper.selectMesMaterialBomList(mesMaterialBom); + for (MesMaterialBom materialBom : materialBomList) { + if (attachType.equals(MesConstants.MES_ATTACH_TYPE_DRAWING)){ + if (StringUtils.isNotEmpty(materialBom.getAttachId())){ + String[] split = materialBom.getAttachId().split(","); + List longList = Arrays.stream(split) + .map(Long::valueOf) // 转换每个字符串为 Long + .collect(Collectors.toList()); + attachIdList.addAll(longList); + } + } else { + if (StringUtils.isNotEmpty(materialBom.getSopId())){ + String[] split = materialBom.getSopId().split(","); + List longList = Arrays.stream(split) + .map(Long::valueOf) // 转换每个字符串为 Long + .collect(Collectors.toList()); + attachIdList.addAll(longList); + } } } } diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesProductPlanServiceImpl.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesProductPlanServiceImpl.java index 7e622df8..c67bb4b3 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesProductPlanServiceImpl.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesProductPlanServiceImpl.java @@ -9,12 +9,10 @@ import com.hw.common.core.constant.MesConstants; import com.hw.common.core.exception.ServiceException; import com.hw.common.core.utils.DateUtils; import com.hw.common.core.utils.SocketUtils; -import com.hw.common.core.utils.ip.IpUtils; import com.hw.common.core.utils.uuid.Seq; import com.hw.common.security.utils.SecurityUtils; import com.hw.mes.api.domain.MesBaseBarcodeInfo; -import com.hw.mes.api.domain.MesBaseStationInfo; import com.hw.mes.config.MesConfig; import com.hw.mes.domain.*; import com.hw.mes.domain.vo.MesAssignTaskVo; @@ -25,7 +23,6 @@ import com.hw.mes.mapper.*; import com.hw.mes.service.IMesBaseAttachInfoService; import com.hw.mes.service.IMesProductOrderService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; import com.hw.common.core.utils.StringUtils; @@ -776,6 +773,81 @@ public class MesProductPlanServiceImpl implements IMesProductPlanService { return mesProductPlanMapper.selectMesProductPlanJoinUserList(mesProductPlan); } + /** + * 获取生产派工附件List列表 + * @param attachType + * @param dispatchCode + * @param processId + * @param userId + * @return + */ + @Override + public List getAttachInfoList(String dispatchCode, Long processId, Long userId, String attachType) { + MesProductPlan queryProductPlan = new MesProductPlan(); + queryProductPlan.setProcessId(processId); + queryProductPlan.setDispatchCode(dispatchCode); + queryProductPlan.setUserId(userId); + List mesProductPlans = mesProductPlanMapper.selectOnlyMesProductPlans(queryProductPlan); + if (mesProductPlans != null && !mesProductPlans.isEmpty()) { + MesProductPlan mesProductPlan = mesProductPlans.get(0); + try { + if (attachType.equals(MesConstants.MES_ATTACH_TYPE_DRAWING)) { + if (StringUtils.isEmpty(mesProductPlan.getAttachId())) { + return new ArrayList<>(); + } + Long[] attachIds = Arrays.stream(mesProductPlan.getAttachId().split(",")) + .map(String::trim) + .map(Long::parseLong) + .toArray(Long[]::new); + return mesBaseAttachInfoService.selectMesBaseAttachInfoByAttachIds(attachIds); + } else if (attachType.equals(MesConstants.MES_ATTACH_TYPE_SOP)) { + if (StringUtils.isEmpty(mesProductPlan.getSopId())) { + return new ArrayList<>(); + } + Long[] sopIds = Arrays.stream(mesProductPlan.getSopId().split(",")) + .map(String::trim) + .map(Long::parseLong) + .toArray(Long[]::new); + return mesBaseAttachInfoService.selectMesBaseAttachInfoByAttachIds(sopIds); + } else { + return new ArrayList<>(); + } + } catch (Exception e) { + return new ArrayList<>(); + } + } + return new ArrayList<>(); + } + + /** + * 校验生产派工是否已绑定附件 + * @param attachType + * @param attachId + * @return + */ + @Override + public String checkMesProductPlanAttachInfo(String attachType, String attachId) { + String result = null; + StringBuilder buffer = new StringBuilder(); + buffer.append("生产派工已绑定此"); + List productPlanList = new ArrayList<>(); + MesProductPlan mesProductPlan = new MesProductPlan(); + if (attachType.equals(MesConstants.MES_ATTACH_TYPE_DRAWING)) { + mesProductPlan.setAttachId(attachId); + productPlanList = mesProductPlanMapper.selectMesProductPlanList(mesProductPlan); + buffer.append("图纸!"); + } else if (attachType.equals(MesConstants.MES_ATTACH_TYPE_SOP)){ + mesProductPlan.setSopId(attachId); + productPlanList = mesProductPlanMapper.selectMesProductPlanList(mesProductPlan); + buffer.append("SOP!"); + } + if (productPlanList.size() > 0){ + result = buffer.toString(); + } + //未绑定 + return result; + } + // public String executeAssignTaskResultTask() { // ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); diff --git a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesMaterialBomMapper.xml b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesMaterialBomMapper.xml index ad32149d..c785794a 100644 --- a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesMaterialBomMapper.xml +++ b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesMaterialBomMapper.xml @@ -62,7 +62,7 @@ and parent_id = #{parentId} - and ancestors like concat('%', #{ancestors},'%') + and (material_bom_id = #{ancestors} or ancestors like concat('%', #{ancestors},'%')) and material_id = #{materialId} and erp_material_id = #{erpMaterialId} and material_name like concat('%', #{materialName}, diff --git a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesProductPlanMapper.xml b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesProductPlanMapper.xml index 293e5821..191f1ebb 100644 --- a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesProductPlanMapper.xml +++ b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesProductPlanMapper.xml @@ -152,7 +152,8 @@ and mpp.plan_end_time = #{planEndTime} and mpp.real_begin_time = #{realBeginTime} and mpp.real_end_time = #{realEndTime} - and mpp.attach_id = #{attachId} + and mpp.attach_id like concat('%', #{attachId},'%') + and mpp.sop_id like concat('%', #{sopId},'%') and mpp.plan_status = #{planStatus} and mpp.is_flag = #{isFlag} @@ -510,6 +511,7 @@ and a.dispatch_code = #{dispatchCode} and a.process_id = #{processId} + and a.user_id = #{userId} and a.final_process_flag = #{finalProcessFlag} and a.product_order_id = #{productOrderId} diff --git a/hw-ui/src/api/mes/productplan.js b/hw-ui/src/api/mes/productplan.js index c3d80d84..5820359d 100644 --- a/hw-ui/src/api/mes/productplan.js +++ b/hw-ui/src/api/mes/productplan.js @@ -154,3 +154,19 @@ export function getUserList(query) { params: query }) } + +// 获取生产派工附件List列表 +export function getAttachInfoList(attachType, dispatchCode, processId, userId) { + return request({ + url: '/mes/productplan/attachInfoList/' + attachType + '/' + dispatchCode + '/' + processId + '/' + userId, + method: 'get' + }) +} + +// 校验生产派工是否已绑定附件 +export function checkMesProductPlanAttachInfo(attachType, attachIds) { + return request({ + url: '/mes/productplan/checkMesProductPlanAttachInfo/' + attachType + '/' + attachIds, + method: 'get' + }) +} diff --git a/hw-ui/src/views/mes/materialBom/index.vue b/hw-ui/src/views/mes/materialBom/index.vue index e5446e6f..1f383bfb 100644 --- a/hw-ui/src/views/mes/materialBom/index.vue +++ b/hw-ui/src/views/mes/materialBom/index.vue @@ -470,7 +470,10 @@ import "@riophae/vue-treeselect/dist/vue-treeselect.css"; import selectMaterial from '@//views/mes/materialinfo/selectMaterial.vue'; import {verifyBOMIsProduction} from "@//api/mes/productOrder"; import {getToken} from "@/utils/auth"; -import {getDispatchDrawingList, getDispatchSOPAttachList, uploadFile} from "@/api/mes/productplan"; +import { + checkMesProductPlanAttachInfo, + uploadFile +} from "@/api/mes/productplan"; import {selectByAttachIds} from "@/api/mes/baseAttachInfo"; import {findUserList} from "@/api/system/user"; import {getConfigKey} from "@/api/system/config"; @@ -972,6 +975,7 @@ export default { }, //添加图纸提交 drawingFileUploadSubmit() { + this.$modal.loading(); this.addProductPlanObject.attachId = this.uploadAttachList[this.addProductPlanObject.materialBomId].join(","); this.uploadAttachList = []; let updateData = { @@ -984,6 +988,7 @@ export default { updateBomAttachInfo(updateData).then(response => { this.$modal.msgSuccess("更新图纸成功"); this.addProductPlanObject = null; + this.$modal.closeLoading(); this.blueprintModel = false; this.getList(); }).catch(() => { @@ -1013,9 +1018,20 @@ export default { ); }, //删除上传的图片 - handleRemoveDrawing(file) { + async handleRemoveDrawing(file) { let arrPic = this.$refs.drawingUpload.uploadFiles; let index = arrPic.indexOf(file); + let flag = false; + let attachId = this.uploadAttachList[this.addProductPlanObject.materialBomId][index]; + await checkMesProductPlanAttachInfo("1", attachId).then(res => { + if (res.msg != null){ + this.$modal.msgWarning(res.msg); + flag = true + } + }) + if (flag){ + return + } this.uploadAttachList[this.addProductPlanObject.materialBomId].splice(index, 1); let num = 0; arrPic.map((item) => { @@ -1050,6 +1066,7 @@ export default { }, //添加sop提交 sopFileUploadSubmit() { + this.$modal.loading(); this.addProductPlanObject.sopId = this.uploadSopList[this.addProductPlanObject.materialBomId].join(","); this.uploadSopList = []; let updateData = { @@ -1062,6 +1079,7 @@ export default { updateBomAttachInfo(updateData).then(response => { this.$modal.msgSuccess("更新SOP成功"); this.addProductPlanObject = null; + this.$modal.closeLoading(); this.sopViewModel = false; this.getList(); }).catch(() => { @@ -1091,9 +1109,20 @@ export default { ); }, //删除上传的图片 - handleRemoveSop(file) { + async handleRemoveSop(file) { let arrPic = this.$refs.drawingUpload.uploadFiles; let index = arrPic.indexOf(file); + let flag = false; + let attachId = this.uploadAttachList[this.addProductPlanObject.materialBomId][index]; + await checkMesProductPlanAttachInfo("2", attachId).then(res => { + if (res.msg != null){ + this.$modal.msgWarning(res.msg); + flag = true + } + }) + if (flag){ + return + } this.uploadSopList[this.addProductPlanObject.materialBomId].splice(index, 1); let num = 0; arrPic.map((item) => { diff --git a/hw-ui/src/views/mes/productplan/editProductPlan.vue b/hw-ui/src/views/mes/productplan/editProductPlan.vue index b08f92e6..387f6f0f 100644 --- a/hw-ui/src/views/mes/productplan/editProductPlan.vue +++ b/hw-ui/src/views/mes/productplan/editProductPlan.vue @@ -409,13 +409,13 @@ import {getProductOrder} from "@//api/mes/productOrder"; import { deleteProductPlansByDispatchCode, - getDispatchCode, getDispatchDrawingList, getDispatchSOPAttachList, + getDispatchCode, selectProductPlans, checkAddMesProductPlanList, orderAddMesProductPlanList, getBaseRouteProcesses, getProcessUsers, - uploadFile + uploadFile, getAttachInfoList } from "@//api/mes/productplan"; import {getConfigKey} from "@//api/system/config" import {deepClone} from "@//utils/index"; @@ -604,7 +604,10 @@ export default { INTERNAL: '2',//对内生产 }, id: 1, - + ATTACH_TYPE: { + DRAWING: "1",//附件类别:加工图纸 + SOP: "2",//附件类别:SOP + }, processUsers: [], //物料BOMList attachInfoList: [], @@ -615,7 +618,6 @@ export default { watch: { 'materialBomAttachIdList': { handler(newVal, oldVal) { - console.log("val:",newVal,oldVal) this.updateAttachInfoByBom(newVal, oldVal); }, } @@ -804,21 +806,23 @@ export default { this.$set(data.children, data.children.length, { id: id, + dispatchCode: scope.row.dispatchCode, processId: scope.row.processId, productionTime: scope.row.productionTime, materialBomId: scope.row.materialBomId, planStatus: this.PLAN_STATUS.DISPATCHED, - userId: "" + userId: null }) } else { this.$set(data, 'children', [ { id: id, + dispatchCode: scope.row.dispatchCode, processId: scope.row.processId, productionTime: scope.row.productionTime, materialBomId: scope.row.materialBomId, planStatus: this.PLAN_STATUS.DISPATCHED, - userId: "", + userId: null, } ]) } @@ -901,8 +905,8 @@ export default { toUpdatedProductPlan.planEndTime = processUser.planEndTime; toUpdatedProductPlan.planId = processUser.planId; toUpdatedProductPlan.planStatus = processUser.planStatus; - toUpdatedProductPlan.attachId = e.attachId; - toUpdatedProductPlan.sopId = e.sopId; + toUpdatedProductPlan.attachId = processUser.attachId; + toUpdatedProductPlan.sopId = processUser.sopId; toUpdatedProductPlan.planAmount = planDispatchAmount; toUpdatedProductPlan.dispatchAmount = planDispatchAmount; toUpdatedProductPlan.children = null; @@ -1117,11 +1121,12 @@ export default { } else { obj.children = [{ id: this.id, + dispatchCode: obj.dispatchCode, processId: obj.processId, materialBomId: obj.materialBomId, planStatus: this.PLAN_STATUS.DISPATCHED, productionTime: obj.productionTime, - userId: "" + userId: null }] } @@ -1166,10 +1171,10 @@ export default { /** 查看图纸 */ handleDrawing(row) { this.fileList = []; - if (row.planId != null && (!this.previewDrawingFlag[row.dispatchCode + "-" + row.processId] - || this.previewDrawingFlag[row.dispatchCode + "-" + row.processId] !== "1")) { - this.previewDrawingFlag[row.dispatchCode + "-" + row.processId] = "1"; - getDispatchDrawingList(row.dispatchCode, row.processId).then(res => { + if (row.planId != null && (!this.previewDrawingFlag[row.dispatchCode + "-" + row.processId + "-" + row.userId] + || this.previewDrawingFlag[row.dispatchCode + "-" + row.processId + "-" + row.userId] !== "1")) { + this.previewDrawingFlag[row.dispatchCode + "-" + row.processId + "-" + row.userId] = "1"; + getAttachInfoList(this.ATTACH_TYPE.DRAWING, row.dispatchCode, row.processId, row.userId).then(res => { let attachList = res.data; attachList.forEach(e => { let previewFile = {}; @@ -1183,19 +1188,19 @@ export default { groupAttachFile.attachId = e.attachId; groupAttachFile.attachPath = e.attachPath; groupAttachFile.attachName = e.attachName; - let groupAttachFileList = this.groupAttachFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId]; - this.groupAttachFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId] = groupAttachFileList ? this.groupAttachFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId] : []; - this.groupAttachFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId].push(groupAttachFile); + let groupAttachFileList = this.groupAttachFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId]; + this.groupAttachFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId] = groupAttachFileList ? this.groupAttachFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId] : []; + this.groupAttachFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId].push(groupAttachFile); - let uploadAttachList = this.uploadAttachList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId]; - this.uploadAttachList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId] = uploadAttachList ? this.uploadAttachList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId] : []; - this.uploadAttachList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId].push(e.attachId); + let uploadAttachList = this.uploadAttachList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId]; + this.uploadAttachList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId] = uploadAttachList ? this.uploadAttachList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId] : []; + this.uploadAttachList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId].push(e.attachId); }) }) } else { - if (this.groupAttachFileList[row.dispatchCode + "-" + row.processId]) { - this.groupAttachFileList[row.dispatchCode + "-" + row.processId].forEach(e => { + if (this.groupAttachFileList[row.dispatchCode + "-" + row.processId + "-" + row.userId]) { + this.groupAttachFileList[row.dispatchCode + "-" + row.processId + "-" + row.userId].forEach(e => { let previewFile = {}; previewFile.url = e.attachPath; previewFile.name = e.attachName; @@ -1206,7 +1211,7 @@ export default { this.addProductPlanObject = row; this.materialBomAttachIdList = []; - getBomAttachInfo("1", this.addProductPlanObject.materialBomId).then(response => { + getBomAttachInfo(this.ATTACH_TYPE.DRAWING, this.addProductPlanObject.materialBomId).then(response => { this.attachInfoList = response.data; for (let e of this.fileList) { let attachInfo = this.attachInfoList.find(item => item.attachPath === e.url); @@ -1222,9 +1227,12 @@ export default { drawingFileUploadSubmit() { for (let i = 0; i < this.mesProductPlanList.length; i++) { let mesProductPlan = this.mesProductPlanList[i]; - if (mesProductPlan.dispatchCode === this.addProductPlanObject.dispatchCode - && mesProductPlan.processId === this.addProductPlanObject.processId) { - this.mesProductPlanList[i].attachId = this.uploadAttachList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId].join(","); + for (let child of mesProductPlan.children) { + if (mesProductPlan.dispatchCode === this.addProductPlanObject.dispatchCode + && mesProductPlan.processId === this.addProductPlanObject.processId + && child.userId === this.addProductPlanObject.userId) { + child.attachId = this.uploadAttachList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId].join(","); + } } } // this.uploadAttachList = []; @@ -1240,12 +1248,12 @@ export default { const formData = new FormData(); formData.append("file", fileData); formData.append("processId", this.addProductPlanObject.processId); - formData.append("attachType", "1"); + formData.append("attachType", this.ATTACH_TYPE.DRAWING); uploadFile(formData).then( (res) => { - let uploadAttachList = this.uploadAttachList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId]; - this.uploadAttachList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId] = uploadAttachList ? this.uploadAttachList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId] : []; - this.uploadAttachList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId].push(res.attachId); + let uploadAttachList = this.uploadAttachList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId]; + this.uploadAttachList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId] = uploadAttachList ? this.uploadAttachList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId] : []; + this.uploadAttachList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId].push(res.attachId); // 存储附件信息主键 let groupAttachFile = {}; @@ -1254,9 +1262,9 @@ export default { groupAttachFile.attachId = res.attachId; groupAttachFile.attachPath = res.imgUrl; groupAttachFile.attachName = res.fileName; - let groupAttachFileList = this.groupAttachFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId]; - this.groupAttachFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId] = groupAttachFileList ? this.groupAttachFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId] : []; - this.groupAttachFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId].push(groupAttachFile); + let groupAttachFileList = this.groupAttachFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId]; + this.groupAttachFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId] = groupAttachFileList ? this.groupAttachFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId] : []; + this.groupAttachFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId].push(groupAttachFile); this.$modal.closeLoading(); }, (err) => { this.$refs.drawingUpload.clearFiles(); //上传失败后清除当前上传的图片 @@ -1269,10 +1277,10 @@ export default { handleRemoveDrawing(file) { let arrPic = this.$refs.drawingUpload.uploadFiles; let index = arrPic.indexOf(file); - this.uploadAttachList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId].splice(index, 1); + this.uploadAttachList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId].splice(index, 1); // this.uploadAttachList.splice(index, 1); this.fileList.splice(index, 1); - this.groupAttachFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId].splice(index, 1); + this.groupAttachFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId].splice(index, 1); let num = 0; arrPic.map((item) => { if (item.uid === file.uid) { @@ -1290,10 +1298,10 @@ export default { /** 查看sop */ handleSop(row) { this.fileList = []; - if (row.planId != null && (!this.previewSopFlag[row.dispatchCode + "-" + row.processId] - || this.previewSopFlag[row.dispatchCode + "-" + row.processId] !== "1")) { - this.previewSopFlag[row.dispatchCode + "-" + row.processId] = "1"; - getDispatchSOPAttachList(row.dispatchCode, row.processId).then(res => { + if (row.planId != null && (!this.previewSopFlag[row.dispatchCode + "-" + row.processId + "-" + row.userId] + || this.previewSopFlag[row.dispatchCode + "-" + row.processId + "-" + row.userId] !== "1")) { + this.previewSopFlag[row.dispatchCode + "-" + row.processId + "-" + row.userId] = "1"; + getAttachInfoList(this.ATTACH_TYPE.SOP, row.dispatchCode, row.processId, row.userId).then(res => { let attachList = res.data; attachList.forEach(e => { let previewFile = {}; @@ -1307,19 +1315,19 @@ export default { groupSopFile.attachId = e.attachId; groupSopFile.attachPath = e.attachPath; groupSopFile.attachName = e.attachName; - let groupSopFileList = this.groupSopFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId]; - this.groupSopFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId] = groupSopFileList ? this.groupSopFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId] : []; - this.groupSopFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId].push(groupSopFile); + let groupSopFileList = this.groupSopFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId]; + this.groupSopFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId] = groupSopFileList ? this.groupSopFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId] : []; + this.groupSopFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId].push(groupSopFile); - let uploadSopList = this.uploadSopList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId]; - this.uploadSopList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId] = uploadSopList ? this.uploadSopList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId] : []; - this.uploadSopList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId].push(e.attachId); + let uploadSopList = this.uploadSopList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId]; + this.uploadSopList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId] = uploadSopList ? this.uploadSopList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId] : []; + this.uploadSopList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId].push(e.attachId); }) }) } else { - if (this.groupSopFileList[row.dispatchCode + "-" + row.processId]) { - this.groupSopFileList[row.dispatchCode + "-" + row.processId].forEach(e => { + if (this.groupSopFileList[row.dispatchCode + "-" + row.processId + "-" + row.userId]) { + this.groupSopFileList[row.dispatchCode + "-" + row.processId + "-" + row.userId].forEach(e => { let previewFile = {}; previewFile.url = e.attachPath; previewFile.name = e.attachName; @@ -1330,7 +1338,7 @@ export default { this.addProductPlanObject = row; this.materialBomAttachIdList = []; - getBomAttachInfo("2", this.addProductPlanObject.materialBomId).then(response => { + getBomAttachInfo(this.ATTACH_TYPE.SOP, this.addProductPlanObject.materialBomId).then(response => { this.attachInfoList = response.data; for (let e of this.fileList) { let attachInfo = this.attachInfoList.find(item => item.attachPath === e.url); @@ -1346,10 +1354,12 @@ export default { sopFileUploadSubmit() { for (let i = 0; i < this.mesProductPlanList.length; i++) { let mesProductPlan = this.mesProductPlanList[i]; - - if (mesProductPlan.dispatchCode === this.addProductPlanObject.dispatchCode - && mesProductPlan.processId === this.addProductPlanObject.processId) { - this.mesProductPlanList[i].sopId = this.uploadSopList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId].join(","); + for (let child of mesProductPlan.children) { + if (mesProductPlan.dispatchCode === this.addProductPlanObject.dispatchCode + && mesProductPlan.processId === this.addProductPlanObject.processId + && child.userId === this.addProductPlanObject.userId) { + child.sopId = this.uploadSopList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId].join(","); + } } } // this.uploadAttachList = []; @@ -1365,12 +1375,12 @@ export default { const formData = new FormData(); formData.append("file", fileData); formData.append("processId", this.addProductPlanObject.processId); - formData.append("attachType", "2"); + formData.append("attachType", this.ATTACH_TYPE.SOP); uploadFile(formData).then( (res) => { - let uploadSopList = this.uploadSopList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId]; - this.uploadSopList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId] = uploadSopList ? this.uploadSopList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId] : []; - this.uploadSopList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId].push(res.attachId); + let uploadSopList = this.uploadSopList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId]; + this.uploadSopList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId] = uploadSopList ? this.uploadSopList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId] : []; + this.uploadSopList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId].push(res.attachId); // 存储附件信息主键 let groupSopFile = {}; @@ -1379,9 +1389,9 @@ export default { groupSopFile.attachId = res.attachId; groupSopFile.attachPath = res.imgUrl; groupSopFile.attachName = res.fileName; - let groupSopFileList = this.groupSopFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId]; - this.groupSopFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId] = groupSopFileList ? this.groupSopFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId] : []; - this.groupSopFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId].push(groupSopFile); + let groupSopFileList = this.groupSopFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId]; + this.groupSopFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId] = groupSopFileList ? this.groupSopFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId] : []; + this.groupSopFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId].push(groupSopFile); this.$modal.closeLoading(); }, (err) => { this.$refs.drawingUpload.clearFiles(); //上传失败后清除当前上传的图片 @@ -1394,8 +1404,8 @@ export default { handleRemoveSop(file) { let arrPic = this.$refs.drawingUpload.uploadFiles; let index = arrPic.indexOf(file); - this.uploadSopList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId].splice(index, 1); - this.groupSopFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId].splice(index, 1); + this.uploadSopList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId].splice(index, 1); + this.groupSopFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId].splice(index, 1); this.fileList.splice(index, 1); let num = 0; arrPic.map((item) => { @@ -1505,12 +1515,12 @@ export default { groupAttachFile.attachId = e.attachId; groupAttachFile.attachPath = e.attachPath; groupAttachFile.attachName = e.attachName; - let groupAttachFileList = this.groupAttachFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId]; - this.groupAttachFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId] = groupAttachFileList ? this.groupAttachFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId] : []; - this.groupAttachFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId].push(groupAttachFile); - let uploadAttachList = this.uploadAttachList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId]; - this.uploadAttachList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId] = uploadAttachList ? this.uploadAttachList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId] : []; - this.uploadAttachList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId].push(e.attachId); + let groupAttachFileList = this.groupAttachFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId]; + this.groupAttachFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId] = groupAttachFileList ? this.groupAttachFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId] : []; + this.groupAttachFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId].push(groupAttachFile); + let uploadAttachList = this.uploadAttachList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId]; + this.uploadAttachList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId] = uploadAttachList ? this.uploadAttachList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId] : []; + this.uploadAttachList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId].push(e.attachId); } } else { //SOP @@ -1525,12 +1535,12 @@ export default { groupSopFile.attachId = e.attachId; groupSopFile.attachPath = e.attachPath; groupSopFile.attachName = e.attachName; - let groupSopFileList = this.groupSopFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId]; - this.groupSopFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId] = groupSopFileList ? this.groupSopFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId] : []; - this.groupSopFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId].push(groupSopFile); - let uploadSopList = this.uploadSopList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId]; - this.uploadSopList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId] = uploadSopList ? this.uploadSopList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId] : []; - this.uploadSopList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId].push(e.attachId); + let groupSopFileList = this.groupSopFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId]; + this.groupSopFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId] = groupSopFileList ? this.groupSopFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId] : []; + this.groupSopFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId].push(groupSopFile); + let uploadSopList = this.uploadSopList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId]; + this.uploadSopList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId] = uploadSopList ? this.uploadSopList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId] : []; + this.uploadSopList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId + "-" + this.addProductPlanObject.userId].push(e.attachId); } } },