李旭东
2023-10-23 37bff611a02107e151a7a9f82b624caff9c7005b
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
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
<template>
    <view class="scan_index">
        <view class="scan_header"></view>
        <view class="scan_content">
            <view class="scan_content_button">
                <u-button 
                    type="primary" 
                    icon="scan" 
                    text="继续扫描管片" 
                    color="#C8DEff"
                    iconColor="#1977FF"
                    customStyle="color: #1977FF"
                    @click="scanChange()">
                </u-button>
            </view>
            <scroll-view class="scan_content_scroll" scroll-y="true">
                <view 
                    v-for="item in pipeDataList"
                    :key="item.id"
                    class="scroll_item">
                    <view class="scroll_item_title">
                        管片信息
                    </view>
                    <view class="scroll_item_content">
                        <view class="item_content_info">
                            <text class="label">项目:</text>
                            <text>{{item.proName}}</text>
                        </view>
                        <view class="item_content_info">
                            <text class="label">环号:</text>
                            <text>{{item.ringNum}}</text>
                        </view>
                        <view class="item_content_info">
                            <text class="label">管片编号:</text>
                            <text>{{item.pipeNum}}</text>
                        </view>
                        <view class="item_content_info">
                            <text class="label">尺寸:</text>
                            <text>{{item.sizeName}}</text>
                        </view>
                        <view class="item_content_info">
                            <text class="label">块号:</text>
                            <text>{{item.blockNumName}}</text>
                        </view>
                    </view>
                </view>
            </scroll-view>
            <view class="scan_content_change">
                <u-form
                    ref="uForm"
                    labelPosition="left"
                    labelWidth="auto"
                    :model="ruleForm"
                    :rules="rules">
                    <u-form-item label="出库时间:" prop="strTime" borderBottom @click="changeTime(1)">
                        <u-input 
                            v-model="ruleForm.strTime" 
                            border="none" 
                            placeholder="请选择出库时间"
                            disabled
                            disabledColor="#FFFFFF">
                        </u-input>
                        <u-icon
                            slot="right"
                            name="calendar"
                        ></u-icon>
                    </u-form-item>
                    <u-form-item label="拟到时间:" prop="endTime" borderBottom @click="changeTime(2)">
                        <u-input 
                            v-model="ruleForm.endTime" 
                            border="none" 
                            placeholder="请选择拟到时间"
                            disabled
                            disabledColor="#FFFFFF">
                        </u-input>
                        <u-icon
                            slot="right"
                            name="calendar"
                        ></u-icon>
                    </u-form-item>
                    <u-form-item label="收货人:" prop="reciverName" borderBottom @click="changeReciverName()">
                        <u-input 
                            v-model="ruleForm.reciverName" 
                            border="none" 
                            placeholder="请选择收货人"
                            disabled
                            disabledColor="#FFFFFF">
                        </u-input>
                        <u-icon
                            slot="right"
                            name="arrow-right"
                        ></u-icon>
                    </u-form-item>
                    <u-form-item label="收货单位:" prop="reciverUnit" borderBottom>
                        <u-input 
                            v-model="ruleForm.reciverUnit" 
                            border="none" 
                            placeholder="收货单位"
                            disabled
                            disabledColor="#FFFFFF">
                        </u-input>
                        <u-icon
                            slot="right"
                            name="arrow-right"
                        ></u-icon>
                    </u-form-item>
                    <u-form-item label="车牌号:" prop="carBrand" borderBottom @click="changeCarBrand()">
                        <u-input 
                            v-model="ruleForm.carBrand" 
                            border="none" 
                            placeholder="请选择车牌号"
                            disabled
                            disabledColor="#FFFFFF">
                        </u-input>
                        <u-icon
                            slot="right"
                            name="arrow-right"
                        ></u-icon>
                    </u-form-item>
                    <u-form-item label="GPS设备:" prop="carBrand" borderBottom @click="changeGpsDevice()">
                        <u-input 
                            v-model="ruleForm.gdName" 
                            border="none" 
                            placeholder="请选择GPS设备"
                            disabled
                            disabledColor="#FFFFFF">
                        </u-input>
                        <u-icon
                            slot="right"
                            name="arrow-right"
                        ></u-icon>
                    </u-form-item>
                    <u-form-item label="项目名称:" prop="proName" borderBottom @click="changeProject()">
                        <u-input 
                            v-model="ruleForm.proName" 
                            border="none" 
                            placeholder="请选择项目名称"
                            disabled
                            disabledColor="#FFFFFF">
                        </u-input>
                        <u-icon
                            slot="right"
                            name="arrow-right"
                        ></u-icon>
                    </u-form-item>
                </u-form>
            </view>
            <view
                v-if="ruleForm.carBrand"
                class="scroll_item scroll_items">
                <view class="scroll_item_title">
                    车辆信息
                </view>
                <view class="scroll_item_content">
                    <view class="item_content_info">
                        <text class="label">车辆类型:</text>
                        <text>{{carData.dictName}}</text>
                    </view>
                    <view class="item_content_info">
                        <text class="label">司机:</text>
                        <text>{{carData.carDriver}}</text>
                    </view>
                    <view class="item_content_info">
                        <text class="label">联系电话:</text>
                        <text>{{carData.carPhone}}</text>
                    </view>
                    <view class="item_content_info">
                        <text class="label">备注:</text>
                        <text>{{carData.carNotes}}</text>
                    </view>
                </view>
            </view>
            <view style="padding-bottom: 10px;">
                <u-button
                    type="primary" 
                    text="提交" 
                    color="#1977FF"
                    @click="checkSubmit()">
                </u-button>
            </view>
        </view>
        <u-modal 
            :show="showModal" 
            content='是否确认出库信息'
            showCancelButton
            @cancel="showModal = false"
            @confirm="submitExitStoreInfo"
        ></u-modal>
        <u-picker
            :show="showPickerCar"
            :columns="columsCarData" 
            keyName="carBrand"
            closeOnClickOverlay
            @cancel="showPickerCar = false"
            @confirm="confirmPickerCar"
            @close="showPickerCar = false"
            ></u-picker>
        <u-picker
            :show="showPickerConsignee"
            :columns="columsConsigneeData" 
            keyName="reciverName"
            closeOnClickOverlay
            @cancel="showPickerConsignee = false"
            @confirm="confirmPickerConsignee"
            @close="showPickerConsignee = false"
            ></u-picker>
            <u-datetime-picker
                :show="showPickerTime"
                @cancel="showPickerTime = false"
                @confirm="confirmPickerTime"
                v-model="defaultTime"
                mode="datetime"
            ></u-datetime-picker>
        <u-picker
            :show="showGps"
            :columns="gpsDeviceList" 
            keyName="gdName"
            closeOnClickOverlay
            @cancel="showGps = false"
            @confirm="confirmGpsDevice"
            @close="showGps = false"
            ></u-picker>
        <u-picker
            :show="showProject"
            :columns="projectList" 
            keyName="proName"
            closeOnClickOverlay
            @cancel="showProject = false"
            @confirm="confirmProject"
            @close="showProject = false"
            ></u-picker>
    </view>
