RoleListView.config.ts 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. import type { SmartColumn, SmartSearchFormSchema } from '@/components/SmartTable';
  2. import type { FormSchema } from '@/components/Form';
  3. import { tableUseYnClass } from '@/components/SmartTable';
  4. export const getTableColumns = (): SmartColumn[] => {
  5. return [
  6. {
  7. type: 'checkbox',
  8. width: 60,
  9. align: 'center',
  10. fixed: 'left',
  11. },
  12. {
  13. title: '{system.views.role.table.roleName}',
  14. field: 'roleName',
  15. width: 120,
  16. fixed: 'left',
  17. },
  18. {
  19. title: '{system.views.role.table.roleCode}',
  20. field: 'roleCode',
  21. width: 150,
  22. fixed: 'left',
  23. },
  24. {
  25. title: '{system.views.role.table.roleType}',
  26. field: 'roleType',
  27. width: 120,
  28. },
  29. {
  30. ...tableUseYnClass(),
  31. sortable: true,
  32. },
  33. {
  34. title: '{common.table.remark}',
  35. field: 'remark',
  36. minWidth: 160,
  37. },
  38. {
  39. title: '{common.table.seq}',
  40. field: 'seq',
  41. width: 100,
  42. sortable: true,
  43. },
  44. {
  45. title: '{common.table.createTime}',
  46. field: 'createTime',
  47. width: 165,
  48. sortable: true,
  49. },
  50. {
  51. title: '{common.table.createUser}',
  52. field: 'createUserId',
  53. width: 120,
  54. formatter: ({ row }: any) => {
  55. if (row.createUser) {
  56. return row.createUser.fullName;
  57. }
  58. return '';
  59. },
  60. },
  61. {
  62. title: '{common.table.updateTime}',
  63. field: 'updateTime',
  64. width: 165,
  65. sortable: true,
  66. },
  67. {
  68. title: '{common.table.updateUser}',
  69. field: 'updateUserId',
  70. width: 120,
  71. formatter: ({ row }: any) => {
  72. if (row.updateUser) {
  73. return row.updateUser.fullName;
  74. }
  75. return '';
  76. },
  77. },
  78. {
  79. title: '{common.table.operation}',
  80. field: 'operation',
  81. width: 120,
  82. fixed: 'right',
  83. slots: {
  84. default: 'table-operation',
  85. },
  86. },
  87. ];
  88. };
  89. export const getSearchSchemas = (t: Function): SmartSearchFormSchema[] => {
  90. return [
  91. {
  92. label: t('system.views.role.table.roleName'),
  93. field: 'roleName',
  94. component: 'Input',
  95. searchSymbol: 'like',
  96. componentProps: {
  97. style: {
  98. width: '130px',
  99. },
  100. },
  101. },
  102. {
  103. label: t('system.views.role.table.roleCode'),
  104. field: 'roleCode',
  105. component: 'Input',
  106. searchSymbol: 'like',
  107. componentProps: {
  108. style: {
  109. width: '130px',
  110. },
  111. },
  112. },
  113. {
  114. label: t('common.title.useYn'),
  115. field: 'useYn',
  116. component: 'Select',
  117. defaultValue: 1,
  118. searchSymbol: '=',
  119. componentProps: {
  120. style: {
  121. width: '100px',
  122. },
  123. options: [
  124. {
  125. label: t('common.form.use'),
  126. value: 1,
  127. },
  128. {
  129. label: t('common.form.noUse'),
  130. value: 0,
  131. },
  132. ],
  133. },
  134. },
  135. ];
  136. };
  137. export const getAddEditFormSchemas = (t: Function): FormSchema[] => {
  138. return [
  139. {
  140. label: '',
  141. field: 'roleId',
  142. component: 'Input',
  143. show: false,
  144. },
  145. {
  146. label: t('system.views.role.table.roleCode'),
  147. field: 'roleCode',
  148. component: 'Input',
  149. required: true,
  150. },
  151. {
  152. label: t('system.views.role.table.roleName'),
  153. field: 'roleName',
  154. component: 'Input',
  155. required: true,
  156. },
  157. {
  158. label: t('common.table.useYn'),
  159. field: 'useYn',
  160. component: 'Switch',
  161. defaultValue: true,
  162. },
  163. {
  164. label: t('system.views.role.table.roleType'),
  165. field: 'roleType',
  166. component: 'Input',
  167. },
  168. {
  169. label: t('common.table.seq'),
  170. field: 'seq',
  171. component: 'InputNumber',
  172. required: true,
  173. defaultValue: 1,
  174. },
  175. ];
  176. };