// async await 改写 promise then
async switch(row) {
const { id, status, name } = row;
try {
const confirm = await this.$confirm(
`You are switching ${status ? 'on' : 'off'} ${name}. Are you sure?`,
'',
{
cancelButtonText: 'No',
confirmButtonText: 'Yes',
type: '',
}
);
if (confirm === 'confirm') {
const { code } = await updateGroupStatus({
groupId,
//启动状态 0:启动 1:关闭 必填
status: status ? OPENSTATUS : CLOSESTATUS,
});
if (code === '0') {
this.$message.success('success');
}
}
} catch (error) {
row.status = !status;
}
},