单据中选择商品的时候支持回车快捷选中

This commit is contained in:
季圣华
2021-10-28 00:15:53 +08:00
parent ad4945d054
commit deead4b32b

View File

@@ -18,7 +18,7 @@
<a-row :gutter="24"> <a-row :gutter="24">
<a-col :md="6" :sm="8"> <a-col :md="6" :sm="8">
<a-form-item label="商品" :labelCol="{span: 5}" :wrapperCol="{span: 18, offset: 1}"> <a-form-item label="商品" :labelCol="{span: 5}" :wrapperCol="{span: 18, offset: 1}">
<a-input placeholder="条码名称规格型号" v-model="queryParam.q"></a-input> <a-input ref="material" placeholder="条码名称规格型号" v-model="queryParam.q"></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :md="6" :sm="8"> <a-col :md="6" :sm="8">
@@ -187,6 +187,12 @@
if (res) { if (res) {
this.dataSource = res.rows this.dataSource = res.rows
this.ipagination.total = res.total this.ipagination.total = res.total
if(res.total ===1) {
this.title = '选择商品【再次回车可以直接选中】'
this.$nextTick(() => this.$refs.material.focus());
} else {
this.title = '选择商品'
}
} }
}).finally(() => { }).finally(() => {
this.loading = false this.loading = false
@@ -217,7 +223,9 @@
}, },
showModal(barCode) { showModal(barCode) {
this.visible = true; this.visible = true;
this.title = '选择商品'
this.queryParam.q = barCode this.queryParam.q = barCode
this.$nextTick(() => this.$refs.material.focus());
this.loadData(); this.loadData();
this.form.resetFields(); this.form.resetFields();
}, },
@@ -297,10 +305,21 @@
this.selectionRows = selectionRows; this.selectionRows = selectionRows;
}, },
onSearch() { onSearch() {
this.loadData(1); if(this.dataSource && this.dataSource.length===1) {
if(this.queryParam.q === this.dataSource[0].mBarCode) {
let arr = []
arr.push(this.dataSource[0].id)
this.selectedRowKeys = arr
this.handleSubmit()
} else {
this.loadData(1)
}
} else {
this.loadData(1)
}
}, },
modalFormOk() { modalFormOk() {
this.loadData(); this.loadData()
}, },
rowAction(record, index) { rowAction(record, index) {
return { return {