schangxiang@126.com
2024-12-08 df485888ecb9f69c0051fc192b87aec700cc4f89
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
<template>
    <view class="overflow">
        <view class="upWp">
            <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">
                操作人:{{operator}}
            </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>{{warehouse.orderNo}}</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="12">
                        <u-form-item label="容器数量:" prop="warehouse.containerQty" required class="myFormItem">
                            <u-input type="number" v-model="warehouse.containerQty" :focus="focusType" placeholder="请输入容器数量"
                                class="width myInp"  clearable/>
                        </u-form-item>
                    </u-col>
                    <u-col span="12">
                        <u-form-item label="容器编号:" prop="warehouse.wareContain" required class="myFormItem">
                        <!--     <input v-model="warehouse.wareContainerCode" :focus="focusType" placeholder="请选择或扫描容器编号"
                                class="width myInp" > -->
                                
                            <u-input  v-model.trim="warehouse.wareContainerCode" :focus="focusType" placeholder="请选择或扫描容器编号"
                                class="width myInp"  clearable/>
                                        
                            <!--     <input v-model="warehouse.wareContainerCode" type="select" @focus="containerFocus"
                                placeholder="请选择容器编号" class="width myInp"> -->
                            <!--     <u-select v-model="modalshow" :list="wolist" @confirm="confirm" value-name="code"
                                label-name="code" ></u-select> -->
                        </u-form-item>
                    </u-col>
                </u-row>
            </u-form>
        </view>
        <view class="wolistWp" v-show="modalshow" :style="{height: mtHeight+'px'}">
            <view :key="index" v-for="(item,index) in wolistRes" @click="confirm(item.code)">
                <text> {{ item.code}}</text>
            </view>
        </view>
        <modal-code ref="resmodal" :rescode='rescode' :resmessage='resmessage' />
 
        <button-modal :empTytowerShow='true' class="dowmWp" cleaningTitle="查询" garmenTitle='确认入库' @submit='submit' @reset='rest' />
 
    </view>
</template>
 
