From 7aff5c2f77cc2d9f7589ee7ca5c547e925f95dd5 Mon Sep 17 00:00:00 2001 From: xs Date: Fri, 9 Aug 2024 15:49:09 +0800 Subject: [PATCH] =?UTF-8?q?2.9.0=20MES:=20-=E7=94=9F=E4=BA=A7=E6=B4=BE?= =?UTF-8?q?=E5=B7=A5=EF=BC=9A=E4=B8=8A=E4=BC=A0=E5=9B=BE=E7=BA=B8=E5=88=B0?= =?UTF-8?q?=E5=85=B1=E4=BA=AB=E6=96=87=E4=BB=B6=E5=A4=B9=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=8A=E4=BC=A0=E5=9B=BE=E7=BA=B8=E5=92=8C?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0SOP=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hw/system/api/RemoteFileService.java | 10 + .../factory/RemoteFileFallbackFactory.java | 5 + .../hw/file/controller/SysFileController.java | 23 ++ .../service/FastDfsSysFileServiceImpl.java | 5 + .../com/hw/file/service/ISysFileService.java | 9 + .../file/service/LocalSysFileServiceImpl.java | 30 ++ .../file/service/MinioSysFileServiceImpl.java | 5 + .../MesBaseAttachInfoController.java | 42 ++- .../views/mes/productplan/editProductPlan.vue | 267 ++++++++++++------ 9 files changed, 280 insertions(+), 116 deletions(-) diff --git a/hw-api/hw-api-system/src/main/java/com/hw/system/api/RemoteFileService.java b/hw-api/hw-api-system/src/main/java/com/hw/system/api/RemoteFileService.java index 17332f0..564637e 100644 --- a/hw-api/hw-api-system/src/main/java/com/hw/system/api/RemoteFileService.java +++ b/hw-api/hw-api-system/src/main/java/com/hw/system/api/RemoteFileService.java @@ -26,4 +26,14 @@ public interface RemoteFileService */ @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) public R upload(@RequestPart(value = "file") MultipartFile file); + + + /** + * 上传文件到共享文件夹 + * + * @param file 文件信息 + * @return 结果 + */ + @PostMapping(value = "/upload2SharePath", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + public R upload2SharePath(@RequestPart(value = "file") MultipartFile file); } diff --git a/hw-api/hw-api-system/src/main/java/com/hw/system/api/factory/RemoteFileFallbackFactory.java b/hw-api/hw-api-system/src/main/java/com/hw/system/api/factory/RemoteFileFallbackFactory.java index 47f194d..4efc302 100644 --- a/hw-api/hw-api-system/src/main/java/com/hw/system/api/factory/RemoteFileFallbackFactory.java +++ b/hw-api/hw-api-system/src/main/java/com/hw/system/api/factory/RemoteFileFallbackFactory.java @@ -30,6 +30,11 @@ public class RemoteFileFallbackFactory implements FallbackFactory upload2SharePath(MultipartFile file) { + return R.fail("上传文件到共享文件夹失败:" + throwable.getMessage()); + } }; } } diff --git a/hw-modules/hw-file/src/main/java/com/hw/file/controller/SysFileController.java b/hw-modules/hw-file/src/main/java/com/hw/file/controller/SysFileController.java index 7af2335..45de984 100644 --- a/hw-modules/hw-file/src/main/java/com/hw/file/controller/SysFileController.java +++ b/hw-modules/hw-file/src/main/java/com/hw/file/controller/SysFileController.java @@ -45,4 +45,27 @@ public class SysFileController return R.fail(e.getMessage()); } } + + + /** + * 文件上传请求,共享文件夹 + */ + @PostMapping("upload2SharePath") + public R upload2SharePath(MultipartFile file) + { + try + { + // 上传并返回访问地址 + String url = sysFileService.uploadFile2SharePath(file); + SysFile sysFile = new SysFile(); + sysFile.setName(FileUtils.getName(url)); + sysFile.setUrl(url); + return R.ok(sysFile); + } + catch (Exception e) + { + log.error("上传文件到共享文件夹失败", e); + return R.fail(e.getMessage()); + } + } } \ No newline at end of file diff --git a/hw-modules/hw-file/src/main/java/com/hw/file/service/FastDfsSysFileServiceImpl.java b/hw-modules/hw-file/src/main/java/com/hw/file/service/FastDfsSysFileServiceImpl.java index 3a931c3..0e060e4 100644 --- a/hw-modules/hw-file/src/main/java/com/hw/file/service/FastDfsSysFileServiceImpl.java +++ b/hw-modules/hw-file/src/main/java/com/hw/file/service/FastDfsSysFileServiceImpl.java @@ -43,4 +43,9 @@ public class FastDfsSysFileServiceImpl implements ISysFileService IoUtils.closeQuietly(inputStream); return domain + "/" + storePath.getFullPath(); } + + @Override + public String uploadFile2SharePath(MultipartFile file) throws Exception { + return null; + } } diff --git a/hw-modules/hw-file/src/main/java/com/hw/file/service/ISysFileService.java b/hw-modules/hw-file/src/main/java/com/hw/file/service/ISysFileService.java index cfb35f9..d5939a6 100644 --- a/hw-modules/hw-file/src/main/java/com/hw/file/service/ISysFileService.java +++ b/hw-modules/hw-file/src/main/java/com/hw/file/service/ISysFileService.java @@ -17,4 +17,13 @@ public interface ISysFileService * @throws Exception */ public String uploadFile(MultipartFile file) throws Exception; + + /** + * 本地文件上传接口,上传到服务器共享文件夹 + * + * @param file 上传的文件 + * @return 访问地址 + * @throws Exception + */ + public String uploadFile2SharePath(MultipartFile file) throws Exception; } diff --git a/hw-modules/hw-file/src/main/java/com/hw/file/service/LocalSysFileServiceImpl.java b/hw-modules/hw-file/src/main/java/com/hw/file/service/LocalSysFileServiceImpl.java index 87b37cb..5fc8f8a 100644 --- a/hw-modules/hw-file/src/main/java/com/hw/file/service/LocalSysFileServiceImpl.java +++ b/hw-modules/hw-file/src/main/java/com/hw/file/service/LocalSysFileServiceImpl.java @@ -33,6 +33,19 @@ public class LocalSysFileServiceImpl implements ISysFileService @Value("${file.path}") private String localFilePath; + /** + * 上传文件存储在本地的共享文件夹路径 + */ + @Value("${file.sharePath}") + public String shareFilePath; + + /** + * 共享文件夹资源映射路径 前缀 + */ + @Value("${file.sharePrefix}") + public String shareFilePrefix; + + /** * 本地文件上传接口 * @@ -47,4 +60,21 @@ public class LocalSysFileServiceImpl implements ISysFileService String url = domain + localFilePrefix + name; return url; } + + + /** + * 本地文件上传接口,上传到服务器共享文件夹 + * + * @param file 上传的文件 + * @return 访问地址 + * @throws Exception + */ + @Override + public String uploadFile2SharePath(MultipartFile file) throws Exception + { + String name = FileUploadUtils.upload(shareFilePath, file); + String url = domain + shareFilePrefix + name; + return url; + } + } diff --git a/hw-modules/hw-file/src/main/java/com/hw/file/service/MinioSysFileServiceImpl.java b/hw-modules/hw-file/src/main/java/com/hw/file/service/MinioSysFileServiceImpl.java index 66d5916..0ba92f1 100644 --- a/hw-modules/hw-file/src/main/java/com/hw/file/service/MinioSysFileServiceImpl.java +++ b/hw-modules/hw-file/src/main/java/com/hw/file/service/MinioSysFileServiceImpl.java @@ -46,4 +46,9 @@ public class MinioSysFileServiceImpl implements ISysFileService IoUtils.closeQuietly(inputStream); return minioConfig.getUrl() + "/" + minioConfig.getBucketName() + "/" + fileName; } + + @Override + public String uploadFile2SharePath(MultipartFile file) throws Exception { + return null; + } } diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesBaseAttachInfoController.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesBaseAttachInfoController.java index a0d2daf..bfb371e 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesBaseAttachInfoController.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesBaseAttachInfoController.java @@ -3,6 +3,7 @@ package com.hw.mes.controller; import java.util.List; import javax.servlet.http.HttpServletResponse; +import com.hw.common.core.constant.MesConstants; import com.hw.common.core.domain.R; import com.hw.common.core.utils.StringUtils; import com.hw.common.core.utils.uuid.UUID; @@ -24,14 +25,13 @@ import org.springframework.web.multipart.MultipartFile; /** * 附件信息Controller - * + * * @author Yinq * @date 2024-01-26 */ @RestController @RequestMapping("/baseAttachInfo") -public class MesBaseAttachInfoController extends BaseController -{ +public class MesBaseAttachInfoController extends BaseController { @Autowired private IMesBaseAttachInfoService mesBaseAttachInfoService; @@ -43,8 +43,7 @@ public class MesBaseAttachInfoController extends BaseController */ @RequiresPermissions("mes:baseAttachInfo:list") @GetMapping("/list") - public TableDataInfo list(MesBaseAttachInfo mesBaseAttachInfo) - { + public TableDataInfo list(MesBaseAttachInfo mesBaseAttachInfo) { startPage(); List list = mesBaseAttachInfoService.selectMesBaseAttachInfoList(mesBaseAttachInfo); return getDataTable(list); @@ -56,8 +55,7 @@ public class MesBaseAttachInfoController extends BaseController @RequiresPermissions("mes:baseAttachInfo:export") @Log(title = "附件信息", businessType = BusinessType.EXPORT) @PostMapping("/export") - public void export(HttpServletResponse response, MesBaseAttachInfo mesBaseAttachInfo) - { + public void export(HttpServletResponse response, MesBaseAttachInfo mesBaseAttachInfo) { List list = mesBaseAttachInfoService.selectMesBaseAttachInfoList(mesBaseAttachInfo); ExcelUtil util = new ExcelUtil(MesBaseAttachInfo.class); util.exportExcel(response, list, "附件信息数据"); @@ -68,8 +66,7 @@ public class MesBaseAttachInfoController extends BaseController */ @RequiresPermissions("mes:baseAttachInfo:query") @GetMapping(value = "/{attachId}") - public AjaxResult getInfo(@PathVariable("attachId") Long attachId) - { + public AjaxResult getInfo(@PathVariable("attachId") Long attachId) { return success(mesBaseAttachInfoService.selectMesBaseAttachInfoByAttachId(attachId)); } @@ -79,8 +76,7 @@ public class MesBaseAttachInfoController extends BaseController @RequiresPermissions("mes:baseAttachInfo:add") @Log(title = "附件信息", businessType = BusinessType.INSERT) @PostMapping - public AjaxResult add(@RequestBody MesBaseAttachInfo mesBaseAttachInfo) - { + public AjaxResult add(@RequestBody MesBaseAttachInfo mesBaseAttachInfo) { return toAjax(mesBaseAttachInfoService.insertMesBaseAttachInfo(mesBaseAttachInfo)); } @@ -90,8 +86,7 @@ public class MesBaseAttachInfoController extends BaseController @RequiresPermissions("mes:baseAttachInfo:edit") @Log(title = "附件信息", businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult edit(@RequestBody MesBaseAttachInfo mesBaseAttachInfo) - { + public AjaxResult edit(@RequestBody MesBaseAttachInfo mesBaseAttachInfo) { return toAjax(mesBaseAttachInfoService.updateMesBaseAttachInfo(mesBaseAttachInfo)); } @@ -100,26 +95,29 @@ public class MesBaseAttachInfoController extends BaseController */ @RequiresPermissions("mes:baseAttachInfo:remove") @Log(title = "附件信息", businessType = BusinessType.DELETE) - @DeleteMapping("/{attachIds}") - public AjaxResult remove(@PathVariable Long[] attachIds) - { + @DeleteMapping("/{attachIds}") + public AjaxResult remove(@PathVariable Long[] attachIds) { return toAjax(mesBaseAttachInfoService.deleteMesBaseAttachInfoByAttachIds(attachIds)); } /** * MES附件上传 - * @param file 附件 - * @param processId 工序 + * + * @param file 附件 + * @param processId 工序 * @param attachType 附件类型 * @return */ @PostMapping(value = "/drawingFileUpload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) - public AjaxResult drawingFileUpload(@RequestPart(value = "file") MultipartFile file, Long processId, String attachType){ - if (!file.isEmpty()) - { + public AjaxResult drawingFileUpload(@RequestPart(value = "file") MultipartFile file, Long processId, String attachType) { + if (!file.isEmpty()) { R fileResult = null; try { - fileResult = remoteFileService.upload(file); + if (attachType.equals(MesConstants.MES_ATTACH_TYPE_DRAWING)) { + fileResult = remoteFileService.upload2SharePath(file); + } else { + fileResult = remoteFileService.upload(file); + } } catch (Exception e) { return error("文件服务异常,请联系管理员"); } diff --git a/hw-ui/src/views/mes/productplan/editProductPlan.vue b/hw-ui/src/views/mes/productplan/editProductPlan.vue index 94688dd..42be72a 100644 --- a/hw-ui/src/views/mes/productplan/editProductPlan.vue +++ b/hw-ui/src/views/mes/productplan/editProductPlan.vue @@ -192,7 +192,7 @@ icon="el-icon-search" size="mini" type="success" - @click="handleSOP(scope.row)" + @click="handleSop(scope.row)" v-if="scope.row.processType !== PROCESS_TYPE.AUTO && scope.row.children != null && scope.row.children !== undefined" >SOP @@ -242,9 +242,9 @@ single ref="drawingUpload" list-type="picture-card" - action="uploadImgUrl" + action="uploadDrawingUrl" :auto-upload="true" - :limit="limit" + :limit="drawingLimit" :headers="headers" :before-upload="handleBeforeUpload" :http-request="httpRequest" @@ -275,7 +275,7 @@ @@ -306,7 +306,7 @@ list-type="picture-card" action="uploadImgUrl" :auto-upload="true" - :limit="limit" + :limit="sopLimit" :headers="headers" :before-upload="handleBeforeUpload" :http-request="httpSopRequest" @@ -337,7 +337,7 @@ @@ -423,15 +423,22 @@ export default { }, props: { value: [String, Object, Array, Number], - // 文件数量限制 - limit: { + // sop文件数量限制 + sopLimit: { + type: Number, + default: 10, + }, + // 图纸数量限制 + drawingLimit: { type: Number, - default: 3, + default: 10, }, - // 文件大小限制(MB) + + + // 文件大小限制(K) fileSize: { type: Number, - default: 5, + default: 500000, }, // 文件类型, 例如['png', 'jpg', 'jpeg'] fileType: { @@ -456,6 +463,7 @@ export default { checkedMesProductPlanList: [], // 上传的文件服务器地址 uploadImgUrl: process.env.VUE_APP_BASE_API, + uploadDrawingUrl: process.env.VUE_APP_BASE_API + "/file/upload2SharePath", // 选中选项卡的 name activeName: "columnInfo", // 表格的高度 @@ -509,15 +517,19 @@ export default { // 根据工序和派工单号分组Sop文件 groupSopFile: {}, // 根据工序和派工单号分组Sop文件列表 - groupSopFileList: [], + groupSopFileList: {}, + // 上传SOP文件回调列表 + uploadSopList: [], + // 根据工序和派工单号分组图纸文件 groupAttachFile: {}, // 根据工序和派工单号分组图纸文件列表 - groupAttachFileList: [], + groupAttachFileList: {}, // 上传图纸文件回调列表 - uploadAttachList: [], - // 上传SOP文件回调列表 - uploadSopList: [], + uploadAttachList: {}, + + previewSopFlag: {},//是否预览过SOP + previewDrawingFlag: {},//是否预览过图纸 //文件上传-生产派工对象 addProductPlanObject: {}, headers: { @@ -768,10 +780,10 @@ export default { if (processUser.userId && processUser.userId !== '') { toUpdatedProductPlan.userId = processUser.userId; - if(processUser.planBeginTime && processUser.planBeginTime!=='' && - processUser.planEndTime && processUser.planEndTime!=='' && - processUser.planBeginTime >= processUser.planEndTime){ - this.$modal.msgError("序号"+(parseInt(e.index)+1)+":计划开始时间须小于计划结束时间"); + if (processUser.planBeginTime && processUser.planBeginTime !== '' && + processUser.planEndTime && processUser.planEndTime !== '' && + processUser.planBeginTime >= processUser.planEndTime) { + this.$modal.msgError("序号" + (parseInt(e.index) + 1) + ":计划开始时间须小于计划结束时间"); return; } toUpdatedProductPlan.planBeginTime = processUser.planBeginTime; @@ -802,11 +814,11 @@ export default { return; } - if(e.firstFlag && e.firstFlag==="1"){//第一个标识,校验派工数量 + if (e.firstFlag && e.firstFlag === "1") {//第一个标识,校验派工数量 let dispatchAmount = e.dispatchAmount; const numericAmount = parseInt(dispatchAmount, 10); if (!this.isPositiveInteger(numericAmount) || numericAmount <= 0) { - this.$modal.msgError( "派工数量须为大于等于0的正整数!"); + this.$modal.msgError("派工数量须为大于等于0的正整数!"); return; } @@ -1045,11 +1057,13 @@ export default { window.open(file.url); }, + /** 查看图纸 */ handleDrawing(row) { this.fileList = []; - this.uploadAttachList = []; - if (row.oldRowFlag) { + if (row.oldRowFlag && (!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 => { let attachList = res.data; attachList.forEach(e => { @@ -1057,52 +1071,36 @@ export default { previewFile.url = e.attachPath; previewFile.name = e.attachName; this.fileList.push(previewFile); - this.uploadAttachList.push(e.attachId); - }) - }) - } - this.groupAttachFileList.forEach(e => { - if (e.dispatchCode === row.dispatchCode && e.processId === row.processId) { - let previewFile = {}; - previewFile.url = e.attachPath; - previewFile.name = e.attachName; - this.fileList.push(previewFile); - this.uploadAttachList.push(e.attachId); - } - }) - this.addProductPlanObject = row; - this.blueprintModel = true; - }, + let groupAttachFile = {}; + groupAttachFile.dispatchCode = row.dispatchCode; + groupAttachFile.processId = row.processId; + 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); - /** 查看SOP附件 */ - handleSOP(row) { - this.fileList = []; - this.uploadSopList = []; - if (row.oldRowFlag) { - getDispatchSOPAttachList(row.dispatchCode, row.processId).then(res => { - let attachList = res.data; - attachList.forEach(e => { + 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); + + }) + }) + } else { + if (this.groupAttachFileList[row.dispatchCode + "-" + row.processId]) { + this.groupAttachFileList[row.dispatchCode + "-" + row.processId].forEach(e => { let previewFile = {}; previewFile.url = e.attachPath; previewFile.name = e.attachName; this.fileList.push(previewFile); - this.uploadSopList.push(e.attachId); }) - }) + } } - this.groupSopFileList.forEach(e => { - if (e.dispatchCode === row.dispatchCode && e.processId === row.processId) { - let previewFile = {}; - previewFile.url = e.attachPath; - previewFile.name = e.attachName; - this.fileList.push(previewFile); - this.uploadSopList.push(e.attachId); - } - }) this.addProductPlanObject = row; - this.sopViewModel = true; + this.blueprintModel = true; }, //添加图纸提交 @@ -1112,28 +1110,14 @@ export default { if (mesProductPlan.dispatchCode === this.addProductPlanObject.dispatchCode && mesProductPlan.processId === this.addProductPlanObject.processId) { - this.mesProductPlanList[i].attachId = this.uploadAttachList.join(","); + this.mesProductPlanList[i].attachId = this.uploadAttachList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId].join(","); } } - this.uploadAttachList = []; + // this.uploadAttachList = []; this.addProductPlanObject = null; this.blueprintModel = false; }, - //添加SOP附件提交 - 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.join(","); - } - } - - this.uploadSopList = []; - this.addProductPlanObject = null; - this.sopViewModel = false; - }, //图纸图片上传 httpRequest(file) { @@ -1145,6 +1129,10 @@ export default { formData.append("attachType", "1"); 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 groupAttachFile = {}; groupAttachFile.dispatchCode = this.addProductPlanObject.dispatchCode; @@ -1152,8 +1140,9 @@ export default { groupAttachFile.attachId = res.attachId; groupAttachFile.attachPath = res.imgUrl; groupAttachFile.attachName = res.fileName; - this.groupAttachFileList.push(groupAttachFile); - this.uploadAttachList.push(res.attachId); + 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); }, (err) => { this.$refs.drawingUpload.clearFiles(); //上传失败后清除当前上传的图片 this.$modal.closeLoading(); @@ -1161,17 +1150,110 @@ 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.splice(index, 1); + // this.fileList.splice(index, 1); + this.groupAttachFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId].splice(index, 1); + let num = 0; + arrPic.map((item) => { + if (item.uid === file.uid) { + arrPic.splice(num, 1); + } + num++; + }); + }, + + - //SOP图片上传 + + + + + + + + + + + /** 查看sop */ + handleSop(row) { + this.fileList = []; + if (row.oldRowFlag && (!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 => { + let attachList = res.data; + attachList.forEach(e => { + let previewFile = {}; + previewFile.url = e.attachPath; + previewFile.name = e.attachName; + this.fileList.push(previewFile); + + let groupSopFile = {}; + groupSopFile.dispatchCode = row.dispatchCode; + groupSopFile.processId = row.processId; + 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); + + }) + }) + } else { + if (this.groupSopFileList[row.dispatchCode + "-" + row.processId]) { + this.groupSopFileList[row.dispatchCode + "-" + row.processId].forEach(e => { + let previewFile = {}; + previewFile.url = e.attachPath; + previewFile.name = e.attachName; + this.fileList.push(previewFile); + }) + } + } + + this.addProductPlanObject = row; + this.sopViewModel = true; + }, + + //添加sop提交 + 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(","); + } + } + // this.uploadAttachList = []; + this.addProductPlanObject = null; + this.sopViewModel = false; + }, + + + //Sop图片上传 httpSopRequest(file) { // 文件信息 const fileData = file.file; const formData = new FormData(); formData.append("file", fileData); formData.append("processId", this.addProductPlanObject.processId); - formData.append("attachType", "1"); + formData.append("attachType", "2"); 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 groupSopFile = {}; groupSopFile.dispatchCode = this.addProductPlanObject.dispatchCode; @@ -1179,8 +1261,9 @@ export default { groupSopFile.attachId = res.attachId; groupSopFile.attachPath = res.imgUrl; groupSopFile.attachName = res.fileName; - this.groupSopFileList.push(groupSopFile); - this.uploadSopList.push(res.attachId); + 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); }, (err) => { this.$refs.drawingUpload.clearFiles(); //上传失败后清除当前上传的图片 this.$modal.closeLoading(); @@ -1188,21 +1271,12 @@ export default { ); }, - // 上传结束处理 - uploadedSuccessfully() { - if (this.number > 0 && this.uploadList.length === this.number) { - this.fileList = this.fileList.concat(this.uploadList); - this.uploadList = []; - this.number = 0; - this.form.monitorPic = this.fileList[0]; - this.$modal.closeLoading(); - } - }, //删除上传的图片 - handleRemove(file) { + handleRemoveSop(file) { let arrPic = this.$refs.drawingUpload.uploadFiles; let index = arrPic.indexOf(file); - this.uploadList.splice(index, 1); + this.uploadSopList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId].splice(index, 1); + this.groupSopFileList[this.addProductPlanObject.dispatchCode + "-" + this.addProductPlanObject.processId].splice(index, 1); let num = 0; arrPic.map((item) => { if (item.uid === file.uid) { @@ -1211,6 +1285,11 @@ export default { num++; }); }, + + + + + // 上传前loading加载 handleBeforeUpload(file) { // let isImg = false;