data.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. import { BasicColumn, FormSchema } from '/@/components/Table';
  2. import { validateStr } from '/@/utils/validate';
  3. export const columns: BasicColumn[] = [
  4. {
  5. title: '字典项名称',
  6. dataIndex: 'label',
  7. },
  8. {
  9. title: '字典项编码',
  10. dataIndex: 'value',
  11. width: 120,
  12. },
  13. {
  14. title: '颜色',
  15. dataIndex: 'color',
  16. width: 120,
  17. },
  18. {
  19. title: '排序',
  20. dataIndex: 'sort',
  21. width: 80,
  22. },
  23. {
  24. title: '备注',
  25. dataIndex: 'remark',
  26. },
  27. ];
  28. export const searchFormSchema: FormSchema[] = [
  29. {
  30. field: 'dictItemName',
  31. label: '字典项名称',
  32. component: 'Input',
  33. componentProps: {
  34. placeholder: '请输入字典项名称',
  35. },
  36. },
  37. {
  38. field: 'dictItemCode',
  39. label: '字典项编码',
  40. component: 'Input',
  41. componentProps: {
  42. placeholder: '请输入字典项编码',
  43. },
  44. },
  45. ];
  46. export const dataFormSchema: FormSchema[] = [
  47. {
  48. field: 'label',
  49. label: '字典项名称',
  50. component: 'Input',
  51. required: true,
  52. componentProps: {
  53. placeholder: '请输入字典项名称',
  54. },
  55. },
  56. {
  57. field: 'value',
  58. label: '字典项编码',
  59. component: 'Input',
  60. required: true,
  61. componentProps: {
  62. placeholder: '请输入字典项编码',
  63. },
  64. dynamicRules: () => {
  65. return [
  66. {
  67. required: true,
  68. validator: async (_, value) => {
  69. if (!value) {
  70. return Promise.reject('字典项编码不能为空');
  71. }
  72. if (validateStr(value)) {
  73. return Promise.reject('字典项编码为字母或数字组成');
  74. }
  75. return Promise.resolve();
  76. },
  77. },
  78. ];
  79. },
  80. },
  81. {
  82. field: 'color',
  83. label: '颜色',
  84. component: 'FormColorPicker',
  85. componentProps: ({ formModel }) => {
  86. return {
  87. onChange: e => {
  88. formModel.color = e;
  89. },
  90. };
  91. },
  92. },
  93. {
  94. field: 'sort',
  95. label: '排序',
  96. component: 'InputNumber',
  97. required: true,
  98. defaultValue: '1',
  99. componentProps: {
  100. placeholder: '请输入排序',
  101. min: 1,
  102. },
  103. },
  104. {
  105. label: '备注',
  106. field: 'remark',
  107. component: 'InputTextArea',
  108. componentProps: {
  109. placeholder: '请输入备注',
  110. },
  111. },
  112. ];