schangxiang@126.com
2025-09-17 ff43ddf18764629ff875478e4e47a7281cbd230a
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
<template>
    <view class="overflow" style="padding-bottom:400px">
        <!-- 顶部 -->
        <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> -->
 
        <div class="boxProp">
            <view class="line">
                <text class="text-gray">
                  <span style="display: inline-block;width: 75px;">新跟踪码 </span>
                </text>
                <text>
                    {{ materlist.snCode }}
                </text>
            </view>
            <view class="line flex justify-between">
                <text class="text-gray">数量</text>
                <text>{{ materlist.quantity }}</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>
        </div>
 
        <!-- 遮挡层 -->
        <modal-code ref="resmodal" :rescode='rescode' :resmessage='resmessage' />
        <view class="">
            <u-form labelPosition="left" :model="warehouse" label-width="180rpx" ref="warehouseRef">
                <u-row class="border_bottom margin_top10rpx  background_fff padding_left25rpx">
                    <u-col span="12">
                        <u-form-item required label="物料跟踪码:" class="uFormItem">
                            <u-input v-model.trim="warehouse.snCode" placeholder="请录入或扫码" @focus="warehouse.snCode = ''"
                                class="width padding_left25rpx" :focus="true" @confirm="materialBlur(1)">
                            </u-input>
                        </u-form-item>
                    </u-col>
                </u-row>
            </u-form>
            <view v-for="(item, eindex) in singlist" :key="eindex" class="margin_top10rpx">
                <u-swipe-action :show="item.show" :index="eindex" @click="longpredel" @open="open" @close="close"
                    :options="options">
                    <view class="fontSize32rpx background_fff padding10" :class="item.isYueku == '是' ? 'bg_item' : ''"
                        style="width: 100vw">
                        <u-row>
                            <u-col span="12">
                                <label class="flex align-center">
                                    <text class="flex justify-center align-center circkle06">{{ eindex + 1 }}</text>
                                    <view class="color_f18202 padding_left10rpx" style="flex: 1; word-break: break-all">
                                        {{ item.materialCode }}-{{ item.materialName }}
                                    </view>
                                </label>
                            </u-col>
                        </u-row>
                        <u-row>
                            <u-col span="12">
                                <view class="padding_left25rpx" style="color: #808080">
                                    跟踪码:{{ item.snCode }}
                                </view>
                            </u-col>
                        </u-row>
                        <u-row>
                            <u-col span="12">
                                <view class="padding_left25rpx" style="color: #808080">
                                    批次:{{ item.batch }}
                                </view>
                            </u-col>
                        </u-row>
                        <!-- <u-row>
                            <u-col span="7">
                                <view class="padding_left25rpx" style="color: #808080">
                                    最高库存数:{{ Number(item.maxImumqty).toFixed(3) }}
                                </view>
                            </u-col>
                            <u-col span="5">
                                <view class="" style="color: #808080">
                                    库存数:{{ Number(item.stockQty).toFixed(3) }}
                                </view>
                            </u-col>
                        </u-row> -->
                        <!-- <u-row>
                            <u-col span="7">
                                <view class="padding_left25rpx" style="color: #808080">
                                    行号:{{ item.asnLineNumber }}
                                </view>
                            </u-col>
                            <u-col span="5">
                                <view class="" style="color: #808080">
                                    转换率:{{ item.translateRate }}
                                </view>
                            </u-col>
                        </u-row> -->
 
                        <u-row>
                            <u-col span="7">
                                <view class="padding_left25rpx" style="color: #808080">
                                    容器编号:{{ item.containerCode }}
                                </view>
                            </u-col>
                            <u-col span="5">
                                <view class="" style="color: #808080">
                                    库存单位:{{ item.materialUnit }}
                                </view>
                            </u-col>
                        </u-row>
 
                        <u-row>
                            <u-col span="7">
                                <view class="padding_left25rpx" style="color: #808080">
                                    库存状态:{{ item.stockStatusName }}
                                </view>
                            </u-col>
                            <u-col span="5">
                                <view class="" style="color: #f18202">
                                    数量:{{ Number(item.quantity).toFixed(3) }}
                                </view>
                            </u-col>
                        </u-row>
                    </view>
                </u-swipe-action>
            </view>
 
            <button-modal :empTytowerShow='true' cleaningTitle="打印" garmenTitle='确认' @submit='submit' @reset='print' />
        </view>
 
    </view>
</template>
 
