role.data.ts 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. import { BasicColumn } from '/@/components/Table';
  2. import { FormSchema } from '/@/components/Table';
  3. import { h } from 'vue';
  4. import { Switch } from 'ant-design-vue';
  5. import { Time } from '/@/components/Time';
  6. import { getAllRoleList } from '/@/api/sys/system'
  7. import { saveRoleApi } from '/@/api/sys/system';
  8. // import { ListAllCompanyApi } from '/@/api/corporation/list';
  9. import { useMessage } from '/@/hooks/web/useMessage';
  10. import { useI18n } from '/@/hooks/web/useI18n';
  11. const { t } = useI18n();
  12. const { createMessage } = useMessage();
  13. export const columns: BasicColumn[] = [
  14. // {
  15. // title: 'ID',
  16. // dataIndex: 'id',
  17. // width: 80,
  18. // },
  19. {
  20. title: t('common.roleNameText'),
  21. dataIndex: 'roleName',
  22. width: 200,
  23. },
  24. {
  25. title: t('routes.system.description'),
  26. dataIndex: 'description',
  27. width: 180,
  28. },
  29. {
  30. title: '系统用户数',
  31. dataIndex: 'adminCount',
  32. width: 100,
  33. customRender: ({ record }) => {
  34. return record.adminCount || 0;
  35. },
  36. },
  37. {
  38. title: '创建人',
  39. dataIndex: 'createUserName',
  40. width: 100,
  41. },
  42. {
  43. title: t('routes.staff.createTime'),
  44. dataIndex: 'createTime',
  45. width: 180,
  46. customRender: ({ record }) => {
  47. return h(Time, {
  48. value: record.createTime,
  49. mode: 'datetime',
  50. });
  51. },
  52. },
  53. {
  54. title: '状态',
  55. dataIndex: 'status',
  56. width: 80,
  57. customRender: ({ record }) => {
  58. if (!Reflect.has(record, 'pendingStatus')) {
  59. record.pendingStatus = false;
  60. }
  61. return h(Switch, {
  62. checked: record.status === 1,
  63. disabled:record.id === 1,
  64. checkedChildren: '启用',
  65. unCheckedChildren: '禁用',
  66. loading: false,
  67. onChange: async (checked: boolean) => {
  68. record.pendingStatus = true;
  69. const newStatus = checked ? 1 : 0;
  70. Reflect.set(record, 'status', newStatus);
  71. await saveRoleApi({ ...record, isShow: newStatus });
  72. createMessage.success(t('common.optSuccess'));
  73. // reload()
  74. },
  75. });
  76. },
  77. },
  78. // {
  79. // title: t('routes.system.remarks'),
  80. // dataIndex: 'remark',
  81. // },
  82. ];
  83. export const searchFormSchema: FormSchema[] = [
  84. {
  85. field: 'roleName',
  86. label: t('common.roleNameText'),
  87. component: 'Input',
  88. componentProps: {
  89. maxLength: 100,
  90. },
  91. colProps: { span: 8 },
  92. },
  93. // {
  94. // field: 'canShow',
  95. // label: '状态',
  96. // component: 'Select',
  97. // componentProps: {
  98. // options: [
  99. // { label: '启用', value: '0' },
  100. // { label: '停用', value: '1' },
  101. // ],
  102. // },
  103. // colProps: { span: 8 },
  104. // },
  105. ];
  106. export const formSchema: FormSchema[] = [
  107. {
  108. label: '',
  109. field: 'id',
  110. component: 'Input',
  111. show:false,
  112. },
  113. {
  114. field: 'roleName',
  115. label: t('common.roleNameText'),
  116. required: true,
  117. component: 'Input',
  118. componentProps:{
  119. maxLength: 15,
  120. }
  121. },
  122. // {
  123. // field: 'companyId',
  124. // label: t('routes.staff.companyId'),
  125. // component: 'ApiSelect',
  126. // // required: true,
  127. // itemProps: {
  128. // validateTrigger: 'blur',
  129. // },
  130. // componentProps: {
  131. // api: getAllRoleList,
  132. // resultField: 'data',
  133. // labelField: 'roleName',
  134. // valueField: 'id',
  135. // immediate: true,
  136. // onChange: function () {
  137. // // Reflect.set(modalRecord, 'shippingName', opt.label);
  138. // },
  139. // params: {
  140. // page: 1,
  141. // limit: 1000,
  142. // },
  143. // required: true,
  144. // },
  145. // },
  146. // {
  147. // field: 'canShow',
  148. // label: '状态',
  149. // component: 'RadioButtonGroup',
  150. // defaultValue: 0,
  151. // componentProps: {
  152. // options: [
  153. // { label: '启用', value: 0 },
  154. // { label: '停用', value: 1 },
  155. // ],
  156. // },
  157. // },
  158. // {
  159. // field: 'status',
  160. // label: t('routes.system.isPlatformRole'),
  161. // component: 'RadioButtonGroup',
  162. // defaultValue: 1,
  163. // componentProps: {
  164. // options: [
  165. // { label: '启用', value: 1 },
  166. // { label: '禁用', value: 0 },
  167. // ],
  168. // },
  169. // },
  170. {
  171. label: t('routes.system.description'),
  172. field: 'description',
  173. component: 'InputTextArea',
  174. required: true,
  175. componentProps:{
  176. rows:4,
  177. maxLength: 200,
  178. }
  179. },
  180. // {
  181. // label: ' ',
  182. // field: 'menuIdList',
  183. // slot: 'menu',
  184. // component: 'Input',
  185. // },
  186. // {
  187. // label: ' ',
  188. // field: 'deptIdList',
  189. // slot: 'dept',
  190. // component: 'Input',
  191. // },
  192. ];