From 26bf11018b2b145942631421c7e634c5df91aea6 Mon Sep 17 00:00:00 2001
From: zhaowei <zhaowei>
Date: 星期二, 21 一月 2025 15:33:53 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 src/views/dnc/base/modules/ProductStructure/Document/SelectFileCompareModal.vue |  134 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 134 insertions(+), 0 deletions(-)

diff --git a/src/views/dnc/base/modules/ProductStructure/Document/SelectFileCompareModal.vue b/src/views/dnc/base/modules/ProductStructure/Document/SelectFileCompareModal.vue
new file mode 100644
index 0000000..9c6b7cd
--- /dev/null
+++ b/src/views/dnc/base/modules/ProductStructure/Document/SelectFileCompareModal.vue
@@ -0,0 +1,134 @@
+<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>
+
+    <FileCompareModal ref="fileCompareModalRef" :fileDiffObject="fileDiffObject" :fileVersionArray="fileVersionArray"/>
+  </a-modal>
+</template>
+
+<script>
+  import dncApi from '@/api/dnc'
+  import FileCompareModal from './FileCompareModal'
+
+  export default {
+    name: 'SelectFileCompareModal',
+    components: { FileCompareModal },
+    props: {
+      dataSource: {
+        type: Array
+      },
+      setCurrentVersionColor: {
+        type: Function
+      }
+    },
+    data() {
+      return {
+        visible: false,
+        title: '',
+        selectedRowKeys: [],
+        fileDiffObject: {},
+        fileVersionArray: [],
+        selectedFileInfo: {},
+        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' } }
+        ]
+      }
+    },
+    watch: {
+      visible: {
+        handler(value) {
+          this.$nextTick(() => {
+            const selectAllCheckboxNode = document.querySelector('.ant-table-selection-column .ant-table-selection')
+            if (value) {
+              if (this.dataSource.length > 2) selectAllCheckboxNode.style.display = 'none'
+              else selectAllCheckboxNode.style.display = 'block'
+            }
+          })
+        }
+      }
+    },
+    methods: {
+      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) {
+          $notification.warning({
+            message: '娑堟伅',
+            description: '璇峰嬀閫変袱涓増鏈瘮瀵�'
+          })
+          return
+        }
+        const that = this
+        $confirm({
+          title: '鎻愮ず',
+          content: '纭鎻愪氦鍚楋紵',
+          okText: '纭',
+          cancelText: '鍙栨秷',
+          onOk: () => {
+            that.fileVersionArray = []
+            dncApi.fileCompareApi(selectedRowKeys)
+              .then(res => {
+                if (res.success) {
+                  $notification.success({
+                    message: '娑堟伅',
+                    description: res.message
+                  })
+                  that.fileDiffObject = res.data
+                  // 浼犻�掔粰瀛愮粍浠跺綋鍓嶉�変腑鐨勬枃浠剁増鏈彿
+                  selectedRowKeys.forEach(fileId => {
+                    const selectedFileVersion = dataSource.find(item => item.fileId === fileId).docVersion
+                    that.fileVersionArray.push(selectedFileVersion)
+                  })
+                  that.handleCloseModal()
+                  if (!that.$refs.fileCompareModalRef) return
+                  that.$refs.fileCompareModalRef.visible = true
+                  that.$refs.fileCompareModalRef.title = title
+                } else {
+                  $notification.error({
+                    message: '娑堟伅',
+                    description: res.message
+                  })
+                }
+              })
+              .catch(err => {
+                $notification.error({
+                  message: '娑堟伅',
+                  description: err.message
+                })
+              })
+          }
+        })
+      },
+
+      handleCloseModal() {
+        this.visible = false
+        this.selectedRowKeys = []
+      }
+    }
+  }
+</script>
+
+<style scoped>
+
+</style>
\ No newline at end of file

--
Gitblit v1.9.3