switch(id, status, name) {
let data = {};
let text = '', msg1 = '', msg2 = '';
if (status === 1) {
data.status = 2;
text = '确定禁用该用户?';
msg1 = '禁用' + name + '用户成功';
msg2 = '禁用' + name + '用户失败';
} else {
data.status = 1;
text = '确定启用该用户?';
msg1 = '启用' + name + '用户成功';
msg2 = '启用' + name + '用户失败';
}
let self = this;
this.$confirm({
text: text,
onOk: function () {
self.$ajax({
url: urls.user_status,
data: {
ids: [id],
status: data.status
}
}).then(data => {
if (data.code === 200) {
self.$Message.success(msg1);
self.getUserList();
} else {
self.$Message.error(msg2);
}
});
},
cancel: function () {
self.getUserList();
}
});
},
getUserList() {
this.$ajax({
url: urls.user_list,
data: {
page: this.pageConfig.page,
size: this.pageConfig.size,
user_name: this.searchList.user_name,
real_name: this.searchList.real_name,
status: this.searchList.status === '-1' ? null : this.searchList.status,
dep_id: this.searchList.dep_id === '-1' ? null: this.searchList.dep_id
}
})
.then(data => {
if (data.code === 200) {
this.data = data.data;
this.pageConfig.total = data.totalRecords;
} else {
this.data = [];
this.pageConfig.total = 0;
}
})
}
状态是启用,点switch的时候,状态变成灰色,点击取消,状态并未回归到绿色状态,需要手动刷新列表才行,代码里点取消的时候是调了getUserList刷新了列表
试下拿到当前行rowIndex,data[rowIndex].status = true