data() {
var checkAge = (rule, value, callback) => {
// console.log(value, "输入的");
// console.log(this.da, "最大的");
// console.log(this.xiao, "最小的");
let value1 = Number(value);
let xiao1 = Number(this.xiao);
let da1 = Number(this.da);
if (value1 > da1 || value1 < xiao1) {
return callback(new Error("请输入价格区间内的金额"));
} else {
callback();
}
};
return {
xiao: "",
da: "",
rules: {
price: [
{
validator: checkAge,
trigger: "blur"
}
]
}
};
},
/* 保存编辑 */
save(form) {
this.$refs[form].validate(valid => {
if (valid) {
this.loading = true;
let info = {
appointment_record_id: this.form.id,
type: 1,
from: this.form.from,
order_id: this.form.order_id,
price: this.form.price
};
this.$http
.post("admin-api/member-order/add", info)
.then(res => {
this.loading = false;
console.log(res);
if (res.data.status == 1) {
this.$message({ type: "success", message: "成功" });
this.form = {
type: 1,
from: 1
};
this.aaaainfo = "";
this.updateVisible(false);
this.$emit("done");
} else {
this.$message.error(res.data.error);
}
})
.catch(e => {
this.loading = false;
this.$message.error(e.message);
});
} else {
return false;
}
});
},
vue中使用elm表单的自定义校验规则
最新推荐文章于 2024-09-30 11:41:17 发布