role.data.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import type { VxeCrudSchema } from '@/hooks/web/useVxeCrudSchemas'
  2. // 国际化
  3. const { t } = useI18n()
  4. // 表单校验
  5. export const rules = reactive({
  6. name: [required],
  7. code: [required],
  8. sort: [required]
  9. })
  10. // CrudSchema
  11. const crudSchemas = reactive<VxeCrudSchema>({
  12. // primaryKey: 'id',
  13. // primaryTitle: '角色编号',
  14. // primaryType: 'seq',
  15. action: true,
  16. actionWidth: '400px',
  17. columns: [
  18. {
  19. title: '角色编号',
  20. field: 'id',
  21. table: {
  22. width: 200
  23. }
  24. },
  25. {
  26. title: '角色名称',
  27. field: 'name',
  28. isSearch: true
  29. },
  30. {
  31. title: '角色类型',
  32. field: 'type',
  33. dictType: DICT_TYPE.SYSTEM_ROLE_TYPE,
  34. dictClass: 'number',
  35. isForm: false
  36. },
  37. {
  38. title: '角色标识',
  39. field: 'code',
  40. isSearch: true
  41. },
  42. {
  43. title: '显示顺序',
  44. field: 'sort'
  45. },
  46. {
  47. title: t('form.remark'),
  48. field: 'remark',
  49. isTable: false,
  50. form: {
  51. component: 'Input',
  52. componentProps: {
  53. type: 'textarea',
  54. rows: 4
  55. },
  56. colProps: {
  57. span: 24
  58. }
  59. }
  60. },
  61. {
  62. title: t('common.status'),
  63. field: 'status',
  64. dictType: DICT_TYPE.COMMON_STATUS,
  65. dictClass: 'number',
  66. isSearch: true
  67. },
  68. {
  69. title: t('common.createTime'),
  70. field: 'createTime',
  71. formatter: 'formatDate',
  72. isForm: false,
  73. search: {
  74. show: true,
  75. itemRender: {
  76. name: 'XDataTimePicker'
  77. }
  78. }
  79. }
  80. ]
  81. })
  82. export const { allSchemas } = useVxeCrudSchemas(crudSchemas)