有关表格新增问题出现在弹框层中
问题: 修改可以,但是新增不行,一点击确定走的是修改的接口。
一开始是在弹框中,添加了客户号码。
本来是要拿着客户号码(id)去判断是新增还是删除。这个客户号码只能在tableData中,而不能再放到form中。如果form 中还有客户号,下面判断,客户号有无 ,就没有意义了,首先如果有id那我是修改,没有id应该要去新增。正是因为我手欠,在form弹框中添加了客户号,也就导致打开弹框顺其自然的 输入了客户号,这才是罪魁祸首!(也就是新增这里我添加了客户号,那底下的判断,就都当成是有id去处理了,所以一直走的是update的接口,OMG终于找到这个bug了)
this.form.customerNo != undefined
// 确定按钮
submitForm: function () {
console.log("1111111");
this.$refs["form"].validate((valid) => {
// 校验成功
console.log(this.form);
if (valid) {
console.log("customerNo=" + this.form.customerNo);
// 判断
if (this.form.customerNo != undefined && this.form.customerNo != "") {
updateClient(this.form).then((response) => {
this.$message("修改成功");
this.open = false;
this.getUserInfo();
});
} else {
addClient(this.form).then((response) => {
this.$message("新增成功");
this.open = false;
this.getUserInfo();
});
}
} //
});
},