下布转数

v-model="scope.row.revolutions_count"

placeholder="请输入"

size="mini"

class="align-right-input count_input table_input"

@input="changeSalary(scope.row,scope.$index,'revolutions_count')"

@keyup.native="keyboard($event, scope.$index)"

>

保底转数

v-model="scope.row.overproduction"

placeholder="请输入"

size="mini"

class="align-right-input over_input table_input"

@input="changeSalary(scope.row,scope.$index,'overproduction')"

@keyup.native="keyboard($event, scope.$index)"

>

单价(元/转)

v-model="scope.row.revolution_price"

placeholder="请输入"

size="mini"

class="align-right-input revolution_input table_input"

@input="changeSalary(scope.row,scope.$index,'revolution_price')"

@keyup.native="keyboard($event, scope.$index)"

>

v-if="wage_scheme == 1 && price_mode ==1 || wage_scheme == 2 && price_mode ==1"

align="right"

width="87px"

>

保底工资

v-model="scope.row.knit_loom_price"

placeholder="请输入"

size="mini"

class="align-right-input knit_input table_input"

@input="changeSalary(scope.row,scope.$index,'knit_loom_price')"

@keyup.native="keyboard($event, scope.$index)"

>

加机费

v-model="scope.row.add_machine_reward"

placeholder="请输入"

size="mini"

class="align-right-input add_input table_input"

@input="changeSalary(scope.row,scope.$index,'add_machine_reward')"

@keyup.native="keyboard($event, scope.$index)"

>

// 双向绑定 输入框(下布转数、保底转数、单价(元/转)、保底工资、加机费) - 限制输入

changeSalary(row, index, type) {

this.$nextTick(() => {

// 先把非数字的都替换掉(空),除了数字和.

this.clothProduceData[index][type] = this.clothProduceData[index][

type

].replace(/[^\d.]/g, "");

// 必须保证第一个为数字而不是.

this.clothProduceData[index][type] = this.clothProduceData[index][

type

].replace(/^\./g, "");

// 保证只有出现一个.而没有多个.

this.clothProduceData[index][type] = this.clothProduceData[index][

type

].replace(/\.{3,}/g, "");

// 保证.只出现一次,而不能出现两次以上

this.clothProduceData[index][type] = this.clothProduceData[index][type]

.replace(".", "$#$")

.replace(/\./g, "")

.replace("$#$", ".");

// 限制几位小数

let subscript = -1;

for (let i in this.clothProduceData[index][type]) {

if (this.clothProduceData[index][type][i] === ".") {

subscript = i;

}

if (subscript !== -1) {

if (i - subscript > this.decimalNum(type)) {

this.clothProduceData[index][type] = this.clothProduceData[index][

type

].substring(0, this.clothProduceData[index][type].length - 1);

}

}

}

});

},

// 下布转数、保底转数:整数;单价(元/转):4位小数; 保底工资、加机费:2位小数

decimalNum(type) {

if (type == "revolutions_count" || type == "overproduction") {

return -1;

}

if (type == "revolution_price") {

return 4;

}

if (type == "knit_loom_price" || type == "add_machine_reward") {

return 2;

}

},

// 键盘事件(向上、向下)

keyboard(evt, index) {

let newIndex;

let _this = this;

let ev = evt ? evt : window.event;

let clssName = ev.target.offsetParent.className;

if (clssName.indexOf("count_input") != -1) {

newIndex = index * this.paramNum;

} else if (clssName.indexOf("over_input") != -1) {

newIndex = index * this.paramNum + 1;

} else if (clssName.indexOf("revolution_input") != -1) {

let num = this.paramNum === 2 ? 1 : 2;

newIndex = index * this.paramNum + num;

} else if (clssName.indexOf("knit_input") != -1) {

newIndex = index * this.paramNum + 3;

} else if (clssName.indexOf("add_input") != -1) {

newIndex = index * this.paramNum + 4;

}

// 获取每一列input

let inputAll = document.querySelectorAll(".table_input input");

let allLength = inputAll.length;

// 向上

if (ev.keyCode == 38) {

if (newIndex <= this.paramNum - 1) {

return false;

} else {

newIndex -= this.paramNum;

}

if (inputAll[newIndex]) {

inputAll[newIndex].focus();

}

}

// 向下

if (ev.keyCode == 40) {

if (newIndex >= allLength - this.paramNum) {

return false;

} else {

newIndex += this.paramNum;

}

if (inputAll[newIndex]) {

inputAll[newIndex].focus();

}

}

},

