From 043e44c2705c58ab6ecd6a83366ba5ef5d75838f Mon Sep 17 00:00:00 2001 From: zer0Black Date: Wed, 14 Apr 2021 16:12:36 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E3=80=91Jtable?= =?UTF-8?q?=E7=9A=84=E5=8F=98=E9=87=8F=E5=90=8D=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jero-web/src/components/jero/JTable.vue | 48 ++++++++++++------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/jero-web/src/components/jero/JTable.vue b/jero-web/src/components/jero/JTable.vue index 7b5d1ec8..9ca4147b 100644 --- a/jero-web/src/components/jero/JTable.vue +++ b/jero-web/src/components/jero/JTable.vue @@ -1,7 +1,7 @@ - + {{ a.slots.title }} @@ -99,7 +99,7 @@ export default { }, data() { return { - aColumns: this.columns, + curTableColumns: this.columns, checkedList: [], plainOptions: [], radioStyle: { @@ -156,10 +156,10 @@ export default { var storageCloumns = JSON.parse(localStorage.getItem('pro__Cloumns')) // console.log(storageCloumns) if (storageCloumns) { - this.aColumns = storageCloumns + this.curTableColumns = storageCloumns } // 遍历出筛选列头中的已选项 - this.aColumns.forEach((item) => { + this.curTableColumns.forEach((item) => { this.checkedList.push(item.slots.title) }) }, @@ -198,17 +198,17 @@ export default { diffList = this.getArrDifference(trfList, initList) if (diffList.length === 0) { // 如果数组为空,则把父组件传过来的表头赋值给 - this.aColumns = this.columns - localStorage.setItem('pro__Cloumns', JSON.stringify(this.aColumns)) + this.curTableColumns = this.columns + localStorage.setItem('pro__Cloumns', JSON.stringify(this.curTableColumns)) return } let midColumns = this.columns for (let i = 0; i < diffList.length; i++) { midColumns = midColumns.filter((item) => item.dataIndex !== diffList[i]) } - this.aColumns = midColumns + this.curTableColumns = midColumns - localStorage.setItem('pro__Cloumns', JSON.stringify(this.aColumns)) + localStorage.setItem('pro__Cloumns', JSON.stringify(this.curTableColumns)) }, // 比较两个数组之间的不同,生成新数组 getArrDifference(arr1, arr2) { @@ -224,38 +224,38 @@ export default { if (e.target.value === 1) { //左侧冻结 - this.aColumns.find((item) => { + this.curTableColumns.find((item) => { if (item.dataIndex === dataIndex) { item.fixed = 'left' } }) // 左侧冻结,先把冻结项删除,再unshift到数组首位 let arr - for (let i = 0; i < this.aColumns.length; i++) { - if (this.aColumns[i].dataIndex === dataIndex) { - arr = this.aColumns.splice(i, 1) + for (let i = 0; i < this.curTableColumns.length; i++) { + if (this.curTableColumns[i].dataIndex === dataIndex) { + arr = this.curTableColumns.splice(i, 1) break } } - this.aColumns.unshift(arr[0]) + this.curTableColumns.unshift(arr[0]) } else if (e.target.value === 2) { //右侧冻结 - this.aColumns.find((item) => { + this.curTableColumns.find((item) => { if (item.dataIndex === dataIndex) { item.fixed = 'right' } }) // 右侧冻结,先把冻结项删除,再push到数组末位 let arr - for (let i = 0; i < this.aColumns.length; i++) { - if (this.aColumns[i].dataIndex === dataIndex) { - arr = this.aColumns.splice(i, 1) + for (let i = 0; i < this.curTableColumns.length; i++) { + if (this.curTableColumns[i].dataIndex === dataIndex) { + arr = this.curTableColumns.splice(i, 1) break } } - this.aColumns.push(arr[0]) + this.curTableColumns.push(arr[0]) } else { - this.aColumns.find((item) => { + this.curTableColumns.find((item) => { //解冻 if (item.dataIndex === dataIndex) { item.fixed = false @@ -269,17 +269,17 @@ export default { let newColumnsList = [] //没有fixed属性的List let newFixedLeftList = [] //fixed=left的List let newFixedRightList = [] //fixed=right的List - this.aColumns.forEach((item) => { + this.curTableColumns.forEach((item) => { if (!item.fixed) { newColumnsList.push(item) } }) - this.aColumns.forEach((item) => { + this.curTableColumns.forEach((item) => { if (item.fixed === 'left') { newFixedLeftList.push(item) } }) - this.aColumns.forEach((item) => { + this.curTableColumns.forEach((item) => { if (item.fixed === 'right') { newFixedRightList.push(item) } @@ -293,7 +293,7 @@ export default { } } // 解构赋值,重新定义列头List - this.aColumns = [...[...newFixedLeftList, ...newColumnsList], ...newFixedRightList] + this.curTableColumns = [...[...newFixedLeftList, ...newColumnsList], ...newFixedRightList] }, }, }