From f461eca56ce1fa7dbd635e266448dc0999da8bf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E5=9C=A3=E5=8D=8E?= <752718920@qq.com> Date: Sat, 14 Mar 2020 00:07:29 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=99=E5=8D=95=E6=8D=AE=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=EF=BC=88=E6=95=B2=E5=9B=9E=E8=BD=A6=E9=94=AE=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E8=B7=B3=E4=B8=8B=E4=B8=80=E4=B8=AA=E6=96=87=E6=9C=AC=E6=A1=86?= =?UTF-8?q?=E7=9A=84=E5=8A=9F=E8=83=BD=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- erp_web/js/common/common.js | 27 +++++++++++++++++++++++++++ erp_web/js/pages/materials/in_out.js | 8 ++++++++ 2 files changed, 35 insertions(+) diff --git a/erp_web/js/common/common.js b/erp_web/js/common/common.js index e25dc3f3..339e3a19 100644 --- a/erp_web/js/common/common.js +++ b/erp_web/js/common/common.js @@ -429,4 +429,31 @@ */ function myIsNaN(value) { return typeof value === 'number' && !isNaN(value); + } + + /** + * 敲回车键自动跳转到下一个文本框 + * @param inputDom + */ + function autoJumpNextInput(inputDom, appendDom) { + inputDom.on("keydown","input:text:visible",function(e){ + //响应回车键按下的处理 + var e = event || window.event || arguments.callee.caller.arguments[0]; + //捕捉是否按键为回车键,可百度JS键盘事件了解更多 + if(e && e.keyCode==13) { + //捕捉inputDom下的文本输入框的个数 + var inputs = inputDom.find("input:text:visible"); + //console.log(inputs.length); + var idx = inputs.index(this);                         // 获取当前焦点输入框所处的位置 + if (idx == inputs.length - 1) {                       // 判断是否是最后一个输入框 + var curKey = e.which; + if (curKey == 13) { + appendDom.click(); //新增行 + } + } else { + inputs[idx + 1].focus(); // 设置焦点 + inputs[idx + 1].select(); // 选中文字 + } + } + }); } \ No newline at end of file diff --git a/erp_web/js/pages/materials/in_out.js b/erp_web/js/pages/materials/in_out.js index 91392dfa..9d779379 100644 --- a/erp_web/js/pages/materials/in_out.js +++ b/erp_web/js/pages/materials/in_out.js @@ -716,6 +716,7 @@ onLoadSuccess: function (rec) { if(rec && rec.total==1) { $(".datagrid-body [field='mBarCode']").click(); //在只有单个商品的时候自动选中 + $("#depotHeadFM .datagrid-body").find("[field='OperNumber']").find(".datagrid-editable-input").focus().select(); } }, onSelect:function(index, rowData){ @@ -824,6 +825,9 @@ }); data.footer = array; $("#materialData").datagrid('loadData',data); + if(type === "add") { + $("#depotHeadDlg #append").click(); //新增行 + } //如果是订单跳转到采购或销售 if(pageType === "skip") { var skipList = $("#depotHeadFM .datagrid-body tr"); @@ -2248,9 +2252,13 @@ function autoReckon() { //延时绑定事件 setTimeout(function(){ + var inputDom = $("#depotHeadFM .panel.datagrid .datagrid-view2 .datagrid-body"); + var appendDom = $("#depotHeadDlg #append"); + autoJumpNextInput(inputDom, appendDom); //敲回车键自动跳转到下一个文本框 var body =$("#depotHeadFM .datagrid-body"); var footer =$("#depotHeadFM .datagrid-footer"); var input = ".datagrid-editable-input"; + body.find("[field='MaterialExtendId']").find(".textbox-text").focus().select(); //默认选择商品框 //点击商品下拉框,自动加载数量、单价、金额 body.find("[field='Stock']").find(input).prop("readonly","readonly"); body.find("[field='Unit']").find(input).prop("readonly","readonly");