user.data.ts 2.2 KB

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