gx
queenwuli
2021-01-15 4b80c98ef5fda8d6358778f2efe8bb35cb20ccf9
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
<template>
    <view>
        <view class="header">
            <search-bar @confirm="search" class="mb-0" placeholder="输入会员姓名、手机号、订单号查询"></search-bar>
        </view>
        <view>
            <h-tabs
                class="tab"
                :activeIndex="orderStatus"
                @tabClick="tabChange"
                :tabData="tabs" 
                :config="{
                    color: '#abb1cc',
                    activeColor: '#518EFF',
                    underLineColor: '#518EFF',
                    underLineHeight: 4,
                    fontSize: '28',
                    underLineWidth: 60
                }"
            />
            <view class="list">
                <navigator :url="'./serviceOrderDetail?id='+item.id" class="list-item" v-for="item in list">
                    <view class="list-header">
                        <text>订单号: {{item.serviceNo}}</text>
                        <text class="gray">{{item.time}}</text>
                    </view>
                    <view class="list-content">
                        <view class="flex flex-v">
                            <view>
                                <image src="../../static/images/order-icon1.png" class="icon"></image>
                                <text>{{item.vipName}}</text>
                            </view>
                            <view class="flex mt-10">
                                <image src="../../static/images/order-icon2.png" class="icon" style="padding-top: 3px;"></image>
                                <view>
                                    <text class="block" :class="index===0?'':'mt-5'" v-for="(op, index) in item.projs">{{op.projName}}</text>
                                </view>
                            </view>
                            <view class="mt-10">
                                <image src="../../static/images/order-icon3.png" class="icon"></image>
                                <text>{{item.bed || '-'}}</text>
                            </view>
                            
                        </view>
                        <view class="flex flex-v right" style="flex: 0 0 70px;">
                            <text class="gray mb-5">{{item.timeLength}}分钟</text>
                            <text class="gray mt-5" v-for="(op, index) in item.projs">{{op.beautyName || '-'}}</text>
                            <text class="mt-10" :class="item.status==7 || item.status==8?'gray':'blue'">{{item.status | formatStatus}}</text>
                        </view>
                    </view>
                    <view :class="isShowFooter(item.status, item.projs, item.staffId)?'list-footer':''">
                        <text class="white-btn small-btn" 
                            v-if="isShowCancelBtn(item.status, item.projs, item.staffId)" 
                            @click.stop="cancelOrder(item.id)">
                            取消
                        </text>
                        <text class="blue-btn small-btn ml-10"
                            v-if="isShowOrder(item.status)"
                            @click.stop="confirmServiceOrder(item.id)">
                            确认预约
                        </text>
                        <text class="blue-btn small-btn ml-10" 
                            v-if="isShowStartServiceBtn(item.status, item.projs)"
                            @click.stop="startService(item.id)">
                            开始服务
                        </text>
                        <text class="blue-btn small-btn ml-10"
                            v-if="isShowEndServiceBtn(item.status, item.projs)"
                            @click.stop="endService(item.id)">
                            结束服务
                        </text>
                    </view>
                </navigator>
                <no-record :isShow="!list.length" txt="暂无服务单记录"></no-record>
                <view v-if="list.length">
                    <uni-load-more :status="loadStatus" color="#a5abaf"></uni-load-more>
                </view>
            </view>
        </view>
    </view>
</template>
 
