user.data.ts 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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: 'createTime',
  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: 'datetimerange',
  119. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  120. defaultTime: [new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)],
  121. shortcuts: [
  122. {
  123. text: '近一周',
  124. value: () => {
  125. const end = new Date()
  126. const start = new Date()
  127. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
  128. return [start, end]
  129. }
  130. },
  131. {
  132. text: '近一个月',
  133. value: () => {
  134. const end = new Date()
  135. const start = new Date()
  136. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
  137. return [start, end]
  138. }
  139. },
  140. {
  141. text: '近三个月',
  142. value: () => {
  143. const end = new Date()
  144. const start = new Date()
  145. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
  146. return [start, end]
  147. }
  148. }
  149. ]
  150. }
  151. }
  152. },
  153. {
  154. field: 'action',
  155. width: '340px',
  156. label: t('table.action'),
  157. form: {
  158. show: false
  159. },
  160. detail: {
  161. show: false
  162. }
  163. }
  164. ])
  165. export const { allSchemas } = useCrudSchemas(crudSchemas)