menu.data.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import { useI18n } from '@/hooks/web/useI18n'
  2. import { DICT_TYPE } from '@/utils/dict'
  3. import { required } from '@/utils/formRules'
  4. import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas'
  5. const { t } = useI18n() // 国际化
  6. // 新增和修改的表单校验
  7. export const rules = reactive({
  8. name: [required],
  9. sort: [required],
  10. path: [required],
  11. status: [required]
  12. })
  13. // CrudSchema
  14. const crudSchemas = reactive<VxeCrudSchema>({
  15. primaryKey: 'id',
  16. primaryType: null,
  17. action: true,
  18. columns: [
  19. {
  20. title: '上级菜单',
  21. field: 'parentId',
  22. isTable: false
  23. },
  24. {
  25. title: '菜单名称',
  26. field: 'name',
  27. isSearch: true,
  28. table: {
  29. treeNode: true,
  30. align: 'left',
  31. width: '200px',
  32. slots: {
  33. default: 'name_default'
  34. }
  35. }
  36. },
  37. {
  38. title: '菜单类型',
  39. field: 'type',
  40. dictType: DICT_TYPE.SYSTEM_MENU_TYPE
  41. },
  42. {
  43. title: '路由地址',
  44. field: 'path'
  45. },
  46. {
  47. title: '组件路径',
  48. field: 'component'
  49. },
  50. {
  51. title: '权限标识',
  52. field: 'permission'
  53. },
  54. {
  55. title: '排序',
  56. field: 'sort'
  57. },
  58. {
  59. title: t('common.status'),
  60. field: 'status',
  61. dictType: DICT_TYPE.COMMON_STATUS,
  62. dictClass: 'number',
  63. isSearch: true
  64. },
  65. {
  66. title: t('common.createTime'),
  67. field: 'createTime',
  68. formatter: 'formatDate'
  69. }
  70. ]
  71. })
  72. export const { allSchemas } = useVxeCrudSchemas(crudSchemas)