From bf42ef43fccdf3d3486eec84ad4073b0c7650aba Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期三, 13 八月 2025 17:35:37 +0800
Subject: [PATCH] 新增场景信息文件导入功能

---
 src/components/table/FYTable.vue |   64 +++++++++++++++++++++++++++++---
 1 files changed, 58 insertions(+), 6 deletions(-)

diff --git a/src/components/table/FYTable.vue b/src/components/table/FYTable.vue
index bec9d06..b759ee0 100644
--- a/src/components/table/FYTable.vue
+++ b/src/components/table/FYTable.vue
@@ -28,12 +28,19 @@
     <slot name="options-expand2"></slot>
   </div>
   <el-table
+    v-bind="$attrs"
+    ref="tableRef"
     :data="tableData"
     v-loading="loading"
     table-layout="fixed"
     :row-class-name="tableRowClassName"
     :height="tableHeight"
     :size="fontSize"
+    @cell-click="cellClick"
+    :cell-class-name="cellClassName"
+    @paste="handlePaste"
+    @sort-change="handleSortChange"
+    :show-overflow-tooltip="true"
     border
   >
     <slot name="table-column" :size="fontSize"></slot>
@@ -64,6 +71,7 @@
 export default {
   props: {
     rowClassName: undefined,
+    cellClassName: Function || String,
     pagination: {
       type: Boolean,
       default: true
@@ -72,6 +80,14 @@
     size: {
       type: String,
       default: 'default'
+    },
+    data: {
+      type: Array,
+      default: () => []
+    },
+    totalCount: {
+      type: Number,
+      default: 0
     }
   },
   data() {
@@ -85,7 +101,7 @@
       fontSize: 'default'
     };
   },
-  emits: ['search'],
+  emits: ['search', 'cellClick', 'tablePaste', 'sortChange'],
   watch: {
     currentPage(nValue, oValue) {
       if (nValue != oValue) {
@@ -104,13 +120,25 @@
         }
       },
       immediate: true
+    },
+    data(nValue, oValue) {
+      if (nValue != oValue) {
+        this.tableData = nValue;
+      }
+    },
+    totalCount(nValue, oValue) {
+      if (nValue != oValue) {
+        this.total = nValue;
+      }
     }
   },
   computed: {
     cTableHeight() {
       if (this.$refs.searchRef) {
         const h1 = this.$refs.searchRef.$el.offsetHeight;
-        const h2 = this.$refs.paginationRef ? this.$refs.paginationRef.$el.offsetHeight : 0;
+        const h2 = this.$refs.paginationRef
+          ? this.$refs.paginationRef.$el.offsetHeight
+          : 0;
         const h3 = this.$refs.expandRef.$el.offsetHeight;
         const h4 = this.$refs.expand2Ref.offsetHeight;
 
@@ -137,15 +165,24 @@
           pageSize: this.pageSize
         },
         (res) => {
-          this.tableData = res.data;
-          this.total = res.total ? res.total : 0;
+          if (res) {
+            if (res.data) {
+              this.tableData = res.data;
+            }
+            if (res.total) {
+              this.total = res.total;
+            }
+          }
           this.loading = false;
+          this.doLayout();
         }
       );
     },
     calcTableHeight() {
       const h1 = this.$refs.searchRef.$el.offsetHeight;
-      const h2 = this.$refs.paginationRef ? this.$refs.paginationRef.$el.offsetHeight : 0;
+      const h2 = this.$refs.paginationRef
+        ? this.$refs.paginationRef.$el.offsetHeight
+        : 0;
       const h3 = this.$refs.expandRef.$el.offsetHeight;
       const h4 = this.$refs.expand2Ref.offsetHeight;
 
@@ -163,12 +200,27 @@
       } else {
         return row.extension1 != '0' ? 'online-row' : 'offline-row';
       }
+    },
+    cellClick(row, column, cell, event) {
+      this.$emit('cellClick', row, column, cell, event);
+    },
+    handlePaste(event) {
+      this.$emit('tablePaste', event);
+    },
+    doLayout() {
+      this.$refs.tableRef.doLayout();
+    },
+    handleSortChange({ column, prop, order }) {
+      this.$emit('sortChange', { column, prop, order });
+    },
+    clearSort() {
+      this.$refs.tableRef.clearSort();
     }
   },
   mounted() {
     this.tableHeight = this.calcTableHeight();
     this.onSearch();
-  }
+  },
 };
 </script>
 

--
Gitblit v1.9.3