</template>
 
<script>
import { throttle, changeTime } from '../../plugins/public';
    export default {
        data() {
            return {
                ruleForm: {
                    strTime: '',
                    endTime: '',
                    reciverName: '',
                    carBrand: ''
                },
                defaultTime: Number(new Date()),
                pipeDataList: [],
                timeType: 1,
                showPickerTime: false, 
                showModal: false, // 模态框
                showPickerCar: false,
                columsCarData: [], // 车辆信息
                showPickerConsignee: false,
                columsConsigneeData: [], // 收获人信息
                carData: {}, // 车辆信息
                rules: {
                    strTime: [{
                        required: true,
                        message: '请选择出发时间',
                        trigger: ['blur', 'change']
                    }],
                    endTime: [{
                        required: true,
                        message: '请选择拟到时间',
                        trigger: ['blur', 'change']
                    }],
                    reciverName: [{
                        required: true,
                        message: '请选择收货人',
                        trigger: ['blur', 'change']
                    }],
                    carBrand: [{
                        required: true,
                        message: '请选择车辆',
                        trigger: ['blur', 'change']
                    }],
                    gdName: [{
                        required: true,
                        message: '请选择GPS设备',
                        trigger: ['blur', 'change']
                    }]
                },
                gpsDeviceList: [],
                showGps: false,
                projectList: [],
                showProject: false,
            }
        },
        onReady() {
            this.$refs.uForm.setRules(this.rules);
        },
        onLoad(option) {
            uni.$off('scancodedate');
            console.log(option.pipeNum,'=====')
            this.getPipeDetailInfo(option.pipeNum).then((data) => {
                console.log(data,'=====')
                this.pipeDataList.push(data);
            })
            this.getAllCarData();
            this.getAllConsigneeData();
            this.getProjectList();
        },
        onUnload() {
            // 移除监听事件
            uni.$off('scancodedate');
        },
        methods: {
            // 获取管片信息详情
            async getPipeDetailInfo(pipeNum) {
                const { data } = await this.$api.exit.getPipeDetailInfo({
                    pipeNum: pipeNum
                })
                return data;
            },
            // 获取收货人信息
            async getAllConsigneeData() {
                this.columsConsigneeData = [];
                const { data } = await this.$api.exit.getAllConsigneeData();
                console.log(data,'收货人信息信息');
                this.$set(this.columsConsigneeData, 0, data);
            },            
            // 获取车辆信息
            async getAllCarData() {
                this.columsCarData = [];
                const { data } = await this.$api.exit.getAllCarData();
                this.$set(this.columsCarData, 0, data);
            },
            async getGpsDeviceLists(carId) {
                this.gpsDeviceList = [];
                const { data } = await this.$api.exit.getGpsDeviceLists({carId: carId});
                this.$set(this.gpsDeviceList, 0, data);
            },
            async getProjectList(carId) {
                this.projectList = [];
                const { data } = await this.$api.exit.searchProjects({
          pageNum: 1,
          pageSize: 1000000
                });
                console.log(data.list,'--');
                this.$set(this.projectList, 0, data.list);
            },
            // 再次扫码
            scanChange() {
                const that = this;
                uni.$on('scancodedate', function(data) {
                    console.log(data.code, '扫码结果????');
                    uni.$u.toast('扫描完成!');
                    uni.$off('scancodedate');
                    that.getPipeDetailInfo(data.code.slice(-17)).then((res) => {
                        const list = that.pipeDataList.map(item => item.pipeNum);
                        if(list.includes(res.pipeNum)) {
                            uni.$u.toast('请勿重复扫描!');
                            return false;
                        } else {
                            that.$nextTick(() => {
                                that.pipeDataList.push(res);
                            })
                        }
                    })
                })
            },
            // 提交打开模态框
             checkSubmit() {
                this.$refs.uForm.validate().then((res) => {
                    this.showModal = true;
                })
             },
            // 确认提交出库信息
            submitExitStoreInfo: throttle(function() {
                console.log('出库完成', this.ruleForm);
                const params = Object.assign({}, this.ruleForm);
                params.pipeIds = this.pipeDataList.map(item => item.pipeId);
                delete params.reciverName;
                delete params.carBrand;
                this.$api.exit.submitPipeOutStore(params).then((res) => {
                    if(res.success) {
                        this.showModal = false;
                        uni.$u.toast('出库成功!');
                        uni.navigateBack();
                    } else {
                        uni.$u.toast(res.statusMsg);
                    }
                })
            }, 3000),
            changeTime(number) {
                if(number === 1) {
                    this.$set(this.ruleForm, 'strTime', '');
                } else {
                    this.$set(this.ruleForm, 'endTime', '');
                }
                this.timeType = number;
                this.showPickerTime = true;
            },
            // 选择收货人信息
            changeReciverName() {
                this.$set(this.ruleForm, 'inUserId', '');
                this.$set(this.ruleForm, 'reciverName', '');
                this.$set(this.ruleForm, 'reciverUnit', '');
                this.showPickerConsignee = true;
            },
            // 选择车辆信息
            changeCarBrand() {
                this.$set(this.ruleForm, 'carId', '');
                this.$set(this.ruleForm, 'carBrand', '');
                this.showPickerCar = true;
            },
            // 选择GPS设备信息
            changeGpsDevice() {
                this.$set(this.ruleForm, 'gdId', '');
                this.$set(this.ruleForm, 'gdName', '');
                this.showGps = true;
            },
            // 选择项目信息
            changeProject() {
                this.$set(this.ruleForm, 'proId', '');
                this.$set(this.ruleForm, 'proName', '');
                this.showProject = true;
            },            
            // 确认选择日期时间
            confirmPickerTime({ value }) {
                if(this.timeType === 1) {
                    this.$set(this.ruleForm, 'strTime', changeTime(value));
                } else {
                    this.$set(this.ruleForm, 'endTime', changeTime(value));
                }
                this.showPickerTime = false;
            },
            // 确认选择gps设备
            confirmGpsDevice({ value }) {
                this.$set(this.ruleForm, 'gdId', value[0].gdId);
                this.$set(this.ruleForm, 'gdName', value[0].gdName);
                this.showGps = false;
            },
            // 确认选择项目
            confirmProject({ value }) {
                this.$set(this.ruleForm, 'proId', value[0].proId);
                this.$set(this.ruleForm, 'proName', value[0].proName);
                this.showProject = false;
            },
            // 确认选择收货人信息
            confirmPickerConsignee({ value }) {
                this.$set(this.ruleForm, 'inUserId', value[0].id);
                this.$set(this.ruleForm, 'reciverName', value[0].reciverName);
                this.$set(this.ruleForm, 'reciverUnit', value[0].reciverUnit);
                this.showPickerConsignee = false;
            },
            // 确认选择车辆信息
            confirmPickerCar({ value }) {
                console.log(value,'--');
                this.$set(this.ruleForm, 'carId', value[0].carId);
                this.$set(this.ruleForm, 'carBrand', value[0].carBrand);
                this.getGpsDeviceLists(value[0].carId);
                this.$api.exit.getCarInfo({
                    carId: value[0].carId
                }).then((res) => {
                    this.carData = res.data;
                })
                this.showPickerCar = false;
            }
        }
    }
