schangxiang@126.com
2025-09-17 c0e20b1b0f1298cdc0af0037d60e74d51e364501
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
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
<template>
    <view class="overflow" style="padding-bottom:300px">
        <!-- 顶部 -->
        <cu-custom bgColor="bg-white" :isBack="true">
            <block slot="backText"></block>
            <block slot="content">生产订单发货</block>
        </cu-custom>
        <!-- 操作人 -->
        <view class="flex justify-end align-center padding_right30rpx padding_top12rpx">
            <text class="fontSize12rpx"> 操作人:{{operator}}  </text>
        </view>
        <!-- 遮挡层 -->
        <modal-code ref="resmodal" :rescode='rescode' :resmessage='resmessage' />
        <view>
            <u-form labelPosition="top" :model="warehouse" ref="warehouseRef">
                <u-row class="border_bottom margin_top10rpx padding10 box200" style="background-color: #fff;" >
                    <u-col span="12">
                        <u-form-item label="工序机床号:" prop="category_name" required
                            style="font-size: 16px;font-weight: bold;padding: 0;">
                            <view class="gxSbBox" v-if="warehouse.equipmentList.length > 0" @click="kuweiFocus">
                                <p class="text10">工序:{{ warehouse.process }} - 机床号:{{ warehouse.equipmentList.join(',') }}
                                </p>
                                <p></p>
                            </view>
                                <span v-if="warehouse.equipmentList.length == 0" readonly @click="kuweiFocus"
                                    style="font-weight: bolder;margin-left: 8px;"  class="width"
                                    >
                                     请选择工序机床号
                                </span>
                        </u-form-item>
                    </u-col>
                </u-row>
            </u-form>
            <view v-show="singlist.length > 0"  class="lineht_sm2">
                <view :show="item.show" :index="eindex" v-for="(item, eindex) in singlist" :key="eindex" :options="options" class="margin_top10rpx">
                    <view class="item u-border-bottom">
                        <!-- 此层wrap在此为必写的,否则可能会出现标题定位错误 -->
                        <view class="title-wrap ">
                            <view :key="eindex+'singlist'" :class="item.cardNum?'bd-ffe6c9':item.edit?'clickactive':''"
                                class="fontSize30rpx width margin_auto background_fff padding10 border_radius  relative box_sizing transition">
                                <u-row>
                                    <u-col span="12" class="flex" style="align-items: flex-start;">
                                        <view style="background-color: #f18202;color: #fff;border-radius: 50%;width: 20px;height: 20px;line-height: 20px;text-align: center;">
                                            {{eindex+1}}
                                        </view>
                                        <view class="color_f18202 padding_left10rpx" style="flex: 1;word-break: break-all;">
                                            {{item.materialCode}}({{item.materialName}})
                                        </view>
                                    </u-col>
                                </u-row>
                                <u-row>
                                    <u-col span="12">
                                        <view class="text06" >
                                            取货波次号:{{item.orderNo}}
                                        </view>
                                    </u-col>
                                </u-row>
                                <u-row>
                                    <u-col span="6">
                                        <view class="text06">
                                            分拣总需求数:{{item.quantity}}
                                        </view>
                                    </u-col>
                                    <u-col span="6">
                                        <view  class="text06">
                                            分拣完成数:{{item.completeQuantity}}
                                        </view>
                                    </u-col>
                                </u-row>
                                <u-row>
                                    <u-col span="12">
                                        <view class="text06">
                                            机床号:{{item.equipment}}
                                        </view>
                                    </u-col>
                                </u-row>
                                <u-row>
                                    <u-col span="6">
                                        <view  class="text06">
                                            工序:{{item.process}}
                                        </view>
                                    </u-col>
                                    <u-col span="6">
                                        <view class="" style="color: #f18202;">
                                            可发货数量:{{item.deliverQuantity}}
                                        </view>
                                    </u-col>
                                </u-row>
                                <!-- <u-row>
                                    <u-col span="6">
                                        <input class="border_bottom_f18202 width text-left fontSize32rpx padding_left10rpx"
                                            v-model="item.thisQuantity" type="number"  @focus="item.thisQuantity = ''"
                                            @blur="changeNum(item)"  placeholder="请输入本次发货数" />
                                    </u-col>
                                </u-row> -->
                            </view>
                        </view>
                    </view>
                </view>
            </view>
 
            <view v-show="showImgBtn"
                class="width fixed bottom140 margin_auto background_fff padding15 border_radius margin_bottom10rpx relative box_sizing transition">
                <view class="" style="width: 140px;height: 140px;border: 1px dashed #aaaaaa;position: relative;">
                    <image :src="image" mode="" @click="imgClick(image)" style="width: 100%;height: 100%;"></image>
                </view>
                <u-icon @click="delimage" name='close-circle-fill' color='red' size='60' v-if="image!==''"
                    style='position: absolute;left:200rpx;top: 20rpx;'>
                </u-icon>
 
                <view style="color: #aaaaaa;" v-if="image==''">
                    <view class="fontSize32rpx" @click='upload' style="position: absolute;left: 40px;top: 80px;">
                        <!-- <u-icon name="plus" size='70' style='position: absolute;left: 19px; top: -35px;'></u-icon> -->
                        <text  style='position: absolute;left: 19px; top: -55px;font-size: 60px;'> + </text>
                      <text style='margin-left: 14px;'>选择图片</text>    
                    </view>
                </view>
 
            </view>
 
            <!-- <button-modal :empTytowerShow='true' cleaningTitle="重置" garmenTitle='确认发货' @submit='submit' @reset='rest' /> -->
 
            <button-modal :issueShow='true' issueTitle="上传图片" subTitle='确认' restTiltle='重置' @reset='rest'
                @submit='submit' @issue="showImg"/>
 
        </view>
 
 
        <u-popup v-model="detailshow" border-radius="14" @close="detailshow=false" mode="bottom">
                <!-- <view class="pop "> -->
                <h2 class="text_align_center padding_bottom18 padding15">物料信息</h2>
                <view class="line flex justify-between">
                    <text class="text-gray">打印张数</text>
                    <text>
                        <u-input v-model.trim="contLabel"   placeholder="请输入打印张数"
                                 class="width"
                                 @focus="contLabel=''"
                                style="font-size: 36rpx;text-align: right;">
                            </u-input>
                    </text>
                </view>
                <view class="line flex justify-between">
                    <text class="text-gray">打印发货数量</text>
                    <text>
                        <u-input v-model.trim="ermNum"   placeholder="请输入打印发货数量"
                                 class="width"
                                 @focus="ermNum=''"
                                style="font-size: 36rpx;text-align: right;">
                            </u-input>
                    </text>
                </view>
                <view class="line flex justify-between">
                    <text class="text-gray">本次发货数量</text>
                    <text>{{materlist.deliverQuantity}}</text>
                </view>
                <view class="line flex justify-between">
                    <text class="text-gray">物料编号</text>
                    <text>{{materlist.materialCode}}</text>
                </view>
                <view class="line flex justify-between">
                    <text class="text-gray">物料名称</text>
                    <text>{{materlist.materialName}}</text>
                </view>
                <view class="line flex justify-between">
                    <text class="text-gray">批次</text>
                    <text>{{materlist.batchNo}}</text>
                </view>
                <!-- <view class="line flex justify-between">
                    <text class="text-gray">物料规格</text>
                    <text>{{materlist.specificationModel}}</text>
                </view> -->
 
                <!-- </view> -->
                <view class="margin_top140rpx">
                    <!-- <button-modal :subShow='true' garmenTitle='打印' @submit='init' @reset='rest' /> -->
                    <button-modal :cleaningShow='true' allTitle='蓝牙打印' cleaningTitle='斑马打印' @allsubmit="init(1)" @submit='init(2)'/>
                </view>
            </u-popup>
 
        <!-- 3级联动 -->
        <cascader ref="cascader" :cascaderData="cascaderData" @confirem="cascaderConfirem" :titleData="titleData">
        </cascader>
        <u-select v-model="containerVisible" :list="containerList" @confirm="containerConfirm"></u-select>
 
 
