[update] 修改在线编辑的查看

This commit is contained in:
lideqin
2024-01-24 16:51:14 +08:00
parent 2825abd049
commit 0031aeb637
13 changed files with 305 additions and 34 deletions
@@ -47,6 +47,8 @@ import TextContentModal from '../../../businessSupport/askForAdvice/modules/Text
import Vue from 'vue'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import { kkFilePreview } from '@/utils/kkFilePreview'
import { queryFileInfoByEditId } from '../../../../api/workCenter'
import { Base64 } from 'js-base64'
export default {
name: 'ApproveBaseInfo',
@@ -179,8 +181,15 @@ export default {
},
// 在线编辑的查看
onlineEditView () {
const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${this.onEditFile}?at=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${this.onEditFile_dictText}`
kkFilePreview(fileFullUrl)
queryFileInfoByEditId({ id: this.onEditFile }).then(res => {
if (res.success) {
const file = res.result
const filePaths = file.filePath.split('/')
const fileName = filePaths[filePaths.length - 1]
const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(this.documentUrl + file.filePath + '&fullfilename=' + fileName))}`
window.open(url, '_blank')
}
})
}
}
}
@@ -692,7 +692,17 @@ export default {
resultList.push(error)
})
if (resultList.every(tt => !tt)) {
return true
// 实施日期需要比发布日期至少大15天
// 发布日期15天后的日期
const releaseDate = new Date(Date.parse(this.formInline.release_date))
const releaseDateAfter = releaseDate.setDate(releaseDate.getDate() + 15)
if (new Date(Date.parse(this.formInline.implementation_date)) <= releaseDateAfter) {
// 实施日期小于等于发布日期的15天后
this.$message.warning(this.$t('implementationNeedGreaterThan'))
return false
} else {
return true
}
}
return false
}
@@ -0,0 +1,185 @@
<template>
<j-modal
:title="title"
:maskClosable="true"
:width="500"
:closable="true"
@cancel="handleCancel"
fullscreen
@ok="handleOk"
:visible="visible">
<div class="content">
<!-- 左侧文件预览 -->
<div class="content-left">
<iframe v-if="iframeSrc" :src="iframeSrc" width="100%" frameborder="0"></iframe>
<a-empty class="empty-file" v-else :description="$t('noFileAvailableForPreview')"></a-empty>
</div>
<!-- 右侧表单区域 -->
<div class="content-right">
<a-spin :spinning="confirmLoading">
<a-form :form="form">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('enterpriseStandardLibrary.standard.subjectToClause')">
<a-input :placeholder="$t('pleaseEnter') + $t('enterpriseStandardLibrary.standard.subjectToClause')"
:maxLength="50"
@change="event => event.target.value = event.target.value.trim()"
v-decorator.trim="[ 'clause', validatorRules.clause ]" />
</a-form-item>
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('enterpriseStandardLibrary.standard.standardContentOrRequirements')">
<a-input :placeholder="$t('pleaseEnter') + $t('enterpriseStandardLibrary.standard.standardContentOrRequirements')"
:maxLength="500"
:rows="4"
type="textarea"
@change="event => event.target.value = event.target.value.trim()"
v-decorator.trim="[ 'requirement', validatorRules.requirement ]" />
</a-form-item>
</a-form>
</a-spin>
</div>
</div>
</j-modal>
</template>
<script>
import pick from 'lodash.pick'
import { getFileInfo } from '@/api/api'
import { previewPdf } from '@/utils/previewPdf'
import Vue from 'vue'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import { queryFileInfoByEditId } from '../../../../api/workCenter'
const Base64 = require('js-base64').Base64
export default {
name: 'CheckContentProcessModal',
data () {
return {
title: '',
visible: false,
confirmLoading: false,
form: this.$form.createForm(this),
model: {},
labelCol: {
xs: { span: 24 },
sm: { span: 6 }
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 16 }
},
validatorRules: {
clause: {
rules: [
{ required: true, message: this.$t('pleaseEnter') + this.$t('enterpriseStandardLibrary.standard.subjectToClause') }
],
validateTrigger: 'blur'
},
requirement: {
rules: [
{ required: true, message: this.$t('pleaseEnter') + this.$t('enterpriseStandardLibrary.standard.standardContentOrRequirements') }
],
validateTrigger: 'blur'
}
},
index: undefined, // 编辑的表格的下标
iframeSrc: '' // 左侧预览的路径
}
},
methods: {
add (fileId) {
this.getFileInfo(fileId).then(res => {
this.handlePreview(res)
})
this.visible = true
this.form.resetFields()
},
edit (fileId, record, index) {
this.getFileInfo(fileId).then(res => {
this.handlePreview(res)
})
this.visible = true
this.index = index
this.form.resetFields()
this.model = Object.assign({}, record)
this.$nextTick(() => {
this.form.setFieldsValue(pick(this.model, 'clause', 'requirement'))
})
},
getFileInfo (fileId) {
return new Promise(resolve => {
let fileInfo
queryFileInfoByEditId({ id: fileId }).then(res => {
if (res.success) {
fileInfo = res.result
}
}).finally(() => {
resolve(fileInfo)
})
})
},
handlePreview (file) {
const filePaths = file.filePath.split('/')
const fileName = filePaths[filePaths.length - 1]
const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(this.documentUrl + file.filePath + '&fullfilename=' + fileName))}`
this.iframeSrc = url
},
close () {
this.visible = false
this.model = {}
this.index = undefined
this.iframeSrc = ''
},
handleCancel () {
this.close()
},
handleOk () {
if (this.confirmLoading) return
this.form.validateFields((err, values) => {
if (!err) {
this.confirmLoading = true
const param = Object.assign({}, values)
console.log(param)
this.$emit('ok', param, this.index)
this.close()
this.confirmLoading = false
}
})
}
}
}
</script>
<style scoped lang="less">
.content {
width: 100%;
height: 100%;
display: flex;
.content-left {
width: 60%;
height: 100%;
overflow-y: scroll;
.left-spin {
height: 100%;
}
/deep/ .ant-spin-container {
height: 100%;
}
iframe {
height: calc(100% - 20px) !important;
}
}
.content-right {
width: 40%;
height: 100%;
overflow-y: scroll;
}
}
.empty-file {
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
}
</style>
@@ -65,6 +65,7 @@ import { previewPdf } from '@/utils/previewPdf'
import Vue from 'vue'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import { USER_INFO } from '../../../../store/mutation-types'
import { queryFileInfoByEditId } from '../../../../api/workCenter'
const Base64 = require('js-base64').Base64
@@ -147,7 +148,7 @@ export default {
getFileInfo (fileId) {
return new Promise(resolve => {
let fileInfo
getFileInfo({ id: fileId }).then(res => {
queryFileInfoByEditId({ id: fileId }).then(res => {
if (res.success) {
fileInfo = res.result
}
@@ -157,17 +158,10 @@ export default {
})
},
handlePreview (file) {
const fileSuffix = file.fileName ? file.fileName.split('.')[file.fileName.split('.').length - 1].toLowerCase() : ''
if (fileSuffix === 'pdf') {
// pdf预览
const url = previewPdf(file.id)
this.iframeSrc = url
} else if (fileSuffix === 'docx') {
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
}
const filePaths = file.filePath.split('/')
const fileName = filePaths[filePaths.length - 1]
const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(this.documentUrl + file.filePath + '&fullfilename=' + fileName))}`
this.iframeSrc = url
},
close () {
this.visible = false
@@ -55,6 +55,8 @@ import CommentModal from './CommentModal'
import Vue from 'vue'
import { kkFilePreview } from '@/utils/kkFilePreview'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import { queryFileInfoByEditId } from '../../../../api/workCenter'
import { Base64 } from 'js-base64'
export default {
name: 'CommentObjectEnterBaseInfo',
@@ -121,6 +123,7 @@ export default {
}
],
dataSource: [],
documentUrl: window._CONFIG.documentUrl,
onEditFile: '' // 在线编辑的文件id
}
},
@@ -207,8 +210,15 @@ export default {
},
// 在线编辑的查看
onlineEditView () {
const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${this.onEditFile}?at=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${this.onEditFile_dictText}`
kkFilePreview(fileFullUrl)
queryFileInfoByEditId({ id: this.onEditFile }).then(res => {
if (res.success) {
const file = res.result
const filePaths = file.filePath.split('/')
const fileName = filePaths[filePaths.length - 1]
const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(this.documentUrl + file.filePath + '&fullfilename=' + fileName))}`
window.open(url, '_blank')
}
})
}
}
}
@@ -64,6 +64,8 @@ import UserSelection from '@/components/selection/UserSelection'
import Vue from 'vue'
import { kkFilePreview } from '@/utils/kkFilePreview'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import { queryFileInfoByEditId } from '../../../../api/workCenter'
import { Base64 } from 'js-base64'
export default {
name: 'ConfirmWhetherCommentBaseInfo',
components: { BaseInfoForm, UserSelection },
@@ -128,8 +130,15 @@ export default {
},
// 在线编辑的查看
onlineEditView () {
const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${this.onEditFile}?at=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${this.onEditFile_dictText}`
kkFilePreview(fileFullUrl)
queryFileInfoByEditId({ id: this.onEditFile }).then(res => {
if (res.success) {
const file = res.result
const filePaths = file.filePath.split('/')
const fileName = filePaths[filePaths.length - 1]
const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(this.documentUrl + file.filePath + '&fullfilename=' + fileName))}`
window.open(url, '_blank')
}
})
}
}
}
@@ -73,6 +73,8 @@ import UserSelection from '@/components/selection/UserSelection'
import Vue from 'vue'
import { kkFilePreview } from '@/utils/kkFilePreview'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import { queryFileInfoByEditId } from '../../../../api/workCenter'
import { Base64 } from 'js-base64'
export default {
name: 'DepartLiaisonCollectBaseInfo',
@@ -236,8 +238,15 @@ export default {
},
// 在线编辑的查看
onlineEditView () {
const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${this.onEditFile}?at=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${this.onEditFile_dictText}`
kkFilePreview(fileFullUrl)
queryFileInfoByEditId({ id: this.onEditFile }).then(res => {
if (res.success) {
const file = res.result
const filePaths = file.filePath.split('/')
const fileName = filePaths[filePaths.length - 1]
const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(this.documentUrl + file.filePath + '&fullfilename=' + fileName))}`
window.open(url, '_blank')
}
})
}
}
}
@@ -63,6 +63,8 @@ import UserSelectByWorkGroup from '@/components/selection/UserSelectByWorkGroup'
import Vue from 'vue'
import { kkFilePreview } from '@/utils/kkFilePreview'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import { queryFileInfoByEditId } from '../../../../api/workCenter'
import { Base64 } from 'js-base64'
export default {
name: 'DepartLiaisonIssueBaseInfo',
@@ -147,8 +149,15 @@ export default {
},
// 在线编辑的查看
onlineEditView () {
const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${this.onEditFile}?at=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${this.onEditFile_dictText}`
kkFilePreview(fileFullUrl)
queryFileInfoByEditId({ id: this.onEditFile }).then(res => {
if (res.success) {
const file = res.result
const filePaths = file.filePath.split('/')
const fileName = filePaths[filePaths.length - 1]
const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(this.documentUrl + file.filePath + '&fullfilename=' + fileName))}`
window.open(url, '_blank')
}
})
}
}
}
@@ -55,6 +55,8 @@ import CommentModal from './CommentModal'
import Vue from 'vue'
import { kkFilePreview } from '@/utils/kkFilePreview'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import { queryFileInfoByEditId } from '../../../../api/workCenter'
import { Base64 } from 'js-base64'
export default {
name: 'DepartLiaisonLeaderApproveBaseInfo',
@@ -217,8 +219,15 @@ export default {
},
// 在线编辑的查看
onlineEditView () {
const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${this.onEditFile}?at=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${this.onEditFile_dictText}`
kkFilePreview(fileFullUrl)
queryFileInfoByEditId({ id: this.onEditFile }).then(res => {
if (res.success) {
const file = res.result
const filePaths = file.filePath.split('/')
const fileName = filePaths[filePaths.length - 1]
const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(this.documentUrl + file.filePath + '&fullfilename=' + fileName))}`
window.open(url, '_blank')
}
})
}
}
}
@@ -161,7 +161,7 @@
</div>
<!-- 稽查内容新增编辑弹框 -->
<check-content-modal ref="checkContentModal" @ok="checkContentOk"></check-content-modal>
<check-content-process-modal ref="checkContentModal" @ok="checkContentOk"></check-content-process-modal>
<!-- 上传文件弹框 -->
<upload-file ref="uploadFile" @change="uploadFileChange" :return-url="false" :fileMaxSize="fileMaxSize" :disabled="disabled"></upload-file>
</div>
@@ -171,7 +171,6 @@
import BaseInfoForm from './BaseInfoForm'
import UserSelection from '@/components/selection/UserSelection'
import JTable from '@/components/jero/JTable'
import CheckContentModal from '@/views/enterpriseStandardLibrary/standard/modules/CheckContentModal'
import UploadFile from '@/components/UploadFile'
import Vue from 'vue'
import { previewPdf } from '@/utils/previewPdf'
@@ -179,6 +178,7 @@ import { downloadFile, getFileAccessHttpUrl } from '@/api/manage'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import { kkFilePreview } from '@/utils/kkFilePreview'
import { onlineEditor } from '../../../../utils/onlyOfficeUtils'
import CheckContentProcessModal from './CheckContentProcessModal'
// 支持预览的文件后缀
const CAN_PREVIEW_FILE_SUFFIX = ['jpg', 'jpeg', 'png', 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx']
@@ -187,7 +187,7 @@ const FILE_TYPE_PDF = 'pdf'
export default {
name: 'MainDrafterCollectUploadMinuteBaseInfo',
components: { BaseInfoForm, UserSelection, JTable, CheckContentModal, UploadFile },
components: { CheckContentProcessModal, BaseInfoForm, UserSelection, JTable, UploadFile },
props: {
disabled: {
type: Boolean,
@@ -23,6 +23,8 @@ import BaseInfoForm from './BaseInfoForm'
import Vue from 'vue'
import { kkFilePreview } from '@/utils/kkFilePreview'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import { queryFileInfoByEditId } from '../../../../api/workCenter'
import { Base64 } from 'js-base64'
export default {
name: 'OtherDrafterProofreadBaseInfo',
components: { BaseInfoForm },
@@ -48,8 +50,15 @@ export default {
},
// 在线编辑的查看
onlineEditView () {
const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${this.onEditFile}?at=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${this.onEditFile_dictText}`
kkFilePreview(fileFullUrl)
queryFileInfoByEditId({ id: this.onEditFile }).then(res => {
if (res.success) {
const file = res.result
const filePaths = file.filePath.split('/')
const fileName = filePaths[filePaths.length - 1]
const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(this.documentUrl + file.filePath + '&fullfilename=' + fileName))}`
window.open(url, '_blank')
}
})
}
}
}
@@ -38,6 +38,8 @@ import BaseInfoForm from './BaseInfoForm'
import { kkFilePreview } from '@/utils/kkFilePreview'
import Vue from 'vue'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import { queryFileInfoByEditId } from '../../../../api/workCenter'
import { Base64 } from 'js-base64'
const fixDataSourse = [
{
id: 1,
@@ -396,8 +398,15 @@ export default {
},
// 在线编辑的查看
onlineEditView () {
const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${this.onEditFile}?at=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${this.onEditFile_dictText}`
kkFilePreview(fileFullUrl)
queryFileInfoByEditId({ id: this.onEditFile }).then(res => {
if (res.success) {
const file = res.result
const filePaths = file.filePath.split('/')
const fileName = filePaths[filePaths.length - 1]
const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(this.documentUrl + file.filePath + '&fullfilename=' + fileName))}`
window.open(url, '_blank')
}
})
}
}
}
@@ -118,6 +118,8 @@ import UserSelection from '@/components/selection/UserSelection'
import Vue from 'vue'
import { kkFilePreview } from '@/utils/kkFilePreview'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import { queryFileInfoByEditId } from '../../../../api/workCenter'
import { Base64 } from 'js-base64'
export default {
name: 'StandardizationAuditBaseInfo',
@@ -219,8 +221,15 @@ export default {
},
// 在线编辑的查看
onlineEditView () {
const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${this.onEditFile}?at=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${this.onEditFile_dictText}`
kkFilePreview(fileFullUrl)
queryFileInfoByEditId({ id: this.onEditFile }).then(res => {
if (res.success) {
const file = res.result
const filePaths = file.filePath.split('/')
const fileName = filePaths[filePaths.length - 1]
const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(this.documentUrl + file.filePath + '&fullfilename=' + fileName))}`
window.open(url, '_blank')
}
})
}
}
}