userList.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <page-meta root-font-size="system" />
  3. <view class="contact_container">
  4. <uv-index-list :index-list="indexList">
  5. <template v-for="(items, index) in itemArr" :key="index">
  6. <uv-index-item>
  7. <uv-index-anchor :text="indexList[index]" size="16"></uv-index-anchor>
  8. <view class="chat_list">
  9. <uni-list :border="true">
  10. <uni-list-chat v-for="(item, index) in items" @click="clickChat(item)" :title="item.name"
  11. :avatar="item.avatar || config.baseUrlPre+config.defaultAvatarPath" :clickable="true"
  12. :avatar-circle="true" :key="index">
  13. <view class="chat-custom-right">
  14. <text class="chat-custom-text">{{ item.dept }}</text>
  15. </view>
  16. </uni-list-chat>
  17. </uni-list>
  18. </view>
  19. </uv-index-item>
  20. </template>
  21. </uv-index-list>
  22. </view>
  23. </template>
  24. <script setup lang="ts">
  25. import { onMounted, ref } from 'vue'
  26. import $tab from '@/plugins/tab.js'
  27. import { getContactAllUser } from '@/api/contacts.js'
  28. import { useUserStore } from '@/store/user.js'
  29. import config from '@/config';
  30. const userStore = useUserStore()
  31. onMounted(() => {
  32. // 获取 通讯录 索引列表
  33. let unitId = userStore.user.unitId
  34. if ( unitId === 0 ) unitId = userStore.user.groupid
  35. getContactAllUser(unitId).then(res => {
  36. getContactList(res.returnParams)
  37. })
  38. })
  39. // 索引列表
  40. const indexList = ref([])
  41. const itemArr = ref([])
  42. function getContactList(data) {
  43. const filtered = {}
  44. Object.keys(data).forEach((key) => {
  45. const users = (data[key] || []).filter((user) => user.userState !== '0' && user.name.slice(-3) !== '管理员')
  46. if (users.length > 0) {
  47. filtered[key] = users
  48. }
  49. })
  50. indexList.value = Object.keys(filtered)
  51. itemArr.value = Object.values(filtered)
  52. }
  53. // 点击通讯录列表
  54. function clickChat(e) {
  55. $tab.navigateTo('/pages/work/homesysSetting/user?userName=' + e.userName)
  56. }
  57. </script>
  58. <style lang="scss">
  59. ::v-deep .contact_container {
  60. .uv-index-list {
  61. .uv-index-list__letter {
  62. .uv-index-list__letter__item {
  63. width: calc(16px + .5*(1rem - 16px)) !important;
  64. height: calc(16px + .5*(1rem - 16px)) !important;
  65. }
  66. }
  67. .uv-index-item {
  68. .uv-index-anchor {
  69. height: calc(32px + .5*(1rem - 16px)) !important;
  70. .uv-index-anchor__text {
  71. font-size: calc(1.5rem + 0px) !important;
  72. }
  73. }
  74. .chat_list {
  75. .uni-list-chat {
  76. .uni-list-chat__header-warp {
  77. .uni-list-chat__header {
  78. width: calc(45px + .5*(1rem - 16px)) !important;
  79. height: calc(45px + .5*(1rem - 16px)) !important;
  80. }
  81. }
  82. .uni-list-chat__content {
  83. .uni-list-chat__content-title {
  84. font-size: calc(1rem + 0px) !important;
  85. }
  86. .uni-list-chat__content-note {
  87. font-size: calc(0.75rem + 0px) !important;
  88. }
  89. }
  90. }
  91. }
  92. }
  93. }
  94. .chat_list {
  95. .chat-custom-right {
  96. .chat-custom-text {
  97. margin-right: 10px;
  98. }
  99. }
  100. }
  101. }
  102. </style>