#
whycq
2023-12-02 72a4a671431d25095146dc7e36efbb4a871c39b9
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<template>
    <view>
        <view class="user" @click="userDetail">
            <!-- 头像 -->
            <view class="user-avatar">
                <image src="../../static/image/user__easyico.png" mode="aspectFit"></image>
            </view>
            <!-- 信息 -->
            <view class="user-info">
                <view class="user-name">{{username}}</view>
                <view class="user-company">中扬立库技术有限公司</view>
            </view>
            <!-- 更多 -->
            <view class="user-icons">
                <uni-icons type="right"></uni-icons>
            </view>
        </view>
        
        <view class="taskbox">
            <view class="taskbox-title">
                <y-title title="待处理任务"></y-title>
            </view>
            <view class="taskbox-main">
                <view class="taskbox-body" v-for="(item,index) in Data" @click="goDetl(item)">
                    <view class="taskbox-body-title">{{item.title}}</view>
                    <view class="taskbox-body-cell">
                        <text class="taskbox-body-number">{{item.value}}</text>
                        <text class="taskbox-body-unit">个</text>
                    </view>
                </view>
            </view>
            
        </view>
    </view>
</template>
 
<script>
    import user from '@/pages/api/user/user.js'
    export default{
        data() {
            return {
                username: '',
                Data: [
                    { field: 'planPendingTaskCount', title: '规划申请单', hide: false,value: ''},
                    { field: 'priOnlinePendingTaskCount', title: '核价审批', hide: false,value: '' },
                    { field: 'priQuotePendingTaskCount', title: '报价审批', hide: false,value: '' },
                    { field: 'businessTripPendingTaskCount', title: '出差审批', hide: false,value: '' },
                    { field: 'reimburseOnlinePendingTaskCount', title: '报销审批', hide: false,value: '' },
                    { field: 'planPriOnlinePendingTaskCount', title: '可接收核价任务', hide: false,value: '' },
                ],
                data2: []
            }
        },
        onShow() {
            this.getDetail()
            this.getPersonData()
        },
        methods: {
            async getDetail() {
                let res = await user.getDetail()
                if (res.code === 200) {
                    this.username = res.data.username
                    console.log(res.data);
                } else if (res.code === 403) {
                    this.backLogin(res)
                }
            },
            userDetail() {
                uni.navigateTo({
                    url:'/pages/user/user_detail/userDetail'
                })
            },
            backLogin(res) {
                uni.showToast({title: res.msg, icon: "none", position: 'top'})
                setTimeout(() => {
                    uni.reLaunch({
                        url: '../login/login'
                    });
                }, 1000);
            },
            // 获取任务信息
            getPersonData() {
                let _this = this
                uni.request({
                    url: `${_this.baseUrl}/dashboard/personData/auth`,
                    header: {'token' : uni.getStorageSync('token')},
                    success(res) {
                        res = res.data
                        if (res.code === 200) {
                            for (let k of _this.Data) {
                                k.value = res.data[k.field]
                                res.data[k.field]
                            }
                        }
                    }
                })
            },
            goDetl(item) {
                if (item.value > 0) {
                    let url = '/pages/business'
                    switch(item.field) {
                        case 'planPendingTaskCount':
                            url = `${url}/plan/plan`
                            break;
                        case 'planPriOnlinePendingTaskCount':
                            url = `${url}/pricing/priOnline`
                            break;
                        case 'priQuotePendingTaskCount':
                            url = `${url}/pricing/priQuote`
                            break;
                        case 'businessTripPendingTaskCount':
                            url = `${url}/goBusiness/goBusiness`
                            break;
                        case 'reimburseOnlinePendingTaskCount':
                            url = `${url}/goBusiness/reimburseOnline`
                            break;
                        case 'priOnlinePendingTaskCount':
                            url = `${url}/pricing/priOnline`
                            break;
                    }
                    uni.navigateTo({
                        url:url
                    })
                }
            }
        }
    }
</script>
 
<style>
    .user {
        width: 100%;
        height: 200rpx;
        background-color: #fff;
        display: grid;
        grid-template-columns: 1fr 4fr 1fr;
    }
    .user-avatar {
        height: 100rpx;
        width: 100rpx;
        padding: 50rpx;
        /* background-color: aquamarine; */
        display: flex;
        justify-content: center;
        align-items: center;
    }
    .user-avatar img {
        height: 100rpx;
        border-radius: 20rpx;
    }
    .user-info {
        height: 200rpx;
        display: grid;
        grid-template-rows: 2fr 2fr;
        /* background-color: aqua; */
    }
    .user-name {
        height: 100rpx;
        width: 100%;
        display: flex;
        align-items: flex-end;
        font-size: 30rpx;
        font-weight: 700;
    }
    .user-company {
        height: 100rpx;
    }
    .user-icons {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .taskbox {
        margin: 32rpx;
        padding: 16rpx;
        background-color: #fff;
        border-radius: 20rpx;
    }
    .taskbox-main {
        display: flex;
        flex-wrap: wrap;
    }
    .taskbox-body-cell {
        /* display: flex; */
        margin-left: 16rpx;
    }
    .taskbox-body-number {
        font-size: 40rpx;
        font-weight: bold;
    }
    .taskbox-body-unit {
        margin-left: 8rpx;
        /* vertical-align: text-bottom; */
    }
    .taskbox-body {
        margin: 16rpx;
        width: 45%;
        /* background-color: aquamarine; */
    }
</style>