因为那五个字段是判断显示的,相应的,paramNum这个参数是一行显示有多少个输入框

clothProduceData是表格绑定的值,也就是tableData

vue 输入框限制3位小数_vue+element 中 el-input框 限制 只能输入数字及几位小数(自定义)和输入框之键盘...相关推荐

  1. vue限制只能输入数字_vue+element 中 el-input框 限制只能输入数字及一位小数

    仅个人经验,希望能帮到有需要的人. 第一次写 就话不多说了直接上代码. // 只能输入数字且只有一位小数 proving(e) { // this.form.skus[e].Price 是input的 ...

  2. input框限制只能输入正整数、字母、小数、汉字

    input框限制只能输入正整数.字母.小数.汉字 有时需要限制文本框输入内容的类型,本节分享下正则表达式限制文本框只能输入数字.小数点.英文字母.汉字等代码. 例如,输入大于0的正整数 代码如下: & ...

  3. html判断整数小数点后两位小数点,js控制input框只能输入数字和一位小数点且小数点后面只有两位小数...

    js控制input框只能输入数字和一位小数点且小数点后面只有两位小数 js控制input框只能输入数字和一位小数点且小数点后面只有两位小数 212或 0.66; 过滤 00000,1.10,0.00 ...

  4. html只能输入两位小数,JQuery控制input只能输入数字和两位小数(有关金额)代码...

    jquery代码: function num(obj){ obj.value = obj.value.replace(/[^\d.]/g,""); //清除"数字&quo ...

  5. 【C#】设置控制文本框(TextBox)只能输入正数,负数,小数

    /* *设置textBox只能输入数字(正数,负数,小数) *使用了TextBox的KeyPress事件*/ private void textBox1_KeyPress(object sender, ...

  6. input 限制只能输入数字,且保留小数后两位

    <input @keyup="value=oninput(value)" @change="value=oninput(value)"/> js方法 ...

  7. element-ui input 只能输入数字保留两位小数

    首先在输入框中加上input事件, 等数据化处理完成后在进行赋值 <el-input v-model="item.price" placeholder="请输入&q ...

  8. element table里的嵌入的input框设置只能输入英文和数字

    // el-input <el-input v-model="value1" oninput="value=value.replace(/[^0-9.]/g, '' ...

  9. php限制输入的小数点位数字,限制文本框只能输入数字,小数点,英文字母,汉字

    1.文本框只能输入数字代码(小数点也不能输入): input οnkeyup="this.value=this.value.replace(//D/g,'')" onafterpa ...

最新文章

  1. 分享一些自己常用的科研/软件工具
  2. Android应用程序键盘(Keyboard)消息处理机制分析(14)
  3. 小米android11新特性,小米已推送安卓11测试版 目前支持三款机型
  4. ADO.NET学习笔记--数据分组
  5. mysql 缓存机制
  6. Linux Kernel ‘install_user_keyrings()’竞争条件漏洞
  7. Java,C++四舍五入
  8. JavaFX技巧9:请勿混用Swing / JavaFX
  9. 【Xmail】使用Xmail搭建局域网邮件服务器
  10. 拼写校正与动态规划的小故事
  11. MVC的Ajax传值问题
  12. [OpenGL] 斯坦福兔子与显示列表
  13. DM manager工具的使用
  14. Sub-center ArcFace
  15. 重试利器之Guava Retrying
  16. 修改oracle用户密码永不过期的方法
  17. apple ID 注册 此时无法创建您的账户
  18. html图片旋转3种方式—— CSS3 transform
  19. 什么是报表工具?和 EXCEL 有什么区别?
  20. [论文阅读]PAN++: Towards Efficient and Accurate End-to-End Spotting of Arbitrarily-Shaped Text

热门文章

  1. 钉钉接入access_无需开发,IT事件接入钉钉的方法详解
  2. 缓冲区溢出_在Java中使用Google的协议缓冲区
  3. 皮一皮:学霸和学渣的区别
  4. 皮一皮:这是谁的脚???
  5. 皮一皮:直男的拍摄水平...
  6. 代码优化的 5 大原则,第 1 条相信你一开始就没想到!
  7. 超实用的 Mybatis 3.5 新特性
  8. 死磕Java并发:J.U.C之AQS:CLH同步队列
  9. 湖北黄冈中学2021年高考成绩查询,【喜报】2020年黄冈中学高考成绩出炉,600分以上人数556人...
  10. 设置 IntelliJ IDEA 智能提醒时忽略大小写