我正在为我们的系统进行验证。我想避免用户输入超过特定药品最大数量的东西。如果事务表中只有一行,那么验证就可以了。如果我的桌子上有多行,就会出现问题。当我输入的数量超过最大数量时,它接受输入,并且另一行的编辑按钮变为启用状态。我如何使用那里的ID将药品表的数量与交易数量进行比较?
saveData () {
for(var index = 0; index < this.gulod_transactions.length; index++) {
for(var index1 = 0; index1 < this.gulod_medicines.length; index1++) {
if(this.gulod_medicines[index1].medicine_id === this.gulod_transactions[index].id) {
if (this.gulod_transactions[index].quantity > this.gulod_medicines[index1].quantity) {
swal("Error Occured!", "You exceed the maximum amount", "error");
} else {
this.editDisabled = false
this.editUser = null
this.beforEditCache = null
this.editedUser = null
this.gulod_transactions[index].total = this.gulod_transactions[index].quantity * this.gulod_transactions[index].price + ".00";
swal("Congrats!", "Successfully change the amount", "success");
}
}
}
}
},