src/views/dnc/base/modules/ProductStructure/Document/DocumentVersionTableList.vue
@@ -1,39 +1,87 @@
<template>
  <a-table :columns="columns" :data-source="dataSource" bordered :pagination="false">
  <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">
      <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>
<script>
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import { getAction } from '@/api/manage'
  export default {
    name: 'DocumentVersionTableList',
    mixins: [JeecgListMixin],
    components: {},
    props: {
      currentDocumentInfo: {
        type: Object
      },
      size: {
        type: String
      }
    },
    data() {
      return {
        disableMixinCreated: true,
        queryParams: {},
        columns: [
          {
            title: '序号',
            dataIndex: 'rowIndex',
            key: 'rowIndex',
            width: 65,
            align: 'center',
            customRender: function(t, r, index) {
              return parseInt(index) + 1
            }
          },
          { title: '文件名称', dataIndex: 'fileName', align: 'center' },
          { title: '版本号', dataIndex: 'docVersion', align: 'center' },
          { title: '文件大小', dataIndex: 'fileSize', align: 'center' }
          { 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: ''
          list: '/nc/file/find/list'
        }
      }
    },
    methods: {}
    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 {
            this.$message.warning(res.message)
          }
        }).finally(() => {
          this.loading = false
        })
      },
      /**
       * 设置表格中为当前版本的文件表格行颜色标识
       * @param publishFlag 是否为当前版本
       * @returns {string} 颜色标识
       */
      setCurrentVersionColor(publishFlag) {
        return publishFlag ? '#DB9538' : ''
      }
    }
  }
</script>