<script>
    import HTabs from "@/components/liuyuno-tabs/liuyuno-tabs.vue";
    import searchBar from '../../components/searchBar/index.vue';
    import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
    export default {
        components: {
            HTabs,
            searchBar,
            uniLoadMore
        },
        data() {
          return {
            queryKey: '',
            orderStatus: 0,
            tabs:[
                {
                    state: 0,
                    name: '全部'
                },
                {
                    state: 1,
                    name: '待确认'
                },
                {
                    state: 2,
                    name: '待排班'
                },
                {
                    state: 3,
                    name: '待配料'
                },
                {
                    state: 4,
                    name: '待服务'
                },
                {
                    state: 5,
                    name: '服务中'
                },
                {
                    state: 6,
                    name: '已完成'
                }
            ],
            list: [],
            userId: '',
            loadStatus: 'more',
            pageNum: 1
          }  
        },
        onLoad(options) {
            if(options.status){
                this.orderStatus = Number(options.status);
            }
            if(options.queryKey){
                this.queryKey = options.queryKey;
            }
            this.loadList();
            this.userId = this.$httpUtils.getRoleInfo().id;
            // 判断权限
            // #ifdef APP-PLUS
            if(!this.$utils.hasPermission('fwdgl.add')){
                let webView = this.$mp.page.$getAppWebview();
                webView.setTitleNViewButtonStyle(0, {
                    width: 0,  
                });
            }
            // #endif
        },
        onPullDownRefresh(){
            this.reloadData();
            let timer = setTimeout(function () {
                uni.startPullDownRefresh();
                clearTimeout(timer);
                timer = null;
            }, 800);
        },
        onReachBottom(){
            this.loadList()
        },
        onNavigationBarButtonTap(Object){
            if(Object.key === 'add'){
                uni.navigateTo({
                    url: './selectCustomer?type=2'
                })
            }
        },
        methods:{
            reloadData(){
                this.list = [];
                this.pageNum = 1;
                this.loadStatus = 'more';
                this.loadList();
            },
            loadList(){
                if(this.loadStatus!=='more'){
                    return;
                }
                this.$httpUtils.request('/api/serviceOrder/findServiceOrderList', {
                    pageNum: this.pageNum,
                    pageSize: 10,
                    queryKey: this.queryKey,
                    status: this.orderStatus
                }, 'POST').then((res) => {
                    if(res.status == 200){
                        let result = res.rows;
                        if(result.length < 10){
                            this.loadStatus = 'noMore';
                        } else {
                            this.pageNum ++ ;
                            this.loadStatus = 'more';
                        }
                        this.list = this.list.concat(result);
                    }
                })
            },
            // 是否显示操作按钮
            isShowFooter(status, items, staffId){
                return this.isShowCancelBtn(status, items, staffId) ||
                    this.isShowStartServiceBtn(status, items) ||
                    this.isShowEndServiceBtn(status, items) ||
                    this.isShowOrder(status)
            },
            // 是否显示取消按钮
            isShowCancelBtn(status, items, staffId){
                // 美疗师和下单顾问可以取消服务
                let isEnable = (items.some((item) => item.id == this.userId)) || (this.userId == staffId);
                return status != 5 && status != 6 && status != 7 && status != 8 && isEnable && this.$utils.hasPermission('fwdgl.cancel');
            },
            // 是否显示确认预约
            isShowOrder(status){
                return status == 9 && this.$utils.hasPermission('fwdgl.qryy');
            },
            // 是否显示开始服务按钮
            isShowStartServiceBtn(status, items){
                // 只有美疗师本人才可以开始服务
                let isEnable = items.some((item) => item.id == this.userId)
                return status == 4 && isEnable && this.$utils.hasPermission('fwdgl.begin');
            },
            // 是否显示结束服务按钮
            isShowEndServiceBtn(status, items){
                // 只有美疗师本人才可以开始服务
                let isEnable = items.some((item) => item.id == this.userId)
                return status == 5 && isEnable && this.$utils.hasPermission('fwdgl.end');
            },
            search(val){
                this.queryKey = val;
                this.reloadData();
            },
            tabChange(index){
                if(this.orderStatus === index){
                    return;
                }
                this.orderStatus = index;
                this.reloadData();
            },
            // 取消订单
            cancelOrder(id){
                uni.showModal({
                    title: '提示',
                    content: '确定取消服务吗?',
                    success: (res) => {
                        if (res.confirm) {
                            this.$httpUtils.request('/api/serviceOrder/cancelService/'+id).then((res) => {
                                if(res.status == 200){
                                    this.reloadData()
                                }
                                this.$toast.info(res.info);
                            })
                        }
                    }
                });
            },
            // 确认预约
            confirmServiceOrder(id){
                uni.showModal({
                    title: '提示',
                    content: '确认预约吗?',
                    success: (res) => {
                        if (res.confirm) {
                            this.$httpUtils.request('/api/serviceOrder/confirmServiceOrder', {
                                id:id
                            }, 'POST').then((res) => {
                                if(res.status == 200){
                                    this.reloadData()
                                }
                                this.$toast.info(res.info);
                            })
                        }
                    }
                });
            },
            //开始服务
            startService(id){
                uni.showModal({
                    title: '提示',
                    content: '确定开始服务吗?',
                    success: (res) => {
                        if (res.confirm) {
                            this.$httpUtils.request('/api/serviceOrder/startService/'+id).then((res) => {
                                if(res.status == 200){
                                    this.reloadData()
                                }
                                this.$toast.info(res.info);
                            })
                        }
                    }
                });
            },
            // 结束服务
            endService(id){
                uni.showModal({
                    title: '提示',
                    content: '确定结束服务吗?',
                    success: (res) => {
                        if (res.confirm) {
                            this.$httpUtils.request('/api/serviceOrder/stopService/'+id).then((res) => {
                                if(res.status == 200){
                                    this.reloadData()
                                }
                                this.$toast.info(res.info);
                            })
                        }
                    }
                });
            }
        },
        filters:{
            // 状态 1-待预约 2-待派单 3-待配料 4-待服务 5-服务中 6-服务完成 7-服务单结束 8-服务单取消
            formatStatus(val){
                if(val==1){
                    return '待预约'
                } else if(val == 2){
                    return '待派单'
                } else if(val == 3){
                    return '待配料'
                } else if(val == 4){
                    return '待服务'
                } else if(val == 5){
                    return '服务中'
                } else if(val == 6){
                    return '已完成'
                } else if(val == 7){
                    return '服务单结束'
                } else if(val == 9){
                    return '待确认'
                } else {
                    return '已取消'
                }
            },
        }
    }
</script>
 
<style>
    page{
        background: #F6F6F8;
    }
    .header{
        padding: 10px 10px 5px;
        background: #FFFFFF;
    }
    .tab{
        background: #FFFFFF;
        border-bottom: 1px solid #EDEAF4;
    }
    .list-item{
        background: #FFFFFF;
        border-radius: 4px;
        margin: 10px;
        color: #3a3f3f;
        padding: 0 10px;
    }
    .list-header{
        display: flex;
        justify-content: space-between;
        padding: 12px 0;
        font-size: 15px;
        border-bottom: 1px solid #EDEAF4;
    }
    .list-content{
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 12px 0;
        font-size: 14px;
    }
    .list-content .icon{
        width: 16px;
        height: 16px;
        vertical-align: sub;
        margin-right: 10px;
    }
    .list-footer{
        display: flex;
        justify-content: flex-end;
        padding: 10px 0;
        border-top: 1px solid #EDEAF4;
    }
</style>