data.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. import { BasicColumn, FormSchema } from '/@/components/Table';
  2. import { sysDictQueryTree } from '/@/api/sys/sysDictApi';
  3. export const columns: BasicColumn[] = [
  4. {
  5. title: '字典名称',
  6. dataIndex: 'dictName',
  7. },
  8. {
  9. title: '字典编码',
  10. dataIndex: 'dictCode',
  11. },
  12. {
  13. title: '字典类型',
  14. dataIndex: 'dictType',
  15. },
  16. {
  17. title: '字体颜色',
  18. dataIndex: 'fontColor',
  19. width: 120,
  20. },
  21. {
  22. title: '背景颜色',
  23. dataIndex: 'bgColor',
  24. width: 120,
  25. },
  26. {
  27. title: '前缀颜色',
  28. dataIndex: 'prefixColor',
  29. width: 120,
  30. },
  31. {
  32. title: '排序',
  33. dataIndex: 'sort',
  34. width: 80,
  35. },
  36. {
  37. title: '备注',
  38. dataIndex: 'remark',
  39. },
  40. ];
  41. export const searchFormSchema: FormSchema[] = [
  42. {
  43. field: 'dictName',
  44. label: '字典名称',
  45. component: 'Input',
  46. componentProps: {
  47. placeholder: '请输入字典名称',
  48. },
  49. },
  50. {
  51. field: 'dictCode',
  52. label: '字典编码',
  53. component: 'Input',
  54. componentProps: {
  55. placeholder: '请输入字典编码',
  56. },
  57. },
  58. ];
  59. export const dataFormSchema: FormSchema[] = [
  60. {
  61. field: 'dictType',
  62. label: '字典类型',
  63. component: 'Input',
  64. componentProps: {
  65. placeholder: '请输入字典类型',
  66. },
  67. show: false,
  68. },
  69. {
  70. field: 'parentId',
  71. label: '上级字典',
  72. required: true,
  73. component: 'ApiTreeSelect',
  74. componentProps: ({ formModel }) => {
  75. return {
  76. placeholder: '请选择上级字典',
  77. api: sysDictQueryTree,
  78. // params root 是否手动添加根节点
  79. params: { dictType: formModel.dictType, root: true },
  80. resultField: 'data',
  81. fieldNames: {
  82. label: 'dictName',
  83. key: 'id',
  84. value: 'id',
  85. },
  86. getPopupContainer: () => document.body,
  87. };
  88. },
  89. },
  90. {
  91. field: 'dictName',
  92. label: '字典名称',
  93. component: 'Input',
  94. required: true,
  95. componentProps: {
  96. placeholder: '请输入字典名称',
  97. },
  98. },
  99. {
  100. field: 'dictCode',
  101. label: '字典编码',
  102. component: 'Input',
  103. required: true,
  104. componentProps: {
  105. placeholder: '请输入字典编码',
  106. },
  107. dynamicRules: () => {
  108. return [
  109. {
  110. required: true,
  111. validator: async (_, value) => {
  112. if (!value) {
  113. return Promise.reject('字典项编码不能为空');
  114. }
  115. // if (validateStr(value)) {
  116. // return Promise.reject('字典项编码为字母或数字组成');
  117. // }
  118. return Promise.resolve();
  119. },
  120. },
  121. ];
  122. },
  123. },
  124. {
  125. field: 'bgColor',
  126. label: '背景颜色',
  127. component: 'FormColorPicker',
  128. componentProps: ({ formModel }) => {
  129. return {
  130. onChange: e => {
  131. formModel.bgColor = e;
  132. },
  133. };
  134. },
  135. },
  136. {
  137. field: 'fontColor',
  138. label: '字体颜色',
  139. component: 'FormColorPicker',
  140. componentProps: ({ formModel }) => {
  141. return {
  142. onChange: e => {
  143. formModel.fontColor = e;
  144. },
  145. };
  146. },
  147. },
  148. {
  149. field: 'prefixColor',
  150. label: '前缀颜色',
  151. component: 'FormColorPicker',
  152. componentProps: ({ formModel }) => {
  153. return {
  154. onChange: e => {
  155. formModel.prefixColor = e;
  156. },
  157. };
  158. },
  159. },
  160. {
  161. field: 'sort',
  162. label: '排序',
  163. component: 'InputNumber',
  164. defaultValue: 999,
  165. componentProps: {
  166. placeholder: '请输入排序',
  167. min: 1,
  168. style: { width: '100%' },
  169. },
  170. },
  171. {
  172. label: '备注',
  173. field: 'remark',
  174. component: 'InputTextArea',
  175. componentProps: {
  176. placeholder: '请输入备注',
  177. },
  178. },
  179. ];