user.data.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import { reactive } from 'vue'
  2. import { required } from '@/utils/formRules'
  3. import { useI18n } from '@/hooks/web/useI18n'
  4. import { DICT_TYPE } from '@/utils/dict'
  5. import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas'
  6. // 国际化
  7. const { t } = useI18n()
  8. // 表单校验
  9. export const rules = reactive({
  10. username: [required],
  11. nickname: [required],
  12. email: [required],
  13. status: [required],
  14. mobile: [
  15. {
  16. pattern:
  17. /^(?:(?:\+|00)86)?1(?:(?:3[\d])|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\d])|(?:9[189]))\d{8}$/,
  18. trigger: 'blur',
  19. message: '请输入正确的手机号码'
  20. }
  21. ]
  22. })
  23. // crudSchemas
  24. const crudSchemas = reactive<VxeCrudSchema>({
  25. primaryKey: 'id',
  26. primaryType: 'seq',
  27. action: true,
  28. actionWidth: '400px',
  29. columns: [
  30. {
  31. title: '用户账号',
  32. field: 'username',
  33. isSearch: true
  34. },
  35. {
  36. title: '用户密码',
  37. field: 'password',
  38. isDetail: false,
  39. isTable: false,
  40. form: {
  41. component: 'InputPassword'
  42. }
  43. },
  44. {
  45. title: '用户昵称',
  46. field: 'nickname'
  47. },
  48. {
  49. title: '用户邮箱',
  50. field: 'email'
  51. },
  52. {
  53. title: '手机号码',
  54. field: 'mobile',
  55. isSearch: true
  56. },
  57. {
  58. title: '部门',
  59. field: 'deptId',
  60. isTable: false,
  61. search: {
  62. visible: false
  63. }
  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. dictData: 'number',
  75. isSearch: true
  76. },
  77. {
  78. title: '最后登录时间',
  79. field: 'loginDate',
  80. isForm: false
  81. },
  82. {
  83. title: '最后登录IP',
  84. field: 'loginIp',
  85. isTable: false,
  86. isForm: false
  87. },
  88. {
  89. title: t('form.remark'),
  90. field: 'remark',
  91. isTable: false
  92. },
  93. {
  94. title: t('common.createTime'),
  95. field: 'createTime',
  96. formatter: 'formatDate',
  97. isTable: false,
  98. isForm: false,
  99. search: {
  100. show: true,
  101. itemRender: {
  102. name: 'XDataTimePicker'
  103. }
  104. }
  105. }
  106. ]
  107. })
  108. export const { allSchemas } = useVxeCrudSchemas(crudSchemas)