dataSourceConfig.data.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { required } from '@/utils/formRules'
  2. import { useI18n } from '@/hooks/web/useI18n'
  3. import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas'
  4. // 国际化
  5. const { t } = useI18n()
  6. // 表单校验
  7. export const rules = reactive({
  8. name: [required],
  9. url: [required],
  10. username: [required],
  11. password: [required]
  12. })
  13. // 新增 + 修改
  14. const crudSchemas = reactive<VxeCrudSchema>({
  15. primaryKey: 'id',
  16. primaryType: 'seq',
  17. action: true,
  18. columns: [
  19. {
  20. title: '数据源名称',
  21. field: 'name'
  22. },
  23. {
  24. title: '数据源连接',
  25. field: 'url',
  26. form: {
  27. component: 'Input',
  28. componentProps: {
  29. type: 'textarea',
  30. rows: 4
  31. },
  32. colProps: {
  33. span: 24
  34. }
  35. }
  36. },
  37. {
  38. title: '用户名',
  39. field: 'username'
  40. },
  41. {
  42. title: '密码',
  43. field: 'password',
  44. isTable: false
  45. },
  46. {
  47. title: t('common.createTime'),
  48. field: 'createTime',
  49. formatter: 'formatDate',
  50. isForm: false
  51. }
  52. ]
  53. })
  54. export const { allSchemas } = useVxeCrudSchemas(crudSchemas)