<script>
import ButtonModal from '@/components/buttonModal.vue'
import ModalCode from '@/components/ModalCode.vue'
import { getSGjRuKuMaterialHander, addWarehouseHbHander,outBoundOrderHander } from '@/api/hander/hander.js'
export default {
    data() {
        return {
            renameFocus: true,
            detailshow: false,
            rescode: 0,
            autoFoucs: true,
            resmessage: "",
            current: 0, //滑块默认值
            singlist: [], //物料详情
            materlist: {
                snCode:"",
                quantity:0,
                materialCode:"",
                materialName:"",
            }, //物料详情数据
            warehouse: {
                snCode: '',
                quantity: 0
            },
            warehouseRules: {
                snCode: [{
                    required: true,
                    message: '物料跟踪码不能为空',
                    trigger: 'blur'
                }]
            },
            options: [
                {
                    text: '删除',
                    style: {
                        backgroundColor: '#fc4b4b'
                    }
                }
            ]
        };
    },
    components: {
        ButtonModal,
        ModalCode,
    },
    onLoad() {
    },
    onReady() {
        this.$refs.warehouseRef.setRules(this.warehouseRules)
    },
    mounted() {
        this.operator = JSON.parse(uni.getStorageSync('userInfo')).name
    },
    methods: {
        //物料查询
        materialBlur() {
            if (!this.warehouse.snCode) {
                this.resmessage = "请扫物料跟踪码";
                this.rescode = 400;
                this.showBtn = 0;
                this.$refs.resmodal.show = true;
                return
            }
            getSGjRuKuMaterialHander({
                page: 1,
                pageSize: 1,
                SNCodeForPda: this.warehouse.snCode
            }).then((res) => {
                if (res.code == 200) {
                    var arrList = res.result.items;
                    if (arrList.length == 0) {
                        this.resmessage = "暂无数据";
                        this.rescode = 400;
                        this.showBtn = 0;
                        this.$refs.resmodal.show = true;
                    }
                    if (Array.isArray(arrList) && arrList.length >= 1) {
                        var IDM = arrList[0].snCode;
                        var arrNo = this.singlist.findIndex((v) => v.snCode == IDM);
                        if (arrNo == -1) {
                            this.singlist.unshift(arrList[0]);
            this.$forceUpdate()
                            
                            if (this.singlist.length == 1) {
                                this.materlist = JSON.parse(JSON.stringify(arrList[0]));
                                this.materlist.snCode = "HB_" + arrList[0].snCode;
                                // this.materlist.materialCode = arrList[0].materialCode
                                // this.materlist.materialName = arrList[0].materialName
                            }
                            this.materlist.quantity = this.singlist.reduce((prev, next) => {
                                let num = Number(prev) + Number(next.quantity);
                                return Number(num).toFixed(3);
                            }, 0);
                        } else {
                            this.resmessage = `跟踪码${arrList[0].snCode}已存在!`;
                            this.rescode = 400;
                            this.showBtn = 0;
                            this.$refs.resmodal.show = true;
                        }
 
                        // var stockQty = arrList[0].stockQty || 0;
                        // var allHe = Number(arrList[0].quantity + stockQty).toFixed(3);
                        // //最高库存maxImumqty < 收货数quantity + 库存数stockQty
                        // if (arrList[0].maxImumqty && arrList[0].maxImumqty > 0 &&
                        //     (arrList[0].maxImumqty < allHe)) {
                        //     uni.showModal({
                        //         title: "提示",
                        //         content: "超出最高库存,是否继续收货?",
                        //         showCancel: true,
                        //         cancelColor: "#333333",
                        //         success: (res) => {
                        //             if (res.confirm) {
                        //                 arrList.forEach((item) => {
                        //                     var arrNo = this.singlist.findIndex((v) => v.id == item.id);
                        //                     if (arrNo == -1) {
                        //                         this.singlist.unshift(item);
                        //                     }
                        //                 });
                        //             } else if (res.cancel) {
                        //             }
                        //         },
                        //     });
                        // } else {
                        //     arrList.forEach((item) => {
                        //         var arrNo = this.singlist.findIndex((v) => v.id == item.id);
                        //         if (arrNo == -1) {
                        //             this.singlist.unshift(item);
                        //         }
                        //     });
                        // }
                    } else {
                        this.resmessage = "暂无数据";
                        this.rescode = 400;
                        this.showBtn = 0;
                        this.$refs.resmodal.show = true;
                    }
                }
            });
        },
        //删除详情
        longpredel(index, eindex) {
            if (eindex == 0) {
                uni.showModal({
                    title: "提示",
                    content: "是否确认删除?",
                    showCancel: true,
                    cancelColor: "#333333",
                    success: (res) => {
                        if (res.confirm) {
                        
                            if(this.singlist.length == 1 ){ // 只剩一个 
                                this.singlist.splice(index, 1);
                                this.materlist = {}
                            }else{
                                this.singlist.splice(index, 1);
                                var itemNew = this.singlist[this.singlist.length - 1]
                                debugger
                                this.materlist.snCode = "HB_" + itemNew.snCode;
                                this.materlist.materialCode = itemNew.materialCode;
                                this.materlist.materialName = itemNew.materialName;
                                this.materlist.quantity = this.singlist.reduce((prev, next) => {
                                    let num = Number(prev) + Number(next.quantity);
                                    return Number(num).toFixed(3);
                                }, 0);
                            }
                            
                        } else if (res.cancel) {
                        }
                    },
                });
            } else {
                this.materlist = this.singlist[index]
                this.detailshow = true
            }
        },
        //卡片选中
        click(e) {
            e.cardNum = true
            this.$forceUpdate()
        },
        // 如果打开一个的时候,不需要关闭其他,则无需实现本方法
        open(index) {
            // 先将正在被操作的swipeAction标记为打开状态,否则由于props的特性限制,
            // 原本为'false',再次设置为'false'会无效
            this.singlist[index].cardNum = true;
            this.singlist[index].show = true;
            this.singlist.map((val, idx) => {
                if (index != idx) this.singlist[idx].show = false;
            })
            this.$forceUpdate()
        },
        close(index) {
            this.singlist[index].show = false;
            this.singlist[index].cardNum = false;
            this.$forceUpdate()
        },
 
        //确认
        submit() {
            if (this.singlist.length <= 1) {
                uni.showToast({
                    title: "请扫码跟踪码",
                    icon: "none",
                    duration: 2000,
                });
                return
            }
            var list = []
            this.singlist.forEach((item) => {
                list.push(item.snCode)
            })
            uni.showModal({
                title: '提示',
                content: '是否确认物料合并?',
                showCancel: true,
                cancelColor: '#333333',
                success: (res => {
                    if (res.confirm) {
                        addWarehouseHbHander({
                            quantity: this.materlist.quantity,
                            snCode: this.materlist.snCode,
                            'snCodeList': list
                        }).then((res) => {
                            this.rescode = res.code
                            this.resmessage = "物料合并成功"
                            this.$refs.resmodal.show = true
                            if (res.code == 200) {
                                this.renameFocus = true
                                this.rest()
                            }
                        })
                    } else if (res.cancel) {
 
                    }
                })
            });
 
        },
        //清楚选中
        rest() {
            this.warehouse.snCode = '';
 
            this.materlist.snCode = '';
            this.materlist.quantity = 0;
            this.materlist.materialCode = "";
            this.materlist.materialName = "";
            this.autoFoucs = true
            this.singlist = [];
        },
        print(){
            if (this.singlist.length <= 0) {
                uni.showToast({
                    title: "请扫码跟踪码",
                    icon: "none",
                    duration: 2000,
                });
                return
            }
            if (!this.materlist.snCode) {
                uni.showToast({
                    title: "请扫码跟踪码",
                    icon: "none",
                    duration: 2000,
                });
                return
            }
            uni.showModal({
                title: '提示',
                content: '是否确认打印?',
                showCancel: true,
                cancelColor: '#333333',
                success: (res => {
                    if (res.confirm) {
                        var {orderNo,relationNo ,orderNoLineNumber,relationNoLineNumber, ...rest } = this.materlist
                        var param = [
                            {
                                ...rest,
                                orderNo:this.materlist.relationNo,
                                PrintType:1, //打印类型:物料跟踪码
                                typeForPda:2 // 物料拆分1 物料合并2 
                            }
                        ]
                        outBoundOrderHander(param).then((res) => {
                            this.rescode = res.code
                            this.resmessage = res.message
                            this.$refs.resmodal.show = true
                            if (res.code == 200) {
                                this.resmessage = "打印成功" 
                            }
                        })
                    } else if (res.cancel) {
 
                    }
                })
            });
        }
    }
}
</script>
 
<style lang="scss">
.title-wrap {
    background-color: white;
    margin-top: 10px;
}
 
.boxProp {
    position: fixed;
    bottom: 150rpx;
    left: 0;
    width: 100%;
    z-index: 9;
}
</style>