| | |
| | | <template> |
| | | <a-table :columns="columns" :data-source="dataSource" bordered :pagination="false" :size="size" 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"> |
| | | <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> |
| | | <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> |
| | | <template slot="fileSize" slot-scope="text,record"> |
| | | <span :style="{color:setCurrentVersionColor(record.publishFlag)}">{{(text/1024).toFixed(2)}}KB</span> |
| | | </template> |
| | | </a-table> |
| | | </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' |
| | | |
| | | export default { |
| | | name: 'DocumentVersionTableList', |
| | | mixins: [JeecgListMixin], |
| | | components: {}, |
| | | components: { SelectFileCompareModal }, |
| | | props: { |
| | | currentDocumentInfo: { |
| | | type: Object |
| | |
| | | return { |
| | | disableMixinCreated: true, |
| | | queryParams: {}, |
| | | currentDocumentVersion: '', |
| | | columns: [ |
| | | { title: '序号', dataIndex: 'rowIndex', width: 65, align: 'center', scopedSlots: { customRender: 'rowIndex' } }, |
| | | { title: '文件名称', dataIndex: 'fileName', align: 'center', scopedSlots: { customRender: 'fileName' } }, |
| | |
| | | list: '/nc/file/find/list' |
| | | } |
| | | } |
| | | }, |
| | | created() { |
| | | this.$bus.$on('tableMenuItemMethodTrigger', this.triggerCorrespondingMethod) |
| | | }, |
| | | methods: { |
| | | loadData() { |
| | |
| | | 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) |
| | | } |
| | |
| | | }, |
| | | |
| | | /** |
| | | * 指定当前文档为当前版本 |
| | | * @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} 颜色标识 |