欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 汽车 > 维修 > element的table获取当前表格行

element的table获取当前表格行

2024/10/25 4:22:32 来源:https://blog.csdn.net/weixin_52326756/article/details/139860096  浏览:    关键词:element的table获取当前表格行

需求:验证表格同一行的最低限价不能超过销售定价

思路:先获取当前行table的index,然后在做大小比较

1.局部html

<el-table-column label="销售定价(元)" min-width="200px"><template slot="header"><span class="star">*</span><span class="star-name">销售定价(元)</span></template><template slot-scope="scope"><el-form-item:prop="'skuList.' + scope.$index + '.price'":rules="tableRules.price"><el-inputsize="small"v-model.trim="scope.row.price"@input="userInput"placeholder="请输入销售定价"/></el-form-item></template>
</el-table-column><el-table-column label="最低限价(元)" min-width="200px"><template slot="header"><span class="star">*</span><span class="star-name">最低限价(元)</span></template><template slot-scope="scope"><el-form-item:prop="'skuList.' + scope.$index + '.floorPrice'":rules="tableRules.floorPrice"><el-inputsize="small"v-model.trim="scope.row.floorPrice"@input="userInput"placeholder="请输入最低限价"/></el-form-item></template>
</el-table-column>

2.验证规则

const checkFloorPrice = (rule, value, callback) => {let index = rule.field.split(".")[1];//获取当前行角标if (!value) {callback(new Error("请输入最低限价"));} else if (value == Infinity || value > Math.pow(2, 31) - 1) {callback(new Error("您填写的数字过长"));} else if (!/^\d+(\.\d{1,2})?$/.test(value)) {callback(new Error("请输入小数不超过两位的自然数"));} else if (value >= this.tableForm.skuList[index].price) {//重点看这里callback(new Error("最低限价不能超过销售定价"));} else {callback();}
};

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com