add 包装

This commit is contained in:
lb
2023-02-24 16:56:39 +08:00
parent b573e2dc2f
commit 55fc9bac3e
4 changed files with 310 additions and 26 deletions

View File

@@ -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;
});
});
// }
},