49 lines
2.0 KiB
TypeScript
49 lines
2.0 KiB
TypeScript
import { Party, PartyStatus } from '@/data/party/party.model';
|
|
import { CommonResponseType, PageAble } from '@/helpers/types';
|
|
import { request } from '@/services/request';
|
|
|
|
export const party_requests = {
|
|
async getAll(params?: {
|
|
page?: number;
|
|
sort?: string;
|
|
direction?: string;
|
|
partyName?: string;
|
|
status?: PartyStatus;
|
|
cargoType?: 'AUTO' | 'AVIA';
|
|
}) {
|
|
return request.get<CommonResponseType<PageAble<Party>>>('/parties/list', { params });
|
|
},
|
|
async changeStatus(params: { partyId: string | number; status: PartyStatus }) {
|
|
return request.put('/parties/change', undefined, { params });
|
|
},
|
|
async create(body: { name: string; cargoType: 'AUTO' | 'AVIA' }) {
|
|
return request.post<CommonResponseType>('/parties/create', body);
|
|
},
|
|
async update(body: { id: number | string; name: string; cargoType: 'AUTO' | 'AVIA' }) {
|
|
return request.put<CommonResponseType<Party[]>>(
|
|
'/parties/update',
|
|
{ name: body.name, cargoType: body.cargoType },
|
|
{
|
|
params: {
|
|
partyId: body.id,
|
|
},
|
|
}
|
|
);
|
|
},
|
|
async find(params: { partyId: number | string }) {
|
|
return request.get<CommonResponseType<Party>>('/parties/find', { params });
|
|
},
|
|
async delete(params: { partyId: number | string }) {
|
|
return request.delete<CommonResponseType>('/parties/delete', { params });
|
|
},
|
|
async downloadExcel(params: { partyId: number | string }) {
|
|
return request.get<Blob>('/parties/download', { params, responseType: 'blob' });
|
|
},
|
|
async downloadPartyItemsExcel(params: { partyId: number | string }) {
|
|
return request.get<Blob>('/parties/items/download', { params, responseType: 'blob' });
|
|
},
|
|
async downloadPartyItemsAllExcel(params: { partyId: number | string }) {
|
|
return request.get<Blob>('/parties/download/box-order', { params, responseType: 'blob' });
|
|
},
|
|
};
|