From 235560b9d7cff1d7dce1f90a08df56d6ef8dd682 Mon Sep 17 00:00:00 2001
From: xiejun <xj@2023>
Date: 星期四, 15 六月 2023 10:27:42 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 Source/UBCS-WEB/src/components/template/TableTransfer.vue |  106 +++++++++++++++++++++++++++-------------------------
 1 files changed, 55 insertions(+), 51 deletions(-)

diff --git a/Source/UBCS-WEB/src/components/template/TableTransfer.vue b/Source/UBCS-WEB/src/components/template/TableTransfer.vue
index 488fb95..abedd0d 100644
--- a/Source/UBCS-WEB/src/components/template/TableTransfer.vue
+++ b/Source/UBCS-WEB/src/components/template/TableTransfer.vue
@@ -1,5 +1,5 @@
 <template>
-    <el-dialog :title="title" width="70%" append-to-body="true" :visible.sync="dialogVisible">
+    <el-dialog :title="title" width="70%" append-to-body="true" :visible.sync="dialogVisible" @close="handelClose">
         <el-row :gutter="20">
             <el-col :span="11">
                 <el-card class="box-card">
@@ -8,9 +8,9 @@
                         <el-input class="input" v-if="showSearch" v-model="searchLeft" placeholder="璇疯緭鍏ユ悳绱㈠唴瀹�"
                             @keyup.enter.native="handleEnter"></el-input>
                     </div>
-                    <el-table ref="transferLeftTable" :data="leftData" height="500" highlight-current-row
-                        tooltip-effect="dark" @selection-change="handleLeftSelectionChange" @row-click="handleLeftRowClick">
-                        <el-table-column type="selection" width="50" align="center" fixed="left" :selectable="selectable" />
+                    <el-table ref="transferTable" :data="leftData" height="500" highlight-current-row tooltip-effect="dark"
+                        @selection-change="handleLeftSelectionChange" @row-click="handleLeftRowClick">
+                        <el-table-column type="selection" width="50" align="center" fixed="left" />
                         <div v-for="(item, index) in columns" :key="index">
                             <el-table-column v-if="item.visible" :label="item.label" align="center" :prop="item.key" />
                         </div>
@@ -74,7 +74,7 @@
         //涓婚敭key鍊�
         keyName: {
             type: String,
-            default: "id",
+            default: "oid",
         },
         columns: {
             type: Array,
@@ -116,17 +116,12 @@
             },
             deep: true,
         },
-        dataList: {
-            handler(data) {
-                console.log(data)
-
-            },
-            deep: true,
-        }
     },
     data() {
         return {
             dialogVisible: this.visible,
+            indeterminate: false,
+            isCheck: false,
             searchLeft: "",
             leftIds: [],
             leftMultiple: true,
@@ -141,25 +136,26 @@
     },
     mounted() {
         this.init();
+        console.log(this.$refs.transferTable)
     },
     methods: {
-        selectable(row, index) {
-            console.log(row)
-            return row.checked === false //涓簍rue鐨勬椂鍊欏彲浠ラ�夛紝涓篺alse鍒欎笉鍙�夋嫨
-        },
         init() {
-            this.rightIds = this.value;
-            console.log(this.rightIds)
-            for (let i = 0; i < this.dataList.length; i++) {
-                if (this.value.some((item) => item == this.dataList[i][this.keyName])) {
-                    this.rightDataList.push(this.dataList[i]);
-                } else {
-                    this.leftDataList.push(this.dataList[i]);
+            let that = this
+            that.rightIds = that.value;
+            for (let i = 0; i < that.dataList.length; i++) {
+                if (that.value.some((item) => item == that.dataList[i][that.keyName])) {
+                    that.rightDataList.push(that.dataList[i]);
                 }
+                // else{
+                //     that.leftDataList.push(that.dataList[i])
+                // }
+                that.leftDataList.push(that.dataList[i])
+
             }
-            this.leftData = [...this.leftDataList];
-            this.rightData = [...this.rightDataList];
+            that.leftData = [...that.leftDataList];
+            that.rightData = [...that.rightDataList];
         },
+
         // left澶氶�夋閫変腑鏁版嵁
         handleLeftSelectionChange(selection) {
             this.leftIds = selection.map((item) => item[this.keyName]);
@@ -176,21 +172,26 @@
                 let a = this.leftIds.findIndex(
                     (item) => item == this.leftDataList[i][this.keyName]
                 );
-                console.log(a)
                 if (a !== -1) {
-                    this.rightDataList.push(this.leftDataList[i]);
-                    // this.leftDataList[i].checked = true
-                    // this.$refs.transferLeftTable.toggleRowSelection(this.leftDataList[i],true)
-                    this.$delete(this.leftDataList, i);
-                    i--;
+                    let moveLefti = this.leftDataList[i];//宸﹁竟缃楄繃鏉ョ殑
+                    let moveLeftiKey = moveLefti['id'];
+                    let isMove = true;
+                    for (let j = 0; j < this.rightDataList.length; j++) {
+                        let rifhtDataListi = this.rightDataList[j];//鍙宠竟寰幆鍑烘潵鐨勬瘡涓�涓�
+                        let rightDataListiKey = rifhtDataListi['id'];//姣忎竴涓猭ey
+                        if (rightDataListiKey == moveLeftiKey) {
+                            isMove = false;
+                            break;
+                        }
+                    }
+                    if (isMove) {
+                        this.rightDataList.push(this.leftDataList[i]);
+                        this.leftDataList[i].checked = true
+                        // this.$delete(this.leftDataList, i);
+                        // i--;
+                    }
                 }
             }
-            // let obj = {}
-            // let filterright = this.rightDataList.reduce((cur, next) => {
-            //     obj[next.id] ? "" : obj[next.id] = true && cur.push(next);
-            //     return cur;
-            // }, [])
-            // console.log('filterright', filterright)
             this.leftData = this.setData(this.leftDataList, this.searchLeft);
             this.rightData = this.setData(this.rightDataList, this.searchRight);
             this.$emit(
@@ -205,17 +206,13 @@
                     (item) => item == this.rightDataList[i][this.keyName]
                 );
                 if (a !== -1) {
-                    this.leftDataList.push(this.rightDataList[i]);
+                    this.leftDataList[i].checked = false
+                    // this.leftDataList.push(this.rightDataList[i]);
                     this.$delete(this.rightDataList, i);
                     i--;
                 }
             }
-            // let obj = {}
-            // let filterleft = this.leftDataList.reduce((cur, next) => {
-            //     obj[next.id] ? "" : obj[next.id] = true && cur.push(next);
-            //     return cur;
-            // }, [])
-            // console.log('filterright', filterleft)
+            console.log(this.rightDataList)
             this.leftData = this.setData(this.leftDataList, this.searchLeft);
             this.rightData = this.setData(this.rightDataList, this.searchRight);
             this.$emit(
@@ -233,9 +230,9 @@
         // 鍗曢��
         handleLeftRowClick(row) {
             if (this.leftData) {
-                this.$refs.transferLeftTable.toggleRowSelection(row)
+                this.$refs.transferTable.toggleRowSelection(row)
             } else {
-                this.$refs.transferLeftTable.clearSelection()
+                this.$refs.transferTable.clearSelection()
             }
         },
         // 鍗曢��
@@ -268,16 +265,23 @@
             console.log(this.value)
         },
         done() {
+            this.leftData = []
+            this.leftDataList = []
+            this.rightDataList = []
+            this.rightData = []
             this.dialogVisible = false
         },
         tableTransferSave() {
             this.$emit('save', this.rightData)
-            this.leftData = [...this.rightData, ...this.leftData]
-            this.leftDataList = [...this.rightDataList, ...this.leftDataList]
-            this.rightDataList = []
-            this.rightData = []
+            this.done()
 
-        }
+
+        },
+        // 鍏抽棴娓呴櫎鎵�鏈夋暟鎹�
+        handelClose() {
+            this.$emit('close')
+            this.done()
+        },
     },
 }
 </script>

--
Gitblit v1.9.3