给单据增加回车事件

This commit is contained in:
季圣华
2021-11-02 01:20:30 +08:00
parent e6b2b1ecf7
commit 1e0d137739
16 changed files with 84 additions and 32 deletions

View File

@@ -1429,6 +1429,9 @@
this.$nextTick(() => {
tbody.scrollTop = tbody.scrollHeight
})
this.$nextTick(() => {
this.autoJumpNextInputBill('billModal')
})
},
/**
* 在指定位置添加一行
@@ -2739,8 +2742,55 @@
return content.substr(0,len)
}
return content;
},
/** 回车后自动跳到下一个input **/
autoJumpNextInputBill(domInfo) {
let that = this
let domIndex = 0
let inputs = document.getElementById(domInfo).getElementsByTagName('input')
inputs[domIndex].focus()
document.getElementById(domInfo).addEventListener('keydown',function(e){
if(e.keyCode === 13){
domIndex++
if(domIndex === inputs.length) {
domIndex = 0
that.handleClickAdd()
}
inputs[domIndex].focus()
}
})
for(let i=0; i<inputs.length; i++){
//这个index就是做个介质来获取当前的i是第几个
inputs[i].index = i;
inputs[i].onclick = function () {
domIndex = this.index
}
inputs[i].onselect = function () {
domIndex = this.index
}
}
},
/** 自动选中特殊的key **/
autoSelectBySpecialKey(specialKey) {
let trs = this.getElement('tbody').getElementsByClassName('tr')
let trEls = []
for (let tr of trs) {
trEls.push(tr)
}
trEls.forEach(tr => {
let { idx } = tr.dataset
let value = this.inputValues[idx]
for (let key in value) {
if (value.hasOwnProperty(key)) {
let elid = `${key}${value.id}`
let el = document.getElementById(elid)
if (el && key === specialKey) {
el.select()
}
}
}
})
}
},
beforeDestroy() {
this.destroyCleanGroupRequest = true

View File

@@ -306,7 +306,10 @@
},
onSearch() {
if(this.dataSource && this.dataSource.length===1) {
if(this.queryParam.q === this.dataSource[0].mBarCode) {
if(this.queryParam.q === this.dataSource[0].mBarCode||
this.queryParam.q === this.dataSource[0].name||
this.queryParam.q === this.dataSource[0].standard||
this.queryParam.q === this.dataSource[0].model) {
let arr = []
arr.push(this.dataSource[0].id)
this.selectedRowKeys = arr