account.data.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas'
  2. import { DictTag } from '@/components/DictTag'
  3. import { TableColumn } from '@/types/table'
  4. import { dateFormatter } from '@/utils/formatTime'
  5. import { getBoolDictOptions } from '@/utils/dict'
  6. const { t } = useI18n() // 国际化
  7. // 表单校验
  8. export const rules = reactive({
  9. mail: [
  10. { required: true, message: t('profile.rules.mail'), trigger: 'blur' },
  11. {
  12. type: 'email',
  13. message: t('profile.rules.truemail'),
  14. trigger: ['blur', 'change']
  15. }
  16. ],
  17. username: [required],
  18. password: [required],
  19. host: [required],
  20. port: [required],
  21. sslEnable: [required]
  22. })
  23. // CrudSchema
  24. const crudSchemas = reactive<CrudSchema[]>([
  25. {
  26. label: '邮箱',
  27. field: 'mail',
  28. isSearch: true
  29. },
  30. {
  31. label: '用户名',
  32. field: 'username',
  33. isSearch: true
  34. },
  35. {
  36. label: '密码',
  37. field: 'password',
  38. isTable: false
  39. },
  40. {
  41. label: 'SMTP 服务器域名',
  42. field: 'host'
  43. },
  44. {
  45. label: 'SMTP 服务器端口',
  46. field: 'port',
  47. form: {
  48. component: 'InputNumber',
  49. value: 465
  50. }
  51. },
  52. {
  53. label: '是否开启 SSL',
  54. field: 'sslEnable',
  55. formatter: (_: Recordable, __: TableColumn, cellValue: boolean) => {
  56. return h(DictTag, {
  57. type: DICT_TYPE.INFRA_BOOLEAN_STRING,
  58. value: cellValue
  59. })
  60. },
  61. form: {
  62. component: 'Radio',
  63. componentProps: {
  64. options: getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)
  65. }
  66. }
  67. },
  68. {
  69. label: '创建时间',
  70. field: 'createTime',
  71. isForm: false,
  72. formatter: dateFormatter
  73. },
  74. {
  75. label: '操作',
  76. field: 'action',
  77. form: {
  78. show: false
  79. }
  80. }
  81. ])
  82. export const { allSchemas } = useCrudSchemas(crudSchemas)