addressbook.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <view class="main">
  3. <view class=" text-center flex tab-custom" style="height: 45px;line-height: 45px;">
  4. <u-tabs :list="list" @click="changeParent" lineWidth="30" lineHeight="1" lineColor="#ffffff" :activeStyle="{
  5. color: '#ffffff',
  6. fontWeight: 'bold',
  7. transform: 'scale(1.05)'
  8. }" :inactiveStyle="{
  9. color: '#fff',
  10. transform: 'scale(1)'
  11. }" itemStyle=" height: 34px;"></u-tabs>
  12. </view>
  13. <!-- <view class="tree">
  14. <ly-tree :tree-data="officeList" :props="props" node-key="id" :checkOnClickNode="true" :showRadio="false"
  15. :show-checkbox="false" :checkOnlyLeaf="false" ref="officeTree" />
  16. </view> -->
  17. <view>
  18. <u-cell-group class="cell_group__title" v-for="(item, index) in indexList" :key="index"
  19. :title="indexList[index].name">
  20. <u-cell class="book_info" v-for="user in getUser(indexList[index].id)">
  21. <view class="book_info_title" slot="title">
  22. {{user.name}}
  23. </view>
  24. <u-avatar v-if="user.photo!=''" slot="icon" shape="circle" size="40" :src="BASE_URL + user.photo"
  25. customStyle="margin: -3px 5px -3px 0"></u-avatar>
  26. <u-avatar v-else slot="icon" shape="circle" size="35" src="../../static/img/avatar.png"
  27. customStyle="margin: -3px 5px -3px 0"></u-avatar>
  28. <view v-if="user.mobile || user.phone" class="ellipsis-description text-gray" slot="label">
  29. {{user.mobile + ' ' + user.phone}}
  30. </view>
  31. <view v-if="user.mobile || user.phone" class="flex" slot="value">
  32. <u-icon @click="toPhone(user)" size="30" style="margin-right: 10px;" name="../../static/img/icon_dh.png"></u-icon>
  33. <u-icon @click="copyPhone(user)" v-if="user.mobile || user.phone" size="30"
  34. name="../../static/img/icon_fz.png"></u-icon>
  35. </view>
  36. </u-cell>
  37. </u-cell-group>
  38. </view>
  39. <u-modal :show="show" title="选择号码" :showConfirmButton="false" :showCancelButton="true" @cancel="show = false">
  40. <view class="slot-content">
  41. <view v-for="(item,index) in phones" :key="index">
  42. <view @click="toPhone(item)" class="modal_content">{{item}}</view>
  43. </view>
  44. </view>
  45. </u-modal>
  46. <u-overlay :show="loading">
  47. <view class="warp">
  48. <view class="rect"><u-button plain loading loadingText="加载中"></u-button></view>
  49. </view>
  50. </u-overlay>
  51. </view>
  52. </template>
  53. <script>
  54. import userService from '@/api/sys/userService'
  55. import officeService from "@/api/sys/officeService"
  56. import BASE_URL from '@/config.js'
  57. export default {
  58. data() {
  59. return {
  60. loading: true,
  61. show: false,
  62. indexList: [],
  63. officeList: [],
  64. userList: [],
  65. total: 0,
  66. searchUserName: '',
  67. list: [],
  68. phones: [],
  69. }
  70. },
  71. props: {
  72. props: {
  73. type: Object,
  74. default: () => {
  75. return {
  76. children: 'children',
  77. label: 'name'
  78. }
  79. }
  80. }
  81. },
  82. created() {
  83. officeService.treeData().then(data => {
  84. this.officeList = data
  85. this.list = this.officeList.filter((item) => {
  86. if (item.type == "1") {
  87. return true
  88. }
  89. })
  90. this.list.sort((a, b) => b.name.localeCompare(a.name) || b.name.localeCompare(a
  91. .name));
  92. userService.list({
  93. current: 1,
  94. size: 10000
  95. }).then((res) => {
  96. this.userList = res.records
  97. this.indexList = this.list[0].children
  98. this.total = res.total
  99. this.loading = false
  100. }).catch((e) => {
  101. throw e
  102. })
  103. })
  104. },
  105. methods: {
  106. // 切换部门
  107. changeParent(e) {
  108. this.indexList = e.children
  109. },
  110. // 获取用户
  111. getUser(id) {
  112. let b = this.userList.filter(item => item.officeDTO && item.officeDTO.id == id)
  113. return b
  114. },
  115. // 打电话
  116. toPhone(user) {
  117. if (user.mobile || user.phone) {
  118. if (user.mobile != '' && user.phone == '') {
  119. uni.makePhoneCall({
  120. phoneNumber: user.mobile //仅为示例
  121. });
  122. } else if (user.mobile == '' && user.phone != '') {
  123. uni.makePhoneCall({
  124. phoneNumber: user.phone //仅为示例
  125. });
  126. } else if (user.mobile != '' && user.phone != '') {
  127. this.phones = []
  128. this.phones.push(user.mobile)
  129. this.phones.push(user.phone)
  130. this.show = true
  131. }
  132. } else {
  133. this.show = false
  134. uni.makePhoneCall({
  135. phoneNumber: user //仅为示例
  136. });
  137. }
  138. },
  139. // 复制号码
  140. copyPhone(user) {
  141. uni.setClipboardData({
  142. data: user.phone + " " + user.mobile,
  143. success: function() {
  144. uni.showToast({
  145. title: '复制成功',
  146. icon: 'success'
  147. });
  148. }
  149. });
  150. },
  151. }
  152. }
  153. </script>
  154. <style lang="scss">
  155. .warp {
  156. display: flex;
  157. align-items: center;
  158. justify-content: center;
  159. height: 100%;
  160. }
  161. .book_info {
  162. background-color: #fefefe;
  163. }
  164. .book_info .cell_group__title span {
  165. // background-color: #ededed;
  166. font-size: 18px !important;
  167. }
  168. .book_info .ellipsis-description {
  169. font-size: 12px !important;
  170. margin-top: 10px;
  171. }
  172. .main .tab-custom {
  173. justify-content: center;
  174. align-items: center;
  175. background-color: #36a7f3;
  176. }
  177. .main .modal_content {
  178. height: 40px;
  179. line-height: 40px;
  180. border-bottom: 1px solid #ededed;
  181. z-index: 10;
  182. }
  183. .book_info_title {
  184. color: #21b7fc;
  185. }
  186. .list {
  187. &__item {
  188. @include flex;
  189. padding: 6px 12px;
  190. align-items: center;
  191. &__avatar {
  192. height: 35px;
  193. width: 35px;
  194. border-radius: 3px;
  195. }
  196. &__user-name {
  197. font-size: 16px;
  198. margin-left: 10px;
  199. color: $u-main-color;
  200. }
  201. }
  202. &__footer {
  203. color: $u-tips-color;
  204. font-size: 14px;
  205. text-align: center;
  206. margin: 15px 0;
  207. }
  208. }
  209. </style>