mirror of
https://github.com/certd/certd.git
synced 2026-05-15 20:47:31 +08:00
🔱: [client] sync upgrade with 3 commits [trident-sync]
perf: dict.getNodesByValues 修改为单例模式也可以运行,无需配置prototype,优化性能 chore: 各ui支持table-select
This commit is contained in:
@@ -39,6 +39,17 @@ function findById(id: any, list: any) {
|
||||
}
|
||||
}
|
||||
}
|
||||
function findByIds(ids: any[], list: any) {
|
||||
const res = [];
|
||||
for (const id of ids) {
|
||||
const item = findById(id, list);
|
||||
if (item != null) {
|
||||
res.push(item);
|
||||
}
|
||||
}
|
||||
console.log("findbyids", res, ids);
|
||||
return res;
|
||||
}
|
||||
const mockUtil: any = {
|
||||
findById,
|
||||
buildMock(options: any) {
|
||||
@@ -173,13 +184,7 @@ const mockUtil: any = {
|
||||
handle(req: any) {
|
||||
let id = req.params.id;
|
||||
id = parseInt(id);
|
||||
let current = null;
|
||||
for (const item of list) {
|
||||
if (item.id === id) {
|
||||
current = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
const current = findById(req.body.id, list);
|
||||
return {
|
||||
code: 0,
|
||||
msg: "success",
|
||||
@@ -187,6 +192,19 @@ const mockUtil: any = {
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
path: "/mock/" + name + "/byIds",
|
||||
method: "post",
|
||||
handle(req: any) {
|
||||
const ids = req.body.ids;
|
||||
const res = findByIds(ids, list);
|
||||
return {
|
||||
code: 0,
|
||||
msg: "success",
|
||||
data: res
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
path: "/mock/" + name + "/add",
|
||||
method: "post",
|
||||
|
||||
Reference in New Issue
Block a user