</script>
 
<style scoped lang="scss">
.scan_index {
    position: relative;
    width: 100vw;
    height: 100vh;
    background: #F6F6F6;
    
    .scan_header {
        height: 14%;
        background: #1976FF;
        border-radius: 0 0 30% 30%;
    }
    
    .scan_content {
        position: absolute;
        top: 4%;
        left: 50%;
        transform: translateX(-50%);
        padding: 0 10px;
        width: calc(100% - 30px);
        // height: 95%;
        background: #FFFFFF;
        
        .scan_content_button {
            padding: 10px 0;
        }
        
        .scan_content_scroll {
            height: 48%;
        }
        
        .scan_content_change {
            padding: 10px 0;
        }
    }
    
    .scroll_item {
        padding: 10px 15px;
        margin: 10px 0;
        background: #F6F9FE;
        border-top: 3px solid #1976FF;
        border-radius: 4px;
        
        
        &:first-child {
            margin-top: 0;
        }
        
        .scroll_item_title {
            position: relative;
            padding: 0 10px;
            color: #1976FF;
            font-size: 18px;
            
            &::before {
                content: '';
                position: absolute;
                top: 50%;
                left: 0;
                transform: translateY(-50%);
                width: 3px;
                height: 60%;
                background: #1976FF;
            }
        }
        
        .scroll_item_content {
            margin-top: 10px;
            
            .item_content_info {
                display: flex;
                align-items: center;
                padding: 2px 0;
                
                .label {
                    color: #AFB0B1;
                }
            }
        }
    }
    
    .scroll_items {
        border-top: 0;
    }
}
</style>