diff --git a/src/api/purchase/goodsBind.js b/src/api/purchase/goodsBind.js index c87f6429..c72fe8ad 100644 --- a/src/api/purchase/goodsBind.js +++ b/src/api/purchase/goodsBind.js @@ -22,6 +22,15 @@ export function getNewBuyBindListDetailsApi(query) { }) } +//二级页面 查看 +export function getMaCodeInfo(query) { + return request({ + url: '/material/purchase_macode_info/list', + method: 'get', + params: query, + }) +} + //任务 详情 export function bindAllData(data) { return request({ @@ -40,6 +49,7 @@ export function getListDetailById(query) { }) } + // 导出 export function exportNewBuy(data) { return request({ diff --git a/src/views/material/purchase/goodsBind/component/bindTools.vue b/src/views/material/purchase/goodsBind/component/bindTools.vue index 6fd1b3c9..547ee655 100644 --- a/src/views/material/purchase/goodsBind/component/bindTools.vue +++ b/src/views/material/purchase/goodsBind/component/bindTools.vue @@ -97,12 +97,12 @@ show-overflow-tooltip /> - + /> --> - - + + + + 报告管理 + + @@ -181,9 +184,9 @@ > - - - + + + @@ -247,8 +250,8 @@ - - + + @@ -286,6 +289,93 @@ + + + + + + + + + {{ this.rowData.maTypeName }} + + + + + {{ this.rowData.typeName }} + + + + + + + + + 上传 + + + + + 查看 + + + + + + + + + + + @@ -294,7 +384,13 @@ import { bindAllData, getListDetailById, getNewBuyBindListDetailsApi, + getMaCodeInfo, } from "@/api/purchase/goodsBind"; +import { getToken } from "@/utils/auth"; +import { + uploadPurchaseFile, + getPurchaseFileList, +} from "@/api/purchase/goodsAccept"; export default { name: "BindTools", @@ -376,6 +472,26 @@ export default { productDate: "", taskStatus: 3, }, + // 是否显示弹出层 + open: false, + rowData: {}, + fileDataList: [ + { dictLabel: "合格证", fileType: "0", name: "", url: "" }, + { dictLabel: "型式试验报告", fileType: "1", name: "", url: "" }, + { dictLabel: "出厂检测报告", fileType: "2", name: "", url: "" }, + { dictLabel: "第三方监测报告", fileType: "3", name: "", url: "" }, + { dictLabel: "其他报告", fileType: "4", name: "", url: "" }, + ], + //图片查看弹窗 + dialogImageUrl: "", + dialogVisible: false, + //上传 + upload: { + // 设置上传的请求头部 + headers: { Authorization: "Bearer " + getToken() }, + // 上传的地址 + url: process.env.VUE_APP_BASE_API + "/file/upload", + }, }; }, created() { @@ -421,6 +537,13 @@ export default { // 查看 handleView(row) { this.viewCodeVisible = true; + getMaCodeInfo({ taskId: row.taskId, typeId: row.typeId }).then( + (response) => { + this.viewCodeList = response.rows; + this.titleBind = "查看"; + this.loadingTwo = false; + } + ); // this.loadingTwo = true // getListDetailById({ taskId: row.taskId, typeId: row.typeId }).then( // (response) => { @@ -434,7 +557,7 @@ export default { // 绑定 handleBind(row) { this.bindCodeVisible = true; - this.waitBindNum = row.purchaseNum; + this.waitBindNum = row.checkNum - row.bindNum; this.queryBindForm.typeId = row.typeId; this.queryBindForm.typeName = row.typeName; this.queryBindForm.maTypeName = row.maTypeName; @@ -459,6 +582,130 @@ export default { .then(() => {}) .catch(() => {}); }, + + //文件管理 + openFileDialog(row) { + this.rowData = row; + this.fileDataList = [ + { dictLabel: "合格证", fileType: "0", name: "", url: "" }, + { dictLabel: "型式试验报告", fileType: "1", name: "", url: "" }, + { dictLabel: "出厂检测报告", fileType: "2", name: "", url: "" }, + { dictLabel: "第三方监测报告", fileType: "3", name: "", url: "" }, + { dictLabel: "其他报告", fileType: "4", name: "", url: "" }, + ]; + if (this.taskId == "") { + // console.log(this.rowData) + // console.log(this.rowData.bmFileInfos) + if (this.rowData.bmFileInfos.length > 0) { + this.rowData.bmFileInfos.forEach((item) => { + let index = this.fileDataList.findIndex( + (v) => v.fileType == item.fileType + ); + this.fileDataList[index].name = item.name; + this.fileDataList[index].url = item.url; + }); + } + } else { + this.getFileData(); + } + this.open = true; + }, + getFileData() { + let param = { + modelId: this.rowData.typeId, + taskType: 0, + taskId: this.rowData.taskId, + }; + getPurchaseFileList(param) + .then((response) => { + if (response.rows.length > 0) { + response.rows.forEach((item) => { + let index = this.fileDataList.findIndex( + (v) => v.fileType == item.fileType + ); + this.fileDataList[index].name = item.name; + this.fileDataList[index].url = item.url; + }); + } + }) + .catch(() => {}); + }, + beforeFileUpload(row) { + this.rowData.fileType = row.fileType; + }, + // 文件上传成功处理 + handleFileSuccess(response, file, fileList) { + if (response.code == 200) { + if (this.taskId == "") { + //新增逻辑 + // console.log(response) + // console.log(this.rowData) + // console.log(this.rowData.bmFileInfos) + let obj = { + taskId: this.taskId, + taskType: "0", + name: response.data.name, + url: response.data.url, + modelId: this.rowData.typeId, + fileType: this.rowData.fileType, + // "dictLabel": this.rowData.dictLabel, + }; + //根据文件上传返回更新文件管理弹窗内容 + let index = this.fileDataList.findIndex( + (v) => v.fileType == this.rowData.fileType + ); + this.fileDataList[index].name = response.data.name; + this.fileDataList[index].url = response.data.url; + //判断当前上传的文件是否已上传过-再往机具类型数据中插入 + if (this.rowData.bmFileInfos.length > 0) { + let index2 = this.rowData.bmFileInfos.findIndex( + (v) => v.fileType == this.rowData.fileType + ); + if (index2 > -1) { + //相同类型文件重复上传-替换 + this.rowData.bmFileInfos.splice(index2, 0, obj); + } else { + //不存在相同类型文件-添加 + this.rowData.bmFileInfos.push(obj); + } + } else { + this.rowData.bmFileInfos.push(obj); + } + } else { + //编辑逻辑 + let param = { + taskId: this.taskId, + taskType: "0", + name: response.data.name, + url: response.data.url, + modelId: this.rowData.typeId, + fileType: this.rowData.fileType, + // "dictLabel": this.rowData.dictLabel, + }; + uploadPurchaseFile(param) + .then((response) => { + this.$modal.msgSuccess("上传成功"); + this.getFileData(); + }) + .catch(() => { + this.$modal.msgError("上传失败"); + }); + } + } + }, + //图片查看 + picturePreview(file) { + this.dialogImageUrl = file.url; + const parts = file.name.split("."); + const extension = parts.pop(); + if (extension === "doc" || extension === "docx" || extension === "pdf") { + const windowName = file.name; + window.open(file.url, windowName); + } else { + this.dialogVisible = true; + } + }, + // 下载 onDownloadQr() { console.log("二维码下载"); @@ -531,6 +778,8 @@ export default { if (res.code == 200) { this.$modal.msgSuccess("绑定成功"); } + this.getCodeList(); + this.bindCodeVisible = false; console.log(res, "编码结果--"); }, // 移除