dict.data.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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 { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas'
  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<CrudSchema[]>([
  16. {
  17. label: t('common.index'),
  18. field: 'id',
  19. type: 'index',
  20. form: {
  21. show: false
  22. },
  23. detail: {
  24. show: false
  25. }
  26. },
  27. {
  28. label: '字典类型',
  29. field: 'dictType',
  30. table: {
  31. show: false
  32. },
  33. form: {
  34. show: false
  35. }
  36. },
  37. {
  38. label: '数据标签',
  39. field: 'label',
  40. search: {
  41. show: true
  42. }
  43. },
  44. {
  45. label: '数据键值',
  46. field: 'value'
  47. },
  48. {
  49. label: '颜色类型',
  50. field: 'colorType',
  51. form: {
  52. component: 'Select',
  53. componentProps: {
  54. options: [
  55. {
  56. label: 'default',
  57. value: ''
  58. },
  59. {
  60. label: 'success',
  61. value: 'success'
  62. },
  63. {
  64. label: 'info',
  65. value: 'info'
  66. },
  67. {
  68. label: 'warning',
  69. value: 'warning'
  70. },
  71. {
  72. label: 'danger',
  73. value: 'danger'
  74. }
  75. ]
  76. }
  77. },
  78. table: {
  79. show: false
  80. }
  81. },
  82. {
  83. label: 'CSS Class',
  84. field: 'cssClass',
  85. table: {
  86. show: false
  87. }
  88. },
  89. {
  90. label: '显示排序',
  91. field: 'sort',
  92. table: {
  93. show: false
  94. }
  95. },
  96. {
  97. label: t('common.status'),
  98. field: 'status',
  99. dictType: DICT_TYPE.COMMON_STATUS
  100. },
  101. {
  102. label: t('form.remark'),
  103. field: 'remark',
  104. form: {
  105. component: 'Input',
  106. componentProps: {
  107. type: 'textarea',
  108. rows: 4
  109. },
  110. colProps: {
  111. span: 24
  112. }
  113. },
  114. table: {
  115. show: false
  116. }
  117. },
  118. {
  119. label: t('table.action'),
  120. field: 'action',
  121. width: '180px',
  122. form: {
  123. show: false
  124. },
  125. detail: {
  126. show: false
  127. }
  128. }
  129. ])
  130. export const { allSchemas } = useCrudSchemas(crudSchemas)