【update】-重汽国标、企标 点击标准名称修改成预览文件
This commit is contained in:
@@ -138,7 +138,7 @@
|
||||
<template v-slot:standard_number="{text, record}">
|
||||
<a-tooltip overlay-class-name="tooltip-style">
|
||||
<template slot="title">{{ text || text === 0 ? text : global.emptyLine }}</template>
|
||||
<div class="table-text can-click-table-text" v-if="text || text === 0" @click="toDetailPage(record)">{{
|
||||
<div class="table-text can-click-table-text" v-if="text || text === 0" @click="filePreview(record)">{{
|
||||
text
|
||||
}}
|
||||
</div>
|
||||
@@ -150,7 +150,7 @@
|
||||
<template v-slot:standard_name="{text, record}">
|
||||
<a-tooltip overlay-class-name="tooltip-style">
|
||||
<template slot="title">{{ text || text === 0 ? text : global.emptyLine }}</template>
|
||||
<div class="table-text can-click-table-text" v-if="text || text === 0" @click="toDetailPage(record)">{{
|
||||
<div class="table-text can-click-table-text" v-if="text || text === 0" @click="filePreview(record)">{{
|
||||
text
|
||||
}}
|
||||
</div>
|
||||
@@ -171,6 +171,8 @@
|
||||
<a-menu-item v-for="(operation, index) in operationList.slice(operateMaxNum)" :key="index">
|
||||
<a @click="operationClick(operation,record)" v-has="operation.has">
|
||||
<div class="operate-btn">
|
||||
<!-- 查看图标-->
|
||||
<i class="iconfont icon-link operate-btn-icon" v-if="operation.text === $t('view')" />
|
||||
<!-- 编辑图标-->
|
||||
<i class="iconfont icon-bianji operate-btn-icon" v-if="operation.text === $t('edit')" />
|
||||
<!-- 分享图标-->
|
||||
@@ -215,7 +217,9 @@ import {
|
||||
shareOverseasStandard,
|
||||
deleteOverseasStandardSystem,
|
||||
configOverseasStandard,
|
||||
removeOverseasStandard
|
||||
removeOverseasStandard,
|
||||
getOverseasStandardForm,
|
||||
getOverseasStandardDocumentInfo
|
||||
} from '../../../api/standardRegulationLibraryApi'
|
||||
import { StandardSource, StandardSystemTreeNodeType, YesOrNoEnum } from '../../../enums/commonEnums'
|
||||
import UserSelectModal from '../../../components/selection/UserSelectModal.vue'
|
||||
@@ -223,6 +227,11 @@ import OverseasStandardModal from './modules/OverseasStandardModal.vue'
|
||||
import OverseasSystemTreeModal from './modules/OverseasSystemTreeModal.vue'
|
||||
import SelectionOverseasStandardDrawer from './modules/SelectionOverseasStandardDrawer.vue'
|
||||
import { postDownFile } from '../../../api/manage.js'
|
||||
import Vue from 'vue'
|
||||
import { ACCESS_TOKEN } from '@/store/mutation-types'
|
||||
import { previewPdf } from '@/utils/previewPdf'
|
||||
import { kkFilePreview } from '@/utils/kkFilePreview'
|
||||
import { getFileInfo } from '@api/api'
|
||||
|
||||
export default {
|
||||
name: 'OverseasStandardList',
|
||||
@@ -249,6 +258,12 @@ export default {
|
||||
clickEvent: 'handleCollection',
|
||||
has: 'overseasStandard:collection'
|
||||
},
|
||||
// 查看
|
||||
{
|
||||
text: this.$t('view'),
|
||||
clickEvent: 'toDetailPage',
|
||||
has: 'overseasStandard:view'
|
||||
},
|
||||
// 编辑
|
||||
{
|
||||
text: this.$t('edit'),
|
||||
@@ -547,6 +562,108 @@ export default {
|
||||
}
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 按顺序打开最新的pdf或word
|
||||
*/
|
||||
async filePreview (record) {
|
||||
console.log('filePreview', record)
|
||||
// 获取并处理过程稿件数据
|
||||
let res = await getOverseasStandardForm({ type: 1 })
|
||||
if (!res.success) {
|
||||
this.$message.warn(res.message)
|
||||
console.log('getDomesticStandardFormModal 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 getOverseasStandardDocumentInfo({ id: record.id, type: 1 })
|
||||
if (!res.success) {
|
||||
this.$message.warn(res.message)
|
||||
console.log('getDomesticStandardDetail 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)
|
||||
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]
|
||||
},
|
||||
/**
|
||||
* 重置查询
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user