<u-select v-model="containerVisibleDo" :list="containerListDo" @confirm="containerConfirmDo"></u-select>
    </view>
</template>
 
<script>
    import cascader from '@/components/cascader.vue';
    import ButtonModal from '../../components/buttonModal.vue'
    import ModalCode from '../../components/ModalCode.vue'
    import {getOutMaterial,addDeliverRecord,getOrderMaterial,getAllOrder ,deletePicture ,getOrderMaterialDo ,getAllOrderDelivery,getOrderKtting} from '../../api/deliver.js'
    import {translateapp , translateImg} from '@/utils/compress.js'
    import printComp from '@/mixins/printDoLabel.js'
    import printBanma from '@/mixins/printBanma.js'
 
    export default {
        mixins: [printComp,printBanma],
        data() {
            return {
                containerVisibleDo: false,
                containerListDo: [],
                containerVisible: false,
                containerList: [],
                rescode: 0,
                resmessage: "",
                singlist: [], //物料详情
                materlist: {}, //物料详情数据
                warehouse: {
                    equipmentList:[],
                    process:'',
                    IsQueryEquipmentAll:false //是否查询所有机床号
                },
                options: [{
                        text: '打印',
                        style: {
                            backgroundColor: '#fc9f35'
                        }
                    }
                ],
                operator: '',
                image: '', //当前显示的图片地址
                action: this.$myHOST + '/delivery/record/uploadImages',
                fileList: [],
                detailshow: false,
                contLabel:1, //打印张数
                ermNum:'',
                timer:null,
                printflag:false,
                arrPt:[],
                showImgBtn:false,
                            // 3级下拉
            cascaderData: [],
            titleData: {
                'locationType': 1,// 1:A3区域,2:A1-A2区域
                'type':'',
                'typeInterface': "KingtingDo"
            },
            category_name: [],
            category_ids: '',
            };
        },
        components: {
            ButtonModal,
            ModalCode,
            cascader
        },
        onReady() {
        },
        mounted() {
            this.operator = JSON.parse(uni.getStorageSync('userInfo')).name
        },
        methods: {
            //打开3级弹框
            kuweiFocus() {
                
                let param = {
                    'PickSortFlag': 2 //1是取货  2是分拣)
                }
                this.$refs.cascader.show(param)
            },
                // 3级弹框 确认
            cascaderConfirem(e) {
                console.log(e)
                if(this.warehouse.process &&  e.process != this.warehouse.process){
                    uni.showToast({
                        title: '只能选择一种工序!',
                        icon: 'none'
                    })
                    return
                }
                this.category_ids = e.select_ids;
                this.category_name = e.select_names;
                this.warehouse.process = e.process;
                this.warehouse.equipmentList = e.equipmentList;
                if(e.equipmentList.length==0){
                    this.warehouse.IsQueryEquipmentAll = true 
                }else{
                    this.warehouse.IsQueryEquipmentAll = false 
                }
                this.warehouse.containerCode = ''
                this.singlist = []
                this.totalPages = ''
                this.orderBlur()
            },
            //DO容器选择
            containerConfirmDo(context){
                this.warehouse.DoOrderNo = context[0].value
                this.orderBlurDo()
            },
            //DO容器聚焦事件
            containerFocusDo() {
                getAllOrderDelivery().then(res => {
                    this.containerListDo = res.data.reduce((curr,item) => {
                        if(item.clientName==null){
                            item.clientName = ''
                        }
                        curr.push({
                            label: item.deliveryNo + '; 时间:' + item.deliveryNoCreateTime + '; 客户:' + item.clientName,
                            value: item.deliveryNo 
                        })
                        return curr;
                    },[])
                    this.containerVisibleDo = true;
                })
            },
            // 1 DO单号
            orderBlurDo(){
                if(this.warehouse.DoOrderNo == ''){
                    return
                }
                this.warehouse.OrderNo = ''
                this.singlist = []
            },
            //容器选择
            containerConfirm(context){
                this.warehouse.OrderNo = context[0].value
                this.orderBlur()
            },
            
            //容器聚焦事件
            containerFocus() {
                if(this.warehouse.DoOrderNo ==''){
                    this.$u.toast('请选择DO单号')
                    return
                }
                console.log("containerFocus")
                getAllOrder({
                    'OrderNo':this.warehouse.DoOrderNo,
                    'DeliveryNo':this.warehouse.DoOrderNo
                }).then(res => {
                    this.containerList = res.data.reduce((curr,item) => {
                        curr.push({
                            label: item,
                            value: item
                        })
                        return curr;
                    },[])
                    this.containerVisible = true;
                })
                
            },
 
        
            // 2 取货波次号
            orderBlur(){
                if(this.warehouse.process == ''){
                    return
                }
                let param  = {
                    'process': this.warehouse.process,
                    "equipmentList": [this.warehouse.equipmentList],
                    "IsQueryEquipmentAll": this.warehouse.IsQueryEquipmentAll
                }
                // 0214
                console.log("orderBlur")
                this.singlist = [];
                getOrderKtting(param).then(res => {
                    if(res.code==200){
                        this.singlist = res.data;
                    }
                    
                })
            },
 
            
            //物料输入框失焦事件
            materialBlur() {
                this.$refs.warehouseRef.validate(vali => {
                    if(vali) {
                        this.getOrderAndMateial()
                    }else {
                        this.rescode = 400
                        this.resmessage = `出库单号和物料编号不能为空`
                        this.$refs.resmodal.show = true
                    }
                })
            },
            //获取信息
            getOrderAndMateial(){
                getOutMaterial(this.warehouse).then(res => {
                    if(res.data.materialCode != null) {
                        this.singlist = [];
                        res.data.thisQuantity = res.data.quantity - res.data.completeQuantity;
                        this.singlist.push(res.data);
                    }else {
                        this.rescode = 400
                        this.resmessage = `当前出库单下找不到该物料${this.warehouse.MaterialCode}`
                        this.$refs.resmodal.show = true
                    }
                })
            },
            //发货数输入
            changeNum(val) {
                if(!val.thisQuantity) {
                    this.rescode = 400
                    this.resmessage = '本次发货数不能为空'
                    this.$refs.resmodal.show = true
                }
                if(!val.thisQuantity <= 0){
                    this.rescode = 400
                    this.resmessage = '本次发货数不能小于等于0'
                    this.$refs.resmodal.show = true
                }
                let num1 =  Number(val.quantity - val.completeQuantity).toFixed(3) //必须保留3位小数 -否则会造成剩余物料是小数的时候,无法收货
                if (Number(val.thisQuantity).toFixed(3)  > Number(num1) ) {
                    val.uncollectedQuantity = 0;
                    this.rescode = 400
                    this.resmessage = '本次发货数不能大于总的需求数减去已发货数'
                    this.$refs.resmodal.show = true
                }
            },
            //确认收货
            submit() {
                if(this.singlist.length == 0) {
                    this.rescode = 400
                    this.resmessage = '发货详情不能为空'
                    this.$refs.resmodal.show = true
                    return 
                }
                if(this.fileList.length<=0){
                    this.rescode = 400
                    this.resmessage = '请上传图片';
                    this.$refs.resmodal.show = true
                    return
                }
                this.singlist.forEach((item)=>{
                    item.img = this.fileList[1]
                })
                console.log(this.singlist)
                uni.showModal({
                    title: '提示',
                    content: '是否确认发货?',
                    showCancel: true,
                    cancelColor: '#333333',
                    success: (res => {
                        if (res.confirm) {
                            addDeliverRecord(this.singlist).then((res) => {
                                this.rescode = 200
                                this.resmessage = '发货成功'
                                this.$refs.resmodal.show = true
                                this.rest(1)
                            })
 
                        } else if (res.cancel) {
                            
                        }
                    })
                });
                
            },
            //重置
            rest(parm) {
                this.warehouse.process = '';
                this.warehouse.equipmentList = [];
                this.singlist = [];
                if(parm!=1 && this.fileList.length>0){
                    this.delimage()
                }
                this.fileList = []
                this.image = ''
            },
            // 上传图片 - 因需要压缩图片 仅支持app上传图片
            upload() {
                this.fileList = []
                uni.chooseImage({
                    sourceType: ["camera", "album"],
                    sizeType: "original",
                    count: 1,
                    success: (res) => {
                        this.image = res.tempFilePaths[0]
                        console.log(res.tempFilePaths)
                        translateapp(res.tempFilePaths[0], 80, imgUrl => {
                            let imgArr = [imgUrl]
                            imgArr.forEach(item => this.fileList.push({
                                uri: item
                            }))    
                            console.log(this.fileList)
                            uni.uploadFile({
                                url: this.action,
                                files: this.fileList,
                                fileType: 'image',
                                success: (res) => {
                                    if(res.statusCode==200){
                                        const result = JSON.parse(res.data)
                                        this.fileList.push(result.data)
                                        if (result.data == null || result.data == '') {
                                            this.image = ''
                                            this.fileList = []
                                            this.$u.toast('图片上传服务器失败')
                                            return
                                        }
                                    }else{
                                        this.$u.toast('图片上传失败')
                                        this.fileList = []
                                        this.image = ''
                                    }
                                }
                            })
                        })
                    }
                })
            },
            delimage() {
                if(this.fileList.length<=0){
                    return
                }
                if(!this.fileList[1]){
                    this.fileList = [];
                    this.image = '';
                    return
                }
                deletePicture({
                    'filepath':this.fileList[1]
                }).then(res => {
                    if(res.code == 200) {
                        this.image = ''
                        this.$u.toast('移除图片成功')
                        this.fileList = []
                    }else {
                        this.rescode = 400
                        this.resmessage = `删除图片失败`
                        this.$refs.resmodal.show = true
                    }
                })
            },
            imgClick(url) {
                if(this.image!==''){
                    var imgArr = [];
                    imgArr.push(url)
                    //预览图片
                    uni.previewImage({
                        urls: imgArr,
                        current: imgArr[0]
                    });
                }
            },
            //监听原生返回键
            onBackPress(e) {
                this.delimage()
            },
            //打印
            init(param) {
                const arr = ['wareMaterialCode','uncollectedQuantity'];
                const arrzw = ['物料编号','实际发货数']
                let isAllow = ''
                Object.keys(this.materlist).forEach(item => {
                    if(arr.includes(item)) {
                        if(!this.materlist[item]) {
                            isAllow =  arr.indexOf(item)
                            // this.rescode = 400
                            // this.resmessage = `${item}为空,不能继续打印`
                            // this.$refs.resmodal.show = true
                            return 
                        }
                    }
                })
                if(isAllow!=''){
                    this.detailshow = false
                    this.rescode = 400
                    this.resmessage = `${arrzw[isAllow]}为空,不能继续打印`
                    this.$refs.resmodal.show = true
                    return
                }
 
                if(!this.contLabel || !this.ermNum){
                    uni.showToast({
                        title: '数量不能为空且大于0',
                        icon: 'none'
                    })
                    return
                }
                this.materlist.supplier = this.materlist.supplier || ''
                this.materlist.deliveryNo = this.warehouse.DoOrderNo || ''
                this.materlist.completeQuantity = this.ermNum
                this.arrPt = [this.materlist]
                if(param==1){
                    this.printComp()
                }else{
                    this.printBanma(0,2)
                }
                
            },
            showImg(){
                this.showImgBtn =!this.showImgBtn
            }
        }
    }
</script>
 
<style lang="scss">
 
</style>