spring
4 天以前 435881d494e2be4ba5ce8bfccb02d6ef49e07314
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
<template>
    <view class="wrap">
        <view class="top">
            <u-form label-position="left">
                <u-form-item label="库位号" label-width="180">
                    <input v-model="tolocationNo" type="text" style="text-align: left!important;font-size: 12px;"
                        placeholder="请选择" maxlength="64" :disabled="true" />
                    <u-button type="primary" size="medium" @click="seachLocationNo">选择</u-button>
                </u-form-item>
            </u-form>
            <view class="row3 flex-row">
                <view class="switch">
                    <u-switch v-model="isAuto"/>
                    <view style="padding-left: 10rpx;">自动提交</view>
                </view>
            </view>
        </view>
        <u-cell-group class="list" :border="false" v-if="scanInfo.newMesCode || scanInfo.pkg || scanInfo.cusMaterialCode" >
            <view class="content">
                <view class="row-list" style="padding-top: 8px;">
                    <view class="_label">MES:</view>
                    <view class="_content">
                        <textarea disabled v-model="scanInfo.newMesCode"  auto-height />
                    </view>
                </view>
                <view class="row-list" style="padding-top: 8px;">
                    <view class="_label">中兴:</view>
                    <view class="_content">
                        <textarea disabled v-model="scanInfo.pkg"  auto-height />
                    </view>
                </view>
                <view class="row-list">
                    <view class="_label">物料编码:</view>
                    <view class="_content"><textarea disabled v-model="scanInfo.cusMaterialCode"  auto-height /></view>
                </view>
            </view>
        </u-cell-group>
        <scan></scan>
        <view class="form-footer" v-if="scanInfo.newMesCode&&tolocationNo&&scanInfo.pkg&&scanInfo.cusMaterialCode">
            <u-button class="btn" type="primary" @click="submit">判定</u-button>
        </view>
    </view>
