user.data.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. import type { VxeCrudSchema } from '@/hooks/web/useVxeCrudSchemas'
  2. // 国际化
  3. const { t } = useI18n()
  4. // 表单校验
  5. export const rules = reactive({
  6. username: [required],
  7. nickname: [required],
  8. email: [
  9. { required: true, message: t('profile.rules.mail'), trigger: 'blur' },
  10. {
  11. type: 'email',
  12. message: t('profile.rules.truemail'),
  13. trigger: ['blur', 'change']
  14. }
  15. ],
  16. status: [required],
  17. mobile: [
  18. {
  19. len: 11,
  20. trigger: 'blur',
  21. message: '请输入正确的手机号码'
  22. }
  23. ]
  24. })
  25. // crudSchemas
  26. const crudSchemas = reactive<VxeCrudSchema>({
  27. primaryKey: 'id',
  28. primaryType: 'seq',
  29. primaryTitle: '用户编号',
  30. action: true,
  31. actionWidth: '200px',
  32. columns: [
  33. {
  34. title: '用户账号',
  35. field: 'username',
  36. isSearch: true
  37. },
  38. {
  39. title: '用户密码',
  40. field: 'password',
  41. isDetail: false,
  42. isTable: false,
  43. form: {
  44. component: 'InputPassword'
  45. }
  46. },
  47. {
  48. title: '用户昵称',
  49. field: 'nickname'
  50. },
  51. {
  52. title: '用户邮箱',
  53. field: 'email'
  54. },
  55. {
  56. title: '手机号码',
  57. field: 'mobile',
  58. isSearch: true
  59. },
  60. {
  61. title: '部门',
  62. field: 'deptId',
  63. isTable: false
  64. },
  65. {
  66. title: '岗位',
  67. field: 'postIds',
  68. isTable: false
  69. },
  70. {
  71. title: t('common.status'),
  72. field: 'status',
  73. dictType: DICT_TYPE.COMMON_STATUS,
  74. dictClass: 'number',
  75. isSearch: true,
  76. table: {
  77. slots: {
  78. default: 'status_default'
  79. }
  80. }
  81. },
  82. {
  83. title: '最后登录时间',
  84. field: 'loginDate',
  85. formatter: 'formatDate',
  86. isForm: false
  87. },
  88. {
  89. title: '最后登录IP',
  90. field: 'loginIp',
  91. isTable: false,
  92. isForm: false
  93. },
  94. {
  95. title: t('form.remark'),
  96. field: 'remark',
  97. isTable: false
  98. },
  99. {
  100. title: t('common.createTime'),
  101. field: 'createTime',
  102. formatter: 'formatDate',
  103. isTable: false,
  104. isForm: false,
  105. search: {
  106. show: true,
  107. itemRender: {
  108. name: 'XDataTimePicker'
  109. }
  110. }
  111. }
  112. ]
  113. })
  114. export const { allSchemas } = useVxeCrudSchemas(crudSchemas)