可以使用条件语句来判断是否隐藏领导这一列。以下是一个示例代码:

// 列表字段
const columns = [
  { id: '0', name: '序号', code: 'xh', width: 65, align: 'center' , checked: true  },
  { id: '1', name: '标题', code: 'title', minWidth: 200, sortable: 'custom' , checked: true  },
  { id: '2', name: '发文号', code: 'fwh', width: 200, sortable: 'custom' },
  { id: '2', name: '拟稿人', code: 'createusername', width: 120, sortable: 'custom', checked: true   },
  { id: '3', name: '拟稿部门', code: 'createdeptname', width: 150, sortable: 'custom', checked: true   },
  { id: '4', name: '发文类型', code: 'ywname', minWidth: 170, sortable: 'custom' , checked: true  },
  { id: '5', name: '拟稿时间', code: 'createtime', width: 140, sortable: 'custom'},
  { id: '2', name: '缓急状态', code: 'hjname', width: 110, sortable: 'custom' },
  { id: '6', name: '到达日期', code: 'taskCreateTime', width: 200, sortable: 'custom' , checked: true  },
  { id: '4', name: '密级', code: 'mjname', width: 90, align: 'center', sortable: 'custom'},
  { id: '7', name: '当前节点', code: 'taskName', minWidth: 110, sortable: 'custom', checked: true   },
  { id: '8', name: '传阅状态', code: 'handlerstatus', minWidth: 110, sortable: 'custom', checked: true  },
  { id: '8', name: '领导', code: 'ld',  width: 100, sortable: 'custom', checked: true  },
  { id: '9', name: '延误天数', code: 'duration', minWidth: 110, sortable: 'custom' , checked: true  },
  { id: '10', name: '状态', code: 'status', width: 90, align: 'center', sortable: 'custom'}
];

const hideLeadersColumn = true; // 根据具体的条件设置为true或false

if (hideLeadersColumn) {
  const columnIndex = columns.findIndex(column => column.code === 'ld');
  if (columnIndex !== -1) {
    columns.splice(columnIndex, 1);
  }
}

console.log(columns);

在上面的示例代码中,设置变量hideLeadersColumntrue表示需要隐藏领导这一列。通过findIndex方法找到领导这一列在columns数组中的索引,然后使用splice方法将这一列从数组中移除。最后,打印输出更新后的columns数组。


原文地址: https://www.cveoy.top/t/topic/pKic 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录