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
<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>
        <u-form labelPosition="top" :model="warehouse" ref="warehouseRef">
            <u-row class="border_bottom margin_top10rpx padding10" style="background-color: #fff;">
                <u-col span="12">
                    <u-form-item label="库位编号:" prop="Code" required
                        style="font-size: 16px;font-weight: bold;padding: 0 0 10rpx;">
                        <input v-model="warehouse.Code" placeholder="请录入或扫码" disabled
                            class="width padding_left25rpx" style="font-weight: bolder;margin-left: 15rpx;">
                        </input>
                    </u-form-item>
                </u-col>
                <!-- <u-select v-model="visibleContainer"  :list="containerList" value-name="wareContainerCode" label-name="wareContainerCode"  @confirm="handleConfirm"></u-select> -->
            </u-row>
            <u-row  class="border_bottom margin_top10rpx padding10" style="background-color: #fff;">
                <u-col span="12">
                    <u-form-item label="物料编号:"  style="font-size: 16px;font-weight: bold;padding: 0 0 10rpx;">
                        <u-input v-model="warehouse.materialCode"  placeholder="请扫码录入" @focus="warehouse.materialCode=''" @blur="materialBlur" :clearable="false" style="font-weight: bolder;margin-left: 15rpx;" 
                         class="width padding_left25rpx">
                        </u-input>
                    </u-form-item>
                </u-col>
            </u-row>
        </u-form>
        <modal-code ref="resmodal" :rescode='rescode' :resmessage='resmessage' />
        <view v-show="singlist.length > 0"  style="height: 450rpx;margin-bottom: 180rpx;overflow-y: scroll;">
            <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  :class="item.edit?'clickactive':''"
                            class="fontSize32rpx width margin_auto background_fff padding15 border_radius margin_bottom10rpx relative box_sizing transition">
                            <u-row style="margin-bottom: 15rpx;">
                                <u-col span="11" 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-col span='1' v-if='sign'>
                                    <u-icon name='question-circle' color='#f18202'></u-icon>
                                </u-col>
                            </u-row>
                            <u-row>
                                <u-col span="6">
                                    <view style="padding: 5px 0 5px 10px;color: #808080;">
                                        SAP:{{item.sap_Location}}
                                    </view>
                                </u-col>
                            </u-row>
                            <u-row>
                                <!-- <u-col span="6">
                                    <view class="" style="padding: 10rpx 0 10rpx 45rpx;color: #808080;">
                                        库存数:{{item.inventoryQuantity}}
                                    </view>
                                </u-col> -->
                                <u-col span="6">
                                    <input
                                        class="border_bottom_f18202 width text-left fontSize32rpx padding_left10rpx"
                                        v-model="item.quantity" type="number" @blur="changeNum(item)"
                                        placeholder="请输入实盘数量" />
                                </u-col>
                                <!-- 隐藏备注 [Editby shaocx,2023-04-21]  -->
                                <!-- <u-col span="6">
                                    <input
                                        class="border_bottom_f18202 width text-left fontSize32rpx padding_left10rpx"
                                        v-model="item.remarks" 
                                        placeholder="请输入备注" />
                                </u-col> -->
                            </u-row>
                        </view>
                    </view>
                </view>
            </u-swipe-action>
            <u-popup v-model="detailshow" border-radius="14" @close="detailshow=false" mode="bottom" :closeable='true'>
                <view class="pop ">
                    <h2 class="text_align_center padding_bottom18 padding15">物料信息</h2>
                    <!-- <scroll-view scroll-y="true" style="height: 50vh;"> -->
                    <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.wareMaterialCategoryName}}</text>
                    </view>
                    <view class="line flex justify-between">
                        <text class="text-gray">物料小类</text>
                        <text>{{materlist.wareMaterialTypeName}}</text>
                    </view>
                    <view class="line flex justify-between">
                        <text class="text-gray">物料名称</text>
                        <text>{{materlist.wareMaterialName}}</text>
                    </view>
                    <view class="line flex justify-between">
                        <text class="text-gray">库存数量</text>
                        <text>{{materlist.inventoryQuantity}}</text>
                    </view>
                    <view class="flex justify-around transition margin_top10rpx margin_bottom10rpx">
                        <button class="width45 bg-ffe6c9 " @click="issue">问题标记</button>
                        <!-- <button class="width25 bg-grey" @click="reset">重置</button> -->
                        <!-- <button class="width25 bg-f18202 color_F2F2F2" @click="sub">确定</button> -->
                    </view>
                    <view class="" v-if="issueShow">
                        <view class="line flex justify-between">
                            <text class="text-gray">问题描述:</text>
                            <u-input v-model="materlist.remarks"></u-input>
                        </view>
                        <!-- <view
                            class="width margin_auto background_fff padding15 border_radius relative box_sizing transition">
                            <scroll-view scroll-y="true" style="height: 16vh;">
                                <u-upload :action="action" upload-text="送货单照片" :file-list="fileList1"
                                    @on-success="successPic" @on-remove="remove">
                                </u-upload>
                            </scroll-view>
                        </view> -->
                        <view class="padding" style="border-top: 1px solid #e4e4e4;">
                            <button class="width bg-grey" @click="subissue">提交问题</button>
                        </view>
                    </view>
                </view>
            </u-popup>
        </view>
        <button-modal :subShow='true'   garmenTitle='盘点完成' @submit='submit' />
    </view>
