user.data.ts 2.2 KB

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