config.data.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import { reactive } from 'vue'
  2. import { useI18n } from '@/hooks/web/useI18n'
  3. import { required } from '@/utils/formRules'
  4. import { DICT_TYPE } from '@/utils/dict'
  5. import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas'
  6. const { t } = useI18n() // 国际化
  7. // 表单校验
  8. export const rules = reactive({
  9. category: [required],
  10. name: [required],
  11. key: [required],
  12. value: [required]
  13. })
  14. // CrudSchema
  15. const crudSchemas = reactive<VxeCrudSchema>({
  16. primaryKey: 'id',
  17. primaryType: null,
  18. action: true,
  19. columns: [
  20. {
  21. title: '参数分类',
  22. field: 'category'
  23. },
  24. {
  25. title: '参数名称',
  26. field: 'name',
  27. isSearch: true
  28. },
  29. {
  30. title: '参数键名',
  31. field: 'key',
  32. isSearch: true
  33. },
  34. {
  35. title: '参数键值',
  36. field: 'value'
  37. },
  38. {
  39. title: '系统内置',
  40. field: 'type',
  41. dictType: DICT_TYPE.INFRA_CONFIG_TYPE,
  42. dictClass: 'number',
  43. isSearch: true
  44. },
  45. {
  46. title: '是否可见',
  47. field: 'visible',
  48. table: {
  49. slots: {
  50. default: 'visible_default'
  51. }
  52. },
  53. form: {
  54. component: 'RadioButton',
  55. componentProps: {
  56. options: [
  57. { label: '是', value: true },
  58. { label: '否', value: false }
  59. ]
  60. }
  61. }
  62. },
  63. {
  64. title: t('form.remark'),
  65. field: 'remark',
  66. isTable: false,
  67. form: {
  68. component: 'Input',
  69. componentProps: {
  70. type: 'textarea',
  71. rows: 4
  72. },
  73. colProps: {
  74. span: 24
  75. }
  76. }
  77. },
  78. {
  79. title: t('common.createTime'),
  80. field: 'createTime',
  81. formatter: 'formatDate',
  82. isForm: false,
  83. search: {
  84. show: true,
  85. itemRender: {
  86. name: 'XDataTimePicker'
  87. }
  88. }
  89. }
  90. ]
  91. })
  92. export const { allSchemas } = useVxeCrudSchemas(crudSchemas)