dict.data.ts 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. title: [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. title: 'default',
  46. value: ''
  47. },
  48. {
  49. title: 'success',
  50. value: 'success'
  51. },
  52. {
  53. title: 'info',
  54. value: 'info'
  55. },
  56. {
  57. title: 'warning',
  58. value: 'warning'
  59. },
  60. {
  61. title: 'danger',
  62. value: 'danger'
  63. }
  64. ]
  65. }
  66. },
  67. isTable: false
  68. },
  69. {
  70. title: 'CSS Class',
  71. field: 'cssClass',
  72. isTable: false
  73. },
  74. {
  75. title: '显示排序',
  76. field: 'sort',
  77. isTable: false
  78. },
  79. {
  80. title: t('common.status'),
  81. field: 'status',
  82. dictType: DICT_TYPE.COMMON_STATUS,
  83. dictClass: 'number'
  84. },
  85. {
  86. title: t('form.remark'),
  87. field: 'remark',
  88. form: {
  89. component: 'Input',
  90. componentProps: {
  91. type: 'textarea',
  92. rows: 4
  93. },
  94. colProps: {
  95. span: 24
  96. }
  97. },
  98. isTable: false
  99. }
  100. ]
  101. })
  102. export const { allSchemas } = useVxeCrudSchemas(crudSchemas)