switchChange(row, e) {
let statusFlag = row.isStatic //保存点击之后v-modeld的值(true,false)
row.isStatic = !row.isStatic //保持switch点击前的状态
let spoken = ''
if(row.isStatic == true){
spoken = '你确定禁用此账号?'
}else{
spoken = '你确定启用此账号?'
}
this.$confirm(spoken, '温馨提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
center: true
}).then(() => {
changeUserStatus({
id: row.id,
status: e ? 1 : 0,
}).then(res => {
statusFlag ? row.isStatic = true : row.isStatic = false // 关键row.isStatic会根据
this.dialogFormVisible = false
this.$message({ message: '修改数据成功', type: 'success' })
this.form = {}
this.getData()
}).catch(err => {
console.error(err)
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消'
});
});
},
el-switch先提示再修改状态
最新推荐文章于 2023-11-08 17:11:16 发布