这段代码 如何进一步优化,例如进一步提炼封装,请教各位大神,谢谢!
filterColumn(){
if(this.searchFilter.asinType === 'sku'){
this.vxeGridTableColumnList.map(item => {
(item.field === 'msku' || item.field === 'asin') && this.columnDynamicShow(item,1)
item.field === 'sku' && this.columnDynamicShow(item,3)
item.field === 'parentAsin' && this.columnDynamicShow(item,2)
item.field === 'devName' && (item.title = '开发员')
})
}
if(this.searchFilter.asinType === 'parentAsin'){
this.vxeGridTableColumnList.map(item => {
if(item.field === 'msku' || item.field === 'sku') this.columnDynamicShow(item,2)
if(item.field === 'asin' || item.field === 'parentAsin') this.columnDynamicShow(item,1)
item.field === 'parentAsin' && this.columnDynamicShow(item,3)
item.field === 'devName' && (item.title = '业务员')
})
}
if(this.searchFilter.asinType === 'msku'){
this.vxeGridTableColumnList.map(item => {
item.field === 'msku' && this.columnDynamicShow(item,3)
if(item.field === 'asin' || item.field === 'sku') this.columnDynamicShow(item,1)
item.field === 'parentAsin' && this.columnDynamicShow(item,2)
item.field === 'devName' && (item.title = '业务员')
})
}
if(this.searchFilter.asinType === 'asin'){
this.vxeGridTableColumnList.map(item => {
(item.field === 'msku' || item.field === 'parentAsin') && this.columnDynamicShow(item,2)
item.field === 'asin' && this.columnDynamicShow(item,3)
item.field === 'sku' && this.columnDynamicShow(item,2)
item.field === 'devName' && (item.title = '业务员')
})
}
// this.initVTCConfig()
},
columnDynamicShow(item,type){
switch (type){
case 1 : //显示 不固定
item.fixed = ''
item.params.visibleNot = false
break;
case 2 : //不显示 不固定
item.fixed = ''
item.params.visibleNot = true
break;
case 3 : //显示 固定
item.fixed = 'left'
item.params.visibleNot = false
break;
default: break;
}
},