zhaowei
2025-03-21 63ac895629d2de0e7f4284b1617d9aa8cbd07d05
src/views/dnc/common/DocumentVersionTableList.vue
@@ -1,23 +1,15 @@
<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)}">
      <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>
@@ -45,12 +37,19 @@
      return {
        disableMixinCreated: true,
        queryParams: {},
        currentDocumentVersion: '',
        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: 'fileSize', align: 'center', scopedSlots: { customRender: 'fileSize' } }
        { title: '版本号', dataIndex: 'docVersion', align: 'center' },
        { title: '文件大小', dataIndex: 'fileSize', align: 'center' }
        ],
        url: {
          list: '/nc/file/find/list'
@@ -60,7 +59,11 @@
    created() {
      this.$bus.$on('tableMenuItemMethodTrigger', this.triggerCorrespondingMethod)
    },
  beforeDestroy() {
    this.$bus.$off('tableMenuItemMethodTrigger', this.triggerCorrespondingMethod)
  },
    methods: {
    // 加载列表数据
      loadData() {
        this.dataSource = []
        if (!this.url.list) {
@@ -73,15 +76,17 @@
          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)
      getAction(this.url.list, params)
        .then((res) => {
          if (res.success) this.dataSource = res.list
          else {
            that.$notification.error({
              message: '消息',
              description: res.message
            })
          }
        }).finally(() => {
        })
        .finally(() => {
          this.loading = false
        })
      },
@@ -90,8 +95,17 @@
       * 指定当前文档为当前版本
       * @param fileId 文件Id
       */
      handleFileAssign({ fileId }) {
    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) {
@@ -99,9 +113,6 @@
                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 {
@@ -119,14 +130,27 @@
          })
      },
    /**
     * 比对两个版本的文档内容
     * @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()
@@ -136,10 +160,6 @@
        }
      },
      triggerCorrespondingMethod({ methodName, level, modalTitle, tableRowInfo }) {
        if (this[methodName]) this[methodName](tableRowInfo, modalTitle)
      },
      /**
       * 设置表格中为当前版本的文件表格行颜色标识
       * @param publishFlag 是否为当前版本
@@ -147,11 +167,11 @@
       */
      setCurrentVersionColor(publishFlag) {
        return publishFlag ? '#DB9538' : ''
    },
    triggerCorrespondingMethod({ methodName, modalTitle, tableRowInfo }) {
      if (this[methodName]) this[methodName](tableRowInfo, modalTitle)
      }
    }
  }
</script>
<style scoped>
</style>