关于按钮调用接口切换
先上图
其中的status是常量引入的文件,
主要是逻辑写的简单,我有重新更改了一份关于有对话框的禁用启用按钮事件。
handleStatus(val) {
console.log(val.state);
var status = "";
if (val.state === true) {
val.state = 0;
status = "禁用";
} else {
val.state = 1;
status = "启用";
}
var data = {
id: val.id,
state: val.state
};
this.$confirm("已成功" + status + ", 是否继续?", "提示", {
type: "warning"
})
.then(async () => {
await changeState(data)
.then(response => {
this.$message.success("已成功" + status + "!");
this.getDirectorysList();
})
.catch(response => {
this.$message.error(status + "失败!");
});
})
.catch(() => {
this.$message.info("已取消操作!");
});
}
记录一下就可以了,不然后面忘了就有参考的了