data.ts 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. import { BasicColumn, FormSchema } from '/@/components/Table';
  2. import { listDictModel } from '/@/api/common';
  3. import { validateStr } from '/@/utils/validate';
  4. export const columns: BasicColumn[] = [
  5. {
  6. title: '字典名称',
  7. dataIndex: 'dictName',
  8. },
  9. {
  10. title: '字典编码',
  11. dataIndex: 'dictCode',
  12. },
  13. {
  14. title: '字典类型',
  15. dataIndex: 'dictType',
  16. },
  17. {
  18. title: '状态',
  19. dataIndex: 'disable',
  20. width: 80,
  21. },
  22. {
  23. title: '备注',
  24. dataIndex: 'remark',
  25. },
  26. ];
  27. export const searchFormSchema: FormSchema[] = [
  28. {
  29. field: 'dictName',
  30. label: '字典名称',
  31. component: 'Input',
  32. componentProps: {
  33. placeholder: '请输入字典名称',
  34. },
  35. },
  36. {
  37. field: 'dictCode',
  38. label: '字典编码',
  39. component: 'Input',
  40. componentProps: {
  41. placeholder: '请输入字典编码',
  42. },
  43. },
  44. {
  45. field: 'dictType',
  46. label: '字典类型',
  47. component: 'ApiSelect',
  48. componentProps: {
  49. api: listDictModel,
  50. params: {
  51. dictCode: 'sys_dict_type',
  52. },
  53. },
  54. defaultValue: '0',
  55. ifShow: false,
  56. },
  57. ];
  58. export const dataFormSchema: FormSchema[] = [
  59. {
  60. field: 'dictName',
  61. label: '字典名称',
  62. component: 'Input',
  63. required: true,
  64. componentProps: {
  65. placeholder: '请输入字典名称',
  66. },
  67. },
  68. {
  69. field: 'dictCode',
  70. label: '字典编码',
  71. component: 'Input',
  72. required: true,
  73. componentProps: {
  74. placeholder: '请输入字典编码',
  75. },
  76. dynamicRules: () => {
  77. return [
  78. {
  79. required: true,
  80. validator: async (_, value) => {
  81. if (!value) {
  82. return Promise.reject('字典项编码不能为空');
  83. }
  84. if (validateStr(value)) {
  85. return Promise.reject('字典项编码为字母或数字组成');
  86. }
  87. return Promise.resolve();
  88. },
  89. },
  90. ];
  91. },
  92. },
  93. {
  94. field: 'dictType',
  95. label: '字典类型',
  96. component: 'ApiSelect',
  97. required: true,
  98. componentProps: {
  99. api: listDictModel,
  100. params: {
  101. dictCode: 'sys_dict_type',
  102. },
  103. },
  104. },
  105. {
  106. field: 'disable',
  107. label: '状态',
  108. component: 'ApiRadioGroup',
  109. required: true,
  110. componentProps: {
  111. api: listDictModel,
  112. params: {
  113. dictCode: 'sys_disable_type',
  114. },
  115. },
  116. defaultValue: '0',
  117. },
  118. {
  119. label: '备注',
  120. field: 'remark',
  121. component: 'InputTextArea',
  122. componentProps: {
  123. placeholder: '请输入备注',
  124. },
  125. },
  126. ];