dict.data.ts 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. import { reactive } from 'vue'
  2. import { DICT_TYPE } from '@/utils/dict'
  3. import { required } from '@/utils/formRules'
  4. import { useI18n } from '@/hooks/web/useI18n'
  5. import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas'
  6. // 国际化
  7. const { t } = useI18n()
  8. // 表单校验
  9. export const dictDataRules = reactive({
  10. label: [required],
  11. value: [required],
  12. sort: [required]
  13. })
  14. // crudSchemas
  15. export const crudSchemas = reactive<VxeCrudSchema>({
  16. primaryKey: 'id',
  17. primaryType: null,
  18. action: true,
  19. actionWidth: '140px',
  20. searchSpan: 12,
  21. columns: [
  22. {
  23. title: '字典类型',
  24. field: 'dictType',
  25. isTable: false,
  26. isForm: false
  27. },
  28. {
  29. title: '数据标签',
  30. field: 'label',
  31. isSearch: true
  32. },
  33. {
  34. title: '数据键值',
  35. field: 'value'
  36. },
  37. {
  38. title: '标签类型',
  39. field: 'colorType',
  40. form: {
  41. component: 'Select',
  42. componentProps: {
  43. options: [
  44. {
  45. label: 'default',
  46. value: ''
  47. },
  48. {
  49. label: 'success',
  50. value: 'success'
  51. },
  52. {
  53. label: 'info',
  54. value: 'info'
  55. },
  56. {
  57. label: 'warning',
  58. value: 'warning'
  59. },
  60. {
  61. label: 'danger',
  62. value: 'danger'
  63. }
  64. ]
  65. }
  66. },
  67. isTable: false
  68. },
  69. {
  70. title: '颜色',
  71. field: 'cssClass',
  72. isTable: false,
  73. form: {
  74. component: 'ColorPicker'
  75. }
  76. },
  77. {
  78. title: '显示排序',
  79. field: 'sort',
  80. isTable: false
  81. },
  82. {
  83. title: t('common.status'),
  84. field: 'status',
  85. dictType: DICT_TYPE.COMMON_STATUS,
  86. dictClass: 'number'
  87. },
  88. {
  89. title: t('form.remark'),
  90. field: 'remark',
  91. form: {
  92. component: 'Input',
  93. componentProps: {
  94. type: 'textarea',
  95. rows: 4
  96. },
  97. colProps: {
  98. span: 24
  99. }
  100. },
  101. isTable: false
  102. }
  103. ]
  104. })
  105. export const { allSchemas } = useVxeCrudSchemas(crudSchemas)