data.config.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. import type {
  2. OnActionClickFn,
  3. VbenFormSchema,
  4. VxeTableGridOptions,
  5. } from '#/adapter';
  6. import { RoleApi } from '#/api';
  7. export const useSearchSchema = (): VbenFormSchema[] => {
  8. return [
  9. {
  10. component: 'Input',
  11. fieldName: 'code',
  12. label: '编号',
  13. },
  14. {
  15. component: 'Input',
  16. fieldName: 'name',
  17. label: '名称',
  18. },
  19. ];
  20. };
  21. export function useColumns(
  22. onActionClick?: OnActionClickFn<RoleApi.RecordItem>,
  23. ): VxeTableGridOptions<RoleApi.RecordItem>['columns'] {
  24. return [
  25. { title: '序号', type: 'seq', width: 50 },
  26. {
  27. align: 'left',
  28. field: 'code',
  29. title: '编号',
  30. width: 150,
  31. },
  32. { align: 'left', field: 'name', title: '名称', width: 200 },
  33. { align: 'left', field: 'sort', title: '排序', width: 70 },
  34. { align: 'left', field: 'remark', title: '备注' },
  35. {
  36. field: 'status',
  37. title: '状态',
  38. width: 82,
  39. cellRender: { name: 'CellTag' },
  40. },
  41. {
  42. align: 'right',
  43. cellRender: {
  44. attrs: {
  45. nameField: 'name',
  46. nameTitle: '名称',
  47. onClick: onActionClick,
  48. },
  49. name: 'CellAction',
  50. options: [
  51. {
  52. code: 'edit',
  53. auth: ['role:edit'],
  54. },
  55. {
  56. code: 'grantMenu',
  57. label: '授权菜单',
  58. auth: ['role:grantMenu'],
  59. },
  60. {
  61. code: 'grantUser',
  62. label: '添加成员',
  63. auth: ['role:grantUser'],
  64. },
  65. {
  66. code: 'setStatus',
  67. label: (row: RoleApi.RecordItem) => {
  68. return row.status === 1 ? '禁用' : '启用';
  69. },
  70. auth: ['role:setStatus'],
  71. },
  72. {
  73. code: 'delete',
  74. auth: ['role:delete'],
  75. },
  76. ],
  77. },
  78. field: 'operation',
  79. fixed: 'right',
  80. headerAlign: 'center',
  81. showOverflow: false,
  82. title: '操作',
  83. width: 170,
  84. },
  85. ];
  86. }
  87. export const useSchema = (): VbenFormSchema[] => {
  88. return [
  89. {
  90. component: 'Input',
  91. componentProps: {
  92. placeholder: '请输入编号',
  93. },
  94. fieldName: 'code',
  95. label: '编号',
  96. rules: 'required',
  97. },
  98. {
  99. component: 'Input',
  100. componentProps: {
  101. placeholder: '请输入名称',
  102. },
  103. fieldName: 'name',
  104. label: '名称',
  105. rules: 'required',
  106. },
  107. {
  108. component: 'InputNumber',
  109. componentProps: {
  110. placeholder: '请输入排序',
  111. },
  112. fieldName: 'sort',
  113. label: '排序',
  114. rules: 'required',
  115. },
  116. {
  117. component: 'Textarea',
  118. componentProps: {
  119. placeholder: '请输入',
  120. },
  121. fieldName: 'remark',
  122. label: '备注',
  123. },
  124. ];
  125. };