user.data.ts 2.2 KB

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