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 @@
{{ text || text === 0 ? text : global.emptyLine }}
- {{ text }}
+ {{ text }}
{{ global.emptyLine }}
@@ -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)