文件预览参数token改为at
This commit is contained in:
@@ -53,6 +53,8 @@ import { kkFilePreview } from '@/utils/kkFilePreview'
|
||||
|
||||
const FILE_TYPE_IMGS = ['jpg', 'jpeg', 'png', 'raw']
|
||||
const FILE_TYPE_PDF = 'pdf'
|
||||
// 支持预览的文件后缀
|
||||
const CAN_PREVIEW_FILE_SUFFIX = ['jpg', 'jpeg', 'png', 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx']
|
||||
|
||||
export default {
|
||||
name: 'CheckReportModal',
|
||||
@@ -149,7 +151,15 @@ export default {
|
||||
handleRelatedMaterialClick (record) {
|
||||
// 截取文件后缀名
|
||||
const fileSuffix = record.declareFileName ? record.declareFileName.split('.')[record.declareFileName.split('.').length - 1] : ''
|
||||
const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${record.declareFile}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${record.declareFileName}`
|
||||
const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${record.declareFile}?at=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${record.declareFileName}`
|
||||
const canPreview = CAN_PREVIEW_FILE_SUFFIX.some(tt => fileSuffix === tt)
|
||||
// 判断是否为可预览格式的文件
|
||||
if (!canPreview) {
|
||||
this.$message.loading(this.$t('uploadFile.cannotPreview')).then(() => {
|
||||
this.handleDownload(record.declareFile, record.declareFileName)
|
||||
})
|
||||
return
|
||||
}
|
||||
// 图片预览,使用自己添加的组件
|
||||
if (FILE_TYPE_IMGS.includes(fileSuffix)) {
|
||||
this.imageUrl = getFileAccessHttpUrl(record.declareFile)
|
||||
@@ -166,13 +176,12 @@ export default {
|
||||
window.open(url)
|
||||
return
|
||||
}
|
||||
// word用KKfile预览
|
||||
if (fileSuffix === 'doc' || fileSuffix === 'docx') {
|
||||
kkFilePreview(fileFullUrl)
|
||||
return
|
||||
}
|
||||
// 如果都不能预览就下载
|
||||
downloadFile(`/sys/common/download/${record.declareFile}`, record.declareFileName)
|
||||
// 其余可预览文件仍使用KKFile进行预览
|
||||
kkFilePreview(fileFullUrl)
|
||||
},
|
||||
handleDownload (id, name) {
|
||||
// 下载文件
|
||||
downloadFile(`/sys/common/download/${id}`, name)
|
||||
},
|
||||
handleCancel () {
|
||||
this.close()
|
||||
|
||||
+16
-42
@@ -22,13 +22,14 @@
|
||||
<a-input :placeholder="$t('pleaseEnter') + $t('workCenter.esInspectionProcess.sectionNumber')"
|
||||
:maxLength="50"
|
||||
@change="event => event.target.value = event.target.value.trim()"
|
||||
v-decorator.trim="[ 'standardNo', validatorRules.sectionNumber ]" />
|
||||
v-decorator.trim="[ 'clause', validatorRules.sectionNumber ]" />
|
||||
</a-form-item>
|
||||
<!-- 标准内容或要求 -->
|
||||
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('workCenter.esInspectionProcess.standardContentOrDemand')">
|
||||
<a-input :placeholder="$t('pleaseEnter') + $t('workCenter.esInspectionProcess.standardContentOrDemand')"
|
||||
:maxLength="500"
|
||||
type="textarea"
|
||||
:rows="4"
|
||||
@change="event => event.target.value = event.target.value.trim()"
|
||||
v-decorator.trim="[ 'requirement', validatorRules.standardContentOrDemand ]" />
|
||||
</a-form-item>
|
||||
@@ -58,7 +59,8 @@ import { getFileInfo } from '@/api/api'
|
||||
import { previewPdf } from '@/utils/previewPdf'
|
||||
import Vue from 'vue'
|
||||
import { ACCESS_TOKEN } from '@/store/mutation-types'
|
||||
import { addInspectionContentTable, editInspectionContentTable, getFileByInspectId } from '@api/workCenter'
|
||||
import { getFileByInspectId } from '@api/workCenter'
|
||||
import moment from 'moment/moment'
|
||||
|
||||
const Base64 = require('js-base64').Base64
|
||||
|
||||
@@ -98,7 +100,7 @@ export default {
|
||||
validateTrigger: 'blur'
|
||||
}
|
||||
},
|
||||
index: undefined, // 编辑的表格的下标
|
||||
index: -1, // 编辑的表格的下标
|
||||
iframeSrc: '' // 左侧预览的路径
|
||||
}
|
||||
},
|
||||
@@ -152,8 +154,8 @@ export default {
|
||||
// pdf预览
|
||||
const url = previewPdf(file.id)
|
||||
this.iframeSrc = url
|
||||
} else if (fileSuffix === 'docx') {
|
||||
const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${file.id}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.fileName}`
|
||||
} else if (['doc', 'docx'].includes(fileSuffix)) {
|
||||
const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${file.id}?at=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.fileName}`
|
||||
// word文件仍使用KKFile进行预览
|
||||
const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(fileFullUrl))}`
|
||||
this.iframeSrc = url
|
||||
@@ -162,7 +164,7 @@ export default {
|
||||
close () {
|
||||
this.visible = false
|
||||
this.model = {}
|
||||
this.index = undefined
|
||||
this.index = -1
|
||||
this.iframeSrc = ''
|
||||
},
|
||||
handleCancel () {
|
||||
@@ -170,53 +172,26 @@ export default {
|
||||
},
|
||||
// 提交并新增
|
||||
handleSubmitAddAdd () {
|
||||
if (this.confirmLoading) return
|
||||
this.form.validateFields((err, values) => {
|
||||
if (!err) {
|
||||
this.confirmLoading = true
|
||||
const param = Object.assign({}, this.model, values)
|
||||
if (!param.processEsInspectId) {
|
||||
param.processEsInspectId = this.data.id
|
||||
if (!param.createTime) {
|
||||
param.createTime = moment().format('YYYY-MM-DD HH:mm:ss')
|
||||
}
|
||||
console.log(param)
|
||||
const fn = param.id ? editInspectionContentTable : addInspectionContentTable
|
||||
fn(param).then(res => {
|
||||
if (res.success) {
|
||||
this.$message.success(res.message)
|
||||
this.$emit('ok', param, this.index)
|
||||
this.form.resetFields()
|
||||
this.model = {}
|
||||
} else {
|
||||
this.$message.warn(res.message)
|
||||
}
|
||||
}).finally(() => {
|
||||
this.confirmLoading = false
|
||||
})
|
||||
this.$emit('ok', param, this.index)
|
||||
this.form.resetFields()
|
||||
}
|
||||
})
|
||||
},
|
||||
handleOk () {
|
||||
if (this.confirmLoading) return
|
||||
this.form.validateFields((err, values) => {
|
||||
if (!err) {
|
||||
this.confirmLoading = true
|
||||
const param = Object.assign({}, this.model, values)
|
||||
if (!this.model.processEsInspectId) {
|
||||
param.processEsInspectId = this.data.id
|
||||
if (!param.createTime) {
|
||||
param.createTime = moment().format('YYYY-MM-DD HH:mm:ss')
|
||||
}
|
||||
console.log(param)
|
||||
const fn = param.id ? editInspectionContentTable : addInspectionContentTable
|
||||
fn(param).then(res => {
|
||||
if (res.success) {
|
||||
this.$message.success(res.message)
|
||||
this.$emit('ok', param, this.index)
|
||||
this.close()
|
||||
} else {
|
||||
this.$message.warn(res.message)
|
||||
}
|
||||
}).finally(() => {
|
||||
this.confirmLoading = false
|
||||
})
|
||||
this.$emit('ok', param, this.index)
|
||||
this.close()
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -232,7 +207,6 @@ export default {
|
||||
.content-left {
|
||||
width: 60%;
|
||||
height: 100%;
|
||||
overflow-y: scroll;
|
||||
iframe {
|
||||
height: calc(100% - 20px) !important;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user