add 包装
This commit is contained in:
@@ -143,32 +143,48 @@ export default {
|
||||
: {
|
||||
params,
|
||||
}
|
||||
).then(({ data: res }) => {
|
||||
console.log("[http response] res is: ", res);
|
||||
)
|
||||
.then(({ data: res }) => {
|
||||
console.log("[http response] res is: ", res);
|
||||
|
||||
// page 场景:
|
||||
if ("list" in res.data) {
|
||||
// real env:
|
||||
this.dataList = res.data.list.map((item) => {
|
||||
return {
|
||||
...item,
|
||||
id: item._id ?? item.id,
|
||||
};
|
||||
// }
|
||||
if (res.code === 0) {
|
||||
// page 场景:
|
||||
if ("list" in res.data) {
|
||||
// real env:
|
||||
this.dataList = res.data.list.map((item) => {
|
||||
return {
|
||||
...item,
|
||||
id: item._id ?? item.id,
|
||||
};
|
||||
// }
|
||||
});
|
||||
this.totalPage = res.data.total;
|
||||
} else if ("records" in res.data) {
|
||||
this.dataList = res.data.records.map((item) => ({
|
||||
...item,
|
||||
id: item._id ?? item.id,
|
||||
}));
|
||||
this.totalPage = res.data.total;
|
||||
} else {
|
||||
this.dataList.splice(0);
|
||||
this.totalPage = 0;
|
||||
}
|
||||
} else {
|
||||
this.$message({
|
||||
message: `${res.code}: ${res.msg}`,
|
||||
type: "error",
|
||||
duration: 2000,
|
||||
});
|
||||
}
|
||||
this.tableLoading = false;
|
||||
})
|
||||
.catch((err) => {
|
||||
this.$message({
|
||||
message: `${err}`,
|
||||
type: "error",
|
||||
duration: 2000,
|
||||
});
|
||||
this.totalPage = res.data.total;
|
||||
} else if ("records" in res.data) {
|
||||
this.dataList = res.data.records.map((item) => ({
|
||||
...item,
|
||||
id: item._id ?? item.id,
|
||||
}));
|
||||
this.totalPage = res.data.total;
|
||||
} else {
|
||||
this.dataList.splice(0);
|
||||
this.totalPage = 0;
|
||||
}
|
||||
this.tableLoading = false;
|
||||
});
|
||||
});
|
||||
// }
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user