logwire-wms-pda-ui
Version:
运匠科技wms-PDA基础组件库
101 lines (87 loc) • 2.72 kB
JavaScript
/*
* 出库拣选所有拣选方式,使用到的公共方法,采用混入方式
* @author: 张文
* @date 2022-06-17
* */
export const all = {
methods: {
// 输入框校验
inputCheck({key, checkVal}) {
const msg = {
locationCode: {
nullMsg: this.$lwLanguage.get('', '拣选库位不能为空'),
checkMsg: this.$lwLanguage.get('', '当前库位与拣选库位不一致')
},
lpn: {
nullMsg: this.$lwLanguage.get('', '托盘号不能为空'),
checkMsg: this.$lwLanguage.get('', '当前托盘号与拣选托盘号不一致')
},
box: {
nullMsg: this.$lwLanguage.get('', '箱号不能为空'),
checkMsg: this.$lwLanguage.get('', '当前箱号与拣选箱号不一致')
},
sku: {
nullMsg: this.$lwLanguage.get('', '商品号不能为空'),
checkMsg: this.$lwLanguage.get('', '当前商品与商品不一致')
},
}
const val = this[key].value
// 非空判断
if (!val) {
this[key].focus = true
this.$lwShowErrorMsg(msg[key].nullMsg)
return false
}
// 一致性判断
if (val !== checkVal) {
this[key].focus = true
this.$lwShowErrorMsg(msg[key].checkMsg)
this[key].value = ''
return false
}
return true
},
// 回到tab页面顶部
goTop() {
const dom = document.querySelector('#tab-top')
dom && dom.scrollIntoView({
behavior: "smooth",
block: 'center',
})
},
// 校验当前索引是否满足未拣选的行数
checkTaskIndex(length) {
if ((this.taskIndex + 1) > length) {
this.taskIndex = length - 1
}
this.cutEnd()
},
// 待拣选列表点击
waitPickClick(index) {
this.tabActive = 'ing'
this.taskIndex = index
this.cutEnd()
},
// 检查给定的数据是否有值,并返回一个异步函数
checkInputVal(arr, need = false) {
return new Promise((res, err) => {
if (
need ||
arr.some(item => !!this[item].value)
) {
this.$dialog.confirm({
title: this.$lwLanguage.get('', '警告'),
message: this.$lwLanguage.get('', '切换后当前输入数据将会被清空')
}).then(() => res()).catch(() => err('用户取消'))
return
}
res()
})
},
// 清空给定的数据,并滚动到顶部
clearInputVal(arr) {
arr.forEach(item => this[item].value = '')
this.goTop()
}
}
}