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
<template>
    <view class="overflow">
        <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>
        <view class="text-bold width fontSize32rpx" style="padding: 10rpx 10rpx;background-color: #d6d6d6;">
            <view class="flex justify-between align-center">
                <text class="width23 padding10">入库单号</text>
                <text>{{putCode}}</text>
            </view>
        </view>
        <u-form labelPosition="top" :model="warehouse" ref="warehouseRef">
            <u-row class="border_bottom margin_top10rpx padding10" style="background-color: #fff;">
                <u-col span="10">
                    <u-form-item label="容器编号:" prop="containerCode" required
                        style="font-size: 16px;font-weight: bold;padding: 0;">
                        <input v-model="warehouse.containerCode" placeholder="请录入或扫码" @focus="focu=true"
                            @blur="getContainerDetails" style="font-weight: bolder;margin-left: 15rpx;"
                            class="width padding_left25rpx">
                        </input>
                        <u-icon name="close-circle-fill" color="#848484" v-if="warehouse.containerCode && focu"
                            @click="warehouse.containerCode=''"></u-icon>
                    </u-form-item>
                </u-col>
                <u-col span="2">
                    <u-icon class="iconfont icon-saoma fontSize60rpx"></u-icon>
                </u-col>
            </u-row>
            <u-row class="border_bottom margin_top10rpx padding10" style="background-color: #fff;">
                <u-col span="10">
                    <u-form-item label="物料编号:" 
                        style="font-size: 16px;font-weight: bold;padding: 0 0 10rpx;">
                        <input v-model="warehouse.materialCode" placeholder="请录入或扫码" @focus="materialFocus"
                            @blur="getMaterialDetails" style="font-weight: bolder;margin-left: 15rpx;"
                            class="width padding_left25rpx ">
                        </input>
                        <u-icon name="close-circle-fill" color="#848484" v-if="warehouse.materialCode && focuM"
                            @click="warehouse.materialCode=''"></u-icon>
                    </u-form-item>
                </u-col>
                <u-col span="2">
                    <u-icon class="iconfont icon-saoma fontSize60rpx"></u-icon>
                </u-col>
            </u-row>
        </u-form>
        <modal-code :rescode='rescode' :resmessage='resmessage' ref="resmodal" />
        <view v-if="singlist.length>0" :style="'height:calc(100vh - '+(CustomBar+155)+'px'">
            <view class="margin_top10rpx overflow_auto" style="height:calc(100% - 265rpx)">
                <scroll-view scroll-y="true">
                    <u-swipe-action :show="item.show" :index="eindex" v-for="(item, eindex) in singlist" :key="eindex"
                        @click="longpress" @open="open" :options="options">
                        <view class="item u-border-bottom">
                            <!-- 此层wrap在此为必写的,否则可能会出现标题定位错误 -->
                            <view class="title-wrap">
                                <view :key="eindex+'singlist'" :class="item.edit?'clickactive':''"
                                    class="fontSize32rpx width margin_auto background_fff padding15 border_radius margin_bottom10rpx relative box_sizing transition">
                                    <u-row>
                                        <u-col span="12" class="flex">
                                            <view class="flex justify-center align-center"
                                                style="background-color: #f18202;color: #fff;border-radius: 50vh;width: 20px;height: 20px;">
                                                {{eindex+1}}
                                            </view>
                                            <view class="color_f18202 padding_left10rpx">
                                                {{item.warematerialCode}} - {{item.batchNo}}
                                            </view>
                                        </u-col>
                                    </u-row>
                                    <u-row>
                                        <u-col span="6">
                                            <view class="" style="padding: 10rpx 0 10rpx 45rpx;color: #808080;">
                                                大类:{{item.category}}
                                            </view>
                                        </u-col>
                                        <u-col span="6">
                                            <view class="" style="padding: 10rpx 0 10rpx 45rpx;color: #808080;">
                                                小类:{{item.warematerialName}}
                                            </view>
                                        </u-col>
                                    </u-row>
                                    <u-row>
                                        <u-col span="6">
                                            <input disabled=""
                                                class="border_bottom_f18202 width45 fontSize32rpx text-left"
                                                style="margin:10rpx 0 10rpx 45rpx;" v-model="item.unit" placeholder="单位"
                                            />
                                        </u-col>
                                        <u-col span="5">
                                            <input
                                                class="border_bottom_f18202 width text-left fontSize32rpx padding_left10rpx"
                                                v-model="item.quantity" type="number" placeholder="请输入组盘数量"/>
                                        </u-col>
                                    </u-row>
                                </view>
                            </view>
                        </view>
                    </u-swipe-action>
                </scroll-view>
            </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>{{materlist.warematerialCode}}</text>
                    </view>
 
                    <view class="line flex justify-between">
                        <text class="text-gray">物料大类</text>
                        <text>{{materlist.category}}</text>
                    </view>
                    <view class="line flex justify-between">
                        <text class="text-gray">物料小类</text>
                        <text>{{materlist.warematerialCode}}</text>
                    </view>
                    <view class="line flex justify-between">
                        <text class="text-gray">物料规格</text>
                        <text>{{materlist.specificationModel}}</text>
                    </view>
                    <view class="line flex justify-between">
                        <text class="text-gray">长(mm)</text>
                        <text>{{materlist.long}}</text>
                    </view>
                    <view class="line flex justify-between">
                        <text class="text-gray">宽(mm)</text>
                        <text>{{materlist.width}}</text>
                    </view>
                    <view class="line flex justify-between">
                        <text class="text-gray">高(mm)</text>
                        <text>{{materlist.high}}</text>
                    </view>
                    <view class="line flex justify-between">
                        <text class="text-gray">重量(kg)</text>
                        <text>{{materlist.weight}}</text>
                    </view>
                    <view class="line flex justify-between">
                        <text class="text-gray">条码</text>
                        <text>{{materlist.barCode}}</text>
                    </view>
                    <view class="line flex justify-between">
                        <text class="text-gray">单位</text>
                        <text>{{materlist.unit}}</text>
                    </view>
                </view>
            </u-popup>
        </view>
        <button-modal :cleaningShow='true' allTitle='全部取消' cleaningTitle='确认组盘' @allsubmit="reset" @submit='submit' />
 
    </view>
