role.data.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { reactive } from 'vue'
  2. import { useI18n } from '@/hooks/web/useI18n'
  3. import { required } from '@/utils/formRules'
  4. import { DICT_TYPE } from '@/utils/dict'
  5. import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas'
  6. // 国际化
  7. const { t } = useI18n()
  8. // 表单校验
  9. export const rules = reactive({
  10. name: [required],
  11. code: [required],
  12. sort: [required]
  13. })
  14. // CrudSchema
  15. const crudSchemas = reactive<VxeCrudSchema>({
  16. primaryKey: 'id',
  17. primaryType: 'seq',
  18. action: true,
  19. actionWidth: '400px',
  20. columns: [
  21. {
  22. title: '角色名称',
  23. field: 'name',
  24. isSearch: true
  25. },
  26. {
  27. title: '角色类型',
  28. field: 'type',
  29. dictType: DICT_TYPE.SYSTEM_ROLE_TYPE,
  30. dictData: 'number'
  31. },
  32. {
  33. title: '角色标识',
  34. field: 'code',
  35. isSearch: true
  36. },
  37. {
  38. title: '显示顺序',
  39. field: 'sort'
  40. },
  41. {
  42. title: t('common.status'),
  43. field: 'status',
  44. dictType: DICT_TYPE.COMMON_STATUS,
  45. dictData: 'number',
  46. isSearch: true
  47. },
  48. {
  49. title: t('common.createTime'),
  50. field: 'createTime',
  51. formatter: 'formatDate',
  52. isForm: false,
  53. search: {
  54. show: true,
  55. itemRender: {
  56. name: 'XDataTimePicker'
  57. }
  58. }
  59. }
  60. ]
  61. })
  62. export const { allSchemas } = useVxeCrudSchemas(crudSchemas)