dept.data.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import { BasicColumn, FormSchema } from '/@/components/Table';
  2. import { h } from 'vue';
  3. import { Tag } from 'ant-design-vue';
  4. export const columns: BasicColumn[] = [
  5. {
  6. title: '部门名称',
  7. dataIndex: 'deptName',
  8. width: 160,
  9. align: 'left',
  10. },
  11. {
  12. title: '排序',
  13. dataIndex: 'orderNo',
  14. width: 50,
  15. },
  16. {
  17. title: '状态',
  18. dataIndex: 'status',
  19. width: 80,
  20. customRender: ({ record }) => {
  21. const status = record.status;
  22. const enable = ~~status === 0;
  23. const color = enable ? 'green' : 'red';
  24. const text = enable ? '启用' : '停用';
  25. return h(Tag, { color: color }, () => text);
  26. },
  27. },
  28. {
  29. title: '创建时间',
  30. dataIndex: 'createTime',
  31. width: 180,
  32. },
  33. {
  34. title: '备注',
  35. dataIndex: 'remark',
  36. },
  37. ];
  38. export const searchFormSchema: FormSchema[] = [
  39. {
  40. field: 'deptName',
  41. label: '部门名称',
  42. component: 'Input',
  43. colProps: { span: 8 },
  44. },
  45. {
  46. field: 'status',
  47. label: '状态',
  48. component: 'Select',
  49. componentProps: {
  50. options: [
  51. { label: '启用', value: '0' },
  52. { label: '停用', value: '1' },
  53. ],
  54. },
  55. colProps: { span: 8 },
  56. },
  57. ];
  58. export const formSchema: FormSchema[] = [
  59. {
  60. field: 'deptName',
  61. label: '部门名称',
  62. component: 'Input',
  63. required: true,
  64. },
  65. {
  66. field: 'parentDept',
  67. label: '上级部门',
  68. component: 'TreeSelect',
  69. ifShow({ values }) {
  70. const { deptName, parentDept } = values;
  71. // Hide without a parentDept when editing
  72. return parentDept || (!deptName && !parentDept);
  73. },
  74. componentProps: {
  75. fieldNames: {
  76. label: 'deptName',
  77. key: 'id',
  78. value: 'id',
  79. },
  80. getPopupContainer: () => document.body,
  81. },
  82. required: true,
  83. },
  84. {
  85. field: 'orderNo',
  86. label: '排序',
  87. component: 'InputNumber',
  88. required: true,
  89. },
  90. {
  91. field: 'status',
  92. label: '状态',
  93. component: 'RadioButtonGroup',
  94. defaultValue: '0',
  95. componentProps: {
  96. options: [
  97. { label: '启用', value: '0' },
  98. { label: '停用', value: '1' },
  99. ],
  100. },
  101. required: true,
  102. },
  103. {
  104. label: '备注',
  105. field: 'remark',
  106. component: 'InputTextArea',
  107. },
  108. ];