点击方向键切换表格内的输入框

 
      
      
      
      
      
      



 clickInput(val, index, type, event) {
      // theoreticalScore 理论考试成绩
      // eleTeScore 电子技术成绩
      // autoConScore 自动化控制成绩
      // plcScore  PLC编程成绩
     
      
      let xPoint;
      switch (type) {
        case "theoreticalScore":
          xPoint = 0;
          break;
        case "eleTeScore":
          xPoint = 1;
          break;
        case "autoConScore":
          xPoint = 2;
          break;
        case "plcScore":
          xPoint = 3;
          break;
        default:
          break;
      }
      let point;
      if (event.code == "ArrowRight") {
        if(type=='plcScore')return
        xPoint++;
        point = xPoint + "-" + index;
      }
      if (event.code == "ArrowLeft") {
        if(type=='theoreticalScore')return
        xPoint--;
        point = xPoint + "-" + index;
      }
      if (event.code == "ArrowUp") {
        if (index ==0) return;
        index--;
        point = xPoint + "-" + index;
      }
      if (event.code == "ArrowDown") {
        if (index+1 == this.total) return;
        index++;
        point = xPoint + "-" + index;
      }
      this.$nextTick(() => {
        document.getElementById(point)?.focus();
      });
    },

X轴固定为0,1,2,3   Y轴根据表格的条数进行限制点击方向键切换表格内的输入框_第1张图片

你可能感兴趣的:(vue.js,javascript,前端)