lyh
10 天以前 76f83ad33466ea704eec9a121d2e0a22c1828a84
src/views/dnc/common/SelectFileCompareModal.vue
@@ -1,27 +1,22 @@
<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'
@@ -45,9 +40,17 @@
        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' }
        ]
      }
    },
@@ -65,11 +68,29 @@
      }
    },
    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) {
@@ -121,14 +142,15 @@
        })
      },
      // 关闭窗口
      handleCloseModal() {
        this.visible = false
        this.selectedRowKeys = []
      }
    }
  }
</script>
  </script>
<style scoped>
  <style scoped>
</style>
  </style>