logwire-wms-ui-test
Version:
运匠科技wms-PDA基础组件库
99 lines (85 loc) • 3.36 kB
JavaScript
/*
* 出库拣选所有拣选方式,使用到的公共方法,采用混入方式
* @author: 张文
* @date 2022-06-17
* */
export const all = {
methods: {
// 输入框校验
inputCheck({key, checkVal, needCheck = true}) {
const msg = {
locationCode: {
nullMsg: this.$lwLanguage.get('wms_project.pda.components.page.outbound.pick.mixin.all.locNull','拣选库位不能为空'),
checkMsg: this.$lwLanguage.get('wms_project.pda.components.page.outbound.pick.mixin.all.locErr','当前库位与拣选库位不一致')
},
lpn: {
nullMsg: this.$lwLanguage.get('wms_project.pda.components.page.outbound.pick.mixin.all.lpnNull','托盘号不能为空'),
checkMsg: this.$lwLanguage.get('wms_project.pda.components.page.outbound.pick.mixin.all.lpnErr','当前托盘号与拣选托盘号不一致')
},
box: {
nullMsg: this.$lwLanguage.get('wms_project.pda.components.page.outbound.pick.mixin.all.boxNull','箱号不能为空'),
checkMsg: this.$lwLanguage.get('wms_project.pda.components.page.outbound.pick.mixin.all.boxErr','当前箱号与拣选箱号不一致')
},
sku: {
nullMsg: this.$lwLanguage.get('wms_project.pda.components.page.outbound.pick.mixin.all.skuNull','商品号不能为空'),
checkMsg: this.$lwLanguage.get('wms_project.pda.components.page.outbound.pick.mixin.all.skuErr','当前商品与商品不一致')
},
}
const val = this[key].value
// 非空判断
if (!val) {
this[key].focus = true
this.$lwShowErrorMsg(msg[key].nullMsg)
return false
}
// 一致性判断
if (needCheck && 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) {
this.taskIndex = this.$lwUtils.cutCardIndexCount(this.taskIndex, length)
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.$lwDialog.confirm({
title: this.$lwLanguage.get('wms_project.pda.components.page.outbound.pick.mixin.all.warn','警告'),
message: this.$lwLanguage.get('wms_project.pda.components.page.outbound.pick.mixin.all.null','切换后当前输入数据将会被清空')
}).then(() => res()).catch(() => err('用户取消'))
return
}
res()
})
},
// 清空给定的数据,并滚动到顶部
clearInputVal(arr) {
arr.forEach(item => this[item].value = '')
this.goTop()
}
}
}