user.data.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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 { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas'
  6. // 国际化
  7. const { t } = useI18n()
  8. // 表单校验
  9. export const rules = reactive({
  10. nickname: [required],
  11. status: [required]
  12. })
  13. // crudSchemas
  14. const crudSchemas = reactive<CrudSchema[]>([
  15. {
  16. label: t('common.index'),
  17. field: 'id',
  18. type: 'index',
  19. form: {
  20. show: false
  21. },
  22. detail: {
  23. show: false
  24. }
  25. },
  26. {
  27. label: '用户账号',
  28. field: 'username',
  29. form: {
  30. show: false
  31. },
  32. search: {
  33. show: true
  34. }
  35. },
  36. {
  37. label: '用户昵称',
  38. field: 'nickname'
  39. },
  40. {
  41. label: '用户邮箱',
  42. field: 'email'
  43. },
  44. {
  45. label: '手机号码',
  46. field: 'mobile',
  47. search: {
  48. show: true
  49. }
  50. },
  51. {
  52. label: '用户性别',
  53. field: 'sex',
  54. dictType: DICT_TYPE.SYSTEM_USER_SEX
  55. },
  56. {
  57. label: '部门',
  58. field: 'deptId',
  59. table: {
  60. show: false
  61. }
  62. },
  63. {
  64. label: '岗位',
  65. field: 'postIds',
  66. table: {
  67. show: false
  68. }
  69. },
  70. {
  71. label: t('common.status'),
  72. field: 'status',
  73. dictType: DICT_TYPE.COMMON_STATUS,
  74. search: {
  75. show: true
  76. }
  77. },
  78. {
  79. label: '最后登录时间',
  80. field: 'loginDate',
  81. form: {
  82. show: false
  83. }
  84. },
  85. {
  86. label: '最后登录IP',
  87. field: 'loginIp',
  88. table: {
  89. show: false
  90. },
  91. form: {
  92. show: false
  93. }
  94. },
  95. {
  96. label: t('form.remark'),
  97. field: 'remark',
  98. table: {
  99. show: false
  100. }
  101. },
  102. {
  103. label: t('common.createTime'),
  104. field: 'daterange',
  105. table: {
  106. show: false
  107. },
  108. form: {
  109. show: false
  110. },
  111. detail: {
  112. show: false
  113. },
  114. search: {
  115. show: true,
  116. component: 'DatePicker',
  117. componentProps: {
  118. type: 'daterange',
  119. valueFormat: 'YYYY-MM-DD HH:mm:ss'
  120. }
  121. }
  122. },
  123. {
  124. field: 'action',
  125. width: '340px',
  126. label: t('table.action'),
  127. form: {
  128. show: false
  129. },
  130. detail: {
  131. show: false
  132. }
  133. }
  134. ])
  135. export const { allSchemas } = useCrudSchemas(crudSchemas)