menu.data.ts 1.5 KB

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