From 63ac895629d2de0e7f4284b1617d9aa8cbd07d05 Mon Sep 17 00:00:00 2001
From: zhaowei <zhaowei>
Date: 星期五, 21 三月 2025 14:16:04 +0800
Subject: [PATCH] 1、删除DNC冗余组件 2、优化DNC文档版本、文档指派及文档预览功能代码

---
 src/views/dnc/common/DocumentVersionTableList.vue |  292 +++++++++++++++++++++++++++++++---------------------------
 1 files changed, 156 insertions(+), 136 deletions(-)

diff --git a/src/views/dnc/common/DocumentVersionTableList.vue b/src/views/dnc/common/DocumentVersionTableList.vue
index aeb3240..ac703ba 100644
--- a/src/views/dnc/common/DocumentVersionTableList.vue
+++ b/src/views/dnc/common/DocumentVersionTableList.vue
@@ -1,157 +1,177 @@
 <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)}">
-        {{text}}.{{record.fileSuffix}}
+      <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>
 </template>
 
 <script>
-  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
-  import { getAction } from '@/api/manage'
-  import dncApi from '@/api/dnc'
-  import SelectFileCompareModal from './SelectFileCompareModal'
+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: { SelectFileCompareModal },
-    props: {
-      currentDocumentInfo: {
-        type: Object
-      },
-      size: {
-        type: String
-      }
+export default {
+  name: 'DocumentVersionTableList',
+  mixins: [JeecgListMixin],
+  components: { SelectFileCompareModal },
+  props: {
+    currentDocumentInfo: {
+      type: Object
     },
-    data() {
-      return {
-        disableMixinCreated: true,
-        queryParams: {},
-        currentDocumentVersion: '',
-        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' } },
-          { title: '鏂囦欢澶у皬', dataIndex: 'fileSize', align: 'center', scopedSlots: { customRender: 'fileSize' } }
-        ],
-        url: {
-          list: '/nc/file/find/list'
-        }
-      }
-    },
-    created() {
-      this.$bus.$on('tableMenuItemMethodTrigger', this.triggerCorrespondingMethod)
-    },
-    methods: {
-      loadData() {
-        this.dataSource = []
-        if (!this.url.list) {
-          this.$message.error('璇疯缃畊rl.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
-            this.currentDocumentVersion = res.list.find(item => item.publishFlag).docVersion
-            console.log('currentDocumentVersion', this.currentDocumentVersion)
-          } else {
-            this.$message.warning(res.message)
+    size: {
+      type: String
+    }
+  },
+  data() {
+    return {
+      disableMixinCreated: true,
+      queryParams: {},
+      columns: [
+        {
+          title: '搴忓彿',
+          dataIndex: 'rowIndex',
+          width: 65,
+          align: 'center',
+          customRender: function(t, r, index) {
+            return parseInt(index) + 1
           }
-        }).finally(() => {
-          this.loading = false
-        })
-      },
-
-      /**
-       * 鎸囧畾褰撳墠鏂囨。涓哄綋鍓嶇増鏈�
-       * @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} 棰滆壊鏍囪瘑
-       */
-      setCurrentVersionColor(publishFlag) {
-        return publishFlag ? '#DB9538' : ''
+        },
+        { title: '鏂囦欢鍚嶇О', dataIndex: 'fileName', align: 'center', scopedSlots: { customRender: 'fileName' } },
+        { title: '鐗堟湰鍙�', dataIndex: 'docVersion', align: 'center' },
+        { title: '鏂囦欢澶у皬', dataIndex: 'fileSize', align: 'center' }
+      ],
+      url: {
+        list: '/nc/file/find/list'
       }
     }
+  },
+  created() {
+    this.$bus.$on('tableMenuItemMethodTrigger', this.triggerCorrespondingMethod)
+  },
+  beforeDestroy() {
+    this.$bus.$off('tableMenuItemMethodTrigger', this.triggerCorrespondingMethod)
+  },
+  methods: {
+    // 鍔犺浇鍒楄〃鏁版嵁
+    loadData() {
+      this.dataSource = []
+      if (!this.url.list) {
+        this.$message.error('璇疯缃畊rl.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 {
+            that.$notification.error({
+              message: '娑堟伅',
+              description: res.message
+            })
+          }
+        })
+        .finally(() => {
+          this.loading = false
+        })
+    },
+
+    /**
+     * 鎸囧畾褰撳墠鏂囨。涓哄綋鍓嶇増鏈�
+     * @param fileId 鏂囦欢Id
+     */
+    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) {
+            that.$notification.success({
+              message: '娑堟伅',
+              description: res.message
+            })
+            that.loadData()
+            that.$emit('releaseFilePreviewApi')
+          } else {
+            that.$notification.error({
+              message: '娑堟伅',
+              description: res.message
+            })
+          }
+        })
+        .catch(err => {
+          that.$notification.error({
+            message: '娑堟伅',
+            description: err.message
+          })
+        })
+    },
+
+    /**
+     * 姣斿涓や釜鐗堟湰鐨勬枃妗e唴瀹�
+     * @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()
+            this.$emit('handleTableContextMenuOpen', Object.assign({ param: 'file' }, record))
+          }
+        }
+      }
+    },
+
+    /**
+     * 璁剧疆琛ㄦ牸涓负褰撳墠鐗堟湰鐨勬枃浠惰〃鏍艰棰滆壊鏍囪瘑
+     * @param publishFlag 鏄惁涓哄綋鍓嶇増鏈�
+     * @returns {string} 棰滆壊鏍囪瘑
+     */
+    setCurrentVersionColor(publishFlag) {
+      return publishFlag ? '#DB9538' : ''
+    },
+
+    triggerCorrespondingMethod({ methodName, modalTitle, tableRowInfo }) {
+      if (this[methodName]) this[methodName](tableRowInfo, modalTitle)
+    }
   }
+}
 </script>
-
-<style scoped>
-
-</style>
\ No newline at end of file

--
Gitblit v1.9.3