user.data.ts 2.3 KB

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