perf(projects): 优化any
This commit is contained in:
@ -1,22 +1,28 @@
|
||||
import type { UserPageQuery } from '@fast-crud/fast-crud';
|
||||
import { mockRequest } from '@/service/request';
|
||||
|
||||
const request = mockRequest;
|
||||
const apiPrefix = '/crud/demo';
|
||||
|
||||
export type DemoRecord = {
|
||||
id: number;
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
function resHandle(res: any) {
|
||||
return res.data;
|
||||
}
|
||||
export async function GetList(query: any) {
|
||||
export async function GetList(query: UserPageQuery) {
|
||||
const res = await request.post(`${apiPrefix}/page`, query);
|
||||
return resHandle(res);
|
||||
}
|
||||
|
||||
export async function AddObj(obj: any) {
|
||||
export async function AddObj(obj: DemoRecord) {
|
||||
const res = await request.post(`${apiPrefix}/add`, obj);
|
||||
return resHandle(res);
|
||||
}
|
||||
|
||||
export async function UpdateObj(obj: any) {
|
||||
export async function UpdateObj(obj: DemoRecord) {
|
||||
const res = await request.post(`${apiPrefix}/update`, obj);
|
||||
return resHandle(res);
|
||||
}
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import type { AddReq, CreateCrudOptionsRet, DelReq, EditReq } from '@fast-crud/fast-crud';
|
||||
import type { AddReq, CreateCrudOptionsRet, DelReq, EditReq, UserPageQuery, UserPageRes } from '@fast-crud/fast-crud';
|
||||
import { dict } from '@fast-crud/fast-crud';
|
||||
import dayjs from 'dayjs';
|
||||
import * as api from './api';
|
||||
|
||||
export default function createCrudOptions(): CreateCrudOptionsRet {
|
||||
const pageRequest = async (query: any) => {
|
||||
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
|
||||
return api.GetList(query);
|
||||
};
|
||||
const editRequest = async (ctx: EditReq) => {
|
||||
|
||||
@ -1,22 +1,28 @@
|
||||
import type { UserPageQuery } from '@fast-crud/fast-crud';
|
||||
import { mockRequest } from '@/service/request';
|
||||
|
||||
const request = mockRequest;
|
||||
const apiPrefix = '/crud/header-group';
|
||||
|
||||
export type HeaderGroupRecord = {
|
||||
id: number;
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
function resHandle(res: any) {
|
||||
return res.data;
|
||||
}
|
||||
export async function GetList(query: any) {
|
||||
export async function GetList(query: UserPageQuery) {
|
||||
const res = await request.post(`${apiPrefix}/page`, query);
|
||||
return resHandle(res);
|
||||
}
|
||||
|
||||
export async function AddObj(obj: any) {
|
||||
export async function AddObj(obj: HeaderGroupRecord) {
|
||||
const res = await request.post(`${apiPrefix}/add`, obj);
|
||||
return resHandle(res);
|
||||
}
|
||||
|
||||
export async function UpdateObj(obj: any) {
|
||||
export async function UpdateObj(obj: HeaderGroupRecord) {
|
||||
const res = await request.post(`${apiPrefix}/update`, obj);
|
||||
return resHandle(res);
|
||||
}
|
||||
|
||||
@ -1,22 +1,22 @@
|
||||
import type { CreateCrudOptionsRet } from '@fast-crud/fast-crud';
|
||||
import { dict } from '@fast-crud/fast-crud';
|
||||
import type { CreateCrudOptionsRet, UserPageQuery, UserPageRes } from '@fast-crud/fast-crud';
|
||||
import type { HeaderGroupRecord } from './api';
|
||||
import * as api from './api';
|
||||
|
||||
export default function createCrudOptions(): CreateCrudOptionsRet {
|
||||
const pageRequest = async (query: any) => {
|
||||
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
|
||||
return api.GetList(query);
|
||||
};
|
||||
const editRequest = async (ctx: { form: any; row: any }) => {
|
||||
const editRequest = async (ctx: { form: HeaderGroupRecord; row: HeaderGroupRecord }) => {
|
||||
const { form, row } = ctx;
|
||||
form.id = row.id;
|
||||
return api.UpdateObj(form);
|
||||
};
|
||||
const delRequest = async (ctx: { row: any }) => {
|
||||
const delRequest = async (ctx: { row: HeaderGroupRecord }) => {
|
||||
const { row } = ctx;
|
||||
return api.DelObj(row.id);
|
||||
};
|
||||
|
||||
const addRequest = async (ctx: { form: any }) => {
|
||||
const addRequest = async (ctx: { form: HeaderGroupRecord }) => {
|
||||
const { form } = ctx;
|
||||
return api.AddObj(form);
|
||||
};
|
||||
@ -69,14 +69,8 @@ export default function createCrudOptions(): CreateCrudOptionsRet {
|
||||
children: {
|
||||
province: {
|
||||
title: '省',
|
||||
search: { show: true },
|
||||
type: 'dict-select',
|
||||
dict: dict({
|
||||
data: [
|
||||
{ value: '广东省', label: '广东省' },
|
||||
{ value: '浙江省', label: '浙江省' }
|
||||
]
|
||||
})
|
||||
type: 'text',
|
||||
search: { show: true }
|
||||
},
|
||||
city: {
|
||||
title: '市',
|
||||
|
||||
Reference in New Issue
Block a user