forked from b2894lxlx/tuanwei-admin
91 lines
2.1 KiB
TypeScript
91 lines
2.1 KiB
TypeScript
import request from '@/utils/request';
|
|
import type { ApiResult, PageResult } from '@/api';
|
|
import type { MerchantClerk, MerchantClerkParam } from './model';
|
|
|
|
/**
|
|
* 分页查询门店店员
|
|
*/
|
|
export async function pageMerchantClerks(params: MerchantClerkParam) {
|
|
const res = await request.get<ApiResult<PageResult<MerchantClerk>>>(
|
|
'/shop/merchant-clerk/page',
|
|
{ params }
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 查询门店店员列表
|
|
*/
|
|
export async function listMerchantClerks(params?: MerchantClerkParam) {
|
|
const res = await request.get<ApiResult<MerchantClerk[]>>(
|
|
'/shop/merchant-clerk',
|
|
{
|
|
params
|
|
}
|
|
);
|
|
if (res.data.code === 0 && res.data.data) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 添加门店店员
|
|
*/
|
|
export async function addMerchantClerk(data: MerchantClerk) {
|
|
const res = await request.post<ApiResult<unknown>>(
|
|
'/shop/merchant-clerk',
|
|
data
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 修改门店店员
|
|
*/
|
|
export async function updateMerchantClerk(data: MerchantClerk) {
|
|
const res = await request.put<ApiResult<unknown>>(
|
|
'/shop/merchant-clerk',
|
|
data
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 删除门店店员
|
|
*/
|
|
export async function removeMerchantClerk(id?: number) {
|
|
const res = await request.delete<ApiResult<unknown>>(
|
|
'/shop/merchant-clerk/' + id
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 批量删除门店店员
|
|
*/
|
|
export async function removeMerchantClerks(data: (number | undefined)[]) {
|
|
const res = await request.delete<ApiResult<unknown>>(
|
|
'/shop/merchant-clerk/batch',
|
|
{
|
|
data
|
|
}
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|