🔱: [client] sync upgrade with 3 commits [trident-sync]

perf: dict.getNodesByValues 修改为单例模式也可以运行,无需配置prototype,优化性能
chore: 各ui支持table-select
This commit is contained in:
GitHub Actions Bot
2023-09-09 19:24:09 +00:00
parent 9788aefcc1
commit 8701303012
98 changed files with 322 additions and 99 deletions
@@ -0,0 +1,99 @@
import * as api from "./api";
import * as textTableApi from "../text/api";
import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, UserPageQuery, UserPageRes } from "@fast-crud/fast-crud";
import createCrudOptionsText from "../text/crud";
export default function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet {
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
return await api.GetList(query);
};
const editRequest = async ({ form, row }: EditReq) => {
form.id = row.id;
return await api.UpdateObj(form);
};
const delRequest = async ({ row }: DelReq) => {
return await api.DelObj(row.id);
};
const addRequest = async ({ form }: AddReq) => {
return await api.AddObj(form);
};
return {
crudOptions: {
request: {
pageRequest,
addRequest,
editRequest,
delRequest
},
columns: {
id: {
title: "ID",
key: "id",
type: "number",
column: {
width: 50
},
form: {
show: false
}
},
single: {
title: "单选",
search: { show: true },
type: "table-select",
dict: dict({
value: "id",
label: "name",
getNodesByValues: async (values: any[]) => {
return await textTableApi.GetByIds(values);
}
}),
form: {
component: {
createCrudOptions: createCrudOptionsText,
crudOptionsOverride: {
table: {
scroll: {
x: 2000
}
},
rowHandle: {
fixed: "right"
}
}
}
}
},
multi: {
title: "多选",
search: { show: true },
type: "table-select",
dict: dict({
value: "id",
label: "name",
getNodesByValues: async (values: any[]) => {
return await textTableApi.GetByIds(values);
}
}),
form: {
component: {
multiple: true,
createCrudOptions: createCrudOptionsText,
crudOptionsOverride: {
table: {
scroll: {
x: 2000
}
},
rowHandle: {
fixed: "right"
}
}
}
}
}
}
}
};
}