</template>
<script>
    import scan from "@/components/scan/scan.vue";
 
    export default {
        components: {
            scan
        },
        data() {
            return {
                isAuto:false,
                list: [],
                tolocationNo: "CPK01",
                scanInfo:{
                    newMesCode:'',
                    pkg:'',
                    cusMaterialCode:'',
                    packagingCode:'',
                    pkgCode:''
                },
                
            };
        },
        onLoad() {
            // this.scanHandle('{"package_code":"TX0922101204332","unit_meas":"m","wdr":"TP09221250000002","lot_batch_no":"*","qty_arrived":"1.2","material_code":"052530100006"}');
            // this.scanHandle('1HIU102211150010&052530100006&1200&GDVV 2G.657A2(Bow-type)+2×1.5mm^2&CN&中天&2022-11-15&221115');
            // this.scanHandle('052530100006');
        },
        onShow() {
 
            let that = this
 
            uni.$off('scan') // 每次进来先 移除全局自定义事件监听器
            uni.$on('scan', function(data) {
                console.log('onscan');
                //扫码成功后的回调,你可以写自己的逻辑代码在这里
                console.log('扫码结果:', data.code);
                const result = data.code.replace(/[\r\n]/g, "")
                that.scanHandle(result)
            })
        },
        onNavigationBarButtonTap(e) {
            uni.scanCode({
                success: res => {
                    try {
                        const result = res.result
 
                    } catch (e) {}
                }
            });
        },
        methods: {
            format(value,type){
                this[type].forEach((obj) => {
                    if (obj.value === value) {
                        value = obj.label
                    }
                })
                return value
            },
            //至库位
            seachLocationNo() {
                uni.navigateTo({
                    url: '/pages/wareHouse/finishProductIn/locNoList'
                })
            },
            //至库位号设置
            setNo(no) {
                this.tolocationNo = no
            },
            scanHandle(result){
                console.log(result)
                if(!this.tolocationNo){
                    this.$u.toast('请选择至库位号')
                    return
                }
                if (result.indexOf('{') >= 0) {
                    //新mes码
                    this.scanInfo.newMesCode = result
                } else if (result.indexOf('&') >= 0) {
                    //pkg码
                    this.scanInfo.pkg = result
                } else {
                    //物料编码
                    this.scanInfo.cusMaterialCode = result
                }
                //自动提交
                if(this.isAuto && this.scanInfo.newMesCode && this.scanInfo.pkg && this.scanInfo.cusMaterialCode){
                    this.submit()
                }
            },
            submit() {
                if (!this.scanInfo.newMesCode) {
                    this.$u.toast('请扫描新MES码')
                    return
                }
                if (!this.scanInfo.pkg) {
                    this.$u.toast('请扫描中兴码')
                    return
                }
                if (!this.scanInfo.cusMaterialCode) {
                    this.$u.toast('请扫描物料编码')
                    return
                }
                
                let mesCodeJSON = JSON.parse(this.scanInfo.newMesCode)
                let mes_materialCode = mesCodeJSON.material_code
                let mes_qty = mesCodeJSON.qty_arrived
                this.scanInfo.packagingCode = mesCodeJSON.package_code
                
                let pkg_sub = this.scanInfo.pkg.substring(this.scanInfo.pkg.indexOf('&')+1)
                let pkg_sub2 = pkg_sub.substring(pkg_sub.indexOf('&')+1)
                let pkg_materialCode = pkg_sub.substring(0,pkg_sub.indexOf('&'))
                let pkg_qty = pkg_sub2.substring(0,pkg_sub2.indexOf('&')) -0 
                this.scanInfo.pkgCode = this.scanInfo.pkg.substring(0, this.scanInfo.pkg.indexOf('&'))
                // let pkg_materialCode = this.scanInfo.pkg.substring(this.scanInfo.pkg.indexOf('&')+1, this.scanInfo.pkg.indexOf('&',1))
                // let pkg_qty = this.scanInfo.pkg.substring(this.scanInfo.pkg.indexOf('&',1)+1, this.scanInfo.pkg.indexOf('&',2)) - 0
                
                console.log(mes_qty+' ' + pkg_qty);
                if (mes_materialCode != pkg_materialCode || mes_materialCode != this.scanInfo.cusMaterialCode) {
                    this.$u.toast('物料编码不一致')
                    return
                }
                if (mes_qty*1000 != pkg_qty) {
                    this.$u.toast('数量不一致')
                    return
                }
                
                //1、校验
                this.$u.api.finishZTE.validateJump({
                    packagingCode: this.scanInfo.packagingCode,
                    pkgCode: this.scanInfo.pkgCode
                }).then(res => {
                    if (res.code == 0) {
                        // this.$u.toast('ok')
                        //2、判定
                        this.$u.api.finishZTE.addJumpZTE({
                            packagingCode: this.scanInfo.packagingCode,
                            pkgCode: this.scanInfo.pkgCode,
                            inLocationNo : this.tolocationNo
                        }).then(res => {
                            if (res.code == 0) {
                                uni.showModal({
                                    title: '提示',
                                    content: '成功',
                                    showCancel: false,
                                    success: ()=> {
                                        this.scanInfo={}
                                    }
                                })
                            } else {
                                uni.showModal({
                                    title: '提示',
                                    content: '失败',
                                    showCancel: false,
                                    success: ()=> {
                                        
                                    }
                                })
                            }
                        }).catch(res => {
                            // this.scanInfo={}
                        })
                    } else {
                        uni.showModal({
                            title: '提示',
                            content: '校验失败',
                            showCancel: false,
                            success: ()=> {
                                
                            }
                        })
                    }
                })
                
            },
        }
    };
</script>
<style lang="scss" scoped>
    .top{
        padding:0 20rpx 25rpx;
        border-bottom: 1px solid #eee;
        .row3{
            margin-top: 20rpx;
            justify-content: space-between;
            padding: 0 15rpx;
            font-size: 30rpx;
            .switch{
                display: flex;
                align-items: center;
            }
            .u-btn{
                margin: initial;
                background:#3281FF;
            }
        }
    }
    .list .content {
        font-size: 14px;
        // background-color: #efefef;
        box-sizing: border-box;
        border-radius: 14rpx;
        margin: 8px;
        padding: 5px 10px;
        box-shadow: none;
        position: relative;
        border: 1px solid #dddddd;
    }
    .scroll-list{
        height: calc(100vh - var(--window-top) - var(--window-bottom) - 300rpx);
    }
 
    .row-list {
        display: flex;
        flex-direction: column;
    }
 
    .row-list ._label {
        flex: 0.8;
        color: #909399;
    }
 
    .row-list ._content {
        flex: 1.5;
        // text-align: right;
    }
 
    .row-img {
        position: absolute;
        right: 2px;
        top: 0px;
    }
 
    >>>.uni-input-input {
        font-size: 12px;
    }
 
    ::v-deep.u-input__input {
        min-height: unset !important;
        text-align: right;
    }
</style>