<template>
            <el-table :data="CreditUnclearOutlineList" border style="width: 100%" ref="table">
<el-table-column align="center" prop="name" label="名称" width="150">
</el-table-column>
<el-table-column align="center" label="正常">
<el-table-column align="center" sortable prop="normalB" label="笔数">
<template scope="scope">
<span>
<el-input style="width: 90px" placeholder="笔数" v-model="scope.row.normalB" @change="handleCreditChange()" class="table_input normalB_input" @keyup.native="show($event,scope.$index)"></el-input>
</span>
</template>
</el-table-column>
<el-table-column align="center" sortable prop="normalY" label="余额(万元)">
<template scope="scope">
<span>
<el-input style="width: 90px" placeholder="余额" v-model="scope.row.normalY" @change="handleCreditChange()" @blur="handleBalanceBlur($event)" @focus="handleBalanceClear($event)" class="table_input normalY_input" @keyup.native="show($event,scope.$index)"></el-input>
</span>
</template>
</el-table-column>
</el-table-column>
<el-table-column align="center" label="关注">
<el-table-column align="center" sortable prop="focusB" label="笔数">
<template scope="scope">
<span>
<el-input style="width: 90px" placeholder="笔数" v-model="scope.row.focusB" @change="handleCreditChange()" class="table_input focusB_input" @keyup.native="show($event,scope.$index)"></el-input>
</span>
</template>
</el-table-column>
<el-table-column align="center" sortable prop="focusY" label="余额(万元)">
<template scope="scope">
<span>
<el-input style="width: 90px" placeholder="余额" v-model="scope.row.focusY" @change="handleCreditChange()" @blur="handleBalanceBlur($event)" @focus="handleBalanceClear($event)" class="table_input focusY_input" @keyup.native="show($event,scope.$index)"></el-input>
</span>
</template>
</el-table-column>
</el-table-column>
<el-table-column align="center" label="不良">
<el-table-column align="center" sortable prop="badB" label="笔数">
<template scope="scope">
<span>
<el-input style="width: 90px" placeholder="笔数" v-model="scope.row.badB" @change="handleCreditChange()" class="table_input badB_input" @keyup.native="show($event,scope.$index)"></el-input>
</span>
</template>
</el-table-column>
<el-table-column align="center" sortable prop="badY" label="余额(万元)">
<template scope="scope">
<span>
<el-input style="width: 90px" placeholder="余额" v-model="scope.row.badY" @change="handleCreditChange()" @blur="handleBalanceBlur($event)" @focus="handleBalanceClear($event)" class="table_input badY_input" @keyup.native="show($event,scope.$index)"></el-input>
</span>
</template>
</el-table-column>
</el-table-column>
<el-table-column align="center" prop="amountY" sortable label="余额(万元)">
<template scope="scope">
<span>{{scope.row.amountY}}</span>
</template>
</el-table-column>
</el-table>
</template>
//键盘触发事件
show(ev,index){ let newIndex ; //通过ev 获取 当前input 名称 用于判断属于哪列
let clssName = ev.target.offsetParent.className; //每一列
if(clssName.indexOf('normalB_input') != -1){ newIndex = index*6 ; } else if (clssName.indexOf('normalY_input') != -1) { newIndex = index*6 + 1 ; } else if (clssName.indexOf('focusB_input') != -1) { newIndex = index*6 + 2; } else if (clssName.indexOf('focusY_input') != -1) { newIndex = index*6 + 3; } else if (clssName.indexOf('badB_input') != -1) { newIndex = index*6 + 4; } else if (clssName.indexOf('badY_input') != -1) { newIndex = index*6 + 5; } //获取每一列的input名称
let normalB_input = document.getElementsByClassName('normalB_input')
let normalY_input = document.getElementsByClassName('normalY_input')
let focusB_input = document.getElementsByClassName('focusB_input')
let focusY_input = document.getElementsByClassName('focusY_input')
let badB_input = document.getElementsByClassName('badB_input')
let badY_input = document.getElementsByClassName('badY_input') //获取54个input
let inputAll = document.querySelectorAll('.table_input input'); //向上 =38
if(ev.keyCode == 38){
//当焦点在第一行的时候 按向上的时候焦点要聚焦到前一列的最后一个
if(newIndex >=1 && newIndex<=5){
newIndex = newIndex + 47;
} else {
newIndex -= 6 ;
} if( inputAll[newIndex] ){ inputAll[newIndex].focus(); } } //下 = 40
if(ev.keyCode == 40){ //当newIndex 在最后一行的时候 焦点要聚焦到 下一列的第一个
if(newIndex>= 48 && newIndex<53){ newIndex = (newIndex%8) + 1
}else {
newIndex += 6 ;
} if( inputAll[newIndex] ){ inputAll[newIndex].focus(); } } //左 = 37
if(ev.keyCode == 37){ newIndex -= 1 ; if( inputAll[newIndex] ){ inputAll[newIndex].focus(); }
} //右 = 39
if(ev.keyCode == 39){ newIndex += 1 ; if( inputAll[newIndex] ){ inputAll[newIndex].focus(); }
} },

