暫無描述

config-data.ts 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. import type { FormSchemaGetter } from '#/adapter/form';
  2. import type { VxeGridProps } from '#/adapter/vxe-table';
  3. import { DictEnum } from '@vben/constants';
  4. import { getDictOptions } from '#/utils/dict';
  5. // 字典标识常量
  6. const DICT_KEYS = {
  7. // 任务类型字典标识
  8. TASK_TYPE: 'task_type',
  9. // 岗位类型字典标识
  10. POST_TYPE: 'post_type',
  11. };
  12. // 获取任务类型字典选项
  13. const getTaskTypeOptions = () => getDictOptions(DICT_KEYS.TASK_TYPE);
  14. // 获取岗位类型字典选项
  15. const getPostTypeOptions = () => getDictOptions(DICT_KEYS.POST_TYPE);
  16. export const tableColumns: VxeGridProps['columns'] = [
  17. {
  18. type: 'checkbox',
  19. width: 60,
  20. },
  21. {
  22. field: 'postId',
  23. title: '岗位编号',
  24. },
  25. {
  26. field: 'postName',
  27. title: '岗位名称',
  28. },
  29. {
  30. field: 'postSort',
  31. title: '岗位排序',
  32. },
  33. {
  34. field: 'taskType',
  35. title: '任务类型',
  36. formatter: (params: {
  37. cellValue: string | string[];
  38. column: any;
  39. row: any;
  40. }) => {
  41. const options = getTaskTypeOptions();
  42. // 处理接口返回的逗号分隔字符串和前端多选的数组
  43. const cellValue = params.cellValue;
  44. const values =
  45. typeof cellValue === 'string'
  46. ? cellValue.split(',')
  47. : (Array.isArray(cellValue)
  48. ? cellValue
  49. : [cellValue]);
  50. return values
  51. .map((value) => {
  52. const option = options.find((item) => item.value === value);
  53. return option ? option.label : value;
  54. })
  55. .filter(Boolean)
  56. .join(', ');
  57. },
  58. },
  59. {
  60. field: 'typeName',
  61. title: '岗位类型',
  62. // formatter: (params: { cellValue: string; column: any; row: any }) => {
  63. // const options = getPostTypeOptions();
  64. // const option = options.find((item) => item.value === params.cellValue);
  65. // return option ? option.label : params.cellValue;
  66. // },
  67. },
  68. {
  69. field: 'status',
  70. title: '状态',
  71. slots: { default: 'status' },
  72. },
  73. {
  74. field: 'createTime',
  75. title: '创建时间',
  76. },
  77. {
  78. field: 'action',
  79. fixed: 'right',
  80. slots: { default: 'action' },
  81. title: '操作',
  82. },
  83. ];
  84. export const querySchema: FormSchemaGetter = () => [
  85. {
  86. component: 'Input',
  87. label: '岗位名称',
  88. fieldName: 'postName',
  89. },
  90. {
  91. component: 'Select',
  92. label: '任务类型',
  93. componentProps: {
  94. placeholder: '请选择任务类型',
  95. options: getTaskTypeOptions(),
  96. multiple: true,
  97. },
  98. fieldName: 'taskType',
  99. },
  100. {
  101. component: 'Select',
  102. label: '岗位类型',
  103. componentProps: {
  104. placeholder: '请选择岗位类型',
  105. options: getPostTypeOptions(),
  106. },
  107. fieldName: 'type',
  108. },
  109. {
  110. component: 'Select',
  111. label: '状态',
  112. componentProps: {
  113. options: getDictOptions(DictEnum.SYS_NORMAL_DISABLE),
  114. },
  115. fieldName: 'status',
  116. },
  117. ];
  118. export const drawerFormSchema: FormSchemaGetter = () => [
  119. {
  120. component: 'Input',
  121. fieldName: 'postId',
  122. dependencies: {
  123. show: () => false,
  124. triggerFields: [''],
  125. },
  126. },
  127. {
  128. component: 'Input',
  129. label: '岗位名称',
  130. componentProps: {
  131. maxlength: 50,
  132. },
  133. fieldName: 'postName',
  134. rules: 'required',
  135. },
  136. {
  137. component: 'InputNumber',
  138. label: '岗位排序',
  139. componentProps: {
  140. max: 9999,
  141. },
  142. fieldName: 'postSort',
  143. defaultValue: '0',
  144. rules: 'required',
  145. },
  146. {
  147. component: 'Select',
  148. label: '任务类型',
  149. componentProps: {
  150. placeholder: '请选择任务类型',
  151. options: getTaskTypeOptions(),
  152. multiple: true,
  153. },
  154. fieldName: 'taskType',
  155. },
  156. {
  157. component: 'Select',
  158. label: '岗位类型',
  159. componentProps: {
  160. placeholder: '请选择岗位类型',
  161. options: getPostTypeOptions(),
  162. },
  163. fieldName: 'type',
  164. },
  165. {
  166. component: 'RadioGroup',
  167. label: '状态',
  168. componentProps: {
  169. isButton: true,
  170. options: getDictOptions(DictEnum.SYS_NORMAL_DISABLE),
  171. },
  172. fieldName: 'status',
  173. defaultValue: '0',
  174. },
  175. {
  176. component: 'Input',
  177. label: '备注',
  178. componentProps: {
  179. type: 'textarea',
  180. maxlength: 500,
  181. showWordLimit: true,
  182. },
  183. fieldName: 'remark',
  184. },
  185. ];