FunctionListView.config.ts 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. import type { SmartColumn, SmartSearchFormSchema } from '@/components/SmartTable';
  2. import type { FormSchema } from '@/components/Form';
  3. export const tableColumns: SmartColumn[] = [
  4. {
  5. type: 'checkbox',
  6. width: 60,
  7. align: 'center',
  8. fixed: 'left',
  9. },
  10. {
  11. title: '{system.views.function.table.functionName}',
  12. field: 'functionName',
  13. width: 220,
  14. fixed: 'left',
  15. treeNode: true,
  16. },
  17. {
  18. title: '{system.views.function.table.functionType}',
  19. field: 'functionType',
  20. width: 110,
  21. align: 'center',
  22. headerAlign: 'left',
  23. slots: {
  24. default: 'table-functionType',
  25. },
  26. },
  27. {
  28. title: '{system.views.function.table.icon}',
  29. field: 'icon',
  30. width: 80,
  31. align: 'center',
  32. headerAlign: 'left',
  33. slots: {
  34. default: 'table-icon',
  35. },
  36. },
  37. {
  38. title: 'URL',
  39. field: 'url',
  40. minWidth: 200,
  41. },
  42. {
  43. title: '{system.views.function.table.permission}',
  44. field: 'permission',
  45. width: 160,
  46. },
  47. {
  48. title: '{system.views.function.table.httpMethod}',
  49. field: 'httpMethod',
  50. width: 120,
  51. },
  52. {
  53. title: '{common.table.seq}',
  54. field: 'seq',
  55. width: 100,
  56. sortable: true,
  57. },
  58. {
  59. title: '{common.table.createTime}',
  60. field: 'createTime',
  61. width: 165,
  62. sortable: true,
  63. },
  64. {
  65. title: '{common.table.createUser}',
  66. field: 'createBy',
  67. width: 120,
  68. },
  69. {
  70. title: '{common.table.updateTime}',
  71. field: 'updateTime',
  72. width: 165,
  73. sortable: true,
  74. },
  75. {
  76. title: '{common.table.updateUser}',
  77. field: 'updateBy',
  78. width: 120,
  79. },
  80. {
  81. title: '{common.table.operation}',
  82. field: 'operation',
  83. width: 200,
  84. fixed: 'right',
  85. slots: {
  86. default: 'table-operation',
  87. },
  88. },
  89. ];
  90. export const getAddEditForm = (t: Function): FormSchema[] => {
  91. return [
  92. {
  93. field: 'functionId',
  94. label: '',
  95. component: 'Input',
  96. show: false,
  97. },
  98. {
  99. field: 'parentName',
  100. label: '上级',
  101. component: 'Input',
  102. componentProps: {
  103. disabled: true,
  104. },
  105. },
  106. {
  107. field: 'parentId',
  108. label: '',
  109. component: 'Input',
  110. show: false,
  111. },
  112. {
  113. field: 'functionName',
  114. label: t('system.views.function.table.functionName'),
  115. component: 'Input',
  116. required: true,
  117. },
  118. {
  119. field: 'functionType',
  120. label: t('system.views.function.table.functionType'),
  121. slot: 'addEditForm-functionType',
  122. required: true,
  123. },
  124. {
  125. field: 'i18nCode',
  126. label: t('system.views.function.table.i18nCode'),
  127. component: 'Input',
  128. },
  129. {
  130. field: 'icon',
  131. label: t('system.views.function.table.icon'),
  132. component: 'IconPicker',
  133. },
  134. {
  135. field: 'seq',
  136. required: true,
  137. label: t('common.table.seq'),
  138. component: 'InputNumber',
  139. defaultValue: 1,
  140. },
  141. {
  142. field: 'componentName',
  143. label: t('system.views.function.table.componentName'),
  144. component: 'Input',
  145. dynamicRules: ({ model }) => {
  146. return [
  147. {
  148. required: model.functionType === 'MENU',
  149. trigger: 'blur',
  150. message: t('system.views.function.validate.componentName'),
  151. },
  152. ];
  153. },
  154. show: ({ model }) => {
  155. return model.functionType !== 'FUNCTION';
  156. },
  157. },
  158. {
  159. field: 'component',
  160. label: t('system.views.function.table.component'),
  161. component: 'Input',
  162. dynamicRules: ({ model }) => {
  163. return [
  164. {
  165. required: model.functionType === 'MENU',
  166. trigger: 'blur',
  167. message: t('system.views.function.validate.component'),
  168. },
  169. ];
  170. },
  171. show: ({ model }) => {
  172. return model.functionType !== 'FUNCTION';
  173. },
  174. },
  175. {
  176. field: 'url',
  177. label: 'URL',
  178. component: 'Input',
  179. dynamicRules: ({ model }) => {
  180. return [
  181. {
  182. required: model.functionType === 'MENU',
  183. trigger: 'blur',
  184. message: t('system.views.function.validate.url'),
  185. },
  186. ];
  187. },
  188. },
  189. {
  190. field: 'redirect',
  191. label: 'Redirect',
  192. component: 'Input',
  193. show: ({ model }) => {
  194. return model.functionType !== 'FUNCTION';
  195. },
  196. },
  197. {
  198. field: 'httpMethod',
  199. label: t('system.views.function.table.httpMethod'),
  200. component: 'Select',
  201. componentProps: {
  202. options: ['GET', 'POST', 'PUT', 'DELETE'].map((item) => ({ label: item, value: item })),
  203. },
  204. show: ({ model }) => {
  205. return model.functionType === 'FUNCTION';
  206. },
  207. },
  208. {
  209. field: 'permission',
  210. label: t('system.views.function.table.permission'),
  211. component: 'Input',
  212. dynamicRules: ({ model }) => {
  213. return [
  214. {
  215. required: model.functionType === 'FUNCTION',
  216. message: t('system.views.function.validate.permission'),
  217. trigger: 'blur',
  218. },
  219. ];
  220. },
  221. show: ({ model }) => {
  222. return model.functionType === 'FUNCTION';
  223. },
  224. },
  225. {
  226. field: 'isMenu',
  227. label: t('system.views.function.table.menuIs'),
  228. component: 'Switch',
  229. defaultValue: true,
  230. show: ({ model }) => {
  231. return model.functionType !== 'FUNCTION';
  232. },
  233. },
  234. {
  235. field: 'internalOrExternal',
  236. label: t('system.views.function.table.internalOrExternal'),
  237. component: 'Switch',
  238. defaultValue: false,
  239. show: ({ model }) => {
  240. return model.functionType === 'MENU';
  241. },
  242. },
  243. {
  244. field: 'dataRule',
  245. label: t('system.views.function.table.dataRule'),
  246. component: 'Switch',
  247. defaultValue: false,
  248. show: ({ model }) => {
  249. return model.functionType === 'FUNCTION';
  250. },
  251. },
  252. {
  253. field: 'cached',
  254. label: t('system.views.function.title.cached'),
  255. component: 'Switch',
  256. defaultValue: true,
  257. show: ({ model }) => {
  258. return model.functionType === 'MENU';
  259. },
  260. },
  261. ];
  262. };
  263. export const getSearchSchemas = (t: Function): SmartSearchFormSchema[] => {
  264. return [
  265. {
  266. label: t('common.title.useYn'),
  267. field: 'useYn',
  268. component: 'Select',
  269. defaultValue: 1,
  270. searchSymbol: '=',
  271. componentProps: {
  272. style: {
  273. width: '100px',
  274. },
  275. options: [
  276. {
  277. label: t('common.form.use'),
  278. value: 1,
  279. },
  280. {
  281. label: t('common.form.noUse'),
  282. value: 0,
  283. },
  284. ],
  285. },
  286. },
  287. ];
  288. };