CodeDesignPage.config.ts 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. import type { FormSchema } from '@/components/Form';
  2. type ButtonType =
  3. | 'SEARCH'
  4. | 'RESET'
  5. | 'ADD'
  6. | 'EDIT'
  7. | 'DELETE'
  8. | 'EXCEL_IMPORT'
  9. | 'EXCEL_EXPORT'
  10. | 'COLUMN_SETTING'
  11. | 'ZOOM'
  12. | 'REFRESH'
  13. | 'SHOW_SEARCH'
  14. | 'PRINT';
  15. interface Button {
  16. key: ButtonType;
  17. value: string;
  18. }
  19. const tableTypeList = [
  20. {
  21. label: 'generator.views.code.title.tableType.single',
  22. value: '10',
  23. },
  24. {
  25. label: 'generator.views.code.title.tableType.main',
  26. value: '20',
  27. },
  28. {
  29. label: 'generator.views.code.title.tableType.addendum',
  30. value: '30',
  31. },
  32. ];
  33. const yesNoList = [
  34. {
  35. label: 'Yes',
  36. value: true,
  37. },
  38. {
  39. label: 'No',
  40. value: false,
  41. },
  42. ];
  43. export const formSchemas = (t: Function): FormSchema[] => {
  44. return [
  45. {
  46. label: '',
  47. field: 'systemId',
  48. component: 'Input',
  49. show: false,
  50. },
  51. {
  52. label: t('generator.views.code.table.connectionName'),
  53. field: 'connectionId',
  54. slot: 'addEditForm-connectionId',
  55. required: true,
  56. },
  57. {
  58. label: t('generator.views.code.table.tableName'),
  59. field: 'tableName',
  60. component: 'Input',
  61. required: true,
  62. },
  63. {
  64. label: t('generator.views.code.table.configName'),
  65. field: 'configName',
  66. component: 'Input',
  67. required: true,
  68. },
  69. {
  70. label: t('generator.views.code.table.type'),
  71. field: 'type',
  72. component: 'Select',
  73. defaultValue: '10',
  74. componentProps: {
  75. options: tableTypeList.map((item) => ({ label: t(item.label), value: item.value })),
  76. },
  77. },
  78. // ------------ 第二行 ---------------------
  79. {
  80. label: t('generator.views.code.title.showCheckBox'),
  81. field: 'showCheckbox',
  82. component: 'RadioGroup',
  83. defaultValue: true,
  84. componentProps: {
  85. options: yesNoList,
  86. },
  87. },
  88. {
  89. label: t('generator.views.code.title.isPage'),
  90. field: 'page',
  91. component: 'RadioGroup',
  92. defaultValue: true,
  93. componentProps: {
  94. options: yesNoList,
  95. },
  96. },
  97. {
  98. label: t('generator.views.code.title.invented'),
  99. field: 'invented',
  100. component: 'RadioGroup',
  101. defaultValue: false,
  102. componentProps: {
  103. options: yesNoList,
  104. },
  105. },
  106. {
  107. label: t('generator.views.code.title.columnSort'),
  108. field: 'columnSort',
  109. component: 'RadioGroup',
  110. defaultValue: false,
  111. componentProps: {
  112. options: yesNoList,
  113. },
  114. },
  115. // ------------ 第三行 ---------------------
  116. {
  117. label: t('generator.views.code.title.leftButton'),
  118. field: 'leftButtonList',
  119. component: 'Select',
  120. defaultValue: ['ADD', 'DELETE'],
  121. componentProps: {
  122. mode: 'multiple',
  123. options: letButtonList.map((item) => ({
  124. label: item.value,
  125. value: item.key,
  126. })),
  127. },
  128. },
  129. {
  130. label: t('generator.views.code.title.rightButton'),
  131. field: 'rightButtonList',
  132. component: 'Select',
  133. defaultValue: ['ZOOM', 'REFRESH', 'SHOW_SEARCH', 'COLUMN_SETTING'],
  134. componentProps: {
  135. mode: 'multiple',
  136. options: rightButtonList.map((item) => ({
  137. label: item.value,
  138. value: item.key,
  139. })),
  140. },
  141. },
  142. {
  143. label: t('generator.views.code.title.rowButtonType.title'),
  144. field: 'rowButtonType',
  145. component: 'Select',
  146. defaultValue: 'NONE',
  147. componentProps: {
  148. options: rowButtonTypeList(t),
  149. },
  150. },
  151. {
  152. label: t('generator.views.code.title.rowButtonList'),
  153. field: 'rowButtonList',
  154. component: 'Select',
  155. componentProps: {
  156. mode: 'multiple',
  157. options: rowButtonList.map((item) => ({
  158. label: item.value,
  159. value: item.key,
  160. })),
  161. },
  162. },
  163. // ------------ 第四行 ---------------------
  164. {
  165. label: t('generator.views.code.title.formColNum'),
  166. field: 'formColNum',
  167. component: 'Select',
  168. defaultValue: 1,
  169. componentProps: {
  170. options: columnNumList(t, false),
  171. },
  172. },
  173. {
  174. label: t('generator.views.code.title.searchColNum'),
  175. field: 'searchColNum',
  176. component: 'Select',
  177. defaultValue: 0,
  178. componentProps: {
  179. options: columnNumList(t),
  180. },
  181. },
  182. {
  183. label: t('common.table.remark'),
  184. field: 'remark',
  185. component: 'Input',
  186. },
  187. {
  188. label: t('generator.views.code.title.i18nPrefix'),
  189. field: 'i18nPrefix',
  190. component: 'Input',
  191. },
  192. // ------------ 第五行 ---------------------
  193. {
  194. label: t('generator.views.code.title.relateTable'),
  195. field: 'addendumTableList',
  196. defaultValue: [],
  197. slot: 'addEditForm-RelateTable',
  198. },
  199. {
  200. label: '',
  201. field: 'id',
  202. slot: 'addEditForm-syncTable',
  203. },
  204. ];
  205. };
  206. /**
  207. * 左侧按钮列表
  208. */
  209. const letButtonList: Button[] = [
  210. {
  211. key: 'SEARCH',
  212. value: '搜索',
  213. },
  214. {
  215. key: 'RESET',
  216. value: '重置',
  217. },
  218. {
  219. key: 'ADD',
  220. value: '添加',
  221. },
  222. {
  223. key: 'EDIT',
  224. value: '修改',
  225. },
  226. {
  227. key: 'DELETE',
  228. value: '删除',
  229. },
  230. ];
  231. const rightButtonList: Button[] = [
  232. {
  233. key: 'EXCEL_IMPORT',
  234. value: 'Excel导入',
  235. },
  236. {
  237. key: 'EXCEL_EXPORT',
  238. value: 'Excel导出',
  239. },
  240. {
  241. key: 'COLUMN_SETTING',
  242. value: '列配置',
  243. },
  244. {
  245. key: 'ZOOM',
  246. value: '放大缩小',
  247. },
  248. {
  249. key: 'REFRESH',
  250. value: '刷新',
  251. },
  252. {
  253. key: 'SHOW_SEARCH',
  254. value: '显示搜索',
  255. },
  256. {
  257. key: 'PRINT',
  258. value: '打印',
  259. },
  260. ];
  261. /**
  262. * 行按钮
  263. */
  264. const rowButtonList = [
  265. {
  266. key: 'EDIT',
  267. value: '修改',
  268. },
  269. {
  270. key: 'DELETE',
  271. value: '删除',
  272. },
  273. ];
  274. const columnNumList = (t: Function, hasZeroColumn = true) => {
  275. const column = [
  276. {
  277. value: 1,
  278. label: t('generator.views.code.title.colNum.one'),
  279. },
  280. {
  281. value: 2,
  282. label: t('generator.views.code.title.colNum.two'),
  283. },
  284. {
  285. value: 3,
  286. label: t('generator.views.code.title.colNum.three'),
  287. },
  288. {
  289. value: 4,
  290. label: t('generator.views.code.title.colNum.four'),
  291. },
  292. ];
  293. if (hasZeroColumn) {
  294. return [
  295. {
  296. value: 0,
  297. label: t('generator.views.design.title.colNum.zero'),
  298. },
  299. ].concat(column);
  300. }
  301. return column;
  302. };
  303. const rowButtonTypeList = (t: Function) => [
  304. {
  305. label: t('generator.views.code.title.rowButtonType.none'),
  306. value: 'NONE',
  307. },
  308. {
  309. label: t('generator.views.code.title.rowButtonType.single'),
  310. value: 'SINGLE',
  311. },
  312. {
  313. label: t('generator.views.code.title.rowButtonType.more'),
  314. value: 'MORE',
  315. },
  316. {
  317. label: t('generator.views.code.title.rowButtonType.text'),
  318. value: 'TEXT',
  319. },
  320. ];