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
<template>
    <view>
        <u-modal v-model="show" ref="uModal" title="" :show-cancel-button="true" @confirm="confirm" @cancel="cancel"
            :async-close="true">
            <view class="packing-registration-param">
                <scroll-view scroll-y="true" style="
            height: 100%;
            transform: translateZ(0);
            -webkit-font-smoothing: antialiased;
          ">
                    <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="form.outBatchNo" />
                            </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="form.ifsBatchNoArr"
                  disabled
                />
              </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="form.overallLength" />
                            </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="form.proposedLocation" disabled />
                            </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="form.reelNumber" />
                            </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="form.reelWeight" />
                            </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="form.grossWeight" />
                            </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="form.netWeight" disabled />
                            </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="form.waste" />
              </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="form.name" disabled />
                            </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="form.outerDiameter" />
                            </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="form.voltage" />
                            </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="form.speed" />
                            </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="form.pressure" />
                            </view>
                        </view>
                        <view class="packing-registration-param-item param-extra">
                            <view class="packing-registration-param-item-left">
                                <text class="item-one item-two">生产速度</text>
                            </view>
                            <view class="packing-registration-param-item-right">
                                <u-input class="item-one item-two" v-model="form.productionSpeed" />
                            </view>
                        </view>
                    </view>
                </scroll-view>
            </view>
        </u-modal>
        <u-modal v-model="showModal" title="" :show-cancel-button="true" :show-confirm-button="true"
            @confirm="confirmTl" @cancel="cancelTl">
            <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">
                            <text class="item-one item-two">{{
                detailedList.ifsBatchNo
              }}</text>
                        </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">
                            <text class="item-one item-two">{{ detailedList.partName }}</text>
                        </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="detailedList.suppliedQuantity" />
                        </view>
                    </view>
                </view>
            </view>
        </u-modal>
    </view>
</template>
 
