import { buildUUID } from '../../../utils/uuid';
|
import { ApiActionPage } from '../../model/baseModel';
|
import {
|
SupplierInfoListItem,
|
SupplierInfoPageParams,
|
SupplierInfoPageListGetResultModel,
|
} from '../model/basModel';
|
import { genAction, Api, genActionPage, isExist } from '../system';
|
import { defHttp } from '/@/utils/http/axios';
|
import { useUserStore } from '../../../store/modules/user';
|
|
/*
|
* 获取储位分页列表
|
*/
|
export const getSupplierListByPage = async (params: SupplierInfoPageParams) => {
|
let sqlcmd = '';
|
if (params?.SUPP_CODE != undefined && params?.SUPP_CODE != '') {
|
sqlcmd += "And SUPP_CODE like '%" + params?.SUPP_CODE + "%'";
|
}
|
if (params?.SUPP_NAME_CN != undefined && params?.SUPP_NAME_CN != '') {
|
sqlcmd += "And SUPP_NAME_CN like '%" + params?.SUPP_NAME_CN + "%'";
|
}
|
const rParams = genActionPage('BAS_SUPPLIER', sqlcmd, params.page, params.pageSize);
|
return getSupplierListByPageAsync(rParams);
|
};
|
async function getSupplierListByPageAsync(params: ApiActionPage) {
|
const data = await defHttp.post<ApiActionPage>(
|
{ url: Api.EntityPageList, params },
|
{
|
isTransformResponse: false,
|
},
|
);
|
const model: SupplierInfoPageListGetResultModel = {
|
items: data.Data.data,
|
total: data.Data.totals,
|
};
|
return model;
|
}
|
//检查
|
export function isAccountExist(params: string) {
|
const usParams = genAction('BAS_SUPPLIER', "SUPP_CODE='" + params + "'");
|
return isExist(usParams);
|
}
|
//保存
|
export const SaveRegion = async (params: SupplierInfoListItem, isUpdate: boolean) => {
|
let data;
|
if (isUpdate) {
|
data = await defHttp.post(
|
{ url: Api.UpdateEntity, params: genAction('BAS_SUPPLIER', params) },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
},
|
);
|
} else {
|
isAccountExist(params.SUPP_CODE);
|
params.ID = buildUUID(); //生成GUID
|
params.CREATE_USER = useUserStore().getUserInfo.userId;
|
data = await defHttp.post(
|
{ url: Api.AddEntity, params: genAction('BAS_SUPPLIER', params) },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
},
|
);
|
}
|
return data;
|
};
|
//删除
|
export const DeleteSupplier = async (params: Recordable) => {
|
const usParams = genAction('BAS_SUPPLIER', [params]);
|
return await defHttp.post(
|
{ url: Api.DeleteList, params: usParams },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
},
|
);
|
};
|