Files
certd/packages/ui/certd-client/src/components/plugins/lib/index.ts
T

37 lines
720 B
TypeScript
Raw Normal View History

2024-09-27 02:15:41 +08:00
import { request } from "/@/api/service";
export type ComponentPropsType = {
2024-11-25 11:35:16 +08:00
type?: string;
typeName?: string;
action: string;
form?: any;
2024-09-27 02:15:41 +08:00
value?: any;
};
export type RequestHandleReq<T = any> = {
2024-09-30 18:00:51 +08:00
type: string;
2024-09-27 02:15:41 +08:00
typeName: string;
action: string;
2024-09-30 18:00:51 +08:00
data?: any;
2024-09-27 02:15:41 +08:00
input: T;
2026-02-15 12:59:08 +08:00
record?: any;
2026-03-16 23:27:24 +08:00
fromType?: string; // sys、user
2024-09-27 02:15:41 +08:00
};
export async function doRequest(req: RequestHandleReq, opts: any = {}) {
2024-11-25 11:35:16 +08:00
const url = `/pi/handle/${req.type}`;
2026-03-16 23:27:24 +08:00
const { typeName, action, data, input, record, fromType } = req;
2024-09-27 02:15:41 +08:00
const res = await request({
url,
method: "post",
data: {
typeName,
action,
data,
input,
2026-02-15 12:59:08 +08:00
record,
2026-03-16 23:27:24 +08:00
fromType,
2024-10-03 01:29:12 +08:00
},
...opts,
2024-09-27 02:15:41 +08:00
});
return res;
}