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;
|
2024-09-27 02:15:41 +08:00
|
|
|
};
|
|
|
|
|
|
2024-10-10 14:28:46 +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-02-15 12:59:08 +08:00
|
|
|
const { typeName, action, data, input, record } = req;
|
2024-09-27 02:15:41 +08:00
|
|
|
const res = await request({
|
|
|
|
|
url,
|
|
|
|
|
method: "post",
|
|
|
|
|
data: {
|
|
|
|
|
typeName,
|
|
|
|
|
action,
|
|
|
|
|
data,
|
2025-03-21 01:02:57 +08:00
|
|
|
input,
|
2026-02-15 12:59:08 +08:00
|
|
|
record,
|
2024-10-03 01:29:12 +08:00
|
|
|
},
|
2025-03-21 01:02:57 +08:00
|
|
|
...opts,
|
2024-09-27 02:15:41 +08:00
|
|
|
});
|
|
|
|
|
return res;
|
|
|
|
|
}
|