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
<template>
    <!-- 核磅录入 -->
    <div class="page">
        <view class="packing-registration-bg" />
        <u-navbar title="核磅录入" :background="background" :border-bottom="false" :title-bold="true" title-color="#000"
            back-icon-color="#000" />
        <u-form :model="form" ref="uForm" :label-width="200" :rules="rules" :error-type="['toast']" class="uForm">
            <u-form-item label="核磅单号" :border-bottom="false" prop="verificationNo">
                <u-input v-model="form.verificationNo" type="select" placeholder="请选择核磅单号" @click="openList" />
            </u-form-item>
            <u-form-item label="产品类型" :border-bottom="false" prop="productType">
                <u-input v-model="productTypeMap[form.productType] || form.productType" placeholder="" disabled />
            </u-form-item>
            <u-form-item label="车牌号" :border-bottom="false" prop="licensePlate">
                <u-input v-model="form.licensePlate" placeholder="" disabled />
            </u-form-item>
            <u-form-item label="发货通知单1" :border-bottom="false" prop="shippingNoticeNo1">
                <u-input v-model="form.shippingNoticeNo1" placeholder="" disabled />
            </u-form-item>
            <u-form-item label="客户名称1" :border-bottom="false" prop="customerName1">
                <u-input v-model="form.customerName1" placeholder="" disabled />
            </u-form-item>
            <u-form-item label="发货通知单2" :border-bottom="false" prop="shippingNoticeNo2">
                <u-input v-model="form.shippingNoticeNo2" placeholder="" disabled />
            </u-form-item>
            <u-form-item label="客户名称2" :border-bottom="false" prop="customerName2">
                <u-input v-model="form.customerName2" placeholder="" disabled />
            </u-form-item>
            <u-form-item label="司磅员" :border-bottom="false" prop="weighingOperator">
                <u-input v-model="form.weighingOperator" placeholder="" disabled />
            </u-form-item>
            <u-form-item label="叉车司机" :border-bottom="false" prop="forkliftOperator">
                <u-input v-model="form.forkliftOperator" placeholder="" disabled />
            </u-form-item>
            <u-form-item label="核磅记录" :border-bottom="false" prop="value8">
                <u-input type="select" placeholder="" @click="openNuclearScaleRecord" />
            </u-form-item>
            <u-form-item :label="`扫码记录(${ScanCodeRecord.length}条):`" :border-bottom="false" prop="shippingNoticeNo1"
                :label-width="260">
            </u-form-item>
        </u-form>
        <view class="wrap">
            <scroll-view class="packing-registration-scroll-list" scroll-y="true">
                <u-cell-group class="packing-registration-scroll-list-group" :border="false">
                    <view class="content" v-for="(item, index) in ScanCodeRecord" :key="index" :index="index"
                        @click="cancelReport(item)">
                        <view class="content-header">
                            <view class="content-header-title">{{ index + 1 }}</view>
                        </view>
                        <view class="content-body">
                            <view class="row-list">
                                <view class="_label">
                                    <view class="_label-name">批号:</view>
                                </view>
                                <view class="_content">
                                    {{ item.outBatchNo }}
                                </view>
                            </view>
                            <view class="row-list">
                                <view class="_label">
                                    <view class="_label-name">零件描述:</view>
                                </view>
                                <view class="_content">
                                    {{ item.netWeight }}
                                </view>
                            </view>
                            <view class="row-list">
                                <view class="_label">
                                    <view class="_label-name">零件号:</view>
                                </view>
                                <view class="_content">
                                    {{ item.partNo }}
                                </view>
                            </view>
                            <view class="row-list">
                                <view class="_label">
                                    <view class="_label-name">毛重:</view>
                                </view>
                                <view class="_content">
                                    {{ item.grossWeight }}
                                </view>
                            </view>
                            <view class="row-list">
                                <view class="_label">
                                    <view class="_label-name">盘重:</view>
                                </view>
                                <view class="_content">
                                    {{ item.trayWeight }}
                                </view>
                            </view>
                            <view class="row-list">
                                <view class="_label">
                                    <view class="_label-name">净重:</view>
                                </view>
                                <view class="_content">
                                    {{ item.netWeight }}
                                </view>
                            </view>
                        </view>
                    </view>
                </u-cell-group>
            </scroll-view>
        </view>
        <!-- 导体 -->
        <u-modal v-model="showModal" title="" :show-cancel-button="true" :show-confirm-button="true"
            @confirm="confirmDt" @cancel="cancelDt">
            <view class="popup-content">
                <view class="packing-registration-param">
                    <view class="packing-registration-param-view">
                        <view class="packing-registration-param-item param-extra">
                            <view class="packing-registration-param-item-left">
                                <text class="item-one">核磅重量:</text>
                            </view>
                            <view class="packing-registration-param-item-right">
                                <u-input class="item-one item-two" v-model="modalList.suppliedQuantity" />
                            </view>
                        </view>
                        <view class="packing-registration-param-item param-extra">
                            <view class="packing-registration-param-item-left">
                                <text class="item-one">叉车盘重:</text>
                            </view>
                            <view class="packing-registration-param-item-right">
                                <u-input class="item-one item-two" v-model="modalList.suppliedQuantity" />
                            </view>
                        </view>
                    </view>
                </view>
            </view>
        </u-modal>
        <u-button type="primary" class="bottom-button" @click="submit">提交</u-button>
        <u-modal v-model="show" @confirm="confirm" content="是否确认提交" show-cancel-button></u-modal>
        <saveForm ref="saveForm" :operationTaskList="this.form" @update="handleUpdate" />
        <scan></scan>
    </div>
