【修改】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>
<div>
<a-table
:columns="aColumns"
:columns="curTableColumns"
:dataSource="dataSource"
:pagination="ispagination"
:rowSelection="rowSelect"
@@ -12,7 +12,7 @@
<slot :name="slotItem" v-bind="{text, record, index}"></slot>
</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-dropdown :trigger="['click']">
<a class="ant-dropdown-link" @click="(e) => e.preventDefault()">
@@ -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]
},
},
}