import { buildUUID } from '../../../utils/uuid';
|
import { ApiAction } from '../../model/baseModel';
|
import {
|
WhPageListGetResultModel,
|
HouseListItem,
|
WhListItem,
|
RegionListItem,
|
ShelfListItem,
|
LocationListItem,
|
} from '../model/warehoueseModel';
|
import { genAction, Api, isExist } from '../system';
|
import { useUserStore } from '/@/store/modules/user';
|
import { formatToDateTime } from '/@/utils/dateUtil';
|
import { defHttp } from '/@/utils/http/axios';
|
//仓库结构树状下拉
|
export const getTreeList = (params?: HouseListItem) =>
|
defHttp.get<WhPageListGetResultModel>(
|
{ url: Api.GetHouseTreeList, params },
|
{
|
isTransformResponse: false,
|
},
|
);
|
//通过仓库code查要修改的数据
|
export function getWHList(params: string) {
|
let rmParams = genAction('', '');
|
if (params.slice(0, 1) == 'W') {
|
rmParams = genAction('WMS_WAREHOUSE', " ID = '" + params.slice(1) + "'");
|
}
|
if (params.slice(0, 1) == 'R') {
|
rmParams = genAction('WMS_REGION', " ID = '" + params.slice(1) + "'");
|
}
|
if (params.slice(0, 1) == 'S') {
|
rmParams = genAction('WMS_SHELF', " ID = '" + params.slice(1) + "'");
|
}
|
|
return getWareHouse(rmParams);
|
}
|
async function getWareHouse(params: ApiAction<string>) {
|
let data;
|
if (params.DataType == 'WMS_WAREHOUSE') {
|
data = await defHttp.post<ApiAction<WhListItem>>(
|
{
|
url: Api.EntityList,
|
params,
|
},
|
{
|
errorMessageMode: 'modal',
|
isTransformResponse: false,
|
},
|
);
|
}
|
if (params.DataType == 'WMS_REGION') {
|
data = await defHttp.post<ApiAction<RegionListItem>>(
|
{
|
url: Api.EntityList,
|
params,
|
},
|
{
|
errorMessageMode: 'modal',
|
isTransformResponse: false,
|
},
|
);
|
}
|
if (params.DataType == 'WMS_SHELF') {
|
data = await defHttp.post<ApiAction<ShelfListItem>>(
|
{
|
url: Api.EntityList,
|
params,
|
},
|
{
|
errorMessageMode: 'modal',
|
isTransformResponse: false,
|
},
|
);
|
}
|
return data.Data;
|
}
|
|
/*
|
* 新增仓库部分
|
*/
|
export const SaveWareHouse = async (params: Recordable, isUpdate: boolean) => {
|
const whitem: any = {
|
ID: params.ID,
|
IS_ACTIVE: params.IS_ACTIVE,
|
REMARK: params.REMARK,
|
TRANSFER_WH: params.TRANSFER_WH?.trim(),
|
WH_NAME: params.WH_NAME,
|
WH_CODE: params.WH_CODE,
|
ORG_CODE: params.ORG_CODE,
|
CREATE_TIME: params.CREATE_TIME,
|
CREATE_USER: params.CREATE_USER,
|
AUTH_ORG: params.AUTH_ORG,
|
//SCAN_AF_CUT:params.SCAN_AF_CUT
|
};
|
let data;
|
if (isUpdate) {
|
const time = new Date();
|
whitem.UPDATE_TIME = formatToDateTime(time);
|
whitem.UPDATE_USER = useUserStore().getUserInfo.userId as string;
|
//whitem.ORG_CODE = useUserStore().getUserInfo.orgCode as string;
|
//whitem.AUTH_ORG = useUserStore().getUserInfo.orgCode as string;
|
data = await defHttp.post(
|
{ url: Api.UpdateEntity, params: genAction('WMS_WAREHOUSE', whitem) },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
},
|
);
|
defHttp.get(
|
{ url: Api.GetUpdateOrg, params: { id: whitem.ID } },
|
{
|
isTransformResponse: false,
|
},
|
);
|
} else {
|
const usParams = genAction('WMS_WAREHOUSE', "WH_CODE='" + params.WH_CODE + "'");
|
const check = await isExist(usParams);
|
console.log('check', check);
|
if (!check.Data) {
|
const time = new Date();
|
whitem.ID = buildUUID(); //生成GUID
|
whitem.UPDATE_TIME = formatToDateTime(time);
|
whitem.CREATE_USER = useUserStore().getUserInfo.userId as string;
|
whitem.UPDATE_USER = useUserStore().getUserInfo.userId as string;
|
//whitem.ORG_CODE = useUserStore().getUserInfo.orgCode as string;
|
//whitem.AUTH_ORG = useUserStore().getUserInfo.orgCode as string;
|
data = await defHttp.post(
|
{ url: Api.AddEntity, params: genAction('WMS_WAREHOUSE', whitem) },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
},
|
);
|
} else {
|
return check.Message;
|
}
|
}
|
return data;
|
};
|
/*
|
* 新增储区部分
|
*/
|
export const SaveRegion = async (params: Recordable, isUpdate: boolean) => {
|
const regionitem: RegionListItem = {
|
ID: params.ID,
|
IS_ACTIVE: params.IS_ACTIVE,
|
REMARK: params.REMARK,
|
REGION_CODE: params.REGION_CODE,
|
REGION_NAME: params.REGION_NAME,
|
WH_ID: isUpdate ? params.WH_ID : params.field1,
|
ORG_CODE: isUpdate ? params?.ORG_CODE : params?.field2,
|
CREATE_TIME: params.CREATE_TIME,
|
CREATE_USER: params.CREATE_USER,
|
AUTH_ORG: isUpdate ? params?.AUTH_ORG : params?.field2,
|
};
|
let data;
|
|
if (isUpdate) {
|
const time = new Date();
|
regionitem.UPDATE_TIME = formatToDateTime(time);
|
regionitem.UPDATE_USER = useUserStore().getUserInfo.userId as string;
|
regionitem.ORG_CODE = useUserStore().getUserInfo.orgCode as string;
|
regionitem.AUTH_ORG = useUserStore().getUserInfo.orgCode as string;
|
data = await defHttp.post(
|
{ url: Api.UpdateEntity, params: genAction('WMS_REGION', regionitem) },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
},
|
);
|
} else {
|
const usParams = genAction(
|
'WMS_REGION',
|
"REGION_CODE='" + params.REGION_CODE + "'AND AUTH_ORG='" + regionitem.ORG_CODE + "'",
|
);
|
const check = await isExist(usParams);
|
console.log('check', check);
|
if (!check.Data) {
|
regionitem.ID = buildUUID(); //生成GUID
|
regionitem.UPDATE_TIME = formatToDateTime(new Date());
|
regionitem.CREATE_USER = useUserStore().getUserInfo.userId as string;
|
regionitem.UPDATE_USER = useUserStore().getUserInfo.userId as string;
|
// regionitem.ORG_CODE = useUserStore().getUserInfo.orgCode as string;
|
// regionitem.AUTH_ORG = useUserStore().getUserInfo.orgCode as string;
|
data = await defHttp.post(
|
{ url: Api.AddEntity, params: genAction('WMS_REGION', regionitem) },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
},
|
);
|
} else {
|
// return check.Message;
|
return '重复了';
|
}
|
}
|
return data;
|
};
|
/*
|
* 新增货架部分
|
*/
|
export const SaveShelf = async (params: Recordable, isUpdate: boolean) => {
|
const Shelfitem: ShelfListItem = {
|
ID: params.ID,
|
//SEQ_NO: params.SEQ_NO,
|
IS_ACTIVE: params.IS_ACTIVE,
|
SHELF_TYPE: params.SHELF_TYPE,
|
REMARK: params.REMARK,
|
SHELF_NAME: params.SHELF_NAME,
|
SHELF_CODE: params.SHELF_CODE,
|
FLOORS: params.FLOORS,
|
FLOOR_COUNT: params.FLOOR_COUNT,
|
REGION_ID: isUpdate ? params?.REGION_ID : params.field1,
|
ORG_CODE: isUpdate ? params?.ORG_CODE : params?.field2,
|
CREATE_TIME: params.CREATE_TIME,
|
CREATE_USER: params.CREATE_USER,
|
// AUTH_ORG:params.AUTH_ORG,
|
AUTH_ORG: isUpdate ? params?.AUTH_ORG : params?.field2,
|
};
|
let data;
|
if (isUpdate) {
|
const time = new Date();
|
Shelfitem.UPDATE_TIME = formatToDateTime(time);
|
Shelfitem.UPDATE_USER = useUserStore().getUserInfo.userId as string;
|
Shelfitem.ORG_CODE = useUserStore().getUserInfo.orgCode as string;
|
Shelfitem.AUTH_ORG = useUserStore().getUserInfo.orgCode as string;
|
data = await defHttp.post(
|
{ url: Api.UpdateEntity, params: genAction('WMS_SHELF', Shelfitem) },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
},
|
);
|
} else {
|
Shelfitem.ID = buildUUID(); //生成GUID
|
Shelfitem.UPDATE_TIME = formatToDateTime(new Date());
|
Shelfitem.CREATE_USER = useUserStore().getUserInfo.userId as string;
|
Shelfitem.UPDATE_USER = useUserStore().getUserInfo.userId as string;
|
// Shelfitem.ORG_CODE = useUserStore().getUserInfo.orgCode as string;
|
// Shelfitem.AUTH_ORG = useUserStore().getUserInfo.orgCode as string;
|
const usParams = genAction(
|
'WMS_SHELF',
|
"SHELF_CODE='" + params.SHELF_CODE + "'AND AUTH_ORG='" + Shelfitem.ORG_CODE + "'",
|
);
|
const check = await isExist(usParams);
|
if (!check.Data) {
|
//Shelfitem.AUTH_ORG = useUserStore().getUserInfo.orgCode as string;
|
data = await defHttp.post(
|
{ url: Api.AddEntity, params: genAction('WMS_SHELF', Shelfitem) },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
},
|
);
|
} else {
|
data = false;
|
}
|
}
|
return data;
|
};
|
/*
|
* 保存储位
|
*/
|
export const UpdateLocation = async (params: Recordable) => {
|
const Locationitem: LocationListItem = {
|
ID: params.ID,
|
//SEQ_NO: params.SEQ_NO,
|
IS_ACTIVE: params.IS_ACTIVE,
|
IS_SINGLE: params.IS_SINGLE,
|
REMARK: params.REMARK,
|
LOCATION_CODE: params.LOCATION_CODE,
|
LOCATION_NAME: params.LOCATION_NAME,
|
SEQ_NO: params.SEQ_NO,
|
ORG_CODE: params.ORG_CODE,
|
SHELF_ID: params.SHELF_ID,
|
FLOOR_NO: params.FLOOR_NO,
|
IS_MIX: params.IS_MIX,
|
LEDID: params.LEDID,
|
CREATE_TIME: params.CREATE_TIME,
|
CREATE_USER: params.CREATE_USER,
|
AUTH_ORG: params.AUTH_ORG,
|
};
|
let data;
|
|
const time = new Date();
|
Locationitem.UPDATE_TIME = formatToDateTime(time);
|
Locationitem.UPDATE_USER = useUserStore().getUserInfo.userId as string;
|
//Locationitem.ORG_CODE = useUserStore().getUserInfo.orgCode as string;
|
Locationitem.AUTH_ORG = useUserStore().getUserInfo.orgCode as string;
|
data = await defHttp.post(
|
{ url: Api.UpdateEntity, params: genAction('WMS_LOCATION', Locationitem) },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
},
|
);
|
|
return data;
|
};
|
/*
|
* 新增储位部分
|
*/
|
export const SaveLocation = async (params: Recordable, isUpdate: boolean) => {
|
let data;
|
{
|
const locations = [];
|
params.forEach((items) => {
|
items.forEach((item) => {
|
item.CREATE_USER = useUserStore().getUserInfo.userId as string;
|
item.UPDATE_USER = useUserStore().getUserInfo.userId as string;
|
//item.ORG_CODE=useUserStore().getUserInfo.orgCode as string;
|
item.AUTH_ORG = useUserStore().getUserInfo.orgCode as string;
|
locations.push(item);
|
});
|
});
|
// const locationcode_guize: LocationGuiZeListItem = {
|
// LOCATION_CODE:params.LOCATION_CODE,
|
// IS_ACTIVE:params.IS_ACTIVE,
|
// ORG_CODE:params.ORG_CODE,
|
// SHELF_CODE:params.SHELF_CODE,
|
// ISMIX:params.ISMIX,
|
// };
|
data = await defHttp.post(
|
{ url: Api.AddLocation, params: locations },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
},
|
);
|
}
|
return data;
|
};
|
//查询货架的所有储位
|
export function getLocationListByPage(params: string, ORG: string) {
|
const rmParams = genAction('WMS_LOCATION', {
|
QueryAble_T: '',
|
where: "SHELF_ID = '" + params + "'",
|
order: 'FLOOR_NO desc, SEQ_NO desc',
|
});
|
return getLocationList(rmParams);
|
}
|
async function getLocationList(params: ApiAction<string>) {
|
const data = await defHttp.post<ApiAction<LocationListItem[]>>(
|
{
|
url: Api.QueryUrl,
|
params,
|
},
|
{
|
errorMessageMode: 'modal',
|
isTransformResponse: false,
|
},
|
);
|
return data.Data;
|
}
|
|
//查询货架所在的仓库
|
export function getWareHouseListByPage(params: string) {
|
const rmParams = genAction('V_WH_UNIT', {
|
QueryAble_T: '',
|
where: "SHELF_CODE = '" + params + "'",
|
});
|
return getWhList(rmParams);
|
}
|
async function getWhList(params: ApiAction<string>) {
|
const data = await defHttp.post(
|
{
|
url: Api.QueryUrl,
|
params,
|
},
|
{
|
errorMessageMode: 'modal',
|
isTransformResponse: false,
|
},
|
);
|
return data.Data;
|
}
|
//查询货架中单个储位
|
export function getLocationByPage(params: string) {
|
let sqlcmd = '';
|
if (params != undefined && params != '') {
|
sqlcmd += " LOCATION_CODE = '" + params + "'";
|
}
|
const rmParams = genAction('WMS_LOCATION', sqlcmd);
|
return getLocation(rmParams);
|
}
|
async function getLocation(params: ApiAction<string>) {
|
const data = await defHttp.post<ApiAction<LocationListItem[]>>(
|
{
|
url: Api.EntityList,
|
params,
|
},
|
{
|
errorMessageMode: 'modal',
|
isTransformResponse: false,
|
},
|
);
|
return data.Data;
|
}
|
//查询检查储位是否有东西
|
export const CheckLocation = async (params: string) => {
|
const dParams = { ID: params, Type: 'shelf' };
|
return await defHttp.post(
|
{ url: Api.CheckLocation, params: dParams },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
},
|
);
|
};
|
|
/*
|
* 删除仓库
|
*/
|
export const DeleteWareHouse = async (params: Recordable) => {
|
const dParams = { ID: params.id.slice(1), Type: params.houseType };
|
return await defHttp.post(
|
{ url: Api.DeleteWareHouse, params: dParams },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
},
|
);
|
};
|
|
//下拉列表
|
export const optionsListApi = async (params: Recordable) => {
|
const usParams = genAction('WMS_SHELF+SHELF_TYPEs', '');
|
return await defHttp.post(
|
{ url: Api.urlQueryEnum, params: usParams },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
},
|
);
|
};
|