member.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <view>
  3. <view class="cu-bar fixed" :class="[NavBarColor]" :style="style" >
  4. <view class="cuIcon-back margin-left" @tap="backRoute()"><text class="margin-left-sm">返回</text></view>
  5. <view class="content" :style="[{top:StatusBar + 'px'}]">
  6. {{ memberTitle }}
  7. </view>
  8. </view>
  9. <!-- 展示部门和用户 -->
  10. <view class="cu-list menu-avatar sm-border" :style="[{marginTop:'calc('+CustomBar+ 'px + 10px)'}]">
  11. <view class="cu-item" v-for="(item, index) in memberList" :key="index" @click="goMemberInfo(item)">
  12. <view class="cu-avatar round lg" :style="[{backgroundImage:'url('+ item.avatar +')'}]"></view>
  13. <view class="content">
  14. <view class="text-grey">{{item.realname}}</view>
  15. <view class="text-grey">{{item.post}}</view>
  16. </view>
  17. </view>
  18. <view class="text-center text-lg"><text>共{{ memberTotal}}人</text></view>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. import { getFileAccessHttpUrl } from "../../api/api.js"
  24. export default {
  25. name: "member",
  26. data(){
  27. return{
  28. CustomBar:this.CustomBar,
  29. StatusBar:this.StatusBar,
  30. NavBarColor:this.NavBarColor,
  31. departUrl:'/sys/sysDepart/queryTreeList',
  32. addressSourceUrl:'/sys/user/queryByOrgCodeForAddressList',
  33. queryByOrgCodeKeyword:'/sys/user/queryByOrgCodeKeyword',
  34. positionUrl:'/sys/position/list',
  35. value:'',
  36. memberTitle:'',
  37. memberList:[],
  38. userId:'',
  39. orgCode:'',
  40. ids:{},
  41. memberTotal:0,
  42. }
  43. },
  44. onLoad(){
  45. console.log("this.$Router", this.$Route);
  46. this.memberTitle = this.$Route.query.title
  47. this.orgCode = this.$Route.query.orgCode
  48. this.loadList()
  49. },
  50. computed:{
  51. style() {
  52. var StatusBar= this.StatusBar;
  53. var CustomBar= this.CustomBar;
  54. var style = `height:${CustomBar}px;padding-top:${StatusBar}px;`;
  55. return style
  56. }
  57. },
  58. methods: {
  59. backRoute() {
  60. this.$Router.push({name: 'levelAddressBook',params:this.$Route.query})
  61. },
  62. goMemberInfo(item){
  63. let parmas = {...item}
  64. parmas.orgCode= this.orgCode
  65. this.$Router.push({name: 'addressDetail',params:parmas})
  66. },
  67. loadList() {
  68. let param = {
  69. orgCode:this.orgCode,
  70. realname:this.value
  71. }
  72. this.$http.get(this.addressSourceUrl,{params:param}).then(res => {
  73. console.log("用户2", res)
  74. if (res.data.success) {
  75. let memberArr = res.data.result.records;
  76. //memberArr = memberArr.filter(item => item.departName == this.memberTitle)
  77. for (let item of memberArr) {
  78. this.avatarHandler(item);
  79. this.memberList.push(item)
  80. // this.userId = item.userId
  81. this.memberTotal = memberArr.length
  82. if (this.memberTotal == undefined){
  83. this.memberTotal = 0
  84. }
  85. }
  86. }
  87. }).catch(e => {
  88. console.log("请求错误", e)
  89. })
  90. this.$http.get(this.positionUrl).then(res=> {
  91. console.log("用户1",res)
  92. if (res.data.success) {
  93. let postArr = res.data.result.records
  94. for (let item of postArr ){
  95. for (let it of this.memberList){
  96. if (it.post == item.code){
  97. it.post = item.name
  98. }
  99. }
  100. }
  101. }
  102. }).catch(e=>{
  103. console.log("请求错误",e)
  104. })
  105. },
  106. avatarHandler(item){
  107. let avatar = item.avatar
  108. if(avatar){
  109. let url = getFileAccessHttpUrl(avatar);
  110. item.avatar = url
  111. }else{
  112. if(item.sex=='2'){
  113. item.avatar = 'static/avatar_girl.png';
  114. }else{
  115. item.avatar = 'static/avatar_boy.png';
  116. }
  117. }
  118. },
  119. }
  120. }
  121. </script>
  122. <style scoped>
  123. </style>