From c7bd6afe3e76d0e1c6f06d1563ffade1cd34f835 Mon Sep 17 00:00:00 2001 From: Xia Zekun Date: Mon, 25 Mar 2024 16:46:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=80=E8=88=AC=E6=A3=80=E7=B4=A2=20?= =?UTF-8?q?=E9=AB=98=E7=BA=A7=E6=A3=80=E7=B4=A2=20=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E6=A0=87=E9=A2=98=E7=9B=B4=E6=8E=A5=E9=A2=84=E8=A7=88=E6=9C=80?= =?UTF-8?q?=E6=96=B0=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/dashboard/search/AdvancedSearch.vue | 125 ++++++++++++++- src/views/dashboard/search/GeneralSearch.vue | 144 +++++++++++++++++- 2 files changed, 265 insertions(+), 4 deletions(-) diff --git a/src/views/dashboard/search/AdvancedSearch.vue b/src/views/dashboard/search/AdvancedSearch.vue index 96d41818..bb771495 100644 --- a/src/views/dashboard/search/AdvancedSearch.vue +++ b/src/views/dashboard/search/AdvancedSearch.vue @@ -140,7 +140,7 @@ @@ -155,7 +155,7 @@ import { filterObj } from '@/utils/util' import { StandardSource, FieldType, EnterpriseStandardStatus, StandardStatus } from '@/enums/commonEnums' import { getAction } from '@/api/manage' -import { getFormDictTreeList, queryDepartTreeList } from '@/api/api' +import { getFormDictTreeList, queryDepartTreeList, getFileInfo } from '@/api/api' import { getDomesticStandardList, getOverseasStandardList, @@ -165,6 +165,17 @@ import { getEnterStandardQuery } from '@/api/dashboard' import JTable from '@/components/jero/JTable' +import { + getDomesticStandardFormModal, + getDomesticStandardDetail, + getOverseasStandardForm, + getOverseasStandardDocumentInfo +} from '../../../api/standardRegulationLibraryApi' +import { getEnterpriseStandardAddForm, getEnterpriseStandardInfoById } from '../../../api/enterpriseStandardLibraryApi' +import Vue from 'vue' +import { ACCESS_TOKEN } from '../../../store/mutation-types' +import { previewPdf } from '../../../utils/previewPdf' +import { kkFilePreview } from '../../../utils/kkFilePreview' export default { name: 'AdvancedSearch', @@ -244,6 +255,8 @@ export default { showSizeChanger: true, total: 0 }, + getFormFunc: getDomesticStandardFormModal, + getDocumentInfoFunc: getDomesticStandardDetail, // 国标和外标的默认标准状态 defaultStandardStatus: `${StandardStatus.CURRENTLY_EFFECTIVE.value},${StandardStatus.BE_IMPLEMENTED_SOON.value},${StandardStatus.RELEASE.value}`, // 企标的默认标准状态 @@ -257,12 +270,18 @@ export default { if (val === '1') { this.getQueryConditionFunc = getDomesticStandardQuery this.getDataListFunc = getDomesticStandardList + this.getFormFunc = getDomesticStandardFormModal + this.getDocumentInfoFunc = getDomesticStandardDetail } else if (val === '2') { this.getQueryConditionFunc = getOverseasStandardQuery this.getDataListFunc = getOverseasStandardList + this.getFormFunc = getOverseasStandardForm + this.getDocumentInfoFunc = getOverseasStandardDocumentInfo } else if (val === '3') { this.getQueryConditionFunc = getEnterStandardQuery this.getDataListFunc = getEnterStandardList + this.getFormFunc = getEnterpriseStandardAddForm + this.getDocumentInfoFunc = getEnterpriseStandardInfoById } this.getSearch() // this.loadData(1) @@ -300,6 +319,108 @@ export default { } }) }, + /** + * 按顺序打开最新的pdf或word + */ + async filePreview (record) { + console.log('filePreview', record) + // 获取并处理过程稿件数据 + let res = await this.getFormFunc({ type: 1 }) + if (!res.success) { + this.$message.warn(res.message) + console.log('getFormFunc error:', res) + return + } + console.log('res.result', res.result) + const data = res.result || {} + const form = data + const partList = Object.keys(data) + let part + const partZh = '过程稿件' + const partEn = 'Process Manuscript' + if (partList.includes(partEn))part = partEn + if (partList.includes(partZh))part = partZh + console.log('part', part) + const processManuscript = form[part] + console.log('过程稿件', processManuscript) + + // 获取并处理详情数据 + res = await this.getDocumentInfoFunc({ id: record.id, type: 1 }) + if (!res.success) { + this.$message.warn(res.message) + console.log('getDocumentInfoFunc error:', res) + return + } + const detailData = Object.assign({}, res.result || {}) + console.log('detailData', detailData) + + // 选择合适的文件 + let file = null + const pdfFileList = [] + const docFileList = [] + let newestFileList = [] + // 按照过程稿件顺序寻找文件 + for (const formItem of processManuscript) { + const keyId = formItem.dbFieldName + const keyName = formItem.dbFieldName + '_dictText' + if (!detailData[keyId]) continue + const idArray = detailData[keyId].split(',') + const nameArray = detailData[keyName].split(',') + // 每个过程中可能有多个文件 + for (let i = 0; i < idArray.length; i++) { + const id = idArray[i] + const name = nameArray[i] + var suffix = name.substring(name.lastIndexOf('.') + 1).toLowerCase() + if (suffix === 'pdf') { + pdfFileList.push({ id, name, suffix }) + } + if (suffix === 'doc' || suffix === 'docx') { + docFileList.push({ id, name, suffix }) + } + } + // 一旦一个过程中找到pdf或者doc,就可以退出 + if (pdfFileList.length > 0 || docFileList.length > 0) { + break + } + } + newestFileList = pdfFileList // 默认从pdf里选最新的文件 + if (pdfFileList.length === 0)newestFileList = docFileList // 如果没有pdf文件,就从doc文件里选 + file = await this.selectNewestFile(newestFileList) + if (file === null) { // 没有找到文件就退出 + console.log('没有找到符合要求的文件!') + this.$message.error('该标准暂无预览文件,请联系标准管理员。') + return + } + console.log('seletedFile', file) + + // 预览选择的文件 + const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${file.id}?at=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.name}` + console.log(fileFullUrl) + if (file.suffix === 'pdf') { // pdf预览 + const url = previewPdf(file.id) + window.open(url) + return + } + kkFilePreview(fileFullUrl)// 其余可预览文件仍使用KKFile进行预览 + }, + /** + * 从文件列表里选择最新文件 + * @param fileList + */ + async selectNewestFile (fileList) { + if (!fileList || fileList.length === 0) return null + if (fileList.length === 1) return fileList[0] + const newFileList = [] + // 获取时间信息 + for (const file of fileList) { + const res = await getFileInfo(file) + newFileList.push({ ...file, ...res.result }) + } + // 排序取出最新 + newFileList.sort((a, b) => b.id - a.id) // 日期只精确到天,用id更能区分 + console.log('newFileList', newFileList) + return newFileList[0] + }, // 标准类型改变 standardTypeChange (value) { this.currStandardType = value diff --git a/src/views/dashboard/search/GeneralSearch.vue b/src/views/dashboard/search/GeneralSearch.vue index b5082ad7..a2a24eac 100644 --- a/src/views/dashboard/search/GeneralSearch.vue +++ b/src/views/dashboard/search/GeneralSearch.vue @@ -80,7 +80,7 @@ -

+

{{ resourceTypeOptions.find(i => i.key === item.resourceType).label }}

@@ -135,6 +135,18 @@ import { import { isHasPermission } from '@/utils/hasPermission' import { mapGetters } from 'vuex' import { StandardStatus } from '@/enums/commonEnums' +import { + getDomesticStandardFormModal, + getDomesticStandardDetail, + getOverseasStandardForm, + getOverseasStandardDocumentInfo +} from '../../../api/standardRegulationLibraryApi' +import { getEnterpriseStandardAddForm, getEnterpriseStandardInfoById } from '../../../api/enterpriseStandardLibraryApi' +import Vue from 'vue' +import { previewPdf } from '../../../utils/previewPdf' +import { kkFilePreview } from '../../../utils/kkFilePreview' +import { ACCESS_TOKEN } from '../../../store/mutation-types' +import { getFileInfo } from '../../../api/api' export default { name: 'GeneralSearch', @@ -195,7 +207,9 @@ export default { showQuickJumper: true, showSizeChanger: true }, - StandardStatus: StandardStatus + StandardStatus: StandardStatus, + getFormFunc: getDomesticStandardFormModal, + getDocumentInfoFunc: getDomesticStandardDetail } }, mounted () { @@ -473,6 +487,132 @@ export default { } }) }, + // 根据类型,选择调用的函数 + adjustFunc (type) { + switch (type) { + case '1': + this.getFormFunc = getDomesticStandardFormModal + this.getDocumentInfoFunc = getDomesticStandardDetail + break + case '2': + this.getFormFunc = getOverseasStandardForm + this.getDocumentInfoFunc = getOverseasStandardDocumentInfo + break + case '3': + this.getFormFunc = getEnterpriseStandardAddForm + this.getDocumentInfoFunc = getEnterpriseStandardInfoById + break + } + }, + filePreviewAll (record) { + if (record.resourceType === '4') { + this.goDetail(record) + } else { + this.filePreview13(record) + } + }, + /** + * 按顺序打开最新的pdf或word + */ + async filePreview13 (record) { + console.log('filePreview', record) + // 获取并处理过程稿件数据 + let res = await this.getFormFunc({ type: 1 }) + if (!res.success) { + this.$message.warn(res.message) + console.log('getFormFunc error:', res) + return + } + console.log('res.result', res.result) + const data = res.result || {} + const form = data + const partList = Object.keys(data) + let part + const partZh = '过程稿件' + const partEn = 'Process Manuscript' + if (partList.includes(partEn))part = partEn + if (partList.includes(partZh))part = partZh + console.log('part', part) + const processManuscript = form[part] + console.log('过程稿件', processManuscript) + + // 获取并处理详情数据 + res = await this.getDocumentInfoFunc({ id: record.id, type: 1 }) + if (!res.success) { + this.$message.warn(res.message) + console.log('getDocumentInfoFunc error:', res) + return + } + const detailData = Object.assign({}, res.result || {}) + console.log('detailData', detailData) + + // 选择合适的文件 + let file = null + const pdfFileList = [] + const docFileList = [] + let newestFileList = [] + // 按照过程稿件顺序寻找文件 + for (const formItem of processManuscript) { + const keyId = formItem.dbFieldName + const keyName = formItem.dbFieldName + '_dictText' + if (!detailData[keyId]) continue + const idArray = detailData[keyId].split(',') + const nameArray = detailData[keyName].split(',') + // 每个过程中可能有多个文件 + for (let i = 0; i < idArray.length; i++) { + const id = idArray[i] + const name = nameArray[i] + var suffix = name.substring(name.lastIndexOf('.') + 1).toLowerCase() + if (suffix === 'pdf') { + pdfFileList.push({ id, name, suffix }) + } + if (suffix === 'doc' || suffix === 'docx') { + docFileList.push({ id, name, suffix }) + } + } + // 一旦一个过程中找到pdf或者doc,就可以退出 + if (pdfFileList.length > 0 || docFileList.length > 0) { + break + } + } + newestFileList = pdfFileList // 默认从pdf里选最新的文件 + if (pdfFileList.length === 0)newestFileList = docFileList // 如果没有pdf文件,就从doc文件里选 + file = await this.selectNewestFile(newestFileList) + if (file === null) { // 没有找到文件就退出 + console.log('没有找到符合要求的文件!') + this.$message.error('该标准暂无预览文件,请联系标准管理员。') + return + } + console.log('seletedFile', file) + + // 预览选择的文件 + const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${file.id}?at=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.name}` + console.log(fileFullUrl) + if (file.suffix === 'pdf') { // pdf预览 + const url = previewPdf(file.id) + window.open(url) + return + } + kkFilePreview(fileFullUrl)// 其余可预览文件仍使用KKFile进行预览 + }, + /** + * 从文件列表里选择最新文件 + * @param fileList + */ + async selectNewestFile (fileList) { + if (!fileList || fileList.length === 0) return null + if (fileList.length === 1) return fileList[0] + const newFileList = [] + // 获取时间信息 + for (const file of fileList) { + const res = await getFileInfo(file) + newFileList.push({ ...file, ...res.result }) + } + // 排序取出最新 + newFileList.sort((a, b) => b.id - a.id) // 日期只精确到天,用id更能区分 + console.log('newFileList', newFileList) + return newFileList[0] + }, // 检索弹框点击历史查数据 historySearch (searchObj) { console.log('--------historySearch--------', searchObj)