【修改】Jtable的变量名修改

This commit is contained in:
zer0Black
2021-04-14 16:12:36 +08:00
parent d9293779ed
commit 043e44c270
+24 -24
View File
@@ -1,7 +1,7 @@
<template> <template>
<div> <div>
<a-table <a-table
:columns="aColumns" :columns="curTableColumns"
:dataSource="dataSource" :dataSource="dataSource"
:pagination="ispagination" :pagination="ispagination"
:rowSelection="rowSelect" :rowSelection="rowSelect"
@@ -12,7 +12,7 @@
<slot :name="slotItem" v-bind="{text, record, index}"></slot> <slot :name="slotItem" v-bind="{text, record, index}"></slot>
</template> </template>
<span :slot="a.slots.title" v-for="a in aColumns" :key="a.dataIndex"> <span :slot="a.slots.title" v-for="a in curTableColumns" :key="a.dataIndex">
{{ a.slots.title }} {{ a.slots.title }}
<a-dropdown :trigger="['click']"> <a-dropdown :trigger="['click']">
<a class="ant-dropdown-link" @click="(e) => e.preventDefault()"> <a class="ant-dropdown-link" @click="(e) => e.preventDefault()">
@@ -99,7 +99,7 @@ export default {
}, },
data() { data() {
return { return {
aColumns: this.columns, curTableColumns: this.columns,
checkedList: [], checkedList: [],
plainOptions: [], plainOptions: [],
radioStyle: { radioStyle: {
@@ -156,10 +156,10 @@ export default {
var storageCloumns = JSON.parse(localStorage.getItem('pro__Cloumns')) var storageCloumns = JSON.parse(localStorage.getItem('pro__Cloumns'))
// console.log(storageCloumns) // console.log(storageCloumns)
if (storageCloumns) { if (storageCloumns) {
this.aColumns = storageCloumns this.curTableColumns = storageCloumns
} }
// 遍历出筛选列头中的已选项 // 遍历出筛选列头中的已选项
this.aColumns.forEach((item) => { this.curTableColumns.forEach((item) => {
this.checkedList.push(item.slots.title) this.checkedList.push(item.slots.title)
}) })
}, },
@@ -198,17 +198,17 @@ export default {
diffList = this.getArrDifference(trfList, initList) diffList = this.getArrDifference(trfList, initList)
if (diffList.length === 0) { if (diffList.length === 0) {
// 如果数组为空,则把父组件传过来的表头赋值给 // 如果数组为空,则把父组件传过来的表头赋值给
this.aColumns = this.columns this.curTableColumns = this.columns
localStorage.setItem('pro__Cloumns', JSON.stringify(this.aColumns)) localStorage.setItem('pro__Cloumns', JSON.stringify(this.curTableColumns))
return return
} }
let midColumns = this.columns let midColumns = this.columns
for (let i = 0; i < diffList.length; i++) { for (let i = 0; i < diffList.length; i++) {
midColumns = midColumns.filter((item) => item.dataIndex !== diffList[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) { getArrDifference(arr1, arr2) {
@@ -224,38 +224,38 @@ export default {
if (e.target.value === 1) { if (e.target.value === 1) {
//左侧冻结 //左侧冻结
this.aColumns.find((item) => { this.curTableColumns.find((item) => {
if (item.dataIndex === dataIndex) { if (item.dataIndex === dataIndex) {
item.fixed = 'left' item.fixed = 'left'
} }
}) })
// 左侧冻结,先把冻结项删除,再unshift到数组首位 // 左侧冻结,先把冻结项删除,再unshift到数组首位
let arr let arr
for (let i = 0; i < this.aColumns.length; i++) { for (let i = 0; i < this.curTableColumns.length; i++) {
if (this.aColumns[i].dataIndex === dataIndex) { if (this.curTableColumns[i].dataIndex === dataIndex) {
arr = this.aColumns.splice(i, 1) arr = this.curTableColumns.splice(i, 1)
break break
} }
} }
this.aColumns.unshift(arr[0]) this.curTableColumns.unshift(arr[0])
} else if (e.target.value === 2) { } else if (e.target.value === 2) {
//右侧冻结 //右侧冻结
this.aColumns.find((item) => { this.curTableColumns.find((item) => {
if (item.dataIndex === dataIndex) { if (item.dataIndex === dataIndex) {
item.fixed = 'right' item.fixed = 'right'
} }
}) })
// 右侧冻结,先把冻结项删除,再push到数组末位 // 右侧冻结,先把冻结项删除,再push到数组末位
let arr let arr
for (let i = 0; i < this.aColumns.length; i++) { for (let i = 0; i < this.curTableColumns.length; i++) {
if (this.aColumns[i].dataIndex === dataIndex) { if (this.curTableColumns[i].dataIndex === dataIndex) {
arr = this.aColumns.splice(i, 1) arr = this.curTableColumns.splice(i, 1)
break break
} }
} }
this.aColumns.push(arr[0]) this.curTableColumns.push(arr[0])
} else { } else {
this.aColumns.find((item) => { this.curTableColumns.find((item) => {
//解冻 //解冻
if (item.dataIndex === dataIndex) { if (item.dataIndex === dataIndex) {
item.fixed = false item.fixed = false
@@ -269,17 +269,17 @@ export default {
let newColumnsList = [] //没有fixed属性的List let newColumnsList = [] //没有fixed属性的List
let newFixedLeftList = [] //fixed=left的List let newFixedLeftList = [] //fixed=left的List
let newFixedRightList = [] //fixed=right的List let newFixedRightList = [] //fixed=right的List
this.aColumns.forEach((item) => { this.curTableColumns.forEach((item) => {
if (!item.fixed) { if (!item.fixed) {
newColumnsList.push(item) newColumnsList.push(item)
} }
}) })
this.aColumns.forEach((item) => { this.curTableColumns.forEach((item) => {
if (item.fixed === 'left') { if (item.fixed === 'left') {
newFixedLeftList.push(item) newFixedLeftList.push(item)
} }
}) })
this.aColumns.forEach((item) => { this.curTableColumns.forEach((item) => {
if (item.fixed === 'right') { if (item.fixed === 'right') {
newFixedRightList.push(item) newFixedRightList.push(item)
} }
@@ -293,7 +293,7 @@ export default {
} }
} }
// 解构赋值,重新定义列头List // 解构赋值,重新定义列头List
this.aColumns = [...[...newFixedLeftList, ...newColumnsList], ...newFixedRightList] this.curTableColumns = [...[...newFixedLeftList, ...newColumnsList], ...newFixedRightList]
}, },
}, },
} }