[update] 修改bug87715

This commit is contained in:
lideqin
2024-07-30 15:12:20 +08:00
parent c78811fb55
commit ea90f75b3b
2 changed files with 11 additions and 63 deletions
@@ -119,11 +119,8 @@
<!-- 附件 -->
<template v-slot:file="{text, record}">
<a-tooltip overlay-class-name="tooltip-style">
<template slot="title">{{ record.file_dictText || record.file_dictText === 0 ? record.file_dictText : global.emptyLine }}</template>
<a v-if="text" class="link-a" @click="previewFile(record)">{{ record.file_dictText }}</a>
<div v-else class="table-text">{{ global.emptyLine }}</div>
</a-tooltip>
<a v-if="text" class="link-a" @click="handleLookFile(record)">{{ $t('view') }}</a>
<div v-else class="table-text">{{ global.emptyLine }}</div>
</template>
</j-table>
@@ -134,37 +131,23 @@
<nonmatch-item-close-modal ref="nonmatchItemCloseModal" @ok="modalFormOk"/>
<!-- 查看弹框 -->
<nonmatch-item-look-modal ref="nonmatchItemLookModal"/>
<!-- 预览图片 -->
<div id="images">
<div class="image" v-viewer="{movable: false}">
<img v-show="image" :src="imageUrl">
</div>
</div>
<!-- 文件查看弹框 -->
<upload-file ref="uploadFile" disabled></upload-file>
</a-card>
</template>
<script>
import { JeroListMixin } from '@/mixins/JeroListMixin'
import Vue from 'vue'
import { previewPdf } from '@/utils/previewPdf'
import { kkFilePreview } from '@/utils/kkFilePreview'
import { downloadFile, getFileAccessHttpUrl } from '@/api/manage'
import JTable from '@/components/jero/JTable'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import { RectificationState } from '../../../enums/commonEnums'
import NonmatchItemCloseModal from './modules/NonmatchItemCloseModal'
import NonmatchItemLookModal from './modules/NonmatchItemLookModal'
import { queryDepartTreeList } from '../../../api/api'
// 支持预览的文件后缀
const CAN_PREVIEW_FILE_SUFFIX = ['jpg', 'jpeg', 'png', 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx']
const FILE_TYPE_IMGS = ['jpg', 'jpeg', 'png', 'raw']
const FILE_TYPE_PDF = 'pdf'
import UploadFile from '@/components/UploadFile'
export default {
name: 'NonmatchItemList',
components: { JTable, NonmatchItemCloseModal, NonmatchItemLookModal },
components: { JTable, NonmatchItemCloseModal, NonmatchItemLookModal, UploadFile },
mixins: [JeroListMixin],
data () {
return {
@@ -290,9 +273,7 @@ export default {
url: {
list: '/assessment/lawsEvaluationNotMet/page',
exportXlsUrl: '/assessment/lawsEvaluationNotMet/exportXls'
},
image: false,
imageUrl: ''
}
}
},
mounted () {
@@ -354,41 +335,9 @@ export default {
}
this.$refs.nonmatchItemCloseModal.open(this.selectedRowKeys.join(','))
},
previewFile (record) {
// 截取文件后缀名
const fileSuffix = record.file_dictText ? record.file_dictText.split('.')[record.file_dictText.split('.').length - 1].toLowerCase() : ''
const canPreview = CAN_PREVIEW_FILE_SUFFIX.some(tt => fileSuffix.toLowerCase() === tt)
// 判断是否为可预览格式的文件
if (!canPreview) {
this.$message.loading('该文件类型不支持预览,正在为您准备下载...').then(() => {
this.handleDownload(record)
})
return
}
const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${record.file}?at=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${record.file_dictText}`
// 图片预览,使用自己添加的组件
if (canPreview && FILE_TYPE_IMGS.includes(fileSuffix)) {
this.imageUrl = getFileAccessHttpUrl(record.file)
// 获取viewer实例
const viewer = this.$el.querySelector('.image').$viewer
// 调用show方法进行显示预览图
viewer.show()
// this.$refs.imagePreviewModal.open(file)
return
}
// pdf预览
if (canPreview && FILE_TYPE_PDF.includes(fileSuffix)) {
const url = previewPdf(record.file)
window.open(url)
return
}
// 其余可预览文件仍使用KKFile进行预览
kkFilePreview(fileFullUrl)
},
// 下载
handleDownload (record) {
// 下载文件
downloadFile(`/sys/common/download/${record.file}`, record.file_dictText)
// 文件查看点击
handleLookFile (record) {
this.$refs.uploadFile.open(record.file)
},
// 查看
handleLook (record) {
@@ -30,8 +30,7 @@
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('attach')">
<j-upload
return-id
:multiple="false"
:number="1"
:multiple="true"
v-decorator.trim="[ 'file', validatorRules.file]"/>
</a-form-item>
</a-form>