From de782bf36f3ea60cc9ee1d0861d0b1acc10ba39c Mon Sep 17 00:00:00 2001 From: yuejiayang <146344614+YangLei105@users.noreply.github.com> Date: Thu, 11 Jul 2024 23:06:49 +0800 Subject: [PATCH] =?UTF-8?q?2024.7.11=20=E4=BA=A7=E5=93=81=E6=96=87?= =?UTF-8?q?=E6=A1=A3=E6=94=B6=E9=9B=86-=E9=A1=B9=E7=9B=AE=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E8=BF=9B=E4=B8=80=E6=AD=A5=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/eam/eamProject.js | 3 + src/api/eam/eamProofing.js | 4 + src/views/modules/common/uploadFileList1.vue | 70 ++- .../modules/eam/com_project_proof_record.vue | 178 +++++- src/views/modules/eam/eamProjectInfo.vue | 519 ++++++++++++++---- 5 files changed, 624 insertions(+), 150 deletions(-) diff --git a/src/api/eam/eamProject.js b/src/api/eam/eamProject.js index f2091cc..06f7f7b 100644 --- a/src/api/eam/eamProject.js +++ b/src/api/eam/eamProject.js @@ -9,6 +9,9 @@ export const getTestPartNo= data => createAPI(`/pms/eamProject/getTestPartNo`,'p export const searchConfirmatorList= data => createAPI(`/pms/eamProject/searchConfirmatorList`,'post',data) export const saveProductionValidationDocumentConfirmator= data => createAPI(`/pms/eamProject/saveProductionValidationDocumentConfirmator`,'post',data) export const saveProductionValidationDocument= data => createAPI(`/pms/eamProject/saveProductionValidationDocument`,'post',data) +export const deleteDocumentInformation= data => createAPI(`/pms/eamProject/deleteDocumentInformation`,'post',data) +export const checkProductionValidationDocument= data => createAPI(`/pms/eamProject/checkProductionValidationDocument`,'post',data) +export const checkConfirmationRecord= data => createAPI(`/pms/eamProject/checkConfirmationRecord`,'post',data) export const searchConfirmProgressDocumentList= data => createAPI(`/pms/eamProject/searchConfirmProgressDocumentList`,'post',data) export const searchConfirmProgressPusherList= data => createAPI(`/pms/eamProject/searchConfirmProgressPusherList`,'post',data) export const uploadProjectFile= data => createAPI(`/base/uploadProjectFile`,'post',data) diff --git a/src/api/eam/eamProofing.js b/src/api/eam/eamProofing.js index 28f05f3..0833b52 100644 --- a/src/api/eam/eamProofing.js +++ b/src/api/eam/eamProofing.js @@ -6,6 +6,8 @@ export const proofingInformationSearch= data => createAPI(`plm/proofingInformati export const proofingInformationSearchForCheck= data => createAPI(`/pms/eamProofing/proofingInformationSearchForCheck`,'post',data) //proofingInformationSave export const proofingInformationSave= data => createAPI(`/plm/proofingInformation/proofingInformationSave`,'post',data) +//deleteProofingRecord +export const deleteProofingRecord= data => createAPI(`/plm/proofingInformation/deleteProofingRecord`,'post',data) //getProofDocument export const getProofDocument= data => createAPI(`/plm/proofingInformation/getProofDocument`,'post',data) @@ -27,3 +29,5 @@ export const projectDocumentSave= data => createAPI(`/plm/proofingInformation/pr export const editProjectDocument= data => createAPI(`/plm/proofingInformation/editProjectDocument`,'post',data) export const searchProjectAllDocument= data => createAPI(`/plm/proofingInformation/searchProjectAllDocument`,'post',data) + +export const deleteProofDocument= data => createAPI(`/plm/proofingInformation/deleteProofDocument`,'post',data) diff --git a/src/views/modules/common/uploadFileList1.vue b/src/views/modules/common/uploadFileList1.vue index 9ba13d9..1c39c1b 100644 --- a/src/views/modules/common/uploadFileList1.vue +++ b/src/views/modules/common/uploadFileList1.vue @@ -107,10 +107,33 @@ export default { return { //fileRemark: '', fileName: '', + conclusionList: [ + {conclusion: '合格'}, + {conclusion: '不合格'}, + {conclusion: '让步接受'}, + {conclusion: 'N/A'} + ], + conclusion:'', //选中当前行 documentClickRow: {}, - bu : this.props.site + "-" + this.props.buNo, + bu : this.site + "-" + this.buNo, dataListLoading: false, + rules: { + noType: [ + { + required: true, + message: ' ', + trigger: ['blur', 'change'] + } + ], + conclusion: [ + { + required: true, + message: ' ', + trigger: ['blur', 'change'] + } + ] + } } }, methods: { @@ -143,6 +166,14 @@ export default { this.$message.warning("未选择需要上传的文件") return; } + if (this.noType === null || this.noType === undefined || this.noType === '') { + this.$message.warning("文件类型不能为空") + return; + } + if (this.conclusion === null || this.conclusion === undefined || this.conclusion === '') { + this.$message.warning("结论不能为空") + return; + } let data = new FormData(); data.append("file", this.fileList[0].raw); data.append("orderRef1", this.$store.state.user.site); @@ -151,6 +182,7 @@ export default { data.append("orderRef4", this.projectId); data.append("documentDesc", this.no); data.append("cAdditionalInfo", this.noType); + data.append("conclusion", this.conclusion); data.append("createBy", this.$store.state.user.name); data.append("folder", this.folder); uploadFileList(this.path, data).then(({data}) => { @@ -273,7 +305,7 @@ export default { @@ -281,13 +283,16 @@ - - + + + + + @@ -310,15 +315,9 @@ - - - - - - + + @@ -425,10 +426,11 @@ import axios from "axios"; import Chooselist from '@/views/modules/common/Chooselist' import { deleteFileInfo, saveFileInfo, updateUploadedFlag } from '@/api/test/fileService.js'; - import {proofingInformationSearch,proofingDocumentNEW,getExtraDocumentList,editProofingRecord,proofingInformationSave,getProofDocument,deleteDocumentType,proofingDocumentSave} from "@/api/eam/eamProofing.js"; + import {proofingInformationSearch,deleteProofingRecord,proofingDocumentNEW,getExtraDocumentList,editProofingRecord,proofingInformationSave,getProofDocument,deleteDocumentType,proofingDocumentSave} from "@/api/eam/eamProofing.js"; import row from "element-ui/packages/row"; import UploadFileList1 from "../common/uploadFileList1.vue"; import he from "element-ui/src/locale/lang/he"; + import {deleteProofDocument} from "../../../api/eam/eamProofing"; export default { computed: { he() { @@ -1076,7 +1078,7 @@ this.refreshCurrentTabTable() } else { this.$message({ - message: '新增失败', + message: '新增失败:数据库已存在该打样单号', type: 'error' }) } @@ -1086,7 +1088,7 @@ let tempData = { site: this.$store.state.user.site, username: this.$store.state.user.name, - projectId: this.searchProofData.projectId, + projectId: this.modalData.projectId, page: 1, limit: 1000 } @@ -1098,8 +1100,6 @@ this.isUpload = true // 设置选中行 this.$refs.proofingTable.setCurrentRow(this.dataList[0]) - // 加载当前的页签的table - this.refreshCurrentTabTable() }else { this.isUpload = false } @@ -1201,9 +1201,13 @@ proofingNo: row.proofingNo, planStartDate: row.planStartDate, requiredDeliveryDate: row.requiredDeliveryDate, + actualityDeliveryDate: row.actualityDeliveryDate, proofingNumber: row.proofingNumber, createDate: row.createDate, - createBy: row.createBy + createBy: row.createBy, + updateBy: this.$store.state.user.name, + id: row.id, + proofDocumentDataList: this.proofDocumentList, } }, saveProofingRecord() { @@ -1249,7 +1253,25 @@ }) return } - editProofingRecord(this.modalData).then(({data}) => { + // let inData = this.modalData + let inData = { + id: this.modalData.id, + site: this.$store.state.user.site, + username: this.$store.state.user.name, + buNo: this.modalData.buNo, + cProjectTypeDb: this.modalData.cProjectTypeDb, + projectCategory: this.modalData.projectCategory, + projectPhase: this.modalData.projectPhase, + projectId: this.modalData.projectId, + proofingNo: this.modalData.proofingNo, + planStartDate: this.modalData.planStartDate, + requiredDeliveryDate: this.modalData.requiredDeliveryDate, + actualityDeliveryDate: this.modalData.actualityDeliveryDate, + proofingNumber: this.modalData.proofingNumber, + proofDocumentDataList: this.proofDocumentList, + updateBy: this.$store.state.user.name, + } + editProofingRecord(inData).then(({data}) => { //区分请求成功和失败的状况 if (data && data.code === 0) { this.$message({ @@ -1258,15 +1280,116 @@ }) this.proofingRecordVisible = false //刷新表格 - this.refreshCurrentTabTable() - } else { - this.$message({ - message: '编辑失败', - type: 'error' - }) + this.getProofingInformation() + this.getProofDocument() + } + // 否则提示后端返回的错误信息 + else { + this.$message.warning(data.msg) } }) }, + proofingRecordDelete(row) { + let tempData = { + site: this.$store.state.user.site, + username: this.$store.state.user.name, + buNo: row.buNo, + cProjectTypeDb: row.cProjectTypeDb, + projectCategory: row.projectCategory, + projectId: row.projectId, + proofingNo: row.proofingNo, + proofDocumentDataList: this.proofDocumentList, + createBy: row.createBy, + } + if (tempData.createBy !== tempData.username) { + this.$message({ + message: '只能删除自己创建的打样记录', + type: 'warning' + }) + }else { + this.$confirm('是否删除该打样记录?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + deleteProofingRecord(tempData).then(({data}) => { + console.log(data) + if (data && data.code === 0) { + this.$message({ + message: '删除成功', + type: 'success' + }) + //刷新表格 + this.getProofingInformation() + this.getProofDocument() + } + // 否则提示后端返回的错误信息 + else { + this.$message.warning(data.msg) + } + }) + }).catch(() => { + this.$message({ + type: 'info', + message: '已取消删除' + }); + }); + } + }, + proofDocumentDelete(row) { + let tempData = { + site: row.site, + username: this.$store.state.user.name, + buNo: row.buNo, + proofingId: row.proofingNo, + projectId: row.projectId, + projectDesc: row.projectDesc, + customerId: row.customerNo, + customerDesc: row.customerDesc, + testPartNo: row.testPartNo, + partDesc: row.partDesc, + id: row.id, + fileName: row.fileName, + uploadedFlag: row.uploadedFlag, + cAdditionalInfo: row.cAdditionalInfo, + createBy: row.createdBy, + documentDefinitionListId: row.documentDefinitionListId, + documentType: row.documentType, + documentId: row.documentId, + } + if (tempData.createBy !== tempData.username) { + this.$message({ + message: '只能删除自己创建的打样文档', + type: 'warning' + }) + }else { + this.$confirm('是否删除该打样文档?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + deleteProofDocument(tempData).then(({data}) => { + if (data && data.code === 0) { + this.$message({ + message: '删除成功', + type: 'success' + }) + //刷新表格 + this.getProofDocument() + } + // 否则提示后端返回的错误信息 + else { + this.$message.warning(data.msg) + } + }) + }).catch(() => { + this.$message({ + type: 'info', + message: '已取消删除' + }); + }); + } + }, searchDocumentTypeList() { this.searchDocumentTypeData.proofingNo = this.modalData.proofingNo this.searchDocumentTypeData.projectId = this.modalData.projectId @@ -1363,10 +1486,7 @@ //刷新表格 this.getProofDocument() } else { - this.$message({ - message: '删除失败', - type: 'error' - }) + this.$message.warning(data.msg) } }) }).catch(() => { diff --git a/src/views/modules/eam/eamProjectInfo.vue b/src/views/modules/eam/eamProjectInfo.vue index 61df40d..a576dab 100644 --- a/src/views/modules/eam/eamProjectInfo.vue +++ b/src/views/modules/eam/eamProjectInfo.vue @@ -733,12 +733,13 @@ @@ -820,7 +821,7 @@ style="width: 100%;margin-top: -10px;" :height="this.height + 128"> - + @@ -833,10 +834,10 @@ style="width: 100%;margin-top: -10px;" :height="this.height + 128"> - + - + @@ -1010,15 +1011,12 @@ - - - + style="width: 110px;"> @@ -1026,14 +1024,16 @@ + header-align="center" + align="center" + width="50"> @@ -1087,7 +1087,7 @@ - + @@ -1098,27 +1098,28 @@ - - + + + + + - - - - + 点击选择文件 - + + + style="width: 100%;margin-top: 17px;margin-left: 0px;"> - - { + deleteProofDocument(tempData).then(({data}) => { + if (data && data.code === 0) { + this.$message({ + message: '删除成功', + type: 'success' + }) + //刷新表格 + this.getProjectOtherDocument() + this.getProofDocument() + } + // 否则提示后端返回的错误信息 + else { + this.$message.warning(data.msg) + } + }) + }).catch(() => { + this.$message({ + type: 'info', + message: '已取消删除' + }); + }); + } + }, getProjectOtherDocument () { let tempData = { site: this.$store.state.user.site, @@ -3554,14 +3622,12 @@ import { if (data && data.code === 0) { this.$message({ message: '删除成功', - type: 'success' + type: 'success', }) this.getProjectOtherDocument() + this.getProofDocument() } else { - this.$message({ - message: '删除失败', - type: 'error' - }) + this.$message.warning(data.msg) } }) }).catch(() => { @@ -3586,6 +3652,12 @@ import { } this.extraProjectDocumentList = [] }, + filteredProjectAllDocumentList() { + this.projectAllDocumentList.map(item => { + item.id = item.documentDefinitionListId + }) + return this.projectAllDocumentList.filter(item => item.uploadedFlag !== 'N') + }, searchProjectDocumentTypeList() { this.searchProjectDocumentTypeData.proofingNo = '*' this.searchProjectDocumentTypeData.projectId = this.modalData.projectId @@ -3683,10 +3755,11 @@ import { page: 1 } this.projectProductionValidationDocumentVisible = true + this.projectAllDocumentList1 = this.filteredProjectAllDocumentList() }, - handleDocumentSelectionChange(selection) { + handleDocumentSelectionChange(val) { // 文档选择页签中选中数据发生变化时的处理 - this.selectedDocumentItems = selection; + this.selectedDocumentItems = val; }, searchConfirmatorList() { let inData = { @@ -3715,50 +3788,42 @@ import { site: this.proofingCurrentRow.site, orderRef1: this.proofingCurrentRow.projectId, userid: item.userid, - // 给itemNo赋值:遍历次数 itemNo: this.projectAllDocumentConfirmatorList.indexOf(item) + 1, wantedConfirmDate: this.modalData.wantedConfirmDate, createBy: this.$store.state.user.name }; return saveProductionValidationDocumentConfirmator(inData); }); + Promise.all(confirmatorPromises) .then(confirmatorResults => { - // 检查确认人员请求的结果 let allConfirmatorSuccess = confirmatorResults.every(result => result.data && result.data.code === 0); if (allConfirmatorSuccess) { - let documentPromises = this.selectedDocumentItems.map(item1 => { - let inData1 = { + let saveDocumentPromises = this.selectedDocumentItems.map(item => { + let inData = { site: this.proofingCurrentRow.site, orderRef1: this.proofingCurrentRow.projectId, - // 给itemNo赋值:遍历次数 - itemNo: this.selectedDocumentItems.indexOf(item1) + 1, - documentId: item1.documentId, + itemNo: '', + documentType: item.documentType, + documentId: item.documentId, createBy: this.$store.state.user.name }; - return saveProductionValidationDocument(inData1); + return this.handleDocumentSave(inData); }); - Promise.all(documentPromises) - .then(documentResults => { - // 检查文档请求的结果 - let allDocumentSuccess = documentResults.every(result => result.data && result.data.code === 0); - if (allDocumentSuccess) { - this.$message({ - message: '新增成功', - type: 'success' - }); - this.projectProductionValidationDocumentVisible = false; - } else { - this.$message({ - message: '新增失败,请检查文档', - type: 'error' - }); - } + + Promise.all(saveDocumentPromises) + .then(() => { + this.$message({ + message: '新增成功', + type: 'success' + }); + this.projectProductionValidationDocumentVisible = false; + this.confirmationPrompted = false; }) .catch(error => { console.error('保存文档出错:', error); this.$message({ - message: '新增失败,请检查文档', + message: '新增失败,请检查文档', type: 'error' }); }); @@ -3777,6 +3842,140 @@ import { }); }); }, + + handleDocumentSave(inData) { + return new Promise((resolve, reject) => { + checkProductionValidationDocument(inData) + .then(({ data }) => { + if (data) { + // 存在生产确认记录,且尚未进行过确认提示 + if (!this.confirmationPrompted) { + this.confirmationPrompted = true; // 标记已进行过确认提示 + this.askForDeleteConfirmation() + .then(confirmDelete => { + if (confirmDelete === 'true') { + this.handleDeleteAndSave(inData) + .then(() => resolve()) + .catch(() => reject()); + } else { + resolve(); // 用户取消操作,直接结束 + } + }) + .catch(() => { + reject('对话框出错'); // 对话框出错处理 + }); + } else { + // 已经进行过一次确认提示,直接保存文档信息 + this.handleDeleteAndSave(inData) + .then(() => resolve()) + .catch(() => reject()); + } + } else { + // 不存在生产确认记录,直接保存文档信息 + this.handleDeleteAndSave(inData) + .then(() => resolve()) + .catch(() => reject()); + } + }) + .catch(error => { + console.error('检查生产确认文档出错:', error); + reject('检查生产确认文档失败'); + }); + }); + }, + + handleDeleteAndSave(inData) { + return new Promise((resolve, reject) => { + checkConfirmationRecord(inData) + .then(({ data }) => { + if (data) { + this.$confirm('该项目已经有人员进行了确认,是否删除重新推送确认信息?', '提示', { + confirmButtonText: '是', + cancelButtonText: '否', + type: 'warning' + }) + .then(() => { + // 用户确认删除,执行删除操作 + deleteDocumentInformation(inData) + .then(() => { + this.projectAllDocumentConfirmatorList.map(item => { + let inData1 = { + site: this.proofingCurrentRow.site, + orderRef1: this.proofingCurrentRow.projectId, + userid: item.userid, + itemNo: this.projectAllDocumentConfirmatorList.indexOf(item) + 1, + wantedConfirmDate: this.modalData.wantedConfirmDate, + createBy: this.$store.state.user.name + }; + saveProductionValidationDocumentConfirmator(inData1); + }); + this.saveDocumentInformation(inData) + .then(() => resolve()) + .catch(() => reject()); + }) + .catch(() => reject('删除确认记录失败')); + }) + .catch(() => { + reject('用户取消操作'); + }); + } else { + deleteDocumentInformation(inData) + .then(() => { + this.projectAllDocumentConfirmatorList.map(item => { + let inData1 = { + site: this.proofingCurrentRow.site, + orderRef1: this.proofingCurrentRow.projectId, + userid: item.userid, + itemNo: this.projectAllDocumentConfirmatorList.indexOf(item) + 1, + wantedConfirmDate: this.modalData.wantedConfirmDate, + createBy: this.$store.state.user.name + }; + saveProductionValidationDocumentConfirmator(inData1); + }); + this.saveDocumentInformation(inData) + .then(() => resolve()) + .catch(() => reject()); + }) + .catch(() => reject('删除确认记录失败')); + } + }) + .catch(() => { + reject('检查确认记录失败'); + }); + }); + }, + + saveDocumentInformation(inData) { + return saveProductionValidationDocument(inData) + .then(response => { + if (response.data && response.data.code === 0) { + return Promise.resolve(); + } else { + return Promise.reject('保存文档失败'); + } + }) + .catch(() => { + return Promise.reject('保存文档失败'); + }); + }, + + askForDeleteConfirmation() { + return new Promise((resolve, reject) => { + this.$confirm('该项目已存在生产确认记录,是否删除重新推送确认信息?', '提示', { + confirmButtonText: '是', + cancelButtonText: '否', + type: 'warning' + }) + .then(() => { + resolve('true'); + }) + .catch(() => { + resolve('false'); + }); + }); + }, + + getConfirmProgressDocumentList() { let inData = { site: this.proofingCurrentRow.site, @@ -3804,37 +4003,87 @@ import { }) }, confirmDocument(row) { - this.confirmData = { - site: row.site, - documentType: row.documentType, - orderRef1: row.orderRef1, - itemNo: row.itemNo, - userid: row.userid, - username: row.username, - userDisplay: row.userDisplay, - wantedConfirmDate: row.wantedConfirmDate, - confirmFlag: row.confirmFlag, - confirmedDate: new Date(), - createBy: row.createBy, - createDate: row.createDate, - confirmedBy: this.$store.state.user.name, - documentId: row.documentId, - remark: '' - } - this.modalData = { - site: this.proofingCurrentRow.site, - projectId: this.proofingCurrentRow.projectId, - projectDesc: this.proofingCurrentRow.projectDesc, - testPartNo: this.proofingCurrentRow.testPartNo, - partDesc: this.proofingCurrentRow.partDesc, - customerNo: this.proofingCurrentRow.customerNo, - customerDesc: this.proofingCurrentRow.customerDesc, - buNo: this.proofingCurrentRow.buNo, - bu: this.proofingCurrentRow.site + '_' + this.proofingCurrentRow.buNo, - cProjectTypeDb: this.proofingCurrentRow.projectCategory, + // 将this.$store.state.user.id转为字符串 + let userId = this.$store.state.user.id.toString() + if (row.userid !== userId) { + // 提示指定确认人为row.confirmedBy,是否继续 + this.$confirm('指定确认人为' + row.userDisplay + ',是否继续确认?', '提示', { + confirmButtonText: '是', + cancelButtonText: '否', + type: 'warning' + }) + .then(() => { + this.confirmData = { + site: row.site, + documentType: row.documentType, + orderRef1: row.orderRef1, + itemNo: row.itemNo, + userid: row.userid, + username: row.username, + userDisplay: row.userDisplay, + wantedConfirmDate: row.wantedConfirmDate, + confirmFlag: row.confirmFlag, + confirmedDate: new Date(), + createBy: row.createBy, + createDate: row.createDate, + confirmedBy: this.$store.state.user.name, + documentId: row.documentId, + remark: row.remark + } + this.modalData = { + site: this.proofingCurrentRow.site, + projectId: this.proofingCurrentRow.projectId, + projectDesc: this.proofingCurrentRow.projectDesc, + testPartNo: this.proofingCurrentRow.testPartNo, + partDesc: this.proofingCurrentRow.partDesc, + customerNo: this.proofingCurrentRow.customerNo, + customerDesc: this.proofingCurrentRow.customerDesc, + buNo: this.proofingCurrentRow.buNo, + bu: this.proofingCurrentRow.site + '_' + this.proofingCurrentRow.buNo, + cProjectTypeDb: this.proofingCurrentRow.projectCategory, + } + this.getProjectConfirmatorFileList(row) + this.confirmVisible = true + }) + .catch(() => { + this.$message({ + type: 'info', + message: '已取消操作' + }); + }); + }else { + this.confirmData = { + site: row.site, + documentType: row.documentType, + orderRef1: row.orderRef1, + itemNo: row.itemNo, + userid: row.userid, + username: row.username, + userDisplay: row.userDisplay, + wantedConfirmDate: row.wantedConfirmDate, + confirmFlag: row.confirmFlag, + confirmedDate: new Date(), + createBy: row.createBy, + createDate: row.createDate, + confirmedBy: this.$store.state.user.name, + documentId: row.documentId, + remark: row.remark + } + this.modalData = { + site: this.proofingCurrentRow.site, + projectId: this.proofingCurrentRow.projectId, + projectDesc: this.proofingCurrentRow.projectDesc, + testPartNo: this.proofingCurrentRow.testPartNo, + partDesc: this.proofingCurrentRow.partDesc, + customerNo: this.proofingCurrentRow.customerNo, + customerDesc: this.proofingCurrentRow.customerDesc, + buNo: this.proofingCurrentRow.buNo, + bu: this.proofingCurrentRow.site + '_' + this.proofingCurrentRow.buNo, + cProjectTypeDb: this.proofingCurrentRow.projectCategory, + } + this.getProjectConfirmatorFileList(row) + this.confirmVisible = true } - this.getProjectConfirmatorFileList(row) - this.confirmVisible = true }, /*选择上传文件时*/ onChange(file,fileList){ @@ -3850,9 +4099,9 @@ import { this.$refs.uploadFile.$el.querySelector('input').click() }, saveUploadFile(){ + console.log('this.confirmData',this.confirmData) updateProjectDocumentConfirm(this.confirmData) .then(({data}) => { if (data.code === 0) { - this.$message.success('操作成功'); this.confirmVisible = false; this.getConfirmProgressDocumentList(); this.getConfirmProgressPusherList(); @@ -3861,11 +4110,6 @@ import { } }) let remark = this.confirmData.remark; - /*判断文件是否上传*/ - if(null == this.fileList || 0 == this.fileList.length){ - this.$message.error("请先上传文件!"); - return false; - } const formData = new FormData(); //片接文件 for (let i = 0; i < this.fileList.length; i++) { @@ -3996,6 +4240,63 @@ import { }) } }, + // 查看文件 + viewFile(row) { + // 预览文件 + let image = ['jpg', 'jpeg', 'png', 'gif', 'bmp'] + let type = '' + if (image.includes(row.fileType.toLowerCase())) { + type = 'image/' + row.fileType + } + let video = ['mp4', 'avi', 'mov', 'wmv', 'flv'] + if (video.includes(row.fileType.toLowerCase())) { + type = 'video/' + row.fileType + } + let txt = ['txt'] + if (txt.includes(row.fileType.toLowerCase())) { + type = 'text/plain' + } + let office = ['doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx'] + if (office.includes(row.fileType.toLowerCase())) { + if (row.fileType.toLowerCase() === 'doc' || row.fileType.toLowerCase() === 'docx') { + type = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' + } else if (row.fileType.toLowerCase() === 'ppt' || row.fileType.toLowerCase() === 'pptx') { + type = 'application/vnd.openxmlformats-officedocument.presentationml.presentation' + } else { + type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' + } + } + let pdf = ['pdf'] + if (pdf.includes(row.fileType.toLowerCase())) { + type = 'application/pdf' + } + downLoadObjectFile(row).then(({data}) => { + const blob = new Blob([data], { type: type }); + // 创建URL来生成预览 + const fileURL = URL.createObjectURL(blob); + // 在新标签页中打开文件预览 + const newTab = window.open(fileURL, '_blank') + }) + }, + // 下载 + downloadFile (row) { + downLoadObjectFile(row) + .then(({data}) => { + // 不限制文件下载类型 + const blob = new Blob([data], {type:'application/octet-stream;charset=utf-8'}) + // 下载文件名称 + const fileName = row.fileName + // a标签下载 + const linkNode = document.createElement('a') + linkNode.download = fileName // a标签的download属性规定下载文件的名称 + linkNode.style.display = 'none' + linkNode.href = URL.createObjectURL(blob) // 生成一个Blob URL + document.body.appendChild(linkNode) + linkNode.click() // 模拟在按钮上的一次鼠标单击 + URL.revokeObjectURL(linkNode.href) // 释放URL 对象 + document.body.removeChild(linkNode) + }) + }, closeProjectProductionValidationDocumentVisibleDialog() { this.projectProductionValidationDocumentVisible = false; this.activeName1 = 'selectDocument';