1: 三元表达式运用: renden函数运用:
lockData(id, isStatus) {
let status = isStatus ? "1" : "2";
api
.enableModelLibrary(
{},
{
url: `/api/ModelLibrary/enable/${id}/${status}`
}
)
.then(res => {
if (res && res.result == 1) {
this.$Modal.success({
title: "提示",
content: `${isStatus ? "开启" : "关闭"}成功`
});
this.search();
} else {
throw new Error("操作失败,请稍后再试!");
}
})
.catch(errData => {
this.$Modal.error({
title: "错误",
content: errData.message
});
});
},
h(
"Poptip",
{
props: {
confirm: true,
title: `你确定要${
params.row.aaa&&
params.row.aaa!= "1"
? "启用"
: "禁用"
}吗?`,
type: "error",
size: "small"
},
style: {
marginRight: "5px"
},
on: {
"on-ok": () => {
this.lockData(
params.row.id,
params.row.status &&
params.row.status != "1"
);
}
}
},
[
h(
"Button",
{
props: {
type: "error",
size: "small"
}
},
params.row.status &&
params.row.status != "1"
? "启用"
: "禁用"
)
]
),