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 99e2b31b..265d4451 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
@@ -146,4 +146,14 @@ public class MesBaseAttachInfoController extends BaseController {
return error("上传图片异常,请联系管理员");
}
+ /**
+ * 根据附件ID查列表
+ * @param attachIds
+ * @return
+ */
+ @GetMapping("/attachInfoByAttachIds/{attachIds}")
+ public AjaxResult selectMesBaseAttachInfoByAttachIds(@PathVariable Long[] attachIds) {
+ return success(mesBaseAttachInfoService.selectMesBaseAttachInfoByAttachIds(attachIds));
+ }
+
}
diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesMaterialBom.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesMaterialBom.java
index fb37e109..12c7c558 100644
--- a/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesMaterialBom.java
+++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesMaterialBom.java
@@ -110,6 +110,28 @@ public class MesMaterialBom extends TreeEntity {
*/
private String ancestors;
+ /** 图纸ID,关联附件信息主键;多个用,隔开 */
+ private String attachId;
+
+ /** sop附件ID,关联附件信息主键;多个用,隔开 */
+ private String sopId;
+
+ public String getAttachId() {
+ return attachId;
+ }
+
+ public void setAttachId(String attachId) {
+ this.attachId = attachId;
+ }
+
+ public String getSopId() {
+ return sopId;
+ }
+
+ public void setSopId(String sopId) {
+ this.sopId = sopId;
+ }
+
public String getBrand() {
return brand;
}
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 267ed02c..802b8663 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
@@ -28,6 +28,8 @@
+
+
@@ -50,6 +52,8 @@
update_by,
update_time,
assemble_time,
+ attach_id,
+ sop_id,
CONCAT(material_name, '-', material_bom_desc) materialNameDesc
from mes_material_bom
@@ -102,6 +106,8 @@
update_by,
update_time,
assemble_time,
+ attach_id,
+ sop_id,
#{materialBomId},
@@ -123,6 +129,8 @@
#{updateBy},
#{updateTime},
#{assembleTime},
+ #{attachId},
+ #{sopId},
@@ -145,6 +153,8 @@
update_by = #{updateBy},
update_time = #{updateTime},
assemble_time = #{assembleTime},
+ attach_id = #{attachId},
+ sop_id = #{sopId},
where material_bom_id = #{materialBomId}
@@ -180,6 +190,8 @@
mmb.update_by,
mmb.update_time,
mmb.assemble_time,
+ mmb.attach_id,
+ mmb.sop_id,
mbmi.material_code,mbmi.material_name,mbmi.material_spec
from mes_material_bom mmb left join mes_base_material_info mbmi on mmb.material_id=mbmi.material_id
diff --git a/hw-ui/src/api/mes/baseAttachInfo.js b/hw-ui/src/api/mes/baseAttachInfo.js
index 9c28d129..139043f7 100644
--- a/hw-ui/src/api/mes/baseAttachInfo.js
+++ b/hw-ui/src/api/mes/baseAttachInfo.js
@@ -42,3 +42,11 @@ export function delBaseAttachInfo(attachId) {
method: 'delete'
})
}
+
+// 根据附件ID查列表
+export function selectByAttachIds(attachIds) {
+ return request({
+ url: '/mes/baseAttachInfo/attachInfoByAttachIds/' + attachIds,
+ method: 'get'
+ })
+}
diff --git a/hw-ui/src/views/mes/materialBom/index.vue b/hw-ui/src/views/mes/materialBom/index.vue
index b755f9a2..990b154e 100644
--- a/hw-ui/src/views/mes/materialBom/index.vue
+++ b/hw-ui/src/views/mes/materialBom/index.vue
@@ -139,8 +139,22 @@
-
-
+
+
+ 图纸
+
+ SOP
+
@@ -165,8 +179,8 @@
-
-
+
+
@@ -279,6 +293,142 @@
+
+
+
+
+
![]()
+
{{ file.name }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
![]()
+
{{ file.name }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -296,6 +446,8 @@ 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 {selectByAttachIds} from "@/api/mes/baseAttachInfo";
export default {
name: "MaterialBom",
@@ -304,6 +456,24 @@ export default {
Treeselect,
'select-material': selectMaterial
},
+ props: {
+ value: [String, Object, Array, Number],
+ // sop文件数量限制
+ sopLimit: {
+ type: Number,
+ default: 20,
+ },
+ // 图纸数量限制
+ drawingLimit: {
+ type: Number,
+ default: 20,
+ },
+ // 是否显示提示
+ isShowTip: {
+ type: Boolean,
+ default: true
+ }
+ },
data() {
return {
// 遮罩层
@@ -398,12 +568,37 @@ export default {
{key: 15, label: `BOM说明`, visible: true},
{key: 16, label: `安装时长`, visible: true},
],
-
//顶级标识
TOP_FLAG: {
YES: 1,
NO: 0
- }
+ },
+ blueprintModel: false,
+ sopViewModel: false,
+ pictureDetailModel: false,
+ // 图片预览地址
+ dialogImageUrl: '',
+ // 文件列表
+ fileList: [],
+ // 上传SOP文件回调列表
+ uploadSopList: [],
+ // 根据工序和派工单号分组图纸文件
+ groupAttachFile: {},
+ // 上传图纸文件回调列表
+ uploadAttachList: {},
+ // SOP文件大小限制(MB)
+ sopFileSize: 50,
+ // SOP文件类型,
+ sopFileType: ["png", "jpg", "jpeg"],
+ // 图纸文件大小限制(MB)
+ drawingFileSize: 50,
+ // 图纸文件类型, 例如['png', 'jpg', 'jpeg']
+ drawingFileType: ["dxf", "dwg", "pdf"],
+ //文件上传-生产派工对象
+ addProductPlanObject: {},
+ headers: {
+ Authorization: "Bearer " + getToken(),
+ },
};
},
watch: {
@@ -681,6 +876,209 @@ export default {
});
},
+ //查看图纸预览
+ handlePictureCardPreview(file) {
+ this.dialogImageUrl = file.url;
+ this.pictureDetailModel = true;
+ },
+ //图纸下载
+ handleDownload(file) {
+ window.open(file.url);
+ },
+ /** 查看图纸 */
+ handleDrawing(row) {
+ this.fileList = [];
+ if (row.attachId != null && row.attachId !== "") {
+ selectByAttachIds(row.attachId).then(res => {
+ let attachList = res.data;
+ attachList.forEach(e => {
+ let previewFile = {};
+ previewFile.url = e.attachPath;
+ previewFile.name = e.attachName;
+ this.fileList.push(previewFile);
+
+ let uploadAttachList = this.uploadAttachList[this.addProductPlanObject.materialBomId];
+ this.uploadAttachList[this.addProductPlanObject.materialBomId] = uploadAttachList ? this.uploadAttachList[this.addProductPlanObject.materialBomId] : [];
+ this.uploadAttachList[this.addProductPlanObject.materialBomId].push(e.attachId);
+
+ })
+ })
+ }
+ this.addProductPlanObject = row;
+ this.blueprintModel = true;
+ },
+ //添加图纸提交
+ drawingFileUploadSubmit() {
+ this.addProductPlanObject.attachId = this.uploadAttachList[this.addProductPlanObject.materialBomId].join(",");
+ this.uploadAttachList = [];
+ let updateData = {
+ materialBomId: this.addProductPlanObject.materialBomId,
+ parentId: this.addProductPlanObject.parentId,
+ attachId: this.addProductPlanObject.attachId
+ }
+ updateMaterialBom(updateData).then(response => {
+ this.$modal.msgSuccess("更新图纸成功");
+ this.addProductPlanObject = null;
+ this.blueprintModel = false;
+ this.getList();
+ });
+ },
+ //图纸图片上传
+ httpRequest(file) {
+ // 文件信息
+ const fileData = file.file;
+ const formData = new FormData();
+ formData.append("file", fileData);
+ // formData.append("processId", this.addProductPlanObject.processId);
+ formData.append("attachType", "1");
+ uploadFile(formData).then(
+ (res) => {
+ let uploadAttachList = this.uploadAttachList[this.addProductPlanObject.materialBomId];
+ this.uploadAttachList[this.addProductPlanObject.materialBomId] = uploadAttachList ? this.uploadAttachList[this.addProductPlanObject.materialBomId] : [];
+ this.uploadAttachList[this.addProductPlanObject.materialBomId].push(res.attachId);
+
+ this.$modal.closeLoading();
+ }, (err) => {
+ this.$refs.drawingUpload.clearFiles(); //上传失败后清除当前上传的图片
+ this.$modal.closeLoading();
+ }
+ );
+ },
+ //删除上传的图片
+ handleRemoveDrawing(file) {
+ let arrPic = this.$refs.drawingUpload.uploadFiles;
+ let index = arrPic.indexOf(file);
+ this.uploadAttachList[this.addProductPlanObject.materialBomId].splice(index, 1);
+ let num = 0;
+ arrPic.map((item) => {
+ if (item.uid === file.uid) {
+ arrPic.splice(num, 1);
+ }
+ num++;
+ });
+ },
+ /** 查看sop */
+ handleSop(row) {
+ this.fileList = [];
+ if (row.sopId != null && row.sopId !== "") {
+ selectByAttachIds(row.sopId).then(res => {
+ let attachList = res.data;
+ attachList.forEach(e => {
+ let previewFile = {};
+ previewFile.url = e.attachPath;
+ previewFile.name = e.attachName;
+ this.fileList.push(previewFile);
+
+ let uploadSopList = this.uploadSopList[this.addProductPlanObject.materialBomId];
+ this.uploadSopList[this.addProductPlanObject.materialBomId] = uploadSopList ? this.uploadSopList[this.addProductPlanObject.materialBomId] : [];
+ this.uploadSopList[this.addProductPlanObject.materialBomId].push(e.attachId);
+
+ })
+ })
+ }
+ this.addProductPlanObject = row;
+ this.sopViewModel = true;
+ },
+ //添加sop提交
+ sopFileUploadSubmit() {
+ this.addProductPlanObject.sopId = this.uploadSopList[this.addProductPlanObject.materialBomId].join(",");
+ this.uploadSopList = [];
+ let updateData = {
+ materialBomId: this.addProductPlanObject.materialBomId,
+ parentId: this.addProductPlanObject.parentId,
+ sopId: this.addProductPlanObject.sopId
+ }
+ updateMaterialBom(updateData).then(response => {
+ this.$modal.msgSuccess("更新SOP成功");
+ this.addProductPlanObject = null;
+ this.sopViewModel = false;
+ this.getList();
+ });
+ },
+ //Sop图片上传
+ httpSopRequest(file) {
+ // 文件信息
+ const fileData = file.file;
+ const formData = new FormData();
+ formData.append("file", fileData);
+ // formData.append("processId", this.addProductPlanObject.processId);
+ formData.append("attachType", "2");
+ uploadFile(formData).then(
+ (res) => {
+ let uploadSopList = this.uploadSopList[this.addProductPlanObject.materialBomId];
+ this.uploadSopList[this.addProductPlanObject.materialBomId] = uploadSopList ? this.uploadSopList[this.addProductPlanObject.materialBomId] : [];
+ this.uploadSopList[this.addProductPlanObject.materialBomId].push(res.attachId);
+
+ this.$modal.closeLoading();
+ }, (err) => {
+ this.$refs.drawingUpload.clearFiles(); //上传失败后清除当前上传的图片
+ this.$modal.closeLoading();
+ }
+ );
+ },
+ //删除上传的图片
+ handleRemoveSop(file) {
+ let arrPic = this.$refs.drawingUpload.uploadFiles;
+ let index = arrPic.indexOf(file);
+ this.uploadSopList[this.addProductPlanObject.materialBomId].splice(index, 1);
+ let num = 0;
+ arrPic.map((item) => {
+ if (item.uid === file.uid) {
+ arrPic.splice(num, 1);
+ }
+ num++;
+ });
+ },
+ // 上传前loading加载
+ handleBeforeUpload(file) {
+ let fileType,fileSize;
+ if(this.sopViewModel){
+ fileType = this.sopFileType;
+ fileSize = this.sopFileSize;
+ }else if(this.blueprintModel){
+ fileType = this.drawingFileType;
+ fileSize = this.drawingFileSize;
+ }
+
+ let isImg = false;
+ if (fileType.length) {
+ let fileExtension = "";
+ if (file.name.lastIndexOf(".") > -1) {
+ fileExtension = file.name.slice(file.name.lastIndexOf(".") + 1);
+ }
+ isImg = fileType.some(type => {
+ if (file.type.indexOf(type) > -1) return true;
+ if (fileExtension && fileExtension.indexOf(type) > -1) return true;
+ return false;
+ });
+ } else {
+ isImg = file.type.indexOf("image") > -1;
+ }
+
+ if (!isImg) {
+ this.$modal.msgError(`文件格式不正确, 请上传${fileType.join("/")}格式文件!`);
+ return false;
+ }
+ if (fileSize) {
+ const isLt = file.size / 1024 / 1024 < fileSize;
+ if (!isLt) {
+ this.$modal.msgError(`上传文件大小不能超过 ${fileSize} MB!`);
+ return false;
+ }
+ }
+ this.$modal.loading("正在上传文件,请稍候...");
+ this.number++;
+ },
+ // 文件个数超出
+ handleExceed() {
+ this.$modal.msgError(`上传文件数量不能超过 ${this.limit} !`);
+ },
+ isAssetTypeAnImage(ext) {
+ let suffix = ext.lastIndexOf(".");
+ let name = ext.substr(suffix + 1);
+ return ['png', 'jpg', 'jpeg'].includes(name.toLowerCase())
+ },
+
}
};