dept.data.ts 2.1 KB

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