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
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
<template>
    <view class="overflow" style="padding-bottom: 150rpx">
        <cu-custom bgColor="bg-white" :isBack="true">
            <block slot="backText"> </block>
            <block slot="content">异常处理</block>
        </cu-custom>
        <u-form labelPosition="left" label-width="180rpx" :model="warehouse" ref="warehouseRef">
            <u-row class="border_bottom margin_top10rpx padding_left25rpx" style="background-color: #fff">
                <u-col span="12">
                    <u-form-item label="容器编号:" prop="containerCode" required class="uFormItem">
                        <u-input v-model.trim="warehouse.containerCode" @confirm="getContainerData(1)"
                            :disabled="kwbhAllowed" placeholder="请录入或扫码" class="width" :focus="curFoucus">
                        </u-input>
                    </u-form-item>
                </u-col>
            </u-row>
            <u-row class="border_bottom margin_top10rpx background_fff padding_left25rpx padding_right30rpx">
                <u-col span="12">
                    <u-form-item label="异常状态:" prop="checkStatus" required class="uFormItem">
                        <u-input v-model="warehouse.checkStatusStr" placeholder="请选择" type="select" @click="show = true"
                            style="font-weight: bolder; margin-left: 15rpx; font-size: 34rpx"
                            class="width padding_left30rpx">
                        </u-input>
                        <u-select v-model="show" :list="checkStatuEnums" @confirm="handlerConfirm"></u-select>
                    </u-form-item>
                </u-col>
            </u-row>
            <!-- v-if="warehouse.containerCode" -->
            <u-row class="border_bottom margin_top10rpx padding_left25rpx" style="background-color: #fff">
                <u-col span="12">
                    <u-form-item label="异常原因:" prop="reason" class="uFormItem">
                        <u-input @focus="warehouse.reason = ''" v-model.trim="warehouse.reason" placeholder="请填写异常原因"
                            style="font-weight: bolder; margin-left: 15rpx" class="width padding_left25rpx">
                        </u-input>
                    </u-form-item>
                </u-col>
            </u-row>
        </u-form>
        <!-- 列表 -->
        <view class="margin_top10rpx">
            <u-swipe-action :show="item.show" :index="eindex" v-for="(item, eindex) in singlist" :key="eindex"
                :options="options" @click="longpress" @open="open" @close="close" class="margin_bottom10rpx">
                <view class="item u-border-bottom">
                    <!-- 此层wrap在此为必写的,否则可能会出现标题定位错误 -->
                    <view class="title-wrap">
                        <view :class="item.checked ? 'bg_item' : ''"
                            class="fontSize32rpx width margin_auto background_fff padding10 relative box_sizing transition">
                            <u-row>
                                <u-col span="12" class="flex align-center">
                                    <u-checkbox v-model="item.checked" size="50rpx"></u-checkbox>
                                    <view class="flex justify-center align-center" style="
                      background-color: #f18202;
                      color: #fff;
                      border-radius: 50vh;
                      width: 40rpx;
                      height: 40rpx;
                    ">
                                        {{ eindex + 1 }}
                                    </view>
                                    <text class="color_f18202 padding_left10rpx">
                                        {{ item.materialCode }} - {{ item.materialName }}
                                    </text>
                                </u-col>
                            </u-row>
                            <u-row>
                                <u-col span="12">
                                    <text class="color_80 padding_left25rpx">
                                        批次:{{ item.batch }}
                                    </text>
                                </u-col>
                            </u-row>
                            <u-row>
                                <u-col span="8">
                                    <text class="color_80 padding_left25rpx"> </text>
                                </u-col>
                                <u-col span="4">
                                    <text class="color_f18202"> 数量:{{ item.quantity }} </text>
                                </u-col>
                            </u-row>
                        </view>
                    </view>
                </view>
            </u-swipe-action>
        </view>
        <modal-code :rescode="rescode" :resmessage="resmessage" ref="resmodal" />
        <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>{{ this.materlist.materialCode }}</text>
            </view>
            <view class="line flex justify-between">
                <text class="text-gray">物料名称</text>
                <text>{{ this.materlist.materialName }}</text>
            </view>
            <view class="line flex justify-between">
                <text class="text-gray">物料小类</text>
                <text>{{ this.materlist.materialTypeName }}</text>
            </view>
            <view class="line flex justify-between">
                <text class="text-gray">批次</text>
                <text>{{ this.materlist.batchNo }}</text>
            </view>
            <view class="line flex justify-between">
                <text class="text-gray">物料规格</text>
                <text>{{ this.materlist.specificationModel }}</text>
            </view>
            <view class="line flex justify-between">
                <text class="text-gray">数量</text>
                <text>{{ this.materlist.unBindQuantity }}</text>
            </view>
            <!-- </view> -->
            <view class="margin_top140rpx">
                <button-modal :subShow="true" garmenTitle="打印" @submit="init" @reset="rest" />
            </view>
        </u-popup>
        <button-modal :empTytowerShow="true" cleaningTitle="重置" garmenTitle="确认" @submit="submit" @reset="back" />
    </view>