</template>
 
<script>
    import scan from "@/components/scan/scan.vue";
    import content_bg from "@/static/custom/packing/backBg.png";
    import saveForm from "./saveForm.vue";
    export default {
        components: {
            scan,
            saveForm,
        },
        data() {
            return {
                modalList: {},
                showModal: false,
                productTypeMap: {
                    1: "导体",
                    2: "铜杆",
                    3: "导体2.6",
                },
                ScanCodeRecord: [],
                background: {
                    backgroundImage: `url(${content_bg})`,
                    backgroundAttachment: "fixed",
                    backgroundSize: "100% auto",
                    backgroundRepeat: "no-repeat",
                },
                show: false,
                form: {
                    value0: "",
                    verificationNo: "",
                    productType: "",
                    licensePlate: "",
                    shippingNoticeNo1: "",
                    customerName1: "",
                    weighingOperator: "",
                    forkliftOperator: "",
                    value8: "",
                    shippingNoticeNo2: "",
                    customerName2: "",
                },
                rules: {
                    verificationNo: [{
                        required: true,
                        message: "请选择核磅单号",
                        trigger: ["change", "blur"],
                    }, ],
                },
            };
        },
        onReady() {
            this.$refs.uForm.setRules(this.rules);
        },
        onShow() {
            let that = this;
            uni.$off("scan"); // 每次进来先 移除全局自定义事件监听器
            uni.$on("scan", function(data) {
                console.log("onscan");
                if (that.form.verificationNo == "") {
                    uni.showToast({
                        icon: "none",
                        title: "请先选择核磅单号!",
                        duration: 2 * 1000,
                    });
                    return;
                }
                //扫码成功后的回调,你可以写自己的逻辑代码在这里
                console.log("页面扫码结果:", data.code);
                if (data.code) {
                    try {
                        let codeInfo = JSON.parse(data.code);
                    } catch (e) {
                        uni.showToast({
                            icon: "none",
                            title: "扫码数据解析失败,请重试!",
                            duration: 2 * 1000,
                        });
                        return;
                    }
                    if (codeInfo.CN != that.form.customerName1) {
                        // 扫描报工单二维码
                        uni.showModal({
                            title: "提示",
                            content: "客户不一致:" +
                                codeInfo.CN +
                                "||" +
                                that.form.customerName1,
                            showCancel: true,
                            success: function() {
                                if (that.form.productType == "2") {
                                    that.$refs.saveForm.open(codeInfo);
                                } else {
                                    that.ScanCodeRecord.push(codeInfo);
                                }
                            },
                        });
                    } else {
                        if (that.form.productType == "2") {
                            that.$refs.saveForm.open(codeInfo);
                        } else {
                            that.ScanCodeRecord.push(codeInfo);
                        }
                    }
                }
            });
        },
        methods: {
            // 取消扫码记录
            cancelReport(item) {
                this.ScanCodeRecord = this.ScanCodeRecord.filter(a => a.outBatchNo !== item.outBatchNo);
            },
            // 导体提交
            confirmDt() {
                      const magnetic =
        Number(this.form.h) - Number(this.form.children) - Number(this.form.m);
                console.log("保存", this.form.verificationNo);
                switch (this.form.productType) {
                    case "导体":
                        if (magnetic > 0 && magnetic < 3) {
                            this.ScanCodeRecord.push(this.form);
                        } else {
                            this.$u.toast("生产核查");
                        }
                        break;
                    case "导体2.6":
                        if (magnetic > -0.5 && magnetic < 0.5) {
                            this.ScanCodeRecord.push(this.form);
                        } else {
                            this.$u.toast("生产核查");
                        }
                        break;
                }
            },
            // 取消
            cancelDt() {
                this.showModal = false;
            },
            handleUpdate(Obj) {
                this.ScanCodeRecord.push(Obj);
            },
            // 提交按钮
            submit() {
                this.showModal = true;
            },
            // 弹框保存
            confirm() {
                console.log("保存", this.form.verificationNo);
                // 请求接口,根据工单号查询其他信息并赋值
            },
            // 选择订单号
            openList() {
                uni.navigateTo({
                    url: "/pages/wareHouse/nuclearScale/nuclearScaleList",
                });
            },
            //核磅记录
            openNuclearScaleRecord() {
                if (this.form.verificationNo == "") {
                    uni.showToast({
                        icon: "none",
                        title: "请先选择核磅单号!",
                        duration: 2 * 1000,
                    });
                    return;
                }
                uni.navigateTo({
                    url: "/pages/wareHouse/nuclearScale/nuclearscalerecord",
                });
            },
            // 存订单号
            setNo(val) {
                this.form = val;
            },
            // 回显扫码的信息-报工单
            // saveForm(val) {
            //     let {
            //         WorkNo,
            //         ProcessName,
            //         ORDER_NO
            //     } = val;
            //     this.form.verificationNo = WorkNo;
            //     this.form.productType = ProcessName;
            //     this.form.licensePlate = ORDER_NO;
            // },
        },
    };
</script>
 
<style lang="scss">
    @import "index.scss";
</style>