wk
2024-11-14 927e4a7caf46bd073c65ce3b8f14dc1f1582c519
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
<template>
    <view>
        <u-list>
            <u-list-item v-for="(item, index) in fleetDriverData"
                :key="index">
                <view class="information-block">
                    <view class="detail-block">
                        <view class="address">
                            {{item.name+'-'+item.carNo}}
                        </view>
                        <view class="edit-icon"
                            @click="addDriver(item)">
                            <u-icon name="man-add-fill"
                                size="40"
                                color="#ababab"></u-icon>
                        </view>
                    </view>
                </view>
            </u-list-item>
        </u-list>
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                fleetId: '', //选择的车队id
                willFleetId: '', // 要邀请的司机车队id
                fleetDriverData: []
            }
        },
        onLoad(params) {
            this.fleetId = params.id
            this.willFleetId = params.willFleetId
            this.GetUserFleet()
        },
        methods: {
            // 获取司机列表
            GetUserFleet() {
                uni.showLoading({
                    title: '加载中...'
                });
                this.$reqGet('GetUserFleet', { fleetId: this.fleetId }).then(res => {
                    uni.hideLoading();
                    this.fleetDriverData = res.data;
                });
            },
            // 邀请司机
            addDriver(v) {
                uni.showLoading({
                    title: '加载中...'
                });
                this.$reqPost('bindUserFleet', {
                    fleetId: this.willFleetId,
                    name: v.name,
                    phone: v.phone,
                    carNo: v.carNo
                }, 'params').then(res => {
                    console.log(res);
                    uni.hideLoading()
                    if (res.code == 0) {
                        this.$u.toast('操作成功');
                        setTimeout(() => {
                            uni.$emit('needRefresh')
                        }, 1500)
                    } else {
                        uni.showToast({
                            title: res.msg ? res.msg : '操作失败',
                            duration: 2000
                        });
                    }
                }).catch(e => {
                    uni.hideLoading()
                })
            }
        }
    }
</script>
 
<style lang="scss"
    scoped>
    .information-block {
        width: 100%;
        display: flex;
        justify-content: center;
 
        .detail-block {
            width: 690rpx;
            height: 120rpx;
            padding: vww(8);
            background: #ffffff;
            box-shadow: 0rpx 0rpx 14rpx 0rpx rgba(73, 120, 240, 0.14), 0rpx 7rpx 45rpx 0rpx rgba(73, 120, 240, 0.12);
            border-radius: 20rpx;
            display: flex;
            justify-content: space-between;
            margin-top: vww(14);
            position: relative;
 
            .address {
                flex: 1;
                display: flex;
                align-items: center;
                margin-left: vww(20);
            }
 
            .edit-icon {
                width: vww(50);
                height: 100%;
                @include flex;
            }
        }
    }
</style>