[update] 标准点击编号或名称跳转详情和删除详情的评价等功能

This commit is contained in:
lideqin
2024-06-12 09:35:44 +08:00
parent 00acf31aa3
commit 0cf0964113
10 changed files with 15 additions and 1449 deletions
@@ -187,7 +187,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>
<a class="link-a" @click="filePreview(record)" v-if="(text || text === 0) && record.detailFlag">{{ text }}</a>
<a class="link-a" @click="detailClick(record)" v-if="(text || text === 0) && record.detailFlag">{{ text }}</a>
<div class="table-text" v-else-if="(text || text === 0) && !record.detailFlag">{{ text }}</div>
<div class="table-text" v-else>{{ global.emptyLine }}</div>
</a-tooltip>
@@ -197,7 +197,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>
<a class="link-a" @click="filePreview(record)" v-if="(text || text === 0) && record.detailFlag">{{ text }}</a>
<a class="link-a" @click="detailClick(record)" v-if="(text || text === 0) && record.detailFlag">{{ text }}</a>
<div class="table-text" v-else-if="(text || text === 0) && !record.detailFlag">{{ text }}</div>
<div class="table-text" v-else>{{ global.emptyLine }}</div>
</a-tooltip>
@@ -232,9 +232,7 @@ import {
shiftStandard,
collectStandard,
cancelCollectStandard,
deleteTreeNode,
getEnterpriseStandardInfoById,
getEnterpriseStandardAddForm
deleteTreeNode
} from '@api/enterpriseStandardLibraryApi'
// 添加、编辑弹框
import EnterpriseStandardModal from './modules/EnterpriseStandardModal'
@@ -245,11 +243,6 @@ import TreeNodeModal from './modules/TreeNodeModal'
import AllocationStandardDrawer from './modules/AllocationStandardDrawer'
import { postDownFile, downloadFile, postAction } from '@/api/manage'
import TemporaryPermissionRecord from './modules/TemporaryPermissionRecord'
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'
import { mapGetters } from 'vuex'
import { isHasPermission } from '@/utils/hasPermission'
@@ -275,12 +268,6 @@ export default {
clickEvent: 'handleCollection',
has: 'enterpriseStandard:collection'
},
// 查看
{
text: this.$t('viewDetail'),
clickEvent: 'detailClick',
has: 'enterpriseStandard:view'
},
{ // 编辑
text: this.$t('edit'),
clickEvent: 'handleEdit',
@@ -717,126 +704,6 @@ export default {
}
})
},
/**
* 按顺序打开最新的pdf或word
*/
async filePreview (record) {
console.log('filePreview', record)
// 获取并处理过程稿件数据
let res = await getEnterpriseStandardAddForm({ 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 getEnterpriseStandardInfoById({ 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 = []
let manuscriptName = '' // 记录找到哪个稿件就找到文件了
// 按照过程稿件顺序寻找文件
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 === 'docx') {
docFileList.push({ id, name, suffix })
}
}
// 一旦一个过程中找到pdf或者doc,就可以退出
if (pdfFileList.length > 0 || docFileList.length > 0) {
manuscriptName = formItem.dbFieldName
break
}
}
if (manuscriptName === 'publish_of_original') {
// 在发布稿就找到了,合并pdf和doc文件列表排序
newestFileList = [...pdfFileList, ...docFileList]
} else {
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)
// 是onlyOffice生成的,预览关联的pdf文件
if (file.pdfId) {
// 说明是onlyOffice生成的
const url = previewPdf(file.pdfId)
window.open(url)
return
}
// 预览选择的文件
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) {
const res = await getFileInfo(fileList[0])
return { ...fileList[0], ...res.result }
}
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]
},
// 操作完需要刷树的回调
modalFormOk () {
this.selectedTreeKeys = []
@@ -4,23 +4,6 @@
<div class="detail-page-part" v-for="(part, index) in partList" :key="part + index">
<div class="detail-page-part-title">
<span>{{ part }}</span>
<div class="detail-page-part-title-operate-box" v-if="index === 0">
<!-- 企标评价-->
<a-button type="link" @click="handleEvaluate" v-has="'enterpriseStandard:detail:evaluate'">
<i class="iconfont icon-edit-1" />
{{ $t('enterpriseStandardLibrary.standard.evaluate') }}
</a-button>
<!-- 更新记录-->
<a-button type="link" @click="handleOpenUpdateRecord" v-has="'enterpriseStandard:detail:updateLog'">
<i class="iconfont icon-root-list" />
{{ $t('enterpriseStandardLibrary.standard.updateRecord') }}
</a-button>
<!-- 提交问题-->
<a-button type="link" @click="submitQuestion" v-has="'enterpriseStandard:detail:submitQuestion'">
<i class="iconfont icon-chat" />
{{ $t('enterpriseStandardLibrary.standard.submitQuestion') }}
</a-button>
</div>
</div>
<div class="detail-page-part-form" v-if="part !== '过程稿件' && part !== 'Process Manuscript'">
<div class="detail-page-part-form-item" v-for="formItem in form[part]" :key="formItem.id">
@@ -129,12 +112,7 @@
</a-table>
</div>
</div>
<!-- 企标评价 -->
<enterprise-standard-evaluate-modal ref="enterpriseStandardEvaluateModal"></enterprise-standard-evaluate-modal>
<!-- 更新记录弹框 -->
<update-record-modal ref="updateRecordModal"></update-record-modal>
<!-- 提交问题弹框 -->
<submit-question-modal ref="submitQuestionModal"></submit-question-modal>
<!-- 标准分解单-->
<standard-resolution-sheet-modal ref="standardResolutionSheetModal" />
<!-- 图片预览容器 -->
@@ -152,14 +130,10 @@ import '@assets/less/common.less'
import { FieldType, StandardSource } from '@/enums/commonEnums'
import { downloadFile, getFileAccessHttpUrl } from '@/api/manage'
import { getEnterpriseStandardInfoById, getEnterpriseStandardAddForm } from '@/api/enterpriseStandardLibraryApi'
import UpdateRecordModal from './module/UpdateRecordModal'
import SubmitQuestionModal from './module/SubmitQuestionModal'
import EnterpriseStandardEvaluateModal from './module/EnterpriseStandardEvaluateModal'
import Vue from 'vue'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import { previewPdf } from '@/utils/previewPdf'
import { getFileInfo } from '../../../../api/api'
import UserSelectModal from '@comp/selection/UserSelectModal'
import StandardResolutionSheetModal from '@views/standardRegulationLibrary/commonPage/modules/StandardResolutionSheetModal'
import { kkFilePreview } from '@/utils/kkFilePreview'
import TextContentModal from './module/TextContentModal'
@@ -172,7 +146,7 @@ const FILE_TYPE_PDF = 'pdf'
export default {
name: 'EnterpriseStandardDetail',
components: { TextContentModal, StandardResolutionSheetModal, UserSelectModal, EnterpriseStandardEvaluateModal, SubmitQuestionModal, UpdateRecordModal },
components: { TextContentModal, StandardResolutionSheetModal },
data () {
return {
FieldType,
@@ -332,18 +306,6 @@ export default {
downloadDraftNoWater (file) {
downloadFile(`/sys/common/devEncryptDownloadWithoutWaterMark/${file.id}`, file.fileName)
},
// 企标评价
handleEvaluate () {
this.$refs.enterpriseStandardEvaluateModal.open(this.detailData.id)
},
// 更新记录
handleOpenUpdateRecord () {
this.$refs.updateRecordModal.open(this.detailData.standard_number)
},
// 提交问题
submitQuestion () {
this.$refs.submitQuestionModal.open(this.detailData.standard_number)
},
/**
* 查看标准分解单
*/
@@ -1,403 +0,0 @@
<template>
<j-modal
:title="title"
:maskClosable="true"
:width="1000"
:closable="true"
switchFullscreen
@cancel="handleCancel"
:footer="false"
:visible="visible">
<a-spin :spinning="confirmLoading">
<div class="content-wrapper">
<div class="left-wrapper">
<div v-for="(item, index) in nameArr" :key="item" class="name-div">
<a-button class="left-btn" :type="leftCurr === item ? 'primary' : ''" :disabled="index === 0" @click="leftChange(item)">{{ item }}</a-button>
</div>
</div>
<div class="right-wrapper">
<a-table
bordered
size="middle"
:scroll="{x: '100%'}"
:columns="columns"
:dataSource="dataSource"
rowKey="id"
:pagination="false"
>
<template slot="text" slot-scope="text">
<a-tooltip overlay-class-name="tooltip-style">
<template slot="title">{{ text || text === 0 ? text : global.emptyLine }}</template>
<div>{{ text || text === 0 ? text : global.emptyLine }}</div>
</a-tooltip>
</template>
</a-table>
</div>
</div>
</a-spin>
</j-modal>
</template>
<script>
import { detailEvaluate } from '@/api/enterpriseStandardLibraryApi'
const fixDataSourse = [
{
id: 1,
project: '文本格式(15)',
desc: '评估标准文件的格式是否符合GB/T 1.1的要求,包括文件名、编号、版本号、' +
'发布日期、生效日期、引用文件章节、图表等内容是否齐全、准确、清晰。',
score: '一般',
scoreRange: '0~5'
},
{
id: 2,
score: '优秀',
scoreRange: '6~10'
},
{
id: 3,
score: '优秀',
scoreRange: '11~15'
},
{
id: 4,
project: '标准内容(45)',
desc: '评估标准文件的内容是否详细准确、内容详实、逻辑清晰、科学合理。包括术语定义、' +
'引用标准、技术要求、试验检测方法等各个方面是否符合/严于法律法规、国家标准、行业标准等要求。',
score: '一般',
scoreRange: '0~20'
},
{
id: 5,
score: '优秀',
scoreRange: '21~35'
},
{
id: 6,
score: '优秀',
scoreRange: '36~45'
},
{
id: 7,
project: '适用性 (10)',
desc: '评估标准文件的应用范围是否明确、适用,是否与研发工艺、质量、生产、采购等环节相符合。',
score: '一般',
scoreRange: '0~3'
},
{
id: 8,
score: '优秀',
scoreRange: '4~6'
},
{
id: 9,
score: '优秀',
scoreRange: '7~10'
},
{
id: 10,
project: '完整性 (15)',
desc: '评估标准文件所涉及的专业领域是否全面、系统,是否涵盖了所有相关模版' +
'(比如设计规范模版、释放规范模版、产品技术条件模版)所规定的要素和环节。',
score: '一般',
scoreRange: '0~5'
},
{
id: 11,
score: '优秀',
scoreRange: '6~10'
},
{
id: 12,
score: '优秀',
scoreRange: '11~15'
},
{
id: 13,
project: '可读性 (5)',
desc: '评估标准文件的可读性是否良好,是否有错别字,是否易于阅读和理解。',
score: '一般',
scoreRange: '0~2'
},
{
id: 14,
score: '优秀',
scoreRange: '3~4'
},
{
id: 15,
score: '优秀',
scoreRange: '5'
},
{
id: 16,
project: '权威性及可执行性(10)',
desc: '评估标准文件的权威性是否足够,是否得到了相关方的认可和信任,是否得到了有效的贯彻和执行。',
score: '一般',
scoreRange: '0~3'
},
{
id: 17,
score: '优秀',
scoreRange: '4~6'
},
{
id: 18,
score: '优秀',
scoreRange: '7~10'
},
{
id: 19,
project: '总分:0'
}
]
export default {
name: 'EnterpriseStandardEvaluateModal',
data () {
return {
title: this.$t('enterpriseStandardLibrary.reviewMeeting.scoreDetailTitle'),
visible: false,
confirmLoading: false,
scoreData: {},
nameArr: [],
leftCurr: '',
columns: [
{
title: this.$t('enterpriseStandardLibrary.reviewMeeting.project'),
align: 'center',
width: 100,
dataIndex: 'project',
customRender: (text, row, index) => {
const obj = {
attrs: {}
}
if (index % 3 === 0) {
obj.children = text || this.global.emptyLine
obj.attrs.rowSpan = 3
} else if (index % 3 !== 0 && index !== 18) {
obj.children = text || this.global.emptyLine
obj.attrs.rowSpan = 0
}
if (index === 18) {
obj.children = <p class="all-score">总分: {this.allScore}</p>
obj.attrs.colSpan = 6
}
return obj
}
},
{
title: this.$t('enterpriseStandardLibrary.reviewMeeting.desc'),
align: 'center',
// width: 100,
dataIndex: 'desc',
customRender: (text, row, index) => {
const obj = {
children: text || this.global.emptyLine,
attrs: {}
}
if (index % 3 === 0) {
obj.attrs.rowSpan = 3
} else if (index % 3 !== 0 && index !== 18) {
obj.attrs.rowSpan = 0
}
if (index === 18) {
obj.attrs.colSpan = 0
}
return obj
}
},
{
title: this.$t('enterpriseStandardLibrary.reviewMeeting.score'),
align: 'center',
width: 100,
dataIndex: 'score',
colSpan: 2,
customRender: (text, row, index) => {
const obj = {
children: text || this.global.emptyLine,
attrs: {}
}
if (index === 18) {
obj.attrs.colSpan = 0
}
return obj
}
},
{
title: this.$t('enterpriseStandardLibrary.reviewMeeting.score'),
align: 'center',
width: 100,
dataIndex: 'scoreRange',
colSpan: 0,
customRender: (text, row, index) => {
const obj = {
children: text || this.global.emptyLine,
attrs: {}
}
if (index === 18) {
obj.attrs.colSpan = 0
}
return obj
}
},
{
title: this.$t('enterpriseStandardLibrary.reviewMeeting.grade'),
align: 'center',
width: 100,
dataIndex: 'evaluateScore',
customRender: (text, row, index) => {
const obj = {
children: text || this.global.emptyLine,
attrs: {}
}
if (index === 18) {
obj.attrs.colSpan = 0
}
if (index % 3 === 0) {
obj.attrs.rowSpan = 3
} else {
obj.attrs.rowSpan = 0
}
return obj
}
},
{
title: this.$t('enterpriseStandardLibrary.reviewMeeting.groundsForDemerit'),
align: 'center',
width: 100,
dataIndex: 'deductionScoreReason',
customRender: (text, row, index) => {
const obj = {
children: text || this.global.emptyLine,
attrs: {}
}
if (index === 18) {
obj.attrs.colSpan = 0
}
if (index % 3 === 0) {
obj.attrs.rowSpan = 3
} else {
obj.attrs.rowSpan = 0
}
return obj
}
}
],
dataSource: [],
allScore: 0
}
},
watch: {
leftCurr: {
immediate: true,
handler (val) {
console.log('leftCurr改变')
if (val) {
// 左侧选中改变,右侧表格数据也随之改变
const dataArr = this.scoreData[val]
if (dataArr) {
for (const i in fixDataSourse) {
this.dataSource[i] = { ...fixDataSourse[i] }
if (i % 3 === 0 && Number(i) !== 18) {
this.dataSource[i].evaluateScore = dataArr[Math.floor(i / 3)].evaluateScore || ''
this.dataSource[i].deductionScoreReason = dataArr[Math.floor(i / 3)].deductionScoreReason || ''
}
}
} else {
this.dataSource = [...fixDataSourse]
}
this.getAllScore()
}
}
}
},
methods: {
open (standardId) {
this.visible = true
this.initData(standardId)
},
// 获取总分
getAllScore () {
const arr = [0, 3, 6, 9, 12, 15]
let score = 0
for (const item of arr) {
score += Number(this.dataSource[item].evaluateScore) || 0
}
this.allScore = score
},
initData (standardId) {
this.confirmLoading = true
detailEvaluate(standardId).then(res => {
if (res.success) {
this.scoreData = res.result
this.nameArr = Object.keys(this.scoreData)
if (this.nameArr && this.nameArr.length > 0) {
// 第一条显示平均分:XX分
this.nameArr[0] = this.$t('enterpriseStandardLibrary.reviewMeeting.reviewMeeting') + this.nameArr[0] +
this.$t('enterpriseStandardLibrary.reviewMeeting.number')
}
this.leftCurr = this.nameArr[1]
} else {
this.$message.warning(res.message)
this.scoreData = []
this.nameArr = []
this.leftCurr = ''
}
}).finally(() => {
this.confirmLoading = false
})
},
// 左侧选中改变
leftChange (value) {
this.leftCurr = value
},
// 通过
handleCancel () {
this.visible = false
}
}
}
</script>
<style scoped lang="less">
.content-wrapper {
display: flex;
.left-wrapper {
width: 20%;
display: flex;
flex-direction: column;
align-items: center;
.name-div {
width: calc(100% - 20px);
margin-right: 20px;
text-align: center;
}
.left-btn {
margin-bottom: 10px;
max-width: 100%;
/deep/ span {
width: 100%;
vertical-align: middle;
//display: inline-block;
overflow-x: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
}
.right-wrapper {
width: 80%;
}
}
/deep/ .ant-table-body {
td {
padding: 8px !important;
}
}
</style>
@@ -1,189 +0,0 @@
<template>
<j-modal
:title="$t('standardRegulationLibrary.submitQuestion')"
:maskClosable="false"
:width="width"
:visible="visible"
switchFullscreen
:confirm-loading="confirmLoading"
@ok="handleOk"
@cancel="handleCancel">
<a-form :form="form">
<a-row :gutter="24">
<a-col :span="12">
<!-- 标题-->
<a-form-item :label="$t('title')" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input :placeholder="$t('pleaseEnter') + $t('title')"
:maxLength="50"
v-decorator="['title', validatorRules.title]" />
</a-form-item>
</a-col>
<a-col :span="12">
<!-- 项目-->
<a-form-item :label="$t('project')" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-select :placeholder="$t('pleaseSelect') + $t('project')"
v-decorator="['project', validatorRules.project]"
show-search
:filter-option="filterOption">
<a-select-option v-for="item in projectSelectOptions" :key="item.id" :title="item.projectName">{{ item.projectName }}</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :span="12">
<!-- 标准编号-->
<a-form-item :label="$t('standardRegulationLibrary.standardDetail.standardNumber')" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input :placeholder="$t('pleaseEnter') + $t('standardRegulationLibrary.standardDetail.standardNumber')"
:maxLength="50"
disabled
v-decorator="['standardNumber', validatorRules.standardNumber]" />
</a-form-item>
</a-col>
<a-col :span="12">
<!-- 提问时间-->
<a-form-item :label="$t('standardRegulationLibrary.standardDetail.problemOccurrenceTime')" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-date-picker :placeholder="$t('pleaseSelect') + $t('standardRegulationLibrary.standardDetail.problemOccurrenceTime')"
:getCalendarContainer="(trigger) => trigger.parentNode"
v-decorator="['quizTime', validatorRules.quizTime]"
showTime
style="width: 100%" />
</a-form-item>
</a-col>
<a-col :span="24">
<!-- 问题描述-->
<a-form-item :label="$t('standardRegulationLibrary.standardDetail.problemDescription')"
:labelCol="longLabelCol"
:wrapperCol="longWrapperCol">
<a-input :placeholder="$t('pleaseEnter') + $t('standardRegulationLibrary.standardDetail.problemDescription')"
type="textarea"
:maxLength="500"
v-decorator="['problemDescription', validatorRules.problemDescription]" />
<j-upload v-decorator="['file', validatorRules.file]" return-id multiple />
</a-form-item>
</a-col>
</a-row>
</a-form>
</j-modal>
</template>
<script>
import { detailSubmitQuestion } from '@/api/enterpriseStandardLibraryApi'
import { getCarTypeProjectList } from '@/api/projectLibraryApi.js'
import pick from 'lodash.pick'
import moment from 'moment'
export default {
name: 'SubmitQuestionModal',
data () {
return {
width: 800,
visible: false,
confirmLoading: false,
form: this.$form.createForm(this),
modal: {},
labelCol: {
xs: { span: 24 },
sm: { span: 8 }
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 16 }
},
longLabelCol: {
xs: { span: 24 },
sm: { span: 4 }
},
longWrapperCol: {
xs: { span: 24 },
sm: { span: 20 }
},
validatorRules: {
// 标题
title: {
rules: [{ required: true, message: this.$t('pleaseEnter') + this.$t('title') }],
validateTrigger: 'blur'
},
// 项目
project: {
rules: [{ required: false, message: this.$t('pleaseSelect') + this.$t('project') }],
validateTrigger: 'change'
},
// 标准编号
standardNumber: {
rules: [{ required: true, message: this.$t('pleaseEnter') + this.$t('standardRegulationLibrary.standardDetail.standardNumber') }],
validateTrigger: 'blur'
},
// 问题发生时间
quizTime: {
rules: [{ required: false, message: this.$t('pleaseSelect') + this.$t('standardRegulationLibrary.standardDetail.problemOccurrenceTime') }],
validateTrigger: 'change'
},
// 问题描述
problemDescription: {
rules: [{ required: true, message: this.$t('pleaseEnter') + this.$t('standardRegulationLibrary.standardDetail.problemDescription') }],
validateTrigger: 'blur'
},
// 附件
file: {}
},
projectSelectOptions: [] // 项目下拉数据
}
},
mounted () {
this.initProjectOptions()
},
methods: {
open (standardNumber) {
this.visible = true
const param = {}
param.standardNumber = standardNumber
param.quizTime = moment().format('YYYY-MM-DD HH:mm:ss')
this.$nextTick(() => {
this.form.setFieldsValue(pick(param, 'standardNumber', 'quizTime'))
})
},
// 获取项目下拉框数据
initProjectOptions () {
getCarTypeProjectList({ column: 'createTime', order: 'desc' }).then(res => {
if (res.success) {
this.projectSelectOptions = res.result
} else {
this.$message.warning(res.message)
}
})
},
handleOk () {
if (this.confirmLoading) return
this.form.validateFields((err, values) => {
if (!err) {
this.confirmLoading = true
const param = Object.assign({}, values)
detailSubmitQuestion(param).then(res => {
if (res.success) {
this.$message.success(res.message)
this.close()
} else {
this.$message.warning(res.message)
}
}).finally(() => {
this.confirmLoading = false
})
}
})
},
handleCancel () {
this.close()
},
close () {
this.visible = false
},
filterOption (input, option) {
return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
}
}
}
</script>
<style scoped>
</style>
@@ -1,76 +0,0 @@
<template>
<j-modal
:title="$t('enterpriseStandardLibrary.standard.updateRecord')"
:maskClosable="false"
:width="width"
:visible="visible"
:confirm-loading="confirmLoading"
switchFullscreen
@cancel="handleCancel">
<a-spin :spinning="confirmLoading">
<template v-if="recordList && recordList.length > 0">
<div class="record-item" v-for="record in recordList" :key="record.id">
{{ record.content }}
</div>
</template>
<a-empty v-else />
</a-spin>
<template v-slot:footer>
<a-button @click="handleCancel">{{ $t('close') }}</a-button>
</template>
</j-modal>
</template>
<script>
import { detailGetUpdateRecord } from '@/api/enterpriseStandardLibraryApi'
export default {
name: 'UpdateRecordModal',
data () {
return {
width: 800,
visible: false,
confirmLoading: false,
recordList: []
}
},
methods: {
open (standardNumber) {
this.visible = true
this.initRecord(standardNumber)
},
initRecord (standardNumber) {
this.confirmLoading = true
detailGetUpdateRecord({ standardNumber }).then(res => {
if (res.success) {
this.recordList = res.result || []
} else {
this.$message.warn(res.message)
}
}).finally(() => {
this.confirmLoading = false
})
},
handleCancel () {
this.visible = false
}
}
}
</script>
<style scoped lang="less">
.record-item {
padding: 20px 0;
border-bottom: 1px solid #E5E6EB;
}
.record-item:first-child {
padding-top: 0;
}
.record-item:last-child {
border-bottom: none;
}
</style>
@@ -6,22 +6,6 @@
<div class="detail-page-part" v-for="(part, index) in partList" :key="part + index">
<div class="detail-page-part-title">
<span>{{ part }}</span>
<div class="detail-page-part-title-operate-box" v-if="index === 0">
<!-- 更新记录-->
<a-button type="link" @click="handleOpenUpdateRecord" v-has="btnPermission.updateRecord">
<i class="iconfont icon-root-list" />
{{ $t('standardRegulationLibrary.updateRecord') }}
</a-button>
<!-- 提交问题-->
<a-button type="link" @click="submitQuestion" v-has="btnPermission.submitQuestion">
<a-icon type="database" />
{{ $t('standardRegulationLibrary.submitQuestion') }}
</a-button>
<!-- 分享-->
<a-button type="link" @click="handleShare" v-has="btnPermission.share">
<i class="iconfont icon-share-internal" />{{ $t('share') }}
</a-button>
</div>
</div>
<div class="detail-page-part-form" v-if="part !== '过程稿件' && part !== 'Process Manuscript'">
<div class="detail-page-part-form-item" v-for="formItem in form[part]" :key="formItem.id">
@@ -122,12 +106,6 @@
</div>
</div>
<!-- 更新记录-->
<update-record-modal ref="uploadRecordModal" />
<!-- 提交问题-->
<submit-question-modal ref="submitQuestionModal" />
<!-- 分享选人-->
<user-select-modal ref="userSelectModal" type="checkbox" @change="continueShare" />
<!-- 标准分解单-->
<standard-resolution-sheet-modal ref="standardResolutionSheetModal" />
<!-- 查看全部弹框 -->
@@ -140,31 +118,22 @@ import '@assets/less/common.less'
import { FieldType, StandardSource } from '../../../enums/commonEnums'
import {
getDomesticStandardFormModal,
shareDomesticStandard,
getDomesticStandardDetail,
getOverseasStandardForm,
getOverseasStandardDocumentInfo,
shareOverseasStandard
getOverseasStandardDocumentInfo
} from '../../../api/standardRegulationLibraryApi'
import UpdateRecordModal from './modules/UpdateRecordModal.vue'
import SubmitQuestionModal from './modules/SubmitQuestionModal.vue'
import UserSelectModal from '../../../components/selection/UserSelectModal.vue'
import StandardResolutionSheetModal from './modules/StandardResolutionSheetModal.vue'
import { getFileInfo } from '../../../api/api.js'
import Vue from 'vue'
import { ACCESS_TOKEN } from '../../../store/mutation-types.js'
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, queryStandardInfoByStandardNumber } from '../../../utils/util'
import { queryStandardInfoByStandardNumber } from '../../../utils/util'
import TextContentModal from '../../enterpriseStandardLibrary/standard/detail/module/TextContentModal'
// 国内标准权限
const DomesticStandardPermission = {
updateRecord: 'domesticStandard:updateRecord', // 更新记录
submitQuestion: 'domesticStandard:submitQuestion', // 提交问题
share: 'domesticStandard:share', // 分享
standardResolutionSheet: 'domesticStandard:standardResolutionSheet', // 标准分解单
download: 'domesticStandard:download', // 下载
unwatermarkedDownload: 'domesticStandard:unwatermarkedDownload' // 无水印下载
@@ -172,9 +141,6 @@ const DomesticStandardPermission = {
// 海外标准权限
const OverseasStandardPermission = {
updateRecord: 'overseasStandard:updateRecord', // 更新记录
submitQuestion: 'overseasStandard:submitQuestion', // 提交问题
share: 'overseasStandard:share', // 分享
standardResolutionSheet: 'overseasStandard:standardResolutionSheet', // 标准分解单
download: 'overseasStandard:download', // 下载
unwatermarkedDownload: 'overseasStandard:unwatermarkedDownload' // 无水印下载
@@ -183,15 +149,13 @@ const OverseasStandardPermission = {
// 国内标准接口
const DomesticApi = {
getFormFunc: getDomesticStandardFormModal, // 获取字段
getDetailData: getDomesticStandardDetail, // 获取详情数据
share: shareDomesticStandard // 分享
getDetailData: getDomesticStandardDetail // 获取详情数据
}
// 海外标准接口
const OverseasApi = {
getFormFunc: getOverseasStandardForm, // 获取字段
getDetailData: getOverseasStandardDocumentInfo, // 获取详情数据
share: shareOverseasStandard // 分享
getDetailData: getOverseasStandardDocumentInfo // 获取详情数据
}
// 支持预览的文件后缀
@@ -201,7 +165,7 @@ const FILE_TYPE_IMGS = ['jpg', 'jpeg', 'png', 'raw']
export default {
name: 'StandardDetailPage',
components: { UpdateRecordModal, SubmitQuestionModal, UserSelectModal, StandardResolutionSheetModal, TextContentModal },
components: { StandardResolutionSheetModal, TextContentModal },
data () {
return {
loading: false,
@@ -273,16 +237,6 @@ 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()
},
@@ -351,45 +305,6 @@ export default {
})
})
},
/**
* 更新记录
*/
handleOpenUpdateRecord () {
this.$refs.uploadRecordModal.open(this.detailData.standard_number)
},
/**
* 提交问题
*/
submitQuestion () {
this.$refs.submitQuestionModal.open(this.detailData.standard_number, this.type)
},
/**
* 分享
*/
handleShare () {
this.$refs.userSelectModal.open()
},
/**
* 选择分享的人之后继续分享
* @param ids
*/
continueShare (ids) {
const params = {
standardId: this.$route.query.id, // 要分享的标准的id
standardNumber: this.detailData.standard_number, // 分享的标准编号
recipientId: ids // 分享给的用户的id
}
this.loading = true
this.operateApiFunc.share(params).then(res => {
if (res.success) {
this.$message.success(res.message)
} else {
this.$message.warn(res.message)
}
}).finally(() => {
this.loading = false
})
},
/**
* 查看标准分解单
*/
@@ -1,202 +0,0 @@
<template>
<j-modal
:title="$t('standardRegulationLibrary.submitQuestion')"
:maskClosable="false"
:width="width"
:visible="visible"
:confirm-loading="confirmLoading"
switchFullscreen
@ok="handleOk"
@cancel="handleCancel">
<a-form :form="form">
<a-row :gutter="24">
<a-col :span="12">
<!-- 标题-->
<a-form-item :label="$t('title')" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input :placeholder="$t('pleaseEnter') + $t('title')"
:maxLength="50"
v-decorator="['title', validatorRules.title]" />
</a-form-item>
</a-col>
<a-col :span="12">
<!-- 项目-->
<a-form-item :label="$t('project')" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-select :placeholder="$t('pleaseSelect') + $t('project')"
v-decorator="['project', validatorRules.project]"
show-search
:filter-option="filterOption">
<a-select-option v-for="item in projectSelectOptions" :key="item.id" :title="item.projectName">{{ item.projectName }}</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :span="12">
<!-- 标准编号-->
<a-form-item :label="$t('standardRegulationLibrary.standardDetail.standardNumber')" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input :placeholder="$t('pleaseEnter') + $t('standardRegulationLibrary.standardDetail.standardNumber')"
:maxLength="50"
disabled
v-decorator="['standardNumber', validatorRules.standardNumber]" />
</a-form-item>
</a-col>
<a-col :span="12">
<!-- 提问时间-->
<a-form-item :label="$t('standardRegulationLibrary.standardDetail.problemOccurrenceTime')" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-date-picker :placeholder="$t('pleaseSelect') + $t('standardRegulationLibrary.standardDetail.problemOccurrenceTime')"
:getCalendarContainer="(trigger) => trigger.parentNode"
v-decorator="['quizTime', validatorRules.quizTime]"
format="YYYY-MM-DD HH:mm:ss"
value-format="YYYY-MM-DD HH:mm:ss"
showTime
style="width: 100%" />
</a-form-item>
</a-col>
<a-col :span="24">
<!-- 问题描述-->
<a-form-item :label="$t('standardRegulationLibrary.standardDetail.problemDescription')"
:labelCol="longLabelCol"
:wrapperCol="longWrapperCol">
<a-input :placeholder="$t('pleaseEnter') + $t('standardRegulationLibrary.standardDetail.problemDescription')"
type="textarea"
:maxLength="500"
v-decorator="['problemDescription', validatorRules.problemDescription]" />
<j-upload v-decorator="['file', validatorRules.file]" return-id multiple />
</a-form-item>
</a-col>
</a-row>
</a-form>
</j-modal>
</template>
<script>
import { submitDomesticQuestion, submitOverseasQuestion } from '../../../../api/standardRegulationLibraryApi.js'
import { getCarTypeProjectList } from '../../../../api/projectLibraryApi.js'
import { StandardSource } from '../../../../enums/commonEnums.js'
import moment from 'moment'
export default {
name: 'SubmitQuestionModal',
data () {
return {
width: 800,
visible: false,
confirmLoading: false,
form: this.$form.createForm(this),
modal: {},
labelCol: {
xs: { span: 24 },
sm: { span: 8 }
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 16 }
},
longLabelCol: {
xs: { span: 24 },
sm: { span: 4 }
},
longWrapperCol: {
xs: { span: 24 },
sm: { span: 20 }
},
validatorRules: {
// 标题
title: {
rules: [{ required: true, message: this.$t('pleaseEnter') + this.$t('title') }],
validateTrigger: 'blur'
},
// 项目
project: {
rules: [{ required: false, message: this.$t('pleaseSelect') + this.$t('project') }],
validateTrigger: 'change'
},
// 标准编号
standardNumber: {
rules: [{ required: true, message: this.$t('pleaseEnter') + this.$t('standardRegulationLibrary.standardDetail.standardNumber') }],
validateTrigger: 'blur'
},
// 问题发生时间
quizTime: {
rules: [{ required: false, message: this.$t('pleaseSelect') + this.$t('standardRegulationLibrary.standardDetail.problemOccurrenceTime') }],
validateTrigger: 'change'
},
// 问题描述
problemDescription: {
rules: [{ required: true, message: this.$t('pleaseEnter') + this.$t('standardRegulationLibrary.standardDetail.problemDescription') }],
validateTrigger: 'blur'
},
// 附件
file: {},
type: null
},
projectSelectOptions: [] // 项目下拉数据
}
},
methods: {
open (standardNumber, type) {
this.visible = true
this.initProjectOptions()
this.type = type
const param = {}
param.standardNumber = standardNumber
param.quizTime = moment().format('YYYY-MM-DD HH:mm:ss')
this.$nextTick(() => {
this.form.setFieldsValue(param)
})
},
// 获取项目下拉框数据
initProjectOptions () {
getCarTypeProjectList({ column: 'createTime', order: 'desc' }).then(res => {
if (res.success) {
this.projectSelectOptions = res.result
} else {
this.$message.warning(res.message)
}
})
},
handleOk () {
if (this.confirmLoading) return
this.form.validateFields((err, values) => {
if (!err) {
let submitFunc
switch (this.type) {
case StandardSource.DOMESTIC.value:
submitFunc = submitDomesticQuestion
break
case StandardSource.OVERSEAS.value:
submitFunc = submitOverseasQuestion
break
default:
break
}
this.confirmLoading = true
const param = Object.assign({}, values)
submitFunc(param).then(res => {
if (res.success) {
this.$message.success(res.message)
this.close()
} else {
this.$message.warning(res.message)
}
}).finally(() => {
this.confirmLoading = false
})
}
})
},
handleCancel () {
this.close()
},
close () {
this.visible = false
},
filterOption (input, option) {
return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
}
}
}
</script>
<style scoped lang="less">
</style>
@@ -1,76 +0,0 @@
<template>
<j-modal
:title="$t('standardRegulationLibrary.updateRecord')"
:maskClosable="false"
:width="width"
:visible="visible"
:confirm-loading="confirmLoading"
switchFullscreen
@cancel="handleCancel">
<a-spin :spinning="confirmLoading">
<template v-if="recordList && recordList.length > 0">
<div class="record-item" v-for="record in recordList" :key="record.id">
{{ record.content }}
</div>
</template>
<a-empty v-else/>
</a-spin>
<template v-slot:footer>
<a-button @click="handleCancel">{{ $t('close') }}</a-button>
</template>
</j-modal>
</template>
<script>
import { getDomesticStandardUpdateRecord } from '../../../../api/standardRegulationLibraryApi.js'
export default {
name: 'UpdateRecordModal',
data () {
return {
width: 800,
visible: false,
confirmLoading: false,
recordList: []
}
},
methods: {
open (standardNumber) {
this.visible = true
this.initRecord(standardNumber)
},
initRecord (standardNumber) {
this.confirmLoading = true
getDomesticStandardUpdateRecord({ standardNumber }).then(res => {
if (res.success) {
this.recordList = res.result || []
} else {
this.$message.warn(res.message)
}
}).finally(() => {
this.confirmLoading = false
})
},
handleCancel () {
this.visible = false
}
}
}
</script>
<style scoped lang="less">
.record-item {
padding: 20px 0;
border-bottom: 1px solid #E5E6EB;
}
.record-item:first-child {
padding-top: 0;
}
.record-item:last-child {
border-bottom: none;
}
</style>
@@ -139,7 +139,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="filePreview(record)">{{
<div class="table-text can-click-table-text" v-if="text || text === 0" @click="toDetailPage(record)">{{
text
}}
</div>
@@ -151,7 +151,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="filePreview(record)">{{
<div class="table-text can-click-table-text" v-if="text || text === 0" @click="toDetailPage(record)">{{
text
}}
</div>
@@ -235,7 +235,6 @@
</template>
<script>
import Vue from 'vue'
import '@assets/less/common.less'
import { ConfigurableTableMixin } from '@/mixins/ConfigurableTableMixin'
import Search from '../../../components/customField/Search.vue'
@@ -244,8 +243,6 @@ import DomesticStandardModal from './modules/DomesticStandardModal.vue'
import {
configDomesticStandard,
deleteDomesticSystemTree,
getDomesticStandardDetail,
getDomesticStandardFormModal,
getDomesticStandardSearchForm,
getDomesticStandardTableHeader,
getDomesticStandardTree,
@@ -263,10 +260,6 @@ import {
import DomesticSystemTreeModal from './modules/DomesticSystemTreeModal.vue'
import SelectionDomesticStandardDrawer from './modules/SelectionDomesticStandardDrawer.vue'
import { postDownFile } from '@api/manage'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import { previewPdf } from '@/utils/previewPdf'
import { kkFilePreview } from '@/utils/kkFilePreview'
import { getFileInfo } from '@api/api'
import { mapGetters } from 'vuex'
export default {
@@ -293,12 +286,6 @@ export default {
clickEvent: 'handleCollection',
has: 'domesticStandard:collection'
},
// 查看
{
text: this.$t('viewDetail'),
clickEvent: 'toDetailPage',
has: 'domesticStandard:view'
},
// 编辑
{
text: this.$t('edit'),
@@ -571,109 +558,6 @@ export default {
}
})
},
/**
* 按顺序打开最新的pdf或word
*/
async filePreview (record) {
console.log('filePreview', record)
// 获取并处理过程稿件数据
let res = await getDomesticStandardFormModal({ 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 getDomesticStandardDetail({ 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).toLowerCase()
if (suffix === 'pdf') {
pdfFileList.push({ id, name, suffix })
}
if (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]
},
/**
* 重置查询
*/
@@ -140,7 +140,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="filePreview(record)">{{
<div class="table-text can-click-table-text" v-if="text || text === 0" @click="toDetailPage(record)">{{
text
}}
</div>
@@ -152,7 +152,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="filePreview(record)">{{
<div class="table-text can-click-table-text" v-if="text || text === 0" @click="toDetailPage(record)">{{
text
}}
</div>
@@ -248,9 +248,7 @@ import {
cancelCollectionOverseasStandard,
deleteOverseasStandardSystem,
configOverseasStandard,
removeOverseasStandard,
getOverseasStandardForm,
getOverseasStandardDocumentInfo
removeOverseasStandard
} from '../../../api/standardRegulationLibraryApi'
import {
OperationType,
@@ -264,11 +262,6 @@ import OverseasSystemTreeModal from './modules/OverseasSystemTreeModal.vue'
import SelectionOverseasStandardDrawer from './modules/SelectionOverseasStandardDrawer.vue'
import { postDownFile } from '../../../api/manage.js'
import { mapGetters } from 'vuex'
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',
@@ -294,12 +287,6 @@ export default {
clickEvent: 'handleCollection',
has: 'overseasStandard:collection'
},
// 查看
{
text: this.$t('viewDetail'),
clickEvent: 'toDetailPage',
has: 'overseasStandard:view'
},
// 编辑
{
text: this.$t('edit'),
@@ -572,109 +559,6 @@ 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).toLowerCase()
if (suffix === 'pdf') {
pdfFileList.push({ id, name, suffix })
}
if (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]
},
/**
* 重置查询
*/