dataSourceConfig.data.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import { reactive } from 'vue'
  2. import { required } from '@/utils/formRules'
  3. import { useI18n } from '@/hooks/web/useI18n'
  4. import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas'
  5. // 国际化
  6. const { t } = useI18n()
  7. // 表单校验
  8. export const rules = reactive({
  9. name: [required],
  10. url: [required],
  11. username: [required],
  12. password: [required]
  13. })
  14. // 新增 + 修改
  15. 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: 'name'
  30. },
  31. {
  32. label: '数据源连接',
  33. field: 'url',
  34. form: {
  35. component: 'Input',
  36. componentProps: {
  37. type: 'textarea',
  38. rows: 4
  39. },
  40. colProps: {
  41. span: 24
  42. }
  43. }
  44. },
  45. {
  46. label: '用户名',
  47. field: 'username'
  48. },
  49. {
  50. label: '密码',
  51. field: 'password',
  52. table: {
  53. show: false
  54. }
  55. },
  56. {
  57. label: t('common.createTime'),
  58. field: 'createTime',
  59. form: {
  60. show: false
  61. },
  62. search: {
  63. show: true,
  64. component: 'DatePicker',
  65. componentProps: {
  66. type: 'datetimerange',
  67. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  68. defaultTime: [new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)]
  69. }
  70. }
  71. },
  72. {
  73. field: 'action',
  74. width: '240px',
  75. label: t('table.action'),
  76. form: {
  77. show: false
  78. },
  79. detail: {
  80. show: false
  81. }
  82. }
  83. ])
  84. export const { allSchemas } = useCrudSchemas(crudSchemas)