2025-03-11 17:57:17 +08:00

147 lines
3.8 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view>
<u-navbar back-text="返回" title="货位移动" :background="background"></u-navbar>
<u-form>
<u-form-item :border-bottom="false">
<p>扫描条码</p>
<u-input :focus="focusBarcode" v-model="barCode" placeholder="请扫描条码" :border="true" />
</u-form-item>
</u-form>
<u-form>
<u-form-item>
<p>扫描库位</p>
<u-input class="uni-input" v-model="location" :focus="focusKw" placeholder="请扫描库位"
@confirm="LabelContactLocation" :border="true" />
<!-- <switch :checked="ischecked" @change="changeischecked" />
<p v-show="ischecked">默认此库位</p>
<p v-show="!ischecked">不默认库位</p> -->
</u-form-item>
</u-form>
</view>
</template>
<script>
export default {
data() {
return {
barCode: "", //物料编号
ERPLocation:'',
Areanames:'',
OldAreaName:'',
location: "", // 库位号
materialList: [], //接收后端传回来的数据
ischecked: false, //默认不使用库位
focusKw: false, //库位输入框焦点
focusBarcode: true, //默认聚焦到条码框
background: {
backgroundImage: 'linear-gradient(45deg, rgb(28, 187, 180), rgb(141, 198, 63))'
}, //返回按钮的样式
useId: "",
};
},
mounted() {
let that = this
uni.getStorage({
key: "userid",
success(res) {
that.userId = res.data
}
})
},
methods: {
//设置选中状态
changeischecked() {
this.ischecked = !this.ischecked //设置选中状态
//console.log("选中状态", this.ischecked)
},
//焦点初始化,让页面所有的焦点同时只能存在一个
initfocus() {
this.focusKw = false //单号焦点
this.focusBarcode = false //条码焦点
},
//标签绑定位置
LabelContactLocation() {
const str = this.barCode;
const elements = str.split("|");
this.getDatabase(elements[4])
this.getLocationDatabase(this.location)
console.log(this.OldAreaName,this.Areanames)
if (this.OldAreaName===this.Areanames) {
this.$MyRequest('/bpel/event', {
header: {
MESSAGENAME: 'ModifyLocation',
LANGUAGE: 'Chinese',
Flag: 'LK' //立库标志
},
body: {
BOXLIST: [{
SITENAME: "SDK",
MATERIALPACKINGNAME: elements[4],
LOCATIONNAME: this.location,
LASTEVENTCOMMENT: ''
}],
ERPLOCATION :this.ERPLocation,
AREANAME: this.Areanames,
LOCATIONNAME: this.location,
}
}).then(res => {
if (res.data.code == '0')
this.$showMessage(res.data.msg)
}).catch(err => {
this.$showMessage(err)
})
} else {
this.$showMessage("不同仓库之间不可以进行货位移动")
}
},
//获取位置标签仓库信息
getLocationDatabase(location) {
this.$MyRequest('/api/ApiQuery', {
queryId: "GetAirName_location",
version: "00001",
params: {
STORAGENAME: location,
}
}).then(res => {
this.ERPLocation= res.data.data[0].ERPLocation
this.Areanames = res.data.data[0].AREANAME
}).catch(err => {
this.$showMessage(err)
})
},
//获取原标签搬出仓库信息
getDatabase(materialpacking) {
this.$MyRequest('/api/ApiQuery', {
queryId: "GetAreName",
version: "00001",
params: {
MATERIALPACKINGNAME: materialpacking,
}
}).then(res => {
this.OldAreaName = res.data.data[0].AREANAME
}).catch(err => {
this.$showMessage(err)
})
},
//获取焦点的公共方法
getfocus(nextfocus) {
this.initfocus()
this[nextfocus] //不能用this.nextfocus
this.$nextTick(() => { //vue是数据全部修改后才进行的视图更新哪nextTick函数就是为了拿到最新的数据还不懂的可以去百度
this[nextfocus] = true
})
},
}
}
</script>
<style lang="scss">
</style>