</template>
<script>
import { getContainerMaterial, unbindOrder } from "@/api/putIn/untie.js";
import BluePrint from "@/pages/print/bluePrint.js";
import ButtonModal from "../../components/buttonModal.vue";
import ModalCode from "../../components/ModalCode.vue";
import { getAttrValue } from "@/utils/tool.js";
import {
    getContainDetail,
    onlyUpdateDutyCycle,
    getBhbMaterialList,
} from "../../api/putIn/artificial.js";
 
import {
    getSGjRuKuMaterialHander,
    unAbnormalOrder,
} from "@/api/hander/hander.js";
export default {
    data() {
        return {
            operator: "",
            warehouse: {
                containerCode: "",
                materialCode: "",
                dutyCycle: "",
                gridNumber: 1,
                useNumber: 0,
                exitNumber: 0,
            },
            singlist: [], //详情列表
            ordersId: 0, //当前容器绑定的上架单
            rescode: 0,
            resmessage: "",
            options: [
                // {
                //   text: "打印",
                //   style: {
                //     backgroundColor: "#fc9f35",
                //   },
                // },
            ],
            detailshow: false,
            materlist: {},
            curFoucus: true,
            timer: null,
            timerSm: null,
            detailableZb: false,
            detailable: false,
            gridFocus: false,
            gridable: true,
            kwbhAllowed: false,
            show: false,
            checkStatuEnums: [
                // {
                //   value: "5",
                //   label: "已报废",
                // },
                // {
                //   value: "6",
                //   label: "已隔离",
                // },
                {
                    value: "7",
                    label: "冻结",
                },
            ],
        };
    },
    components: {
        ButtonModal,
        ModalCode,
    },
    onLoad() {
        this.operator = JSON.parse(uni.getStorageSync("userInfo")).name;
    },
    watch: {
        containerCode(val) {
            if (!val) {
                this.detailable = false;
                this.detailableZb = false;
                this.warehouse.exitNumber = 0;
            }
        },
    },
    methods: {
        // 如果打开一个的时候,不需要关闭其他,则无需实现本方法
        open(index) {
            // 先将正在被操作的swipeAction标记为打开状态,否则由于props的特性限制,
            // 原本为'false',再次设置为'false'会无效
            this.singlist[index].show = true;
            this.singlist.map((val, idx) => {
                if (index != idx) this.singlist[idx].show = false;
            });
        },
        close(index) {
            this.singlist[index].show = false;
        },
        //物料详情
        longpress(index, eindex) {
            this.materlist = this.singlist[index];
            this.detailshow = true;
        },
        //物料状态选择
        handlerConfirm(e) {
            this.warehouse.checkStatusStr = e[0].label;
            this.checkStatus = e[0].value;
        },
        //标签重新打印
        init() {
            const arr = ["materialCode", "unBindQuantity"];
            const arrzw = ["物料编号", "本次解绑数量"];
            let isAllow = "";
            Object.keys(this.materlist).forEach((item) => {
                if (arr.includes(item)) {
                    if (!this.materlist[item]) {
                        isAllow = arr.indexOf(item);
                        return;
                    }
                }
            });
            if (isAllow != "") {
                this.detailshow = false;
                this.rescode = 400;
                this.resmessage = `${arrzw[isAllow]}为空,不能继续打印`;
                this.$refs.resmodal.show = true;
                return;
            }
            if (
                this.materlist.unBindQuantity <= 0 ||
                this.materlist.unBindQuantity > this.materlist.quantity
            ) {
                this.detailshow = false;
                this.rescode = 400;
                this.resmessage = `数量不符合规范,不能继续打印`;
                this.$refs.resmodal.show = true;
                return;
            }
            if (!this.materlist.specificationModel) {
                this.materlist.specificationModel = "";
            }
            let ptintContext = [
                {
                    type: "text",
                    x: 0,
                    y: 0,
                    text: "",
                    size: 2,
                    rotate: 0,
                    bold: 0,
                    underline: false,
                    reverse: false,
                },
                {
                    type: "text",
                    x: 0,
                    y: 0,
                    text: "",
                    size: 2,
                    rotate: 0,
                    bold: 0,
                    underline: false,
                    reverse: false,
                },
                {
                    type: "text",
                    x: 0,
                    y: 0,
                    text: "",
                    size: 2,
                    rotate: 0,
                    bold: 0,
                    underline: false,
                    reverse: false,
                },
                /* 以上空数据,为防止丢包时打印不正常 */
                { type: "line", x1: 3, y1: 3, x2: 565, y2: 3, width: 2 },
                { type: "line", x1: 3, y1: 3, x2: 3, y2: 345, width: 2 },
                { type: "line", x1: 3, y1: 345, x2: 565, y2: 345, width: 2 },
                { type: "line", x1: 565, y1: 345, x2: 565, y2: 3, width: 2 },
                {
                    type: "text",
                    x: 80,
                    y: 15,
                    text: "牧野汽车装备(武汉)有限公司",
                    size: 3,
                    rotate: 0,
                    bold: 1,
                    underline: false,
                    reverse: false,
                },
                { type: "line", x1: 3, y1: 60, x2: 565, y2: 60, width: 2 },
                {
                    type: "text",
                    x: 10,
                    y: 75,
                    text: `物料编号: ${this.materlist.materialCode}`,
                    size: 2,
                    rotate: 0,
                    bold: 1,
                    underline: false,
                    reverse: false,
                },
                { type: "line", x1: 3, y1: 110, x2: 380, y2: 110, width: 2 },
                {
                    type: "text",
                    x: 10,
                    y: 125,
                    text: `物料名称: ${this.materlist.materialTypeName || ""}`,
                    size: 2,
                    rotate: 0,
                    bold: 1,
                    underline: false,
                    reverse: false,
                },
                { type: "line", x1: 3, y1: 160, x2: 380, y2: 160, width: 2 },
                {
                    type: "text",
                    x: 10,
                    y: 175,
                    text: `批次: ${this.materlist.batchNo}`,
                    size: 2,
                    rotate: 0,
                    bold: 1,
                    underline: false,
                    reverse: false,
                },
                { type: "line", x1: 3, y1: 210, x2: 565, y2: 210, width: 2 },
                { type: "line", x1: 380, y1: 60, x2: 380, y2: 210, width: 2 },
                {
                    type: "qr",
                    x: 410,
                    y: 72,
                    text: `PARTS NUMBER: ${this.materlist.materialCode},SAP: ${this.materlist.sap_Location || ""
                        },BOXNUM: ${this.materlist.boxNo || ""},LOT NO: ${this.materlist.batchNo
                        },QUANTITY: ${this.materlist.unBindQuantity}`,
                    width: 3,
                    level: 1,
                },
                {
                    type: "text",
                    x: 10,
                    y: 225,
                    text: `规格型号: ${this.materlist.specificationModel.length > 32
                            ? this.materlist.specificationModel.substr(0, 32)
                            : this.materlist.specificationModel
                        }`,
                    size: 2,
                    rotate: 0,
                    bold: 1,
                    underline: false,
                    reverse: false,
                },
                { type: "line", x1: 3, y1: 260, x2: 565, y2: 260, width: 2 },
                {
                    type: "text",
                    x: 120,
                    y: 290,
                    text: "MAKINO J(CHINA) CO.LTD",
                    size: 3,
                    rotate: 0,
                    bold: 1,
                    underline: false,
                    reverse: false,
                },
            ];
            console.log(ptintContext);
            BluePrint.print(this.$store, ptintContext)
                .then(() => {
                    // 关闭弹框 并恢复滑动块
                    this.detailshow = false;
                    this.addForm.code = this.materlist.materlist;
                    this.addForm.name = this.materlist.materialName;
                    this.addForm.batchNo = this.materlist.batchNo;
                    this.addForm.specificationModel = this.materlist.specificationModel;
                    addPrintRecord(this.addForm).then((res) => {
                        console.log(res);
                    });
                    uni.showToast({
                        title: "打印成功",
                        duration: 2000,
                    });
                })
                .catch((err) => {
                    // uni.showToast({
                    //     title:'打印失败',
                    //     duration: 2000
                    // })
                });
        },
        materialBlur() {
            clearTimeout(this.timerSm);
            this.timerSm = null;
            if (this.warehouse.materialCode == "") {
                return;
            }
 
            this.timer = setTimeout(() => {
                //多次触发bug 延迟bug
                //判断当前物料是否在盘点列表中
                const index = this.singlist.findIndex(
                    (item) =>
                        item.materialCode == this.warehouse.materialCode &&
                        item.batchNo == lotNo
                );
                if (index > -1) {
                    this.singlist[index].checked = 1;
                    this.singlist.unshift(...this.singlist.splice(index, 1));
                    return;
                } else {
                    clearTimeout(this.timer);
                    this.timer = null;
                    this.containerBlur();
                }
            }, 100);
        },
        containerBlur() {
            if (
                this.warehouse.containerCode == "" ||
                this.warehouse.materialCode == ""
            ) {
                return;
            }
            getContainerMaterial(this.warehouse).then((res) => {
                if (res.data == null || res.data.length == 0) {
                    this.rescode = 400;
                    this.resmessage = "暂无数据";
                    this.$refs.resmodal.show = true;
                    return;
                }
                this.warehouse.dutyCycle = res.data[0].dutyCycle || 0;
                //给所有的材料一个未选中的状态
                res.data.map((item) => {
                    (item.checked = true), (item.unBindQuantity = "");
                });
                this.singlist.unshift(...res.data);
                this.ordersId = res.data[0].ordersId;
            });
        },
        //解绑数量失焦事件
        changeNum(option) {
            //判断是否勾选,如果勾选了,就要对数量校验
            if (!option.checked) {
                return;
            }
            if (option.unBindQuantity == "") {
                this.rescode = 400;
                this.resmessage = "解绑数量不能为空";
                this.$refs.resmodal.show = true;
            }
 
            if (option.unBindQuantity <= 0) {
                this.rescode = 400;
                this.resmessage = "解绑数量必须大于0";
                this.$refs.resmodal.show = true;
            }
            if (option.unBindQuantity > option.quantity) {
                this.rescode = 400;
                this.resmessage = "解绑数量不能大于库存数量";
                this.$refs.resmodal.show = true;
            }
            if (this.detailable) {
                let filterHas = this.singlist.filter(
                    (item) => item.unBindQuantity == Number(item.quantity)
                );
                if (filterHas.length > 0) {
                    this.warehouse.exitNumber =
                        this.warehouse.useNumber - filterHas.length;
                }
            }
        },
        //确认解绑
        submit() {
            const filterArr = this.singlist.filter((item) => item.checked);
            if (filterArr.length <= 0) {
                this.rescode = 400;
                this.resmessage = "请选择解绑的物料!";
                this.$refs.resmodal.show = true;
                return;
            }
            //   const warehousOrderDetails = filterArr.reduce((curr, item) => {
            //     curr.push({
            //       ...item,
            //     });
            //     return curr;
            //   }, []);
            const handleArr = [];
            filterArr.forEach((item) => {
                handleArr.push(item.id);
            });
            uni.showModal({
                title: "异常处理",
                content: "是否确认异常处理?",
                showCancel: true,
                cancelColor: "#333333",
                success: (res) => {
                    if (res.confirm) {
                        unAbnormalOrder({
                            checkStatusStr: this.warehouse.checkStatusStr,
                            reason: this.warehouse.reason,
                            WmsStockIdList: handleArr,
                        }).then((res) => {
                            this.rescode = 200;
                            this.$refs.resmodal.show = true;
                            this.resmessage = "异常处理成功";
                            this.back();
                        });
                    } else if (res.cancel) {
                    }
                },
            });
        },
        rest() { },
        //检查容器栅格数
        checkGrid() { },
        //888获取容器的信息
        getContainerData(param) {
            if (this.warehouse.containerCode == "") {
                uni.showToast({
                    title: "请扫容器编号",
                    icon: "none",
                    duration: 2000,
                });
                return;
            }
            getSGjRuKuMaterialHander({
                containerCode: this.warehouse.containerCode,
                pageSize: 1000,
            }).then((res) => {
                const result = res.result.items;
                console.log("55555555");
                console.log(result);
 
                debugger;
                if (Array.isArray(result) && result.length == 0) {
                    uni.showToast({
                        title: "数据不存在",
                        icon: "none",
                        duration: 2000,
                    });
                    return;
                }
                if (result && result.length == 1) {
                    result[0].checked = true;
                }
                this.singlist = result;
            });
        },
        onlyUpdateDutyCycleClick() {
            this.$refs.warehouseRef.setRules(this.warehouseRules);
            this.$refs.warehouseRef.validate((valid) => {
                if (valid) {
                    //请求参数
                    let params = {
                        wareContainerCode: this.warehouse.containerCode,
                        dutyCycle: this.warehouse.dutyCycle,
                    };
                    uni.showModal({
                        title: "提示",
                        content: "是否确认仅更新空间占比数据?",
                        showCancel: true,
                        cancelColor: "#333333",
                        success: (res) => {
                            if (res.confirm) {
                                onlyUpdateDutyCycle(params).then((res) => {
                                    this.warhouseTph = this.warehouse.containerCode;
                                    this.rescode = res.code;
                                    this.resmessage = res.message;
                                    this.$refs.resmodal.show = true;
                                    this.rest();
                                });
                            } else if (res.cancel) {
                            }
                        },
                    });
                }
            });
        },
        gridBtnClick() {
            this.gridable = !this.gridable;
            if (!this.gridable) {
                this.$nextTick(() => {
                    this.gridFocus = true;
                });
            } else {
                this.$nextTick(() => {
                    this.gridFocus = false;
                });
            }
        },
        //全部取消
        back() {
            this.ordersId = 0;
            this.singlist = [];
            this.$refs.warehouseRef.resetFields();
            this.warehouse.containerCode = "";
            this.warehouse.checkStatusStr = "";
            this.warehouse.reason = "";
        },
    },
    unmounted() {
        if (this.timer) {
            clearTimeout(this.timer);
            this.timer = null;
        }
    },
};
</script>
<style lang="scss">
.content {
    height: 500rpx;
    overflow-y: scroll;
    width: 100%;
    padding: 15rpx;
    box-sizing: border-box;
 
    .content-item {
        padding: 15rpx;
        background-color: #fff;
        margin-bottom: 15rpx;
        border-radius: 8rpx;
        font-size: 32rpx;
    }
}
 
.bg_item {
    background: #ffebcd !important;
}
</style>