columns.tsx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import { ref } from "vue";
  2. import dayjs from "dayjs";
  3. import { statusList, levelList } from "/@/utils/status";
  4. export function useColumns() {
  5. const columns = ref([
  6. {
  7. type: "selection",
  8. width: 55,
  9. hide: ({ checkList }) => !checkList.includes("勾选列")
  10. },
  11. {
  12. label: "序号",
  13. type: "index",
  14. width: 70,
  15. hide: ({ checkList }) => !checkList.includes("序号列")
  16. },
  17. {
  18. label: "角色名称",
  19. prop: "role_name"
  20. },
  21. // {
  22. // label: "业务公司",
  23. // prop: "companyName"
  24. // },
  25. {
  26. label: "等级",
  27. prop: "level",
  28. cellRenderer: ({ row, props }) => (
  29. <el-tag
  30. size={props.size}
  31. type={
  32. (levelList.find(item => item.value == row.level + "") || {}).type ||
  33. "info"
  34. }
  35. effect="plain"
  36. >
  37. {(levelList.find(item => item.value == row.level + "") || {}).label ||
  38. "--"}
  39. </el-tag>
  40. )
  41. },
  42. {
  43. label: "状态",
  44. prop: "status",
  45. cellRenderer: ({ row, props }) => (
  46. <el-tag
  47. size={props.size}
  48. type={
  49. (statusList.find(item => item.value == row.status + "") || {})
  50. .type || "info"
  51. }
  52. effect="plain"
  53. >
  54. {(statusList.find(item => item.value == row.status + "") || {})
  55. .label || "--"}
  56. </el-tag>
  57. )
  58. },
  59. {
  60. label: "创建时间",
  61. prop: "createTime",
  62. formatter: ({ addtime }) => dayjs(addtime).format("YYYY-MM-DD HH:mm:ss")
  63. },
  64. {
  65. label: "操作",
  66. fixed: "right",
  67. width: 145,
  68. slot: "operation"
  69. }
  70. ]);
  71. return {
  72. columns
  73. };
  74. }