注意点:

1.vue element-ui 绑定@keyup事件无效 ,加上.native覆盖原有封装的keyup事件即可

vue+elementui 中 @keyup 键盘上下左右移动聚焦的更多相关文章

  1. vue+element-ui中的图片获取与上传

    vue+element-ui中的图片获取与上传 工作上接触了一下图片的处理,图片的格式是文件流, 记录如下. 请求图片 请求图片的时候,带上{ responseType: 'blob' }, 否则图片 ...

  2. vue element-ui中引入第三方icon

    vue element-ui中引入第三方icon 把图标加入项目 设置项目名称,下载项目(项目名称自定义) 解压项目到开发目录 在main.js中全局引入css文件 修改下载下来的项目中的css文件, ...

  3. vue+elementUI中单选框el-radio设置默认值和唯一标识某个单选框

    vue+elementUI中单选框el-radio设置默认值 如果后台返回的单选框的值是number:单选框的lable需要设置成 :lable='0';如下: <el-form-item la ...

  4. vue+element-ui中引入阿里播放器

    1.在public文件下的index.html文件中插入以下代码: <link rel="stylesheet" href="https://g.alicdn.co ...

  5. Vue:Elementui中的Tag与页面其它元素相互交互的两三事

    前言 公司系统在用elementui做后台开发,不免遇到一些需要自己去根据原有的功能上,加一些交互的功能.今天来介绍下我在用elementUi里的Tag标签与多选框交互的过程,东西听上去很简单,但就是 ...

  6. 关于Vue element-ui中诡异问题的解决思路

    最近在做Element-ui项目时总是会出现些异步及其一些诡异问题,关于vue 的异步原理就不多说了,感觉大部分的问题都可以用Vue.nextTick来解决,Vue.nextTick是等DOM二次加载 ...

  7. vue element-ui 绑定@keyup事件无效

    解决办法: <el-input @keyup.native="ajax"></el-input> 加上.native覆盖原有封装的keyup事件即可

  8. vue+element-ui中的表单验证(电话等等)

    1. 2. 3. ============================================================上代码============================ ...

  9. Vue Element-UI 中列表单选的实现

    el-table中单选的实现 引用场景: 选择单条数据进行业务操作 实现方式: 给el-table-column设置el-radio Template 代码 <div class="r ...

随机推荐

  1. systemd-tmpfiles - Operation not permitted chown ; systemd-modules-load.service

    systemd-tmpfiles-setup.service  fail  一般为 /exports/rfs/var/lib/systemd/ 下的文件属性问题 , chown -R   root:r ...

  2. 例行性工作排程 (crontab)

    说白了,就是一些例行工作的日常执行的排序程序 Linux  工作排程的种类:  at,cron 鸟叔说,atd并不是在所有版本都是开启的,但是centos7默认是开启的 [root@localhost ...

  3. spring security学习总结

    这几天一直在学习spring security的相关知识.逛各大论坛,看相关api与教学视频,获益良多! 简介 Spring Security是为基于Spring的企业应用系统提供声明式的安全访问控制 ...

  4. Java中IO流之字符流

    我们有了字节流,为什么还需要字符流? 字符的底层是 字节 + 编码表 = 字符,字符是人能看懂的信息. 字符流在使用的时候,会以字节流为基础,把字节写入缓冲区,在缓冲区内根据编码类型(UTF-8,GB ...

  5. 根据ID查询实体

    //查询实体 $scope.findOne=function(id){ $http.get('../brand/findOne.do?id='+id).success( function(respon ...

  6. 【操作】Linux快捷键

  7. 模拟+双指针——cf1244E

    排一遍序然后用l,r指针进行移动,每次移动的是靠1,或靠n更近的那个指针 #include<bits/stdc++.h> using namespace std; typedef long ...

  8. NX二次开发-Block UI C++界面关于 在Block UI中UF_initialize();和UF_terminate();的使用

    关于 在Block UI中UF_initialize();和UF_terminate();的使用 用Block UI作NX二次开发的时候,不需要在使用UFUN函数的时候加UF_initialize() ...

  9. (转)Linux查看程序端口占用情况

    转:http://www.cnblogs.com/benio/archive/2010/09/15/1826728.html 今天发现服务器上Tomcat 8080端口起不来,老提示端口已经被占用. ...

  10. ORM-Dapper:Dapper列表

    ylbtech-ORM-Dapper:Dapper列表 1.返回顶部 1.1. https://dapper-tutorial.net/ 1.2. 2.1. https://www.nuget.org ...