<script>
    export default {
        props: {
            operationTaskList: {
                type: Object,
                required: true,
                default: () => ({}),
            },
            dutyId: {
                type: Number,
                required: true,
                default: "",
            },
        },
        data() {
            return {
                showModal: false,
                detailedList: {},
                show: false,
                form: {},
                ifsBatchNo: [],
                productInputList: [],
                // loading: false,
            };
        },
        watch: {
            "form.grossWeight"(val) {
                if (val === "") {
                    this.form.netWeight = "";
                } else if (this.form.reelWeight) {
                    this.form.netWeight =
                        parseFloat(val) - parseFloat(this.form.reelWeight);
                }
            },
            "form.reelWeight"(val) {
                if (this.form.grossWeight && val) {
                    this.form.netWeight =
                        parseFloat(this.form.grossWeight) - parseFloat(val);
                }
            },
        },
        methods: {
            confirm() {
                // if (this.loading) return;
                // if (!this.form.outerDiameter) {
                //   this.$u.toast("请输入成品外径测量值");
                //   this.$refs.uModal.clearLoading(); // 清除加载状态
                //   return;
                // }
                // if (!this.form.voltage) {
                //   this.$u.toast("请输入退火电压");
                //   this.$refs.uModal.clearLoading(); // 清除加载状态
                //   return;
                // }
                // if (!this.form.speed) {
                //   this.$u.toast("请输入转速");
                //   this.$refs.uModal.clearLoading(); // 清除加载状态
                //   return;
                // }
                // if (!this.form.pressure) {
                //   this.$u.toast("请输入外部气压");
                //   this.$refs.uModal.clearLoading(); // 清除加载状态
                //   return;
                // }
                // if (!this.form.productionSpeed) {
                //   this.$u.toast("请输入生产速度");
                //   this.$refs.uModal.clearLoading(); // 清除加载状态
                //   return;
                // }
                if (!this.form.outBatchNo) {
                    this.$u.toast("请输入批号");
                    this.$refs.uModal.clearLoading(); // 清除加载状态
                    return;
                }
                if (Number(this.form.netWeight) == 0) {
                    this.$u.toast("净重不为0");
                    this.$refs.uModal.clearLoading(); // 清除加载状态
                    return;
                }
                // if (!this.form.waste) {
                //   this.$u.toast("请输入废料");
                //   this.$refs.uModal.clearLoading(); // 清除加载状态
                //   return;
                // }
                // if (this.form.productInputList.length == 0) {
                //   this.$u.toast("投料批次不能为空,请扫码投料");
                //   this.$refs.uModal.clearLoading(); // 清除加载状态
                //   return;
                // }
                // this.operationTaskList.operationTaskId = this.operationTaskList.id;
                // this.form.operationTaskId = this.operationTaskList.id;
                // this.form.status = this.operationTaskList.status;
                // this.form.Persons = this.operationTaskList.Persons;
                // this.form.productStaffIds = this.operationTaskList.productStaffIds;
                // this.form.productStaffs = this.operationTaskList.productStaffs;
                // this.form.dutyRecordId = this.dutyId;
                // this.operationTaskList.productOutputList = []; // 创建一个空数组
                // this.operationTaskList.productOutputList.push(this.form); // 向数组中添加元素
                // console.log("this.operationTaskList", this.operationTaskList);
                // this.loading = true;
                // this.$u.api.workReporting
                //   .submitPDA(this.operationTaskList)
                //   .then((res) => {
                //     this.$emit("update",this.operationTaskList);
                //     this.$refs.uModal.cancel();
                //   })
                //   .finally(() => {
                //     this.loading = false;
                //     this.$refs.uModal.clearLoading();
                //   });
                this.$emit("update", this.form);
                this.$refs.uModal.clearLoading();
                this.$refs.uModal.cancel();
            },
            cancel() {
                this.show = false;
                this.form = {};
                this.ifsBatchNo = [];
                this.productInputList = [];
            },
            cancelTl() {
                this.showModal = false;
                this.detailedList = {};
            },
            updateArray(arr, newObj) {
                // 查找数组中是否有相同的 id
                let index = arr.findIndex(item => item.ifsBatchNo === newObj.ifsBatchNo);
 
                if (index !== -1) {
                    // 如果找到相同 id 的对象,替换原有对象
                    arr[index] = newObj;
                } else {
                    // 如果没有找到相同 id 的对象,直接推入新对象
                    arr.push(newObj);
                }
                return arr;
            },
            confirmTl() {
                let ifsBatchNoArr = [];
                let updatedArrayList = this.updateArray(this.productInputList, this.detailedList);
                console.log("updatedArrayList", updatedArrayList);
                // this.productInputList.push(updatedArrayList);
                this.$set(this.form, "productInputList", this.productInputList);
 
                this.productInputList.forEach((item) => {
                    ifsBatchNoArr.push(item.ifsBatchNo)
                })
                console.log("ifsBatchNoArr", ifsBatchNoArr);
                // this.ifsBatchNo.push(ifsBatchNoArr);
                this.$set(this.form, "ifsBatchNoArr", ifsBatchNoArr);
                console.log("this.form", this.form);
                this.showModal = false;
                this.detailedList = {};
            },
            open(val) {
                this.show = true;
                this.form = val.data;
            },
            // 回显扫码的信息-报工单
            saveForm(val) {
                this.$u.api.cancelReporting
                    .selInputPartInfoPDA({
                        outBatchNo: val.BN,
                        partNo: val.PN,
                        moOn: this.operationTaskList.moOn,
                    })
                    .then((res) => {
                        const list = {
                            suppliedQuantity: res.data.suppliedQuantity,
                            ifsBatchNo: res.data.ifsBatchNo,
                            partNo: res.data.partNo,
                            partName: res.data.partName,
                            locationNo: res.data.locationNo,
                            ifsLineItemNo: res.data.ifsLineItemNo,
                            serialNo: res.data.serialNo,
                            engChgLevel: res.data.engChgLevel,
                            ifsWdr: res.data.waivDevRejNo,
                            activitySeq: res.data.activitySeq,
                        };
                        this.detailedList = list;
                        this.showModal = true;
                    });
            },
        },
    };
</script>
 
<style lang="scss" scoped>
    ::v-deep .u-model__title {
        padding-top: 0 !important;
    }
 
    ::v-deep .u-input__input {
        text-align: right !important;
    }
 
    @import "../index.scss";
</style>