<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>
|