1、删除DNC冗余组件
2、优化DNC文档版本、文档指派及文档预览功能代码
| | |
| | | checkedKeys: [], |
| | | expandedKeys: [], |
| | | autoExpandParent: true, |
| | | isExpandAllTreeNode: false, |
| | | isExpandAllTreeNode: true, |
| | | date: [], |
| | | url: { |
| | | list: '/nc/doc/find/list' |
| | |
| | | <template> |
| | | <div> |
| | | <a-table :columns="columns" :data-source="dataSource" bordered :pagination="false" :size="size" rowKey="fileId" |
| | | :customRow="customRow"> |
| | | <template slot="rowIndex" slot-scope="text,record,index"> |
| | | <span :style="{color:setCurrentVersionColor(record.publishFlag)}">{{parseInt(index) + 1}}</span> |
| | | </template> |
| | | :customRow="customRow" :scroll="{y:189}"> |
| | | <template slot="fileName" slot-scope="text,record,index"> |
| | | <span :style="{color:setCurrentVersionColor(record.publishFlag)}"> |
| | | {{text}}.{{record.fileSuffix}} |
| | | <span> |
| | | {{ text }}.{{ record.fileSuffix }} |
| | | <span v-if="record.publishFlag">[å½åçæ¬]</span> |
| | | </span> |
| | | </template> |
| | | <template slot="docVersion" slot-scope="text,record"> |
| | | <span :style="{color:setCurrentVersionColor(record.publishFlag)}">{{text}}</span> |
| | | </template> |
| | | <template slot="fileSize" slot-scope="text,record"> |
| | | <span :style="{color:setCurrentVersionColor(record.publishFlag)}">{{(text/1024).toFixed(2)}}KB</span> |
| | | </template> |
| | | </a-table> |
| | | |
| | | <SelectFileCompareModal :dataSource="dataSource" :setCurrentVersionColor="setCurrentVersionColor" |
| | | ref="selectFileCompareModalRef"/> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import { JeecgListMixin } from '@/mixins/JeecgListMixin' |
| | | import { getAction } from '@/api/manage' |
| | | import dncApi from '@/api/dnc' |
| | | import SelectFileCompareModal from './SelectFileCompareModal' |
| | | import { JeecgListMixin } from '@/mixins/JeecgListMixin' |
| | | import { getAction } from '@/api/manage' |
| | | import dncApi from '@/api/dnc' |
| | | import SelectFileCompareModal from './SelectFileCompareModal' |
| | | |
| | | export default { |
| | | name: 'DocumentVersionTableList', |
| | | mixins: [JeecgListMixin], |
| | | components: { SelectFileCompareModal }, |
| | | props: { |
| | | currentDocumentInfo: { |
| | | type: Object |
| | | }, |
| | | size: { |
| | | type: String |
| | | } |
| | | export default { |
| | | name: 'DocumentVersionTableList', |
| | | mixins: [JeecgListMixin], |
| | | components: { SelectFileCompareModal }, |
| | | props: { |
| | | currentDocumentInfo: { |
| | | type: Object |
| | | }, |
| | | data() { |
| | | return { |
| | | disableMixinCreated: true, |
| | | queryParams: {}, |
| | | currentDocumentVersion: '', |
| | | columns: [ |
| | | { title: 'åºå·', dataIndex: 'rowIndex', width: 65, align: 'center', scopedSlots: { customRender: 'rowIndex' } }, |
| | | { title: 'æä»¶åç§°', dataIndex: 'fileName', align: 'center', scopedSlots: { customRender: 'fileName' } }, |
| | | { title: 'çæ¬å·', dataIndex: 'docVersion', align: 'center', scopedSlots: { customRender: 'docVersion' } }, |
| | | { title: 'æä»¶å¤§å°', dataIndex: 'fileSize', align: 'center', scopedSlots: { customRender: 'fileSize' } } |
| | | ], |
| | | url: { |
| | | list: '/nc/file/find/list' |
| | | } |
| | | } |
| | | }, |
| | | created() { |
| | | this.$bus.$on('tableMenuItemMethodTrigger', this.triggerCorrespondingMethod) |
| | | }, |
| | | methods: { |
| | | loadData() { |
| | | this.dataSource = [] |
| | | if (!this.url.list) { |
| | | this.$message.error('请设置url.list屿§!') |
| | | return |
| | | } |
| | | var params = this.getQueryParams()//æ¥è¯¢æ¡ä»¶ |
| | | params.docId = this.currentDocumentInfo.docId |
| | | if (!params) { |
| | | return false |
| | | } |
| | | this.loading = true |
| | | getAction(this.url.list, params).then((res) => { |
| | | if (res.success) { |
| | | this.dataSource = res.list |
| | | this.currentDocumentVersion = res.list.find(item => item.publishFlag).docVersion |
| | | console.log('currentDocumentVersion', this.currentDocumentVersion) |
| | | } else { |
| | | this.$message.warning(res.message) |
| | | size: { |
| | | type: String |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | | disableMixinCreated: true, |
| | | queryParams: {}, |
| | | columns: [ |
| | | { |
| | | title: 'åºå·', |
| | | dataIndex: 'rowIndex', |
| | | width: 65, |
| | | align: 'center', |
| | | customRender: function(t, r, index) { |
| | | return parseInt(index) + 1 |
| | | } |
| | | }).finally(() => { |
| | | this.loading = false |
| | | }) |
| | | }, |
| | | |
| | | /** |
| | | * æå®å½åææ¡£ä¸ºå½åçæ¬ |
| | | * @param fileId æä»¶Id |
| | | */ |
| | | handleFileAssign({ fileId }) { |
| | | const that = this |
| | | dncApi.appointCurrentDocumentVersionApi(fileId) |
| | | .then(res => { |
| | | if (res.success) { |
| | | that.$notification.success({ |
| | | message: 'æ¶æ¯', |
| | | description: res.message |
| | | }) |
| | | const currentAssignDocumentVersion = that.dataSource.find(item => item.fileId === fileId).docVersion |
| | | // 妿å½åæå®çæ¬ççæ¬å·ä¸å½åçæ¬ççæ¬å·ä¸è´åä¸éæ°å è½½å表并ä¸ä¸éæ°éæ¾é¢è§æ¥å£è°å |
| | | if (that.currentDocumentVersion === currentAssignDocumentVersion) return |
| | | that.loadData() |
| | | that.$emit('releaseFilePreviewApi') |
| | | } else { |
| | | that.$notification.error({ |
| | | message: 'æ¶æ¯', |
| | | description: res.message |
| | | }) |
| | | } |
| | | }) |
| | | .catch(err => { |
| | | that.$notification.error({ |
| | | message: 'æ¶æ¯', |
| | | description: err.message |
| | | }) |
| | | }) |
| | | }, |
| | | |
| | | handleFileAddRelative(_, modalTitle) { |
| | | if (!this.$refs.selectFileCompareModalRef) return |
| | | this.$refs.selectFileCompareModalRef.visible = true |
| | | this.$refs.selectFileCompareModalRef.title = modalTitle |
| | | }, |
| | | |
| | | customRow(record) { |
| | | return { |
| | | on: { |
| | | contextmenu: event => { |
| | | event.preventDefault() |
| | | this.$emit('handleTableContextMenuOpen', Object.assign({ param: 'file' }, record)) |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | |
| | | triggerCorrespondingMethod({ methodName, level, modalTitle, tableRowInfo }) { |
| | | if (this[methodName]) this[methodName](tableRowInfo, modalTitle) |
| | | }, |
| | | |
| | | /** |
| | | * è®¾ç½®è¡¨æ ¼ä¸ä¸ºå½åçæ¬çæä»¶è¡¨æ ¼è¡é¢è²æ è¯ |
| | | * @param publishFlag æ¯å¦ä¸ºå½åçæ¬ |
| | | * @returns {string} é¢è²æ è¯ |
| | | */ |
| | | setCurrentVersionColor(publishFlag) { |
| | | return publishFlag ? '#DB9538' : '' |
| | | }, |
| | | { title: 'æä»¶åç§°', dataIndex: 'fileName', align: 'center', scopedSlots: { customRender: 'fileName' } }, |
| | | { title: 'çæ¬å·', dataIndex: 'docVersion', align: 'center' }, |
| | | { title: 'æä»¶å¤§å°', dataIndex: 'fileSize', align: 'center' } |
| | | ], |
| | | url: { |
| | | list: '/nc/file/find/list' |
| | | } |
| | | } |
| | | }, |
| | | created() { |
| | | this.$bus.$on('tableMenuItemMethodTrigger', this.triggerCorrespondingMethod) |
| | | }, |
| | | beforeDestroy() { |
| | | this.$bus.$off('tableMenuItemMethodTrigger', this.triggerCorrespondingMethod) |
| | | }, |
| | | methods: { |
| | | // å è½½åè¡¨æ°æ® |
| | | loadData() { |
| | | this.dataSource = [] |
| | | if (!this.url.list) { |
| | | this.$message.error('请设置url.list屿§!') |
| | | return |
| | | } |
| | | var params = this.getQueryParams()//æ¥è¯¢æ¡ä»¶ |
| | | params.docId = this.currentDocumentInfo.docId |
| | | if (!params) { |
| | | return false |
| | | } |
| | | this.loading = true |
| | | getAction(this.url.list, params) |
| | | .then((res) => { |
| | | if (res.success) this.dataSource = res.list |
| | | else { |
| | | that.$notification.error({ |
| | | message: 'æ¶æ¯', |
| | | description: res.message |
| | | }) |
| | | } |
| | | }) |
| | | .finally(() => { |
| | | this.loading = false |
| | | }) |
| | | }, |
| | | |
| | | /** |
| | | * æå®å½åææ¡£ä¸ºå½åçæ¬ |
| | | * @param fileId æä»¶Id |
| | | */ |
| | | handleFileAssign({ fileId, publishFlag }) { |
| | | const that = this |
| | | console.log('publishFlag', publishFlag) |
| | | // 妿å½åæå®çæ¬ççæ¬å·ä¸å½åçæ¬ççæ¬å·ä¸è´åä¸åèµ·è¯·æ± |
| | | if (publishFlag) { |
| | | that.$notification.info({ |
| | | message: 'æ¶æ¯', |
| | | description: 'å½åææ¡£çæ¬å³ä¸ºå½åæä»¶' |
| | | }) |
| | | return |
| | | } |
| | | dncApi.appointCurrentDocumentVersionApi(fileId) |
| | | .then(res => { |
| | | if (res.success) { |
| | | that.$notification.success({ |
| | | message: 'æ¶æ¯', |
| | | description: res.message |
| | | }) |
| | | that.loadData() |
| | | that.$emit('releaseFilePreviewApi') |
| | | } else { |
| | | that.$notification.error({ |
| | | message: 'æ¶æ¯', |
| | | description: res.message |
| | | }) |
| | | } |
| | | }) |
| | | .catch(err => { |
| | | that.$notification.error({ |
| | | message: 'æ¶æ¯', |
| | | description: err.message |
| | | }) |
| | | }) |
| | | }, |
| | | |
| | | /** |
| | | * æ¯å¯¹ä¸¤ä¸ªçæ¬çææ¡£å
容 |
| | | * @param _ |
| | | * @param modalTitle å¼¹çªæ é¢ |
| | | */ |
| | | handleFileAddRelative(_, modalTitle) { |
| | | if (!this.$refs.selectFileCompareModalRef) return |
| | | this.$refs.selectFileCompareModalRef.visible = true |
| | | this.$refs.selectFileCompareModalRef.title = modalTitle |
| | | }, |
| | | |
| | | /** |
| | | * å®å¶è¡¨æ ¼è¡æ ·å¼ååè½ |
| | | * @param record è¡¨æ ¼è¡ä¿¡æ¯ |
| | | * @returns {{style: {color: (string)}, on: {contextmenu: *}}} æ ·å¼ååè½ |
| | | */ |
| | | customRow(record) { |
| | | return { |
| | | style: { |
| | | color: this.setCurrentVersionColor(record.publishFlag) |
| | | }, |
| | | on: { |
| | | contextmenu: event => { |
| | | event.preventDefault() |
| | | this.$emit('handleTableContextMenuOpen', Object.assign({ param: 'file' }, record)) |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | |
| | | /** |
| | | * è®¾ç½®è¡¨æ ¼ä¸ä¸ºå½åçæ¬çæä»¶è¡¨æ ¼è¡é¢è²æ è¯ |
| | | * @param publishFlag æ¯å¦ä¸ºå½åçæ¬ |
| | | * @returns {string} é¢è²æ è¯ |
| | | */ |
| | | setCurrentVersionColor(publishFlag) { |
| | | return publishFlag ? '#DB9538' : '' |
| | | }, |
| | | |
| | | triggerCorrespondingMethod({ methodName, modalTitle, tableRowInfo }) { |
| | | if (this[methodName]) this[methodName](tableRowInfo, modalTitle) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | |
| | | </style> |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import dncApi from '@/api/dnc' |
| | | import dncApi from '@/api/dnc' |
| | | |
| | | export default { |
| | | name: 'FilePreview', |
| | | components: {}, |
| | | props: { |
| | | currentDocumentInfo: { |
| | | type: Object |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | | spinning: false, |
| | | pdfUrl: '' |
| | | } |
| | | }, |
| | | methods: { |
| | | getFilePreviewByApi() { |
| | | const { docId, docSuffix } = this.currentDocumentInfo |
| | | console.log('currentDocumentInfo', this.currentDocumentInfo) |
| | | // if (docSuffix !== 'pdf') { |
| | | // document.getElementById('ncFileInfo').innerHTML = '' |
| | | // dncApi.getFilePreviewApi(docId) |
| | | // .then(res => { |
| | | // console.log('res----------------------------', res) |
| | | // if (res.success && res.list) { |
| | | // let str = '' |
| | | // res.list.forEach((val, k) => { |
| | | // str += val |
| | | // if (k != res.list.length - 1) { |
| | | // str += '\n' |
| | | // } |
| | | // }) |
| | | // document.getElementById('ncFileInfo').innerHTML = str |
| | | // } else { |
| | | // this.$notification.error({ |
| | | // message: 'æ¶æ¯', |
| | | // description: res.message |
| | | // }) |
| | | // } |
| | | // }) |
| | | // } else { |
| | | // dncApi.getPdfFilePreviewApi(docId) |
| | | // .then(res => { |
| | | // let url = window.URL.createObjectURL(new Blob([res], { type: 'application/zip' })) |
| | | // this.pdfUrl = './static/pdf/web/viewer.html?file=' + encodeURIComponent(url) |
| | | // console.log('url===========================', url) |
| | | // console.log('pdfUrl===========================', this.pdfUrl) |
| | | // }) |
| | | // } |
| | | this.spinning = true |
| | | document.getElementById('ncFileInfo').innerHTML = '' |
| | | dncApi.getFilePreviewApi(docId) |
| | | .then(res => { |
| | | console.log('res----------------------------', res) |
| | | if (res.success && res.list) { |
| | | let str = '' |
| | | res.list.forEach((val, k) => { |
| | | str += val |
| | | if (k != res.list.length - 1) { |
| | | str += '\n' |
| | | } |
| | | }) |
| | | document.getElementById('ncFileInfo').innerHTML = str |
| | | } else { |
| | | this.$notification.error({ |
| | | message: 'æ¶æ¯', |
| | | description: res.message |
| | | }) |
| | | } |
| | | }) |
| | | .finally(() => { |
| | | this.spinning = false |
| | | }) |
| | | }, |
| | | export default { |
| | | name: 'FilePreview', |
| | | components: {}, |
| | | props: { |
| | | currentDocumentInfo: { |
| | | type: Object |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | | spinning: false, |
| | | pdfUrl: '' |
| | | } |
| | | }, |
| | | methods: { |
| | | getFilePreviewByApi() { |
| | | const { docId, docSuffix } = this.currentDocumentInfo |
| | | console.log('currentDocumentInfo', this.currentDocumentInfo) |
| | | // if (docSuffix !== 'pdf') { |
| | | // document.getElementById('ncFileInfo').innerHTML = '' |
| | | // dncApi.getFilePreviewApi(docId) |
| | | // .then(res => { |
| | | // console.log('res----------------------------', res) |
| | | // if (res.success && res.list) { |
| | | // let str = '' |
| | | // res.list.forEach((val, k) => { |
| | | // str += val |
| | | // if (k != res.list.length - 1) { |
| | | // str += '\n' |
| | | // } |
| | | // }) |
| | | // document.getElementById('ncFileInfo').innerHTML = str |
| | | // } else { |
| | | // this.$notification.error({ |
| | | // message: 'æ¶æ¯', |
| | | // description: res.message |
| | | // }) |
| | | // } |
| | | // }) |
| | | // } else { |
| | | // dncApi.getPdfFilePreviewApi(docId) |
| | | // .then(res => { |
| | | // let url = window.URL.createObjectURL(new Blob([res], { type: 'application/zip' })) |
| | | // this.pdfUrl = './static/pdf/web/viewer.html?file=' + encodeURIComponent(url) |
| | | // console.log('url===========================', url) |
| | | // console.log('pdfUrl===========================', this.pdfUrl) |
| | | // }) |
| | | // } |
| | | document.getElementById('ncFileInfo').innerHTML = '' |
| | | if (docSuffix == 'jpg' || docSuffix == 'png' || docSuffix == 'jpeg' || docSuffix === 'gif' || docSuffix == 'pdf') return |
| | | this.spinning = true |
| | | dncApi.getFilePreviewApi(docId) |
| | | .then(res => { |
| | | console.log('res----------------------------', res) |
| | | if (res.success && res.list) { |
| | | let str = '' |
| | | res.list.forEach((val, k) => { |
| | | str += val |
| | | if (k != res.list.length - 1) { |
| | | str += '\n' |
| | | } |
| | | }) |
| | | document.getElementById('ncFileInfo').innerHTML = str |
| | | } else { |
| | | this.$notification.error({ |
| | | message: 'æ¶æ¯', |
| | | description: res.message |
| | | }) |
| | | } |
| | | }) |
| | | .finally(() => { |
| | | this.spinning = false |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | /deep/ .ant-spin-container { |
| | | height: 100%; |
| | | } |
| | | /deep/ .ant-spin-container { |
| | | height: 100%; |
| | | } |
| | | </style> |
| | |
| | | <template> |
| | | <a-modal :title="title" :visible="visible" :width="700" @cancel="handleCloseModal" @ok="handleOpenCompareModal" |
| | | :maskClosable="false"> |
| | | <a-table :dataSource="dataSource" :columns="columns" :pagination="false" bordered :scroll="{y:364}" |
| | | :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}" rowKey="fileId"> |
| | | <template slot="rowIndex" slot-scope="text,record,index"> |
| | | <span :style="{color:setCurrentVersionColor(record.publishFlag)}">{{parseInt(index) + 1}}</span> |
| | | </template> |
| | | <template slot="fileName" slot-scope="text,record,index"> |
| | | <span :style="{color:setCurrentVersionColor(record.publishFlag)}"> |
| | | {{text}}.{{record.fileSuffix}} |
| | | <span v-if="record.publishFlag">[å½åçæ¬]</span> |
| | | </span> |
| | | </template> |
| | | <template slot="docVersion" slot-scope="text,record"> |
| | | <span :style="{color:setCurrentVersionColor(record.publishFlag)}">{{text}}</span> |
| | | </template> |
| | | </a-table> |
| | | <template> |
| | | <a-modal :title="title" :visible="visible" :width="700" @cancel="handleCloseModal" @ok="handleOpenCompareModal" |
| | | :maskClosable="false"> |
| | | <a-table :dataSource="dataSource" :columns="columns" :pagination="false" bordered :scroll="{y:364}" |
| | | :customRow="customRow" |
| | | :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}" rowKey="fileId"> |
| | | <template slot="fileName" slot-scope="text,record,index"> |
| | | <span :style="{color:setCurrentVersionColor(record.publishFlag)}"> |
| | | {{ text }}.{{ record.fileSuffix }} |
| | | <span v-if="record.publishFlag">[å½åçæ¬]</span> |
| | | </span> |
| | | </template> |
| | | </a-table> |
| | | |
| | | <FileCompareModal ref="fileCompareModalRef" :fileDiffObject="fileDiffObject" :fileVersionArray="fileVersionArray"/> |
| | | </a-modal> |
| | | </template> |
| | | <FileCompareModal ref="fileCompareModalRef" :fileDiffObject="fileDiffObject" :fileVersionArray="fileVersionArray"/> |
| | | </a-modal> |
| | | </template> |
| | | |
| | | <script> |
| | | <script> |
| | | import dncApi from '@/api/dnc' |
| | | import FileCompareModal from './FileCompareModal' |
| | | |
| | |
| | | fileVersionArray: [], |
| | | selectedFileInfo: {}, |
| | | columns: [ |
| | | { title: 'åºå·', dataIndex: 'rowIndex', width: 65, align: 'center', scopedSlots: { customRender: 'rowIndex' } }, |
| | | { |
| | | title: 'åºå·', |
| | | dataIndex: 'rowIndex', |
| | | width: 65, |
| | | align: 'center', |
| | | customRender: function(t, r, index) { |
| | | return parseInt(index) + 1 |
| | | } |
| | | }, |
| | | { title: 'æä»¶åç§°', dataIndex: 'fileName', align: 'center', scopedSlots: { customRender: 'fileName' } }, |
| | | { title: 'çæ¬å·', dataIndex: 'docVersion', align: 'center', scopedSlots: { customRender: 'docVersion' } } |
| | | { title: 'çæ¬å·', dataIndex: 'docVersion', align: 'center' } |
| | | ] |
| | | } |
| | | }, |
| | |
| | | } |
| | | }, |
| | | methods: { |
| | | /** |
| | | * å®å¶è¡¨æ ¼è¡æ ·å¼ |
| | | * @param record è¡¨æ ¼è¡ä¿¡æ¯ |
| | | * @returns {{style: {color: *}}} æ ·å¼ |
| | | */ |
| | | customRow(record) { |
| | | return { |
| | | style: { |
| | | color: this.setCurrentVersionColor(record.publishFlag) |
| | | } |
| | | } |
| | | }, |
| | | |
| | | /** |
| | | * å½è¡¨æ ¼å¤éæ¡æ¹åæ¶è§¦å |
| | | * @param selectedRowKeys éä¸çæ¯ä¸è¡çkeyéå |
| | | */ |
| | | onSelectChange(selectedRowKeys) { |
| | | if (selectedRowKeys.length < 3) this.selectedRowKeys = selectedRowKeys |
| | | else this.selectedRowKeys = selectedRowKeys.slice(-2) |
| | | }, |
| | | |
| | | // æå¼å¯¹æ¯çªå£ |
| | | handleOpenCompareModal() { |
| | | const { $confirm, $notification, selectedRowKeys, title, dataSource } = this |
| | | if (selectedRowKeys.length < 2) { |
| | |
| | | }) |
| | | }, |
| | | |
| | | // å
³éçªå£ |
| | | handleCloseModal() { |
| | | this.visible = false |
| | | this.selectedRowKeys = [] |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | </script> |
| | | |
| | | <style scoped> |
| | | <style scoped> |
| | | |
| | | </style> |
| | | </style> |