import { buildUUID } from '../../../utils/uuid';
|
import { ApiActionPage } from '../../model/baseModel';
|
import {
|
LocationListItem,
|
LocationPageParams,
|
LocationPageListGetResultModel,
|
} from '../model/warehoueseModel';
|
import { genAction, Api, genActionPage } from '../system';
|
import { defHttp } from '/@/utils/http/axios';
|
|
/*
|
* 获取储位分页列表
|
*/
|
export const getLocationListByPage = async (params: LocationPageParams) => {
|
let sqlcmd = '';
|
if (params?.SHELF_CODE != undefined && params?.SHELF_CODE != '') {
|
sqlcmd += " And SHELF_CODE = '" + params?.SHELF_CODE + "'";
|
}
|
if (params?.LOCATION_CODE != undefined && params?.LOCATION_CODE != '') {
|
sqlcmd += "And LOCATION_CODE like '%" + params?.LOCATION_CODE + "%'";
|
}
|
if (params?.LOCATION_NAME != undefined && params?.LOCATION_NAME != '') {
|
sqlcmd += "And LOCATION_NAME = '" + params?.LOCATION_NAME + "'";
|
}
|
if (params?.FLOOR_NO != undefined) {
|
sqlcmd += "And FLOOR_NO = '" + params?.FLOOR_NO + "'";
|
}
|
const rParams = genActionPage('WMS_LOCATION', sqlcmd, params.page, params.pageSize);
|
return getLocationListByPageAsync(rParams);
|
};
|
async function getLocationListByPageAsync(params: ApiActionPage) {
|
const data = await defHttp.post<ApiActionPage>(
|
{ url: Api.EntityPageList, params },
|
{
|
isTransformResponse: false,
|
},
|
);
|
const model: LocationPageListGetResultModel = {
|
items: data.Data.data,
|
total: data.Data.totals,
|
};
|
return model;
|
}
|
|
export const SaveLocation = async (params: LocationListItem, isUpdate: boolean) => {
|
let data;
|
if (isUpdate) {
|
data = await defHttp.post(
|
{ url: Api.UpdateEntity, params: genAction('WMS_LOCATION', params) },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
},
|
);
|
} else {
|
params.ID = buildUUID(); //生成GUID
|
data = await defHttp.post(
|
{ url: Api.AddEntity, params: genAction('WMS_LOCATION', params) },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
},
|
);
|
}
|
return data;
|
};
|
|
export const DeleteLocation = async (params: Recordable) => {
|
const usParams = genAction('WMS_LOCATION', [params]);
|
return await defHttp.post(
|
{ url: Api.DeleteList, params: usParams },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
},
|
);
|
};
|