写个对话框,valbut是判断是新增还是编辑
新增按钮
新增
修改按钮
修改
dialogFormVisible的初始值是false,表示隐藏
dialogFormVisible: false,
formList: {},
点新增按钮
// 新增
addList() {
this.dialogFormVisible = true;
this.formList = {};
},
弹框确定按钮
// 弹框确定按钮
addLibrary(row) {
let query = {
...this.formList
};
if (this.valBut == 1) {
postAction("/consumeRule/insertConsumeRule", query).then(res => {
this.$message({
type: res.success ? "success" : "error",
message: res.message
});
console.log(res);
this.getLibraryList();
this.dialogFormVisible = false;
});
}else{
putAction('/consumeRule/updateConsumeRuleById',query).then(res=>{
this.getLibraryList();
this.dialogFormVisible = false;
this.valBut=1
})
}
}
修改按钮
//修改
handleEdit(row) {
this.valBut = 0;
this.dialogFormVisible = true;
getAction("/consumeRule/getConsumeRuleById", {id:row.id}).then(res=>{
console.log(res);
this.formList=res.result //把相对应id的数据返回给formList表单展示
});
},