</template>
 
<script>
    import ButtonModal from '../../components/buttonModal.vue'
    import ModalCode from '../../components/ModalCode.vue'
    import {getSquareMaterial,issueSubmit,finish,getContainerData} from '@/api/check/check.js'
    import {getAttrValue} from '@/utils/tool.js'
    export default {
        data() {
            return {
                visibleContainer: false,
                containerList: [],
                detailshow: false,
                renameFocus: false,
                modalshow: false,
                issueShow: false,
                rescode: 0,
                resmessage: "",
                focuM: false,
                focu: false,
                sign: false, //问题标识
                operator: '',
                singlist: [], //物料详情
                options: [
                    // {
                    // text: '详情',
                    // style: {
                    //     backgroundColor: '#fc9f35'
                    // }},
                ],
                materlist: [],
                warehouse: {
                    Code: '',
                    materialCode: '',
                    orderId: ''
                },
                containerCode: '',
                warehouseRules: {
                    Code: [{
                        required: true,
                        message: '容器编号不能为空',
                        trigger: 'blur'
                    }]
                },
            };
        },
        components: {
            ButtonModal,
            ModalCode
        },
        onReady() {
            this.$refs.warehouseRef.setRules(this.warehouseRules)
        },
        onLoad(option) {
            if(option) {
                this.warehouse.Code = option.wareContainerCode;
                this.warehouse.orderId = option.orderId;
            }
             this.checkTask();
        },
        mounted() {
            this.operator = JSON.parse(uni.getStorageSync('userInfo')).name
        },
        methods: {
            //二维码内容处理 chenzhuwen
            materialBlur() {
                if(this.warehouse.materialCode==''){
                    return
                }
                if(this.warehouse.materialCode.length<50){
                    return
                }
                //获取批次
                let lotNo = getAttrValue(this.warehouse.materialCode,'LOTNO')
                //物料编号
                this.warehouse.materialCode = getAttrValue(this.warehouse.materialCode,'PARTSNUMBER')
                // SAP --- && item.sap_Location == SAP
                let SAP = getAttrValue(this.warehouse.materialCode,'SAP')
                //判断当前物料是否在盘点列表中
                const index = this.singlist.findIndex(item => item.wareMaterialCode == this.warehouse.materialCode && item.batchNo == lotNo);
                if(index > -1) {
                    this.singlist.unshift(...this.singlist.splice(index,1))
                }else {
                    this.rescode = 400
                    this.resmessage = '此批次的物料不在盘点列表中'
                    this.$refs.resmodal.show = true
                }
            },
            //验证容器
            checkTask() {
                this.containerCode = this.warehouse.Code;
                this.focu = false
                if (this.warehouse.Code !== '') {
                    getSquareMaterial(this.warehouse).then((res) => {
                        if (res.code == 200) {
                            if (res.data.length == 0) {
                                this.rescode = 400
                                this.resmessage = '暂无数据'
                                this.$refs.resmodal.show = true
                                return
                            }
                            
                            res.data.map(item => {
                                item.quantity = '';
                                item.remarks = '';
                                item.edit = false;
                                item.show = false;
                            })
                            this.singlist = res.data
                            
                        } else {
                            this.$refs.resmodal.show = true
                            this.rescode = res.code
                            this.resmessage = res.message
                        }
                    })
                }else {
                    this.rescode = 400
                    this.resmessage = '库位好不能为空'
                    this.$refs.resmodal.show = true
                }
            },
            //删除详情
            longpress(index, eindex) {
                this.singlist.forEach(item => {
                    item.materlist = [{
                        issue: ''
                    }]
                })
                this.materlist = this.singlist[index]
                this.detailshow = true
            },
            //问题标记
            issue() {
                this.issueShow = true
            },
            //提交问题
            subissue() {
                this.issueShow = false
                let params = {
                    wareContainerCode: this.materlist.wareContainerCode,
                    wareMaterialCode: this.materlist.wareMaterialCode,
                    batchNo: this.materlist.batchNo,
                    remarks: this.materlist.remarks,
                    orderId: this.materlist.orderId
                }    
                issueSubmit(params).then((res) => {
                    // if(res.code==200){
                    // this.$refs.resmodal.show = true
                    // this.resmessage = res.message
                    // this.rescode = res.code
                    this.$u.toast(res.data)
                    // }
                })
            },
            // 如果打开一个的时候,不需要关闭其他,则无需实现本方法
            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) {
                // 盘点允许0
                // if (val.quantity && val.quantity > 0) {
                if (val.quantity && val.quantity >= 0) {
                    // val.quantity = Number(val.quantity.toString().match(/^\d+(?:\.\d{0,2})?/)) // 保留两位小数
                    val.edit = true
                    this.$forceUpdate()
                } else {
                    val.edit = false
                    this.$forceUpdate()
                }
 
            },
            rest() {
                this.warehouse.Code = ''
                this.warehouse.materialCode = ''
                this.singlist = []
            },
            //确认
            submit() {
                this.$refs.warehouseRef.validate(valid => {
                    if (valid) {
                        if(this.singlist.length == 0) {
                            this.$refs.resmodal.show = true
                            this.resmessage = '盘点材料列表为空'
                            this.rescode = res.code
                            return
                        }
                        
                        const filterArr = this.singlist.filter(item =>item.edit == true)
                        const index = filterArr.findIndex(item => item.quantity == '' || item.quantity < 0)
                        if(index > -1) {
                            this.$refs.resmodal.show = true
                            this.resmessage = '请填写实盘数量'
                            this.rescode = res.code
                            return
                        }
                        let details = filterArr.reduce((curr,item) => {
                            curr.push({
                                wareMaterialCode: item.wareMaterialCode,
                                batchNo: item.batchNo,
                                checkQuantity: item.quantity,
                                orderId: item.orderId,
                                sap_Location:item.sap_Location
                            })
                            return curr
                        },[])
 
                        let params = {
                            wareContainerCode: this.warehouse.Code,
                            details
                        }
                        finish(params).then((res) => {
                            this.$refs.resmodal.show = true
                            this.resmessage = res.message
                            this.rescode = res.code
                            if (res.code == 200) {
                                uni.navigateTo({
                                    url: `./square`
                                })
                                this.rest()
                            }
                        })
                    }
                })
            },
            //容器回库
            goBack() {
                uni.navigateTo({
                    url:`/pages/sort/return?containerCode=${this.containerCode}&taskType=2`
                })
            }
        },
 
    }
</script>
 
<style lang="scss">
 
</style>