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