change - 根据materialBomId上传图纸、SOP

master
yinq 3 months ago
parent b9d0f6c356
commit ad2da3edb0

@ -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));
}
}

@ -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;
}

@ -28,6 +28,8 @@
<result property="assembleTime" column="assemble_time"/>
<result property="materialSpec" column="material_spec"/>
<result property="attachId" column="attach_id"/>
<result property="sopId" column="sop_id"/>
</resultMap>
<sql id="selectMesMaterialBomVo">
@ -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
</sql>
@ -102,6 +106,8 @@
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="assembleTime != null">assemble_time,</if>
<if test="attachId != null">attach_id,</if>
<if test="sopId != null">sop_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="materialBomId != null">#{materialBomId},</if>
@ -123,6 +129,8 @@
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="assembleTime != null">#{assembleTime},</if>
<if test="attachId != null">#{attachId},</if>
<if test="sopId != null">#{sopId},</if>
</trim>
</insert>
@ -145,6 +153,8 @@
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="assembleTime != null">assemble_time = #{assembleTime},</if>
<if test="attachId != null">attach_id = #{attachId},</if>
<if test="sopId != null">sop_id = #{sopId},</if>
</trim>
where material_bom_id = #{materialBomId}
</update>
@ -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

@ -42,3 +42,11 @@ export function delBaseAttachInfo(attachId) {
method: 'delete'
})
}
// 根据附件ID查列表
export function selectByAttachIds(attachIds) {
return request({
url: '/mes/baseAttachInfo/attachInfoByAttachIds/' + attachIds,
method: 'get'
})
}

@ -139,8 +139,22 @@
</template>
</el-table-column>
<!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">-->
<!-- <template slot-scope="scope">-->
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
icon="el-icon-upload2"
size="mini"
type="primary"
@click="handleDrawing(scope.row)"
>图纸
</el-button>
<el-button
icon="el-icon-upload2"
size="mini"
type="success"
@click="handleSop(scope.row)"
>SOP
</el-button>
<!-- <el-button-->
<!-- size="mini"-->
<!-- type="text"-->
@ -165,8 +179,8 @@
<!-- v-hasPermi="['mes:materialBom:remove']"-->
<!-- >删除-->
<!-- </el-button>-->
<!-- </template>-->
<!-- </el-table-column>-->
</template>
</el-table-column>
</el-table>
<!-- 添加或修改物料BOM信息对话框 -->
@ -279,6 +293,142 @@
</div>
</el-dialog>
<el-dialog
:visible.sync="blueprintModel"
title="上传图纸"
width="30%"
@before-close="blueprintModel = false">
<el-upload
single
ref="drawingUpload"
list-type="picture-card"
action="uploadDrawingUrl"
:auto-upload="true"
:limit="drawingLimit"
:headers="headers"
:before-upload="handleBeforeUpload"
:http-request="httpRequest"
:on-exceed="handleExceed"
:file-list="fileList"
>
<i slot="default" class="el-icon-plus"></i>
<div slot="file" slot-scope="{file}">
<img
v-if="isAssetTypeAnImage(file.name)"
:alt="file.name"
:src="file.url" class="el-upload-list__item-thumbnail"
>
<span v-else>{{ file.name }}</span>
<span class="el-upload-list__item-actions">
<span
v-if="isAssetTypeAnImage(file.name)"
class="el-upload-list__item-preview"
@click="handlePictureCardPreview(file)"
>
<i class="el-icon-zoom-in"></i>
</span>
<span
class="el-upload-list__item-delete"
@click="handleDownload(file)"
>
<i class="el-icon-download"></i>
</span>
<span
class="el-upload-list__item-delete"
@click="handleRemoveDrawing(file)"
>
<i class="el-icon-delete"></i>
</span>
</span>
</div>
</el-upload>
<span slot="footer" class="dialog-footer">
<!-- 上传提示 -->
<div class="el-upload__tip" slot="tip" v-if="isShowTip">
请上传
<template v-if="drawingFileSize"> <b style="color: #f67c7c">{{ drawingFileSize }}MB</b></template>
<template v-if="drawingFileType"> <b style="color: #f56c6c">{{ drawingFileType.join("/") }}</b></template>
的文件
</div>
<el-button type="primary" @click="drawingFileUploadSubmit"> </el-button>
<el-button @click="blueprintModel = false"> </el-button>
</span>
</el-dialog>
<el-dialog
:visible.sync="sopViewModel"
title="上传SOP附件"
width="30%"
@before-close="sopViewModel = false">
<el-upload
single
ref="drawingUpload"
list-type="picture-card"
action="uploadImgUrl"
:auto-upload="true"
:limit="sopLimit"
:headers="headers"
:before-upload="handleBeforeUpload"
:http-request="httpSopRequest"
:on-exceed="handleExceed"
:file-list="fileList"
>
<i slot="default" class="el-icon-plus"></i>
<div slot="file" slot-scope="{file}">
<img
v-if="isAssetTypeAnImage(file.name)"
:alt="file.name"
:src="file.url" class="el-upload-list__item-thumbnail"
>
<span v-else>{{ file.name }}</span>
<span class="el-upload-list__item-actions">
<span
v-if="isAssetTypeAnImage(file.name)"
class="el-upload-list__item-preview"
@click="handlePictureCardPreview(file)"
>
<i class="el-icon-zoom-in"></i>
</span>
<span
class="el-upload-list__item-delete"
@click="handleDownload(file)"
>
<i class="el-icon-download"></i>
</span>
<span
class="el-upload-list__item-delete"
@click="handleRemoveSop(file)"
>
<i class="el-icon-delete"></i>
</span>
</span>
</div>
</el-upload>
<span slot="footer" class="dialog-footer">
<!-- 上传提示 -->
<div class="el-upload__tip" slot="tip" v-if="isShowTip">
请上传
<template v-if="sopFileSize"> <b style="color: #f56c6c">{{ sopFileSize }}MB</b></template>
<template v-if="sopFileType"> <b style="color: #f56c6c">{{ sopFileType.join("/") }}</b></template>
的文件
</div>
<el-button type="primary" @click="sopFileUploadSubmit"> </el-button>
<el-button @click="sopViewModel = false"> </el-button>
</span>
</el-dialog>
<el-dialog
:visible.sync="pictureDetailModel"
title="图纸预览"
width="800"
append-to-body
>
<img
:src="dialogImageUrl"
style="display: block; max-width: 100%; margin: 0 auto"
/>
</el-dialog>
</div>
</template>
@ -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())
},
}
};
</script>

Loading…
Cancel
Save