问:switch(id, status, name) {
let data = {};
let text = '', msg1 = '', msg2 = '';
if (status === 1) {
data.status = 2;
Text: 'are you sure you want to disable this user? ';
MSG1 ='disable '+ name +'user succeeded';
Msg2 ='disable '+ name +'user failed';
} else {
data.status = 1;
Text: 'are you sure you want to enable this user? ';
MSG1 ='enable '+ name +'user succeeded';
Msg2 ='enable '+ name +'user failed';
}
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;
}
})
}
状态为启用。单击切换时,状态变为灰色。如果您单击取消,状态不会返回到绿色状态。您需要手动刷新列表。在代码中单击“取消”时,调用getuserlist刷新列表
答:我以前没有使用过iView。我不确定具体问题是什么,但是如果我只看问题:
建议检查网络请求以查看是否已刷新
status是否返回数据中的标准属性,例如object obj = {id: 1, name: 'foo'},您obj.status = 1没有响应
取消时重置状态