data.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import { h } from 'vue';
  2. import { Tag } from 'ant-design-vue';
  3. import { BasicColumn } from '/@/components/Table';
  4. import { FormSchema } from '/@/components/Form/index';
  5. import { adapt } from '/@/utils/adapt';
  6. const adaptWidth = adapt();
  7. export const columns: BasicColumn[] = [
  8. {
  9. title: 'ID',
  10. dataIndex: 'id',
  11. align: 'left',
  12. editComponentProps: {
  13. prefix: '$',
  14. },
  15. width: 150,
  16. },
  17. {
  18. title: '父级',
  19. dataIndex: 'pid',
  20. width: 160,
  21. },
  22. {
  23. title: '名称',
  24. dataIndex: 'name',
  25. width: 160,
  26. },
  27. {
  28. title: '状态',
  29. dataIndex: 'status',
  30. width: 80,
  31. customRender: ({ record }) => {
  32. const status = record.status;
  33. const enable = status === 'normal';
  34. const color = enable ? 'green' : 'red';
  35. const text = enable ? '启用' : '停用';
  36. return h(Tag, { color: color }, () => text);
  37. },
  38. },
  39. ];
  40. // popup =====================================================
  41. export const schemas: FormSchema[] = [
  42. {
  43. field: 'pid',
  44. label: '父级',
  45. component: 'TreeSelect',
  46. componentProps: {
  47. replaceFields: {
  48. title: 'name',
  49. key: 'id',
  50. value: 'id',
  51. },
  52. getPopupContainer: () => document.body,
  53. },
  54. labelWidth: adaptWidth.labelWidth,
  55. colProps: {
  56. span: adaptWidth.elContainer,
  57. },
  58. },
  59. {
  60. field: 'name',
  61. component: 'Input',
  62. label: '名称',
  63. labelWidth: adaptWidth.labelWidth,
  64. colProps: {
  65. span: adaptWidth.elContainer,
  66. },
  67. },
  68. // {
  69. // field: 'rules',
  70. // component: 'Input',
  71. // label: '规则',
  72. // labelWidth: adaptWidth.labelWidth,
  73. // colProps: {
  74. // span: adaptWidth.elContainer,
  75. // },
  76. // },
  77. {
  78. field: 'status',
  79. label: '状态',
  80. component: 'RadioButtonGroup',
  81. defaultValue: 'normal',
  82. componentProps: {
  83. options: [
  84. { label: '启用', value: 'normal' },
  85. { label: '停用', value: 'locked' },
  86. ],
  87. },
  88. labelWidth: adaptWidth.labelWidth,
  89. colProps: {
  90. span: adaptWidth.elContainer,
  91. },
  92. },
  93. ];