<script>
    import {
        getDate
    } from '../../../utils/dateTime.js'
    import ModalCode from '../../../components/ModalCode.vue'
    import ButtonModal from '../../../components/buttonModal.vue'
    import {
        trayPutStorage,
        getContainerNumList,
        getOrderNumList,
        containerTypeArr,
        getAllEnums
    } from '@/api/container/index.js'
    import calBoxHt from '@/mixins/calBoxHt.js'
    export default {
        mixins:[calBoxHt],
        data() {
            return {
                mtHeight: 'auto',
                focusType: true,
                rescode: 0,
                resmessage: "",
                focu: true,
                Datetime: getDate(),
                containerTypeArr: [],
                warehouse: { //入库请求参数
                    orderNo: "",
                    containerQty: 1, //空托-默认1
                    containerType: "",
                    wareContainerCode: "", //容器编号
                    createdTime: "",
                    updatedTime: "",
                    createdUserId: "",
                    createdUserName: "",
                    orderStatus: 3,
                    orderType: 13, //空托入库
                    warehousOrderDetails: []
                },
                warehouseRules: {
                    ContainerCode: [{
                        required: true,
                        message: '容器编号不能为空',
                        trigger: 'blur'
                    }],
                    // StorehouseCode: [{
                    //     required: true,
                    //     message: '入库口不能为空',
                    //     trigger: 'blur'
                    // }],
                },
                operator: '', //
                wolist: [],
                wolistRes: [111,2222,33333,33333,33333],
                modalshow: false
            };
        },
        components: {
            ModalCode,
            ButtonModal
        },
        onReady() {
            this.$refs.warehouseRef.setRules(this.warehouseRules)
 
            this.calBoxHt() //动态计算滚动区域的高度
        },
        mounted() {
            this.operator = JSON.parse(uni.getStorageSync('userInfo')).name
        
            this.getOrderNum()
            this.getContainerNum()
            this.getAllEnums()
        },
        // 模糊查询
        watch: {
            'warehouse.wareContainerCode': {
                immediate: true, //在框的值还没变化时执行如下函数显示出所有的情况
                handler(val) {
                    this.modalshow = true
                    this.wolistRes = this.wolist.filter((p) => {
                        return p.code.indexOf(val.trim()) !== -1
                    })
                }
            }
        },
        methods: {
            // 获取入库单号 
            getOrderNum() {
                getOrderNumList().then((res) => {
                    if (res.code != 200) {
                        this.rescode = res.code
                        this.resmessage = '暂无数据'
                        this.$refs.resmodal.show = true
                        return
                    }
                    this.warehouse.orderNo = res.data
                })
            },
            // 获取容器编号 
            getContainerNum(trayNumber) {
                getContainerNumList().then((res) => {
                    if(res.code==200){
                        if (res.data.length == 0) {
                            this.rescode = res.data.code
                            this.resmessage = '暂无数据'
                            this.$refs.resmodal.show = true
                            return
                        }
                        this.wolist = res.data
                        this.wolistRes = res.data
                        // 捕获操作过程中 被空出来的容器
                        if(trayNumber&&this.warehouse.wareContainerCode!=''){
                            this.wolistRes = this.wolist.filter((p) => {
                                return p.code.indexOf(this.warehouse.wareContainerCode) !== -1
                            })
                        }
                    }
                })
            },
            // 确认
            submit() {
                if (this.warehouse.orderNo == '' || this.warehouse.orderNo == undefined) {
                    this.getOrderNum()
                    this.$u.toast('稍等,重新获取入库单号');
                    return
                }
                if(this.warehouse.containerQty <= 0){
                    this.$u.toast('请输入容器数量');
                    return
                }
                if(this.warehouse.wareContainerCode == ''){
                        this.$u.toast('容器编号未扫描或未选择');
                    return
                }
                
                this.$refs.warehouseRef.validate(valid => {
                    if (valid) {
                        var jsonSom = {
                            createdUserId: JSON.parse(uni.getStorageSync('userInfo')).id,
                            createdUserName: JSON.parse(uni.getStorageSync('userInfo')).name,
                            createdTime: this.Datetime,
                            updatedTime: this.Datetime,
                            containerQty: this.warehouse.containerQty
                        }
                        this.warehouse = Object.assign(this.warehouse, jsonSom);
                        this.warehouse.containerType =  ''; 
                        const arr = this.wolist.filter((item) => item.code == this.warehouse.wareContainerCode)
                        if (arr.length > 0) {
                            let nameTray = arr[0].typeName //塑料容器
                            const arr2 = this.containerTypeArr.filter((item) => item.title == nameTray)
                            if (arr2.length <= 0) {
                                this.$u.toast('对应容器类型找不到');
                                return;
                            }
                            this.warehouse.containerType = arr2[0].value || ''; //"299120688255045"
                        }
                        trayPutStorage(this.warehouse).then((res) => {
                            if (res.code === 200) {
                                this.rescode = res.code
                                this.resmessage = res.message
                                this.$refs.warehouseRef.resetFields()
                                this.warehouse = {
                                    orderNo: "",
                                    containerQty: 1, //空托-默认1
                                    containerType: "",
                                    wareContainerCode: "", //容器编号
                                    createdTime: "",
                                    updatedTime: "",
                                    createdUserId: "",
                                    createdUserName: "",
                                    orderStatus: 3,
                                    orderType: 13, //空托入库
                                    warehousOrderDetails: []
                                }
                                this.focusType = true
                                this.getOrderNum()
                                this.getContainerNum()
                                this.$refs.resmodal.show = true
                            }
                        })
                    }
                })
            },
            // 获取常用变量 应存入vuex
            getAllEnums() {
                getAllEnums().then((res) => {
                    if (res.data.length == 0 || res.data.containerType.length == 0) {
                        this.rescode = res.code
                        this.resmessage = '暂无数据'
                        this.$refs.resmodal.show = true
                        return
                    }
                    this.containerTypeArr = res.data.containerType
                })
            },
            //容器 聚焦事件
            containerFocus() {
                // uni.hideKeyboard()
                // this.modalshow = true
            },
            //选择 容器
            confirm(e) {
                if(e==this.warehouse.wareContainerCode){
                    return
                }
                this.warehouse.wareContainerCode = e
                this.modalshow = false
            },
            //出入库口扫描
            wareScane() {
                uni.scanCode({
                    scanType: ['barCode', 'qrCode'],
                    autoDecodeCharset: true,
                    success: (res) => {
                        this.warehouseRules.StorehouseCode = res.result.trim()
                    },
                    fail: (err) => {
                        this.rescode = 400
                        this.resmessage = `扫描失败${JSON.stringify(err)}`
                        this.$refs.resmodal.show = true
                    }
                })
            },
            //容器扫描
            containerScane() {
                uni.scanCode({
                    scanType: ['barCode', 'qrCode'],
                    autoDecodeCharset: true,
                    success: (res) => {
                        this.warehouse.ContainerCode = res.result
                    },
                    fail: (err) => {
                        this.rescode = 400
                        this.resmessage = `扫描失败${JSON.stringify(err)}`
                        this.$refs.resmodal.show = true
                    }
                })
            },
            //重置
            rest() {
                this.getContainerNum(1)
            },
            _empty(v) {
                let tp = typeof v,
                    rt = false;
                if (tp == "number" && String(v) == "") {
                    rt = true
                } else if (tp == "undefined") {
                    rt = true
                } else if (tp == "object") {
                    if (JSON.stringify(v) == "{}" || JSON.stringify(v) == "[]" || v == null) rt = true
                } else if (tp == "string") {
                    if (v == "" || v == "undefined" || v == "null" || v == "{}" || v == "[]") rt = true
                } else if (tp == "function") {
                    rt = false
                }
                return rt
            }
        }
 
    }
</script>
 
<style lang="scss">
    .myFormItem {
        font-size: 32rpx;
        font-weight: bold;
        padding: 0;
    }
 
    .myInp {
        font-weight: bolder;
        margin-left: 30rpx;
        margin-top: 16rpx;
    }
 
    /deep/.u-drawer__scroll-view {
        border-top: 5px solid #d6d6d6;
    }
    .wolistWp{
        z-index: 999;
        // height: 45vh;
        padding-top: 10px;
        padding-bottom: 20px;
        border-top: 1px solid gray;
        // border-bottom: 1px solid gray;
        overflow: auto;
        text-align: left;
        view{
            display: inline-block;
            border-radius: 3px;
            border: 1px solid orange;
                width: 27.3%;
            text-align: center;
            min-width: 80px;
            padding: 5px ;
            margin: 8px 3%;
            color: #f18202;
            text{
            }
        }
    }
</style>