role.data.ts 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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 { setRoleStatus } from '/@/api/system/system';
  7. // import { useMessage } from '/@/hooks/web/useMessage';
  8. export const columns: BasicColumn[] = [
  9. {
  10. title: 'ID',
  11. dataIndex: 'roleId',
  12. width: 80,
  13. },
  14. {
  15. title: '角色名称',
  16. dataIndex: 'roleName',
  17. width: 200,
  18. },
  19. {
  20. title: '所属部门',
  21. dataIndex: 'deptName',
  22. width: 180,
  23. },
  24. {
  25. title: '排序',
  26. dataIndex: 'orderNo',
  27. width: 50,
  28. },
  29. {
  30. title: '状态',
  31. dataIndex: 'canShow',
  32. width: 120,
  33. customRender: ({ record }) => {
  34. if (!Reflect.has(record, 'pendingStatus')) {
  35. record.pendingStatus = false;
  36. }
  37. return h(Switch, {
  38. checked: record.canShow === 0,
  39. checkedChildren: '已启用',
  40. unCheckedChildren: '已禁用',
  41. loading: record.pendingStatus as any as boolean,
  42. // onChange(checked: boolean) {
  43. // record.pendingStatus = true;
  44. // const newStatus = checked ? '1' : '0';
  45. // const { createMessage } = useMessage();
  46. // setRoleStatus(record.id, newStatus)
  47. // .then(() => {
  48. // record.status = newStatus;
  49. // createMessage.success(`已成功修改角色状态`);
  50. // })
  51. // .catch(() => {
  52. // createMessage.error('修改角色状态失败');
  53. // })
  54. // .finally(() => {
  55. // record.pendingStatus = false;
  56. // });
  57. // },
  58. });
  59. },
  60. },
  61. {
  62. title: '创建时间',
  63. dataIndex: 'createTime',
  64. width: 180,
  65. customRender: ({ record }) => {
  66. return h(Time, {
  67. value: record.createTime,
  68. mode: 'datetime',
  69. });
  70. },
  71. },
  72. {
  73. title: '备注',
  74. dataIndex: 'remark',
  75. },
  76. ];
  77. export const searchFormSchema: FormSchema[] = [
  78. {
  79. field: 'roleNme',
  80. label: '角色名称',
  81. component: 'Input',
  82. colProps: { span: 8 },
  83. },
  84. {
  85. field: 'canShow',
  86. label: '状态',
  87. component: 'Select',
  88. componentProps: {
  89. options: [
  90. { label: '启用', value: '0' },
  91. { label: '停用', value: '1' },
  92. ],
  93. },
  94. colProps: { span: 8 },
  95. },
  96. ];
  97. export const formSchema: FormSchema[] = [
  98. {
  99. field: 'roleName',
  100. label: '角色名称',
  101. required: true,
  102. component: 'Input',
  103. },
  104. // {
  105. // field: 'roleValue',
  106. // label: '角色值',
  107. // required: true,
  108. // component: 'Input',
  109. // },
  110. {
  111. field: 'status',
  112. label: '状态',
  113. component: 'RadioButtonGroup',
  114. defaultValue: '0',
  115. componentProps: {
  116. options: [
  117. { label: '启用', value: '0' },
  118. { label: '停用', value: '1' },
  119. ],
  120. },
  121. },
  122. {
  123. label: '备注',
  124. field: 'remark',
  125. component: 'InputTextArea',
  126. },
  127. {
  128. label: ' ',
  129. field: 'menuIdList',
  130. slot: 'menu',
  131. component: 'Input',
  132. },
  133. {
  134. label: ' ',
  135. field: 'deptIdList',
  136. slot: 'dept',
  137. component: 'Input',
  138. },
  139. ];