From d25c4c32a2219ab39b69befa65f440c709494f03 Mon Sep 17 00:00:00 2001 From: yuejiayang <146344614+YangLei105@users.noreply.github.com> Date: Wed, 24 Jul 2024 17:30:40 +0800 Subject: [PATCH] =?UTF-8?q?2024.7.24=20=E2=91=A0=E4=BA=A7=E5=93=81?= =?UTF-8?q?=E6=96=87=E6=A1=A3=E6=94=B6=E9=9B=86-=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E8=BF=9B=E4=B8=80=E6=AD=A5=E4=BC=98=E5=8C=96?= =?UTF-8?q?=20=E2=91=A1=E4=BB=A3=E5=8A=9E=E4=BA=8B=E5=AE=9C=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E7=AC=AC=E4=B8=80=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/eam/eamProjectInfoForConfirm.vue | 329 +++++++++++++++++- 1 file changed, 316 insertions(+), 13 deletions(-) diff --git a/src/views/modules/eam/eamProjectInfoForConfirm.vue b/src/views/modules/eam/eamProjectInfoForConfirm.vue index b74d0eb..5307e60 100644 --- a/src/views/modules/eam/eamProjectInfoForConfirm.vue +++ b/src/views/modules/eam/eamProjectInfoForConfirm.vue @@ -14,18 +14,62 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -36,15 +80,22 @@ import { searchProjectOverUploadsDocumentList, searchConfirmProgressList, searchOverConfirmProgressList } from "../../../api/eam/eamProofing"; -import {searchConfirmProgressPusherList} from "../../../api/eam/eamProject"; +import { + deleteProjectFile, + searchConfirmProgressPusherList, + searchProjectConfirmatorFileList +} from "../../../api/eam/eamProject"; +import {downLoadObjectFile} from "../../../api/eam/eam_object_list"; export default { data() { return { dataList: [], confirmProgressList: [], + projectConfirmatorFileList: [], height: 200, dataListLoading: false, + viewDocumentFileVisible: false, searchData: { site: this.$store.state.user.site, userId: this.$store.state.user.id, @@ -73,7 +124,259 @@ export default { }) } }, - + viewDocumentFile(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.userDisplay, + documentId: row.documentId, + remark: row.remark + } + let inData = { + orderRef1: row.site, + orderRef2: row.itemNo, + orderRef3: row.userid, + orderRef4: row.orderRef1, + page: 1, + limit: 1000 + } + searchProjectConfirmatorFileList(inData).then(({data}) => { + if (data && data.code === 0){ + this.projectConfirmatorFileList = data.page.list; + } + }) + this.viewDocumentFileVisible = true + }, + closeViewDocumentFileVisible(){ + this.viewDocumentFileVisible = false; + this.projectConfirmatorFileList = []; + }, + // 查看文件 + viewFile(row) { + // 预览文件 + let image = ['jpg', 'jpeg', 'png', 'gif', 'bmp'] + let video = ['mp4', 'avi', 'mov', 'wmv', 'flv'] + let office = ['doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx'] + let txt = ['txt'] + let type = '' + let pdf = ['pdf'] + if (image.includes(row.fileType.toLowerCase())) { + type = 'image/' + row.fileType + downLoadObjectFile(row).then(({data}) => { + const blob = new Blob([data], { type: type }); + // 创建URL来生成预览 + const fileURL = URL.createObjectURL(blob); + // 在新标签页中打开文件预览 + const newTab = window.open(fileURL, '_blank') + }) + } + else if (video.includes(row.fileType.toLowerCase())) { + type = 'video/' + row.fileType + downLoadObjectFile(row).then(({data}) => { + const blob = new Blob([data], { type: type }); + // 创建URL来生成预览 + const fileURL = URL.createObjectURL(blob); + // 在新标签页中打开文件预览 + const newTab = window.open(fileURL, '_blank') + }) + } + else if (txt.includes(row.fileType.toLowerCase())) { + type = 'text/plain' + downLoadObjectFile(row).then(({data}) => { + const blob = new Blob([data], { type: type }); + // 创建URL来生成预览 + const fileURL = URL.createObjectURL(blob); + // 在新标签页中打开文件预览 + const newTab = window.open(fileURL, '_blank') + }) + } + else 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' + } + downLoadObjectFile(row).then(({data}) => { + const blob = new Blob([data], { type: type }); + // 创建URL来生成预览 + const fileURL = URL.createObjectURL(blob); + // 在新标签页中打开文件预览 + const newTab = window.open(fileURL, '_blank') + }) + } + else 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') + }) + } + else { + this.$message({ + message: '不支持的文件类型', + type: 'warning' + }) + } + }, + // 下载 + 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) + }) + }, + deleteFile(row) { + if (this.confirmData.confirmedBy === this.$store.state.user.userDisplay) { + this.$confirm('是否删除该文件?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + let inData = { + id: row.id, + orderRef1: row.orderRef1, + orderRef2: row.orderRef2, + orderRef3: row.orderRef3, + orderRef4: row.orderRef4, + createdBy: this.$store.state.user.name + } + deleteProjectFile(inData).then(({data}) => { + if (data && data.code === 0) { + this.$message({ + message: '删除成功', + type: 'success' + }) + this.getProjectConfirmatorFileList(this.confirmData) + } else { + this.$message({ + message: '删除失败', + type: 'error' + }) + } + }) + }).catch(() => { + this.$message({ + type: 'info', + message: '已取消删除' + }); + }); + } else { + this.$message({ + message: '只有确认人员才能删除文件', + type: 'error' + }) + } + }, + confirmDocument(row) { + // 将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.userDisplay, + 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 + } + }, formatDate(row, column) { // row 是当前行的数据对象 // column 是当前列的属性信息对象