From 1cf035de45207376e2deda97917a341a084e115f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E9=9C=84?= Date: Wed, 10 Jan 2024 10:42:04 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E6=A0=87=E5=87=86=E5=85=A5=E5=BA=93/?= =?UTF-8?q?=E5=8F=98=E6=9B=B4=E3=80=81=E6=A0=87=E5=87=86=E5=BE=81=E6=B1=82?= =?UTF-8?q?=E6=84=8F=E8=A7=81=E3=80=81=E6=B3=95=E8=A7=84=E9=87=87=E8=B4=AD?= =?UTF-8?q?=E6=B5=81=E7=A8=8B=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/kkFilePreview.js | 19 ++++++---- src/utils/util.js | 37 +++++++++++++++++++ .../commonPage/StandardDetailPage.vue | 11 ++++++ .../StandardConsultationProcess.vue | 22 ++++++++++- .../StandardEntryOrChangeProcess.vue | 6 ++- .../StandardProcurementProcess.vue | 2 + 6 files changed, 86 insertions(+), 11 deletions(-) diff --git a/src/utils/kkFilePreview.js b/src/utils/kkFilePreview.js index ce83d9cf..38eec74b 100644 --- a/src/utils/kkFilePreview.js +++ b/src/utils/kkFilePreview.js @@ -13,11 +13,7 @@ function fillZero (str) { return realNum } -/** - * kkFile预览文件并添加水印 - * @param fileUrl - */ -export const kkFilePreview = (fileUrl) => { +export function dealUrl (fileUrl) { const userInfo = Vue.ls.get(USER_INFO) // 获取当前时间 const date = new Date() @@ -32,6 +28,13 @@ export const kkFilePreview = (fileUrl) => { const watermarkTxt = `${userInfo.username} ${userInfo.realname} ${time}` // 客户环境预览需要加的加密参数 const watermarkSign = md5(watermarkTxt + 'cnhtc') - const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(fileUrl))}&watermarkTxt=${encodeURIComponent(watermarkTxt)}&watermarkSign=${watermarkSign}` - window.open(url) -} \ No newline at end of file + return `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(fileUrl))}&watermarkTxt=${encodeURIComponent(watermarkTxt)}&watermarkSign=${watermarkSign}` +} + +/** + * kkFile预览文件并添加水印 + * @param fileUrl + */ +export const kkFilePreview = (fileUrl) => { + window.open(dealUrl(fileUrl)) +} diff --git a/src/utils/util.js b/src/utils/util.js index 7061ef4e..e8a44a35 100644 --- a/src/utils/util.js +++ b/src/utils/util.js @@ -2,6 +2,9 @@ import Vue from 'vue' import * as api from '@/api/api' import { isURL } from '@/utils/validate' import { ACCESS_TOKEN } from '@/store/mutation-types' +import { getFileInfo } from '@/api/api' +import { dealUrl, kkFilePreview } from './kkFilePreview' +import { previewPdf } from './previewPdf' // import onlineCommons from '@/components/onlineForm/onlineForm' // @@ -678,3 +681,37 @@ export function getConfusionCode (tableName, fieldName) { } return '' } + +/** + * 通过文件id在当前窗口预览文件 + * @param fileId + */ +export function previewFileCurrentWindowByFileId (fileId) { + return new Promise((resolve, reject) => { + getFileInfo({ id: fileId }).then(res => { + if (res.success) { + const file = res.result || {} + // 支持预览的文件后缀 + const CAN_PREVIEW_FILE_SUFFIX = ['jpg', 'jpeg', 'png', 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx'] + const fileSuffix = file.fileName ? file.fileName.split('.')[file.fileName.split('.').length - 1] : '' + const canPreview = CAN_PREVIEW_FILE_SUFFIX.some(tt => fileSuffix.toLowerCase() === tt) + // 判断是否为可预览格式的文件 + if (!canPreview) { + reject('该文件类型不支持预览') + } + const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${file.id}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.fileName}` + const FILE_TYPE_IMGS = ['jpg', 'jpeg', 'png', 'raw'] + const FILE_TYPE_PDF = 'pdf' + // pdf预览 + if (canPreview && FILE_TYPE_PDF.includes(fileSuffix)) { + const url = previewPdf(file.id) + window.open(url, '_self') + return + } + // 其余可预览文件仍使用KKFile进行预览 + const kkFileUrl = dealUrl(fileFullUrl) + window.open(kkFileUrl, '_self') + } + }) + }) +} diff --git a/src/views/standardRegulationLibrary/commonPage/StandardDetailPage.vue b/src/views/standardRegulationLibrary/commonPage/StandardDetailPage.vue index 774ce289..788eb90d 100644 --- a/src/views/standardRegulationLibrary/commonPage/StandardDetailPage.vue +++ b/src/views/standardRegulationLibrary/commonPage/StandardDetailPage.vue @@ -140,6 +140,7 @@ import { downloadFile, getFileAccessHttpUrl } from '../../../api/manage.js' import { previewPdf } from '../../../utils/previewPdf.js' import { Base64 } from 'js-base64' import { kkFilePreview } from '../../../utils/kkFilePreview' +import { previewFileCurrentWindowByFileId } from '../../../utils/util' // 国内标准权限 const DomesticStandardPermission = { @@ -251,6 +252,16 @@ export default { } }, async created () { + // 如果是要直接看文件 + // if (this.$route.query.viewFile) { + // // TODO 这里需要调一个接口,通过标准id按规则获取文件 + // const fileId = '1734843741558288385' + // previewFileCurrentWindowByFileId(fileId).then(() => { + // }).catch((message) => { + // this.$message.warning(message) + // }) + // return + // } await this.initForm() this.initDetailData() }, diff --git a/src/views/workCenter/standardConsultationProcess/StandardConsultationProcess.vue b/src/views/workCenter/standardConsultationProcess/StandardConsultationProcess.vue index 71786244..cb221025 100644 --- a/src/views/workCenter/standardConsultationProcess/StandardConsultationProcess.vue +++ b/src/views/workCenter/standardConsultationProcess/StandardConsultationProcess.vue @@ -140,7 +140,8 @@ + :placeholder="$t('pleaseSelect') + $t('workCenter.standardConsultationProcess.moduleOwner')" + @nameChange="handleModuleOwnerNameChange" /> @@ -151,7 +152,8 @@ + :placeholder="$t('pleaseSelect') + $t('workCenter.standardConsultationProcess.designEngineer')" + @nameChange="handleDesignEngineerNameChange" /> @@ -977,6 +979,7 @@ export default { basicServiceInfo = Object.assign(this.basicServiceInfo, this.basicServiceInfoForm.getFieldsValue()) // 流程审批信息 approvalInfo = Object.assign(this.approvalInfo, this.approvalInfoForm.getFieldsValue()) + approvalInfo.finishFlag = 1 // 保存——1;提交/同意/驳回——2 // 业务分派信息 if (this.showDispatchInformation) { dispatchInfo = Object.assign(this.dispatchInfo, this.dispatchInfoForm.getFieldsValue()) @@ -1012,6 +1015,7 @@ export default { this.approvalInfoForm.validateFields((errors, values) => { if (!errors) { approvalInfo = Object.assign(this.approvalInfo, values) + approvalInfo.finishFlag = 2 // 保存——1;提交/同意/驳回——2 } else { flag = false } @@ -1248,6 +1252,20 @@ export default { */ consultationDueDateDisabledDate (current) { return current && current < moment().subtract(1, 'days').endOf('day') + }, + /** + * 模块负责人名字 + * @param name + */ + handleModuleOwnerNameChange (name) { + this.dispatchInfo.moduleOwnerId_dictText = name + }, + /** + * 设计工程师名字 + * @param name + */ + handleDesignEngineerNameChange (name) { + this.dispatchInfo.designEngineerId_dictText = name } } } diff --git a/src/views/workCenter/standardEntryOrChangeProcess/StandardEntryOrChangeProcess.vue b/src/views/workCenter/standardEntryOrChangeProcess/StandardEntryOrChangeProcess.vue index 31a0c77a..6872df23 100644 --- a/src/views/workCenter/standardEntryOrChangeProcess/StandardEntryOrChangeProcess.vue +++ b/src/views/workCenter/standardEntryOrChangeProcess/StandardEntryOrChangeProcess.vue @@ -846,6 +846,7 @@ export default { if (!errors) { formData.basicTaskInfoDTO = Object.assign(this.approvalInfo, values) formData.basicTaskInfoDTO.taskId = this.$route.query.taskId + formData.basicTaskInfoDTO.finishFlag = 2 // 保存——1;提交/同意/驳回——2 } else { flag = false this.$message.warning(this.$t('pleaseEnterRemarks')) @@ -890,7 +891,10 @@ export default { businessMap: formInline, id: this.businessId }, // 业务信息 - basicTaskInfoDTO: Object.assign(this.approvalInfo, this.approvalInfoForm.getFieldsValue(), { taskId: this.$route.query.taskId }), // 流程审批信息 + basicTaskInfoDTO: Object.assign(this.approvalInfo, this.approvalInfoForm.getFieldsValue(), { + taskId: this.$route.query.taskId, + finishFlag: 1 // 保存——1;提交/同意/驳回——2 + }), // 流程审批信息 userInfoMap: this.$refs.personnelInfo.getDataObj() // 用户信息 } const params = { ...formData.basicProcessInfoDTO, ...this.formInline, ...formData.basicTaskInfoDTO } diff --git a/src/views/workCenter/standardProcurementProcess/StandardProcurementProcess.vue b/src/views/workCenter/standardProcurementProcess/StandardProcurementProcess.vue index bf839128..5651a021 100644 --- a/src/views/workCenter/standardProcurementProcess/StandardProcurementProcess.vue +++ b/src/views/workCenter/standardProcurementProcess/StandardProcurementProcess.vue @@ -364,6 +364,7 @@ export default { businessInfo = this.dataSource approvalInfo = Object.assign(this.approvalInfo, this.approvalInfoForm.getFieldsValue()) approvalInfo.taskId = approvalInfo.taskId || this.$route.query.taskId + approvalInfo.finishFlag = 1 // 保存——1;提交/同意/驳回——2 userInfoMap = this.$refs.personnelInfo.getDataObj() const params = { ...processInfo, ...businessInfo, ...approvalInfo, ...userInfoMap } if (!Object.values(params).some(tt => !!tt || (tt && tt.length > 0))) { @@ -391,6 +392,7 @@ export default { if (!errors) { approvalInfo = Object.assign(this.approvalInfo, values) approvalInfo.taskId = approvalInfo.taskId || this.$route.query.taskId + approvalInfo.finishFlag = 2 // 保存——1;提交/同意/驳回——2 } else { flag = false this.$message.warning(this.$t('pleaseEnterRemarks'))