From 37a242d6192053d8b72954292d60300460d36eba Mon Sep 17 00:00:00 2001 From: fuliqi <fuliqi@qq.com> Date: 星期一, 25 十一月 2024 22:22:25 +0800 Subject: [PATCH] 项目库排序功能 --- src/views/projectEngineering/projectLibrary/index.vue | 14 ++++++++------ src/components/VisibilityToolbar/index.vue | 18 +++++++++++++++++- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/components/VisibilityToolbar/index.vue b/src/components/VisibilityToolbar/index.vue index 2773bb6..d58270f 100644 --- a/src/components/VisibilityToolbar/index.vue +++ b/src/components/VisibilityToolbar/index.vue @@ -68,6 +68,7 @@ table: false, currentPage: 1, columnRef: null, + cpList: [] }; }, props: { @@ -123,7 +124,22 @@ this.currentPage = page; }, sortChange(row, val) { - this.$emit('update:sort', { key: row.key, serialNumber: val }); + // // 鍒涘缓涓�涓柊鐨刢olumns鏁扮粍锛屼互閬垮厤鐩存帴淇敼鍘熷鏁扮粍 + // this.cpList = this.columns.map(item => ({ ...item })); // 浣跨敤瑙f瀯鏉ュ垱寤哄璞$殑娴呮嫹璐� + // + // // 鏇存柊鎸囧畾椤圭殑serialNumber + // this.cpList.forEach(item => { + // if (item.key === row.key) { + // item.serialNumber = row.serialNumber; + // } + // }); + // + // // 鏍规嵁serialNumber瀵筺ewColumns杩涜鎺掑簭 + // this.cpList = this.cpList.sort((a, b) => a.serialNumber - b.serialNumber); + // + // // 瑙﹀彂浜嬩欢閫氱煡鐖剁粍浠禼olumns宸叉洿鏂帮紙濡傛灉鐖剁粍浠堕渶瑕佺煡閬撹繖涓彉鍖栵級 + // this.$emit('update:sort', this.cpList); + this.$emit('update:sort', row); }, resetSort() { this.$emit('update:resetSort'); diff --git a/src/views/projectEngineering/projectLibrary/index.vue b/src/views/projectEngineering/projectLibrary/index.vue index bdbfa4c..c1ff4cc 100644 --- a/src/views/projectEngineering/projectLibrary/index.vue +++ b/src/views/projectEngineering/projectLibrary/index.vue @@ -189,6 +189,7 @@ </el-form> <el-table + :key="tableKey" ref="elTable" style="margin-top: 20px" v-loading="loading" @@ -205,7 +206,6 @@ v-if="item.visible" :prop="item.id" :label="item.label" - v-bind="item" :min-width="item.minWidth" > <template slot-scope="scope"> @@ -324,6 +324,7 @@ // 寮瑰嚭灞傛爣棰� title: "", // 鏄惁鏄剧ず寮瑰嚭灞� + tableKey: 0, open: false, timeRange: [], // 鏌ヨ鍙傛暟 @@ -353,7 +354,7 @@ {required: true, message: "椤圭洰鍚嶇О涓嶈兘涓虹┖", trigger: "blur"} ], projectStatus: [ - {required: true, message: "椤圭洰鐘舵�� (0鏈紑宸ワ紝1宸插紑宸ワ紝2宸茬宸ワ紝3鏆傚仠)涓嶈兘涓虹┖", trigger: "change"} + {required: true, message: "椤圭洰鐘舵�佷笉鑳戒负绌�", trigger: "change"} ], } }; @@ -402,17 +403,18 @@ return item; }); }, - handleUpdateSort(data) { + handleUpdateSort(row) { console.log( this.columns, '鎺掑簭鍓嶇殑鍒�'); this.columns = this.columns.map(item => { - if (item.key === data.key) { - item.serialNumber = data.serialNumber; + if (item.key === row.key) { + return row; } return item; }); this.defaultColumns = JSON.parse(JSON.stringify(this.columns)).sort((a, b) => a.index - b.index); this.columns.sort((a, b) => a.serialNumber - b.serialNumber); - + //寮哄埗table娓叉煋 + this.tableKey = this.tableKey +1; console.log( this.columns, '鎺掑簭鍚庣殑鍒�'); }, // 鍏抽棴鏂囦欢澶勭悊寮规鐨勬柟娉� -- Gitblit v1.8.0