Antdesignvue表格的字段根据⾓⾊等条件显隐
⼀、⾸先在columns中设置所有字段信息,例:
columns: [
{antdesignvuetable动态表头
title: '序号',
dataIndex: '',
key: 'rowIndex',
align: 'center',
customRender: function (t, r, index) {
return parseInt(index) + 1
},
},
{
title: '任务描述',
align: 'center',
dataIndex: 'alarmTitle',
customRender: (t) => ellipsis(t)
},
{
title: '接收⼈员',
align: 'center',
dataIndex: 'realName',
customRender: (t) => ellipsis(t)
},
{
title: '下发⼈员',
align: 'center',
dataIndex: 'xiafaName',
customRender: (t) => ellipsis(t)
},
{
title: '任务下发单位',
align: 'center',
dataIndex: 'lordSendUnitTxt',
},
{
title: '操作',
dataIndex: 'action',
align: 'center',
fixed: 'right',
scopedSlots: { customRender: 'action' },
},
]
其中下发⼈员和接收⼈员字段是根据⾓⾊来显⽰隐藏的【当⾓⾊是isywgl 时不展⽰接收⼈员字段realName,⾮isywgl⾓⾊不展⽰下发⼈员字段xiafaName】
created() {
  // ⽤户在登录时会将⾓⾊信息等存到localStorage,所以这⾥直接从localStorage拿到⽤户的⾓⾊信息
this.isywgl = Item('roleArr').indexOf('ywgl')
},
mounted(){
  if (this.isywgl ==-1) {
   //通过⾓⾊过滤掉需要隐藏的字段
}else{
}
},