</template>
 
<script>
    import ButtonModal from '../../../components/buttonModal.vue'
    import ModalCode from '../../../components/ModalCode.vue'
    import {
        getOrderNo,
        getContainerDetails,
        add,
        WarematerialCode
    } from '../../../api/putIn/artificial.js'
    import {
        getDate
    } from '../../../utils/dateTime.js'
    export default {
        data() {
            return {
                modalshow: false,
                show: false,
                rescode: 0,
                resmessage: "",
                purchaseNo: '',
                putCode: '', //容器二维码
                detailshow: false,
                operator: '',
                focu: false, //清空按钮隐显
                focuM: false, //物料隐显按钮
                Datetime: getDate(),
                singlist: [], //物料详情
                options: [{
                        text: '详情',
                        style: {
                            backgroundColor: '#fc9f35'
                        }
                    },
                    {
                        text: '删除',
                        style: {
                            backgroundColor: '#fc4b4b'
                        }
                    }
                ],
                materlist: [],
                warehouse: {
                    containerCode: '',
                    materialCode: ''
                },
                batchNo: '',当前扫码的物料的批次
                warehouseRules: {
                    containerCode: [{
                        required: true,
                        message: '容器编号不能为空',
                        trigger: 'blur'
                    }],
                    materialCode: [{
                        required: true,
                        message: '物料编号不能为空',
                        trigger: 'blur'
                    }]
                },
                containerCodeRules: {
                    containerCode: [{
                        required: true,
                        message: '容器编号不能为空',
                        trigger: 'blur'
                    }],
                },
                materialCodeRules: {
                    materialCode: [{
                        required: true,
                        message: '物料编号不能为空',
                        trigger: 'blur'
                    }]
                },
            };
        },
        components: {
            ButtonModal,
            ModalCode
        },
        onReady() {
            // this.$refs.warehouseRef.setRules(this.warehouseRules)
        },
        mounted() {
            this.operator = JSON.parse(uni.getStorageSync('userInfo')).name
            this.$refs.warehouseRef.setRules(this.warehouseRules)
            this.getOrderNo()
        },
        methods: {
            //入库单号
            getOrderNo() {
                getOrderNo().then((res) => {
                    if (res.code == 200) {
                        this.putCode = res.data
                    } else {
                        this.$refs.resmodal.show = true
                    }
                })
            },
            //查询空托
            getContainerDetails() {
                this.$refs.warehouseRef.validate(valid => {
                    if (valid) {
                        setTimeout(() => {
                            this.focu = false
                            if (this.warehouse.containerCode !== '') {
                                getContainerDetails({
                                    materialCode: this.warehouse.containerCode
                                }).then((res) => {
                                    if (res.code == 200) {
                                        if (res.data.length == 0) {
                                            this.rescode = 400
                                            this.resmessage = '无此容器'
                                            this.$refs.resmodal.show = true
                                            return
                                        }
                                    } else {
                                        this.resmessage = res.message
                                        this.rescode = res.code
                                        this.$refs.resmodal.show = true
                                    }
                                })
                            }
                        }, 200)
                    }
                })
            },
            //物料查询
            getMaterialDetails() {
                this.$refs.warehouseRef.setRules(this.materialCodeRules)
                this.$refs.warehouseRef.validate(valid => {
                    if (valid) {
                        setTimeout(() => {
                            this.focuM = false
                            if (this.warehouse.materialCode !== '') {
                                let params = {
                                    WarematerialCode: this.warehouse.materialCode
                                }
                                WarematerialCode(params).then((res) => {
                                    if (res.code == 200) {
                                        // this.singlist=res.data
                                        if (res.data.rows.length == 0) {
                                            this.rescode = 400
                                            this.resmessage = '无此物料'
                                            this.$refs.resmodal.show = true
                                            return
                                        }
                                        res.data.rows.map(item => {
                                            item.batchNo = this.batchNo
                                            item.quantity = ''
                                            return item;
                                        })
                                        
                                        this.singlist.unshift(...res.data.rows)
                                        let deWeightThree = (val) => {
                                            let map = new Map()
                                            for (let item of val) {
                                                if (!map.has(item.warematerialCode && item.barNo)) {
                                                    map.set(item.warematerialCode && item.barNo,
                                                        item)
                                                } else {
                                                    uni.showModal({
                                                        title: '提示',
                                                        content: '请勿重复扫描',
                                                        showCancel: false
                                                    })
                                                }
                                            }
                                            return [...map.values()]
                                        }
                                        this.singlist = deWeightThree(this.singlist)
                                    } else {
                                        this.resmessage = res.message
                                        this.rescode = res.code
                                        this.$refs.resmodal.show = true
                                    }
                                })
                            }
                        }, 200)
                    }
                })
            },
            //物料编号聚焦事件
            materialFocus() {
                this.warehouse.materialCode = ''
                uni.hideKeyboard()
            }
            //删除详情
            longpress(index, eindex) {
                if (eindex == 1) {
                    this.singlist.splice(index, 1)
                } else {
                    this.materlist = this.singlist[index]
                    this.detailshow = true
                }
 
            },
            // 如果打开一个的时候,不需要关闭其他,则无需实现本方法
            open(index) {
                // 先将正在被操作的swipeAction标记为打开状态,否则由于props的特性限制,
                // 原本为'false',再次设置为'false'会无效
                this.singlist[index].show = true;
                this.singlist.map((val, idx) => {
                    if (index != idx) this.singlist[idx].show = false;
                })
            },
            //改变组盘数量
            changeNum(val) {
                if (val.quantity > val.uncollectedQuantity) {
                    val.quantity = val.uncollectedQuantity
                }
                if (val.quantity && val.quantity > 0) {
                    val.edit = true
                    this.$forceUpdate()
                } else {
                    val.edit = false
                    this.$forceUpdate()
                }
 
            },
            //全部取消
            reset() {
                this.singlist.forEach(item => {
                    item.quantity = ""
                    item.edit = false
                })
                this.$forceUpdate()
            },
            //重置页面信息
            rest() {
                this.warehouse.containerCode = ''
                this.warehouse.materialCode = ''
                this.singlist.forEach(item => {
                    item.quantity = ''
                })
                this.singlist = []
                this.getOrderNo()
            },
            //确认
            submit() {
                this.$refs.warehouseRef.setRules(this.warehouseRules)
                this.$refs.warehouseRef.validate(valid => {
                    if (valid) {
                        let arr = this.singlist.filter(item => item.edit)
                        if (arr.length == 0 && this.singlist.length !== 0) {
                            uni.showModal({
                                title: '提示',
                                content: '未填写组盘数量',
                                showCancel: false
                            })
                            return
                        }
                        let matatilDetails = []
                        arr.forEach(item => {
                            matatilDetails.push({
                                createdUserId: JSON.parse(uni.getStorageSync('userInfo')).id,
                                createdUserName: JSON.parse(uni.getStorageSync('userInfo')).name,
                                updatedUserId: JSON.parse(uni.getStorageSync('userInfo')).id,
                                updatedUserName: JSON.parse(uni.getStorageSync('userInfo')).name,
                                wareMaterialCode: item.warematerialCode,
                                batchNo: item.batchNo,
                                purchaseNo: item.purchaseNo,
                                collectNo: item.collectNo,
                                deliveryNo: item.deliveryNo,
                                completeQuantity: item.quantity,
                                quantity: item.quantity
                            })
                        })
                        let params = {
                            createdUserId: JSON.parse(uni.getStorageSync('userInfo')).id,
                            createdUserName: JSON.parse(uni.getStorageSync('userInfo')).name,
                            updatedUserId: JSON.parse(uni.getStorageSync('userInfo')).id,
                            updatedUserName: JSON.parse(uni.getStorageSync('userInfo')).name,
                            orderNo: this.putCode,
                            wareContainerCode: this.warehouse.containerCode,
                            warehousOrderDetails: matatilDetails,
 
                        }
                        add(params).then((res) => {
                            this.$refs.resmodal.show = true
                            this.rescode = res.code
                            this.resmessage = res.message
                            if (res.code == 200) {
                                this.rest()
                            }
                        })
                    }
                })
            }
        },
 
    }
</script>
 
<style lang=scss">
 
</style>