import { buildUUID } from '../../../utils/uuid';
|
import { ApiAction, ApiActionPage } from '../../model/baseModel';
|
import {
|
InventoryListItem,
|
InventoryPageListGetResultModel,
|
InventoryPageParams,
|
iV_ITEM_COUNT,
|
iWMS_COUNT_LDTL,
|
iWMS_COUNT_MDTL,
|
iWMS_COUNT_SUM,
|
WhPageListGetResultModel,
|
HouseListItem
|
} from '../model/warehoueseModel';
|
import { genAction, Api, genActionPage, isExist } from '../system';
|
import { defHttp } from '/@/utils/http/axios';
|
import { useUserStore } from '/@/store/modules/user';
|
import { isNullOrEmpty } from '/@/utils/is';
|
//仓库结构树状下拉
|
export const getTreeList = async (params: HouseListItem) => {
|
params.AUTH_ORG = useUserStore().getUserInfo.orgCode as string
|
const data = await defHttp.post<WhPageListGetResultModel>(
|
{ url: Api.GetHouseOrgTreeList, params },
|
{
|
isTransformResponse: false,
|
},
|
);
|
return data
|
}
|
//生成盘点单单据
|
export const CreateBillCode = async () => {
|
const data = await defHttp.get<any>(
|
{ url: Api.GetCreateBillCode },
|
{
|
isTransformResponse: false,
|
},
|
);
|
return data.Data
|
}
|
/*
|
* 获取盘点分页列表
|
*/
|
export const getInventoryListByPage = async (params: InventoryPageParams) => {
|
// var org=useUserStore().getUserInfo.orgCode as string;
|
// let sqlcmd = "AND AUTH_ORG like '" + org + "'";
|
let order = ''
|
if (params.order != undefined) {
|
order = params.order == 'descend' ? (params.field + ' desc') : params.field
|
}
|
let sqlcmd = '1=1';
|
if (params?.COUNT_NO != undefined && params?.COUNT_NO != '') {
|
sqlcmd += " And COUNT_NO = '" + params?.COUNT_NO + "'";
|
}
|
// 按镜像时间
|
if (params?.MIRROR_DATE != undefined && params?.MIRROR_DATE != '') {
|
sqlcmd += " And MIRROR_DATE > '" + params?.MIRROR_DATE[0] + "'";
|
}
|
if (params?.MIRROR_DATE != undefined && params?.MIRROR_DATE != '') {
|
sqlcmd += " And MIRROR_DATE < '" + params?.MIRROR_DATE[1] + "'";
|
}
|
if (params?.STATUS != undefined && params?.STATUS != '') {
|
sqlcmd += " And STATUS = '" + params?.STATUS + "'";
|
}
|
if (params?.COUNT_TYPE != undefined && params?.COUNT_TYPE != '') {
|
sqlcmd += " And COUNT_TYPE = '" + params?.COUNT_TYPE + "'";
|
}
|
if (params?.COUNT_MODE != undefined && params?.COUNT_MODE != '') {
|
sqlcmd += " And COUNT_MODE = '" + params?.COUNT_MODE + "'";
|
}
|
// if (params?.AUTH_ORG != undefined && params?.AUTH_ORG != '') {
|
// sqlcmd += "And AUTH_ORG like '%" + params?.AUTH_ORG + "%'";
|
// }
|
var option = {
|
UserId: useUserStore().getUserInfo.userId as string,
|
ByOrg: true,
|
OrgCode: useUserStore().getUserInfo.orgCode as string
|
}
|
//const rParams = genActionPage('WMS_COUNT', sqlcmd, params.page, params.pageSize,option);
|
const usParams = genAction('WMS_COUNT', {
|
QueryAble_T: '',
|
where: sqlcmd,
|
order: isNullOrEmpty(order)?'MIRROR_DATE desc':'MIRROR_DATE, '+order,
|
page: {
|
pageAble_T: 'string',
|
draw: 1,
|
pageIndex: params.page,
|
pageSize: params.pageSize,
|
},
|
option
|
},option);
|
return getWmsItemListByPageAsync(usParams);
|
};
|
async function getWmsItemListByPageAsync(params: any) {
|
const data = await defHttp.post(
|
{ url: Api.QueryUrl, params },
|
{
|
isTransformResponse: false,
|
},
|
);
|
const model: any = {
|
// items: data.Data.data,
|
// total: data.Data.totals,
|
items: data.Data.page.data,
|
total: data.Data.page.totals,
|
};
|
return model;
|
}
|
//查询单个盘点单
|
export const getInventorytByPage = async (params: string) => {
|
const rmParams = genAction('WMS_COUNT', { QueryAble_T: "", where: "ID = '" + params + "'" });
|
return getInventoryByPageAsync(rmParams);
|
};
|
async function getInventoryByPageAsync(params: ApiAction<string>) {
|
const data = await defHttp.post<ApiAction<InventoryListItem[]>>(
|
{
|
url: Api.QueryUrl,
|
params,
|
},
|
{
|
errorMessageMode: 'modal',
|
isTransformResponse: false,
|
},
|
);
|
return data.Data.Items;
|
}
|
//获取物料列表
|
export const getItemListByPage = async (params: any) => {
|
let sqlcmd = ''
|
if (params?.ITEM_CODE != undefined && params?.ITEM_CODE != '') {
|
sqlcmd += " And ITEM_CODE like '%" + params?.ITEM_CODE + "%'";
|
}
|
const rParams = genActionPage('BAS_ITEM', sqlcmd, params.page, params.pageSize);
|
return getItemListByPageAsync(rParams);
|
}
|
async function getItemListByPageAsync(params: ApiActionPage) {
|
const data = await defHttp.post<ApiActionPage>(
|
{ url: Api.EntityPageList, params },
|
{
|
isTransformResponse: false,
|
},
|
);
|
const model: InventoryPageListGetResultModel = {
|
items: data.Data.data,
|
total: data.Data.totals,
|
};
|
return model;
|
}
|
//获取物品明细
|
export function getMdtlListByPage(params: any) {
|
let order = ''
|
if (params.order != undefined) {
|
order = params.order == 'descend' ? (params.field + ' desc') : params.field
|
}
|
undefined
|
if (params.ITEM_CODE != undefined || params.RESULT != undefined || params.STATUS != undefined) {
|
var sql = "COUNT_NO='" + params.COUNT_NO + "'";
|
if (params.ITEM_CODE != undefined) {
|
sql += "and ITEM_CODE like '%" + params.ITEM_CODE + "%'";
|
}
|
if (params.RESULT != undefined) {
|
sql += "and RESULT='" + params.RESULT + "'";
|
}
|
if (params.STATUS != undefined) {
|
sql += "and STATUS='" + params.STATUS + "'";
|
}
|
const rmParams = genAction('V_WMS_COUNT_MDTL', {
|
QueryAble_T: "",
|
where: sql,
|
order: order,
|
page: {
|
pageAble_T: 'string',
|
draw: 1,
|
pageIndex: params.page,
|
pageSize: params.pageSize,
|
},
|
});
|
return getMdtlListByPageAsync(rmParams);
|
} else {
|
//params = params?.COUNT_NO == undefined ? params : params.COUNT_NO
|
const rmParams = genAction('V_WMS_COUNT_MDTL', {
|
QueryAble_T: "", where: "COUNT_NO = '" + params?.COUNT_NO + "'", order:order,page: {
|
pageAble_T: 'string',
|
draw: 1,
|
pageIndex: params.page,
|
pageSize: params.pageSize,
|
},
|
});
|
return getMdtlListByPageAsync(rmParams);
|
}
|
|
}
|
async function getMdtlListByPageAsync(params: any) {
|
const data = await defHttp.post(
|
{
|
url: Api.QueryUrl,
|
params,
|
},
|
{
|
errorMessageMode: 'modal',
|
isTransformResponse: false,
|
},
|
);
|
const model = {
|
items: data.Data.page.data,
|
total: data.Data.page.totals,
|
};
|
return model;
|
}
|
//获取物品明细导出
|
export function getMdtlListByPageOut(params: any) {
|
if (params.ITEM_CODE != undefined || params.RESULT != undefined || params.STATUS != undefined) {
|
var sql = "COUNT_NO='" + params.COUNT_NO + "'";
|
if (params.ITEM_CODE != undefined) {
|
sql += "and ITEM_CODE like '%" + params.ITEM_CODE + "%'";
|
}
|
if (params.RESULT != undefined) {
|
sql += "and RESULT='" + params.RESULT + "'";
|
}
|
if (params.STATUS != undefined) {
|
sql += "and STATUS='" + params.STATUS + "'";
|
}
|
const rmParams = genAction('V_WMS_COUNT_MDTL', {
|
QueryAble_T: "",
|
where: sql
|
// where: "COUNT_NO = '" + params.COUNT_NO+
|
// params.ITEM_CODE==undefined?'':"and ITEM_CODE = '" + params.ITEM_CODE+
|
// params.RESULT==undefined?'':"and RESULT=" + params.RESULT+
|
// params.STATUS==undefined?'':"and STATUS=" + params.STATUS
|
});
|
return getMdtlListByPageAsyncOut(rmParams);
|
} else {
|
params = params?.COUNT_NO == undefined ? params : params.COUNT_NO
|
const rmParams = genAction('V_WMS_COUNT_MDTL', { QueryAble_T: "", where: "COUNT_NO = '" + params + "'" });
|
return getMdtlListByPageAsyncOut(rmParams);
|
}
|
|
}
|
async function getMdtlListByPageAsyncOut(params: ApiAction<string>) {
|
const data = await defHttp.post<ApiAction<iWMS_COUNT_MDTL[]>>(
|
{
|
url: Api.QueryUrl,
|
params,
|
},
|
{
|
errorMessageMode: 'modal',
|
isTransformResponse: false,
|
},
|
);
|
return data.Data.Items;
|
}
|
//获取储位明细
|
export function getLdtlListByPage(params: string) {
|
if (params.ITEM_CODE != undefined || params.RESULT != undefined || params.STATUS != undefined) {
|
var sql = "COUNT_NO='" + params.COUNT_NO + "'";
|
if (params.ITEM_CODE != undefined) {
|
sql += "and ITEM_CODE like '%" + params.ITEM_CODE + "%'";
|
}
|
if (params.RESULT != undefined) {
|
sql += "and RESULT='" + params.RESULT + "'";
|
}
|
if (params.STATUS != undefined) {
|
sql += "and STATUS='" + params.STATUS + "'";
|
}
|
const rmParams = genAction('V_WMS_COUNT_LDTL', {
|
QueryAble_T: "",
|
where: sql
|
});
|
return getLdtlListByPageAsync(rmParams);
|
} else {
|
params = params?.COUNT_NO == undefined ? params : params.COUNT_NO
|
const rmParams = genAction('V_WMS_COUNT_LDTL', { QueryAble_T: "", where: "COUNT_NO = '" + params + "'" });
|
return getLdtlListByPageAsync(rmParams);
|
}
|
|
}
|
async function getLdtlListByPageAsync(params: ApiAction<string>) {
|
const data = await defHttp.post<ApiAction<iWMS_COUNT_LDTL[]>>(
|
{
|
url: Api.QueryUrl,
|
params,
|
},
|
{
|
errorMessageMode: 'modal',
|
isTransformResponse: false,
|
},
|
);
|
return data.Data.Items;
|
}
|
//获取汇总明细
|
export const getSumListByPage = async (params: any) => {
|
let order = ''
|
if (params.order != undefined) {
|
order = params.order == 'descend' ? (params.field + ' desc') : params.field
|
}
|
if (params.ITEM_CODE != undefined || params.RESULT != undefined) {
|
var sql = "COUNT_NO='" + params.COUNT_NO + "'";
|
if (params.ITEM_CODE != undefined) {
|
sql += " and ITEM_CODE like'%" + params.ITEM_CODE + "%'";
|
}
|
if (params.RESULT != undefined) {
|
sql += " and RESULT='" + params.RESULT + "'";
|
}
|
const rmParams = genAction('V_WMS_COUNT_SUM', {
|
QueryAble_T: "",
|
where: sql,
|
order:order,
|
page: {
|
pageAble_T: 'string',
|
draw: 1,
|
pageIndex: params.page,
|
pageSize: params.pageSize,
|
},
|
});
|
return getSumListByPageAsync(rmParams);
|
} else {
|
// params = params?.COUNT_NO == undefined ? params : params.COUNT_NO
|
const rmParams = genAction('V_WMS_COUNT_SUM', {
|
QueryAble_T: "", where: "COUNT_NO = '" + params?.COUNT_NO + "'", page: {
|
pageAble_T: 'string',
|
draw: 1,
|
pageIndex: params.page,
|
pageSize: params.pageSize,
|
},
|
});
|
return getSumListByPageAsync(rmParams);
|
}
|
|
}
|
async function getSumListByPageAsync(params: any) {
|
const data = await defHttp.post(
|
{
|
url: Api.QueryUrl,
|
params,
|
},
|
{
|
errorMessageMode: 'modal',
|
isTransformResponse: false,
|
},
|
);
|
const model = {
|
items: data.Data.page.data,
|
total: data.Data.page.totals,
|
};
|
return model;
|
}
|
//获取汇总明细导出
|
export function getSumListByPageOut(params: any) {
|
if (params.ITEM_CODE != undefined || params.RESULT != undefined) {
|
var sql = "COUNT_NO='" + params.COUNT_NO + "'";
|
if (params.ITEM_CODE != undefined) {
|
sql += "and ITEM_CODE like'%" + params.ITEM_CODE + "%'";
|
}
|
if (params.RESULT != undefined) {
|
sql += "and RESULT='" + params.RESULT + "'";
|
}
|
const rmParams = genAction('V_WMS_COUNT_SUM', {
|
QueryAble_T: "",
|
where: sql
|
});
|
return getSumListByPageAsyncOut(rmParams);
|
} else {
|
params = params?.COUNT_NO == undefined ? params : params.COUNT_NO
|
const rmParams = genAction('V_WMS_COUNT_SUM', { QueryAble_T: "", where: "COUNT_NO = '" + params + "'" });
|
return getSumListByPageAsyncOut(rmParams);
|
}
|
|
}
|
async function getSumListByPageAsyncOut(params: any) {
|
const data = await defHttp.post(
|
{
|
url: Api.QueryUrl,
|
params,
|
},
|
{
|
errorMessageMode: 'modal',
|
isTransformResponse: false,
|
},
|
);
|
return data.Data.Items;
|
}
|
|
export const SaveInventory = async (params: any, isUpdate: boolean) => {
|
let data;
|
const CountItem: InventoryListItem = {
|
ID: params.ID,
|
//SEQ_NO: params.SEQ_NO,
|
CREATE_USER: params.CREATE_USER,
|
MIRROR_DATE: params.MIRROR_DATE,
|
CREATE_TIME: params.CREATE_TIME,
|
COUNT_NO: params.COUNT_NO,
|
STATUS: params?.STATUS,
|
COUNT_TYPE: params.COUNT_TYPE,
|
COUNT_MODE: params.COUNT_MODE,
|
WH_IDS: params.WH_IDS,
|
REGION_IDS: params.REGION_IDS,
|
SHELF_IDS: params.SHELF_IDS,
|
LOCATION_IDS: params.LOCATION_IDS,
|
ITEM_CODE_LIST: params.ITEM_CODE_LIST,
|
AUTH_ORG: params.AUTH_ORE,
|
BEGIN_DATE: params.BEGIN_DATE,
|
END_DATE: params.END_DATE
|
};
|
const usParams = genAction('WMS_COUNT', "COUNT_NO='" + params.COUNT_NO + "'");
|
var check = await isExist(usParams);
|
if (check.Data || isUpdate) {
|
//CountItem.CREATE_USER = useUserStore().getUserInfo.userId as string;
|
CountItem.UPDATE_USER = useUserStore().getUserInfo.userId as string;
|
CountItem.ORG_CODE = useUserStore().getUserInfo.orgCode as string;
|
CountItem.AUTH_ORG = useUserStore().getUserInfo.orgCode as string;
|
data = await defHttp.post(
|
{ url: Api.UpdateEntity, params: genAction('WMS_COUNT', CountItem) },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
},
|
);
|
} else {
|
CountItem.ID = buildUUID(); //生成GUID
|
CountItem.CREATE_USER = useUserStore().getUserInfo.userId as string;
|
CountItem.UPDATE_USER = useUserStore().getUserInfo.userId as string;
|
CountItem.ORG_CODE = useUserStore().getUserInfo.orgCode as string;
|
CountItem.AUTH_ORG = useUserStore().getUserInfo.orgCode as string;
|
data = await defHttp.post(
|
{ url: Api.AddEntity, params: genAction('WMS_COUNT', CountItem) },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
},
|
);
|
}
|
return data;
|
};
|
//汇总盘点
|
export const SummaryCount = async (params: any) => {
|
//const rmParams = genAction('WMS_LOCATION', { QueryAble_T:"", where: "SHELF_CODE = '" + params + "'", order:'FLOOR_NO desc, SEQ_NO'});
|
params.AUTH_ORG = useUserStore().getUserInfo.orgCode as string
|
return getSummaryCountList(params);
|
}
|
async function getSummaryCountList(params: any) {
|
const data = await defHttp.post<ApiAction<iV_ITEM_COUNT[]>>(
|
{
|
url: Api.SummaryCount,
|
params: params,
|
},
|
{
|
errorMessageMode: 'modal',
|
isTransformResponse: false,
|
},
|
);
|
return data.Data;
|
}
|
//生成盘点
|
export const GenerateCount = async (params: any) => {
|
//const rmParams = genAction('WMS_LOCATION', { QueryAble_T:"", where: "SHELF_CODE = '" + params + "'", order:'FLOOR_NO desc, SEQ_NO'});
|
params.CREATE_USER = useUserStore().getUserInfo.userId as string;
|
params.ORG_CODE = useUserStore().getUserInfo.orgCode as string;
|
params.AUTH_ORG = useUserStore().getUserInfo.orgCode as string;
|
return getGenerateCountList(params);
|
}
|
async function getGenerateCountList(params: any) {
|
const data = await defHttp.post(
|
{
|
url: Api.GenerateCount,
|
params: params,
|
timeout: 30 * 60 * 1000
|
},
|
{
|
errorMessageMode: 'modal',
|
isTransformResponse: false,
|
},
|
);
|
return data;
|
}
|
|
export const DeleteInventory = async (params: Recordable) => {
|
const usParams = genAction('Minsun.WMS_STORAGEINVENTORY_H', [params]);
|
return await defHttp.post(
|
{ url: Api.DeleteList, params: usParams },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
},
|
);
|
};
|
// 下拉
|
//状态
|
export const optionsListApi = async (params: Recordable) => {
|
const usParams = genAction('WMS_COUNT+STATUSs', "");
|
return await defHttp.post(
|
{ url: Api.urlQueryEnum, params: usParams },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
//apiUrl: globSetting.taskApiUrl
|
},
|
);
|
};
|
//盘点类型
|
export const optionsListApi2 = async (params: Recordable) => {
|
const usParams = genAction('WMS_COUNT+COUNT_TYPEs', "");
|
return await defHttp.post(
|
{ url: Api.urlQueryEnum, params: usParams },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
//apiUrl: globSetting.taskApiUrl
|
},
|
);
|
};
|
//盘点模式
|
export const optionsListApi3 = async (params: Recordable) => {
|
const usParams = genAction('WMS_COUNT+COUNT_MODEs', "");
|
return await defHttp.post(
|
{ url: Api.urlQueryEnum, params: usParams },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
//apiUrl: globSetting.taskApiUrl
|
},
|
);
|
};
|
//物品状态
|
export const optionsListApiMdtlStatus = async (params: Recordable) => {
|
const usParams = genAction('WMS_COUNT_MDTL+STATUSs', "");
|
return await defHttp.post(
|
{ url: Api.urlQueryEnum, params: usParams },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
//apiUrl: globSetting.taskApiUrl
|
},
|
);
|
};
|
//物品结果
|
export const optionsListApiMdtlResult = async (params: Recordable) => {
|
const usParams = genAction('WMS_COUNT_MDTL+RESULTs', "");
|
return await defHttp.post(
|
{ url: Api.urlQueryEnum, params: usParams },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
//apiUrl: globSetting.taskApiUrl
|
},
|
);
|
};
|
//储位状态
|
export const optionsListApiLdtlStatus = async (params: Recordable) => {
|
const usParams = genAction('WMS_COUNT_LDTL+STATUSs', "");
|
return await defHttp.post(
|
{ url: Api.urlQueryEnum, params: usParams },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
//apiUrl: globSetting.taskApiUrl
|
},
|
);
|
};
|
//储位结果
|
export const optionsListApiLdtlResult = async (params: Recordable) => {
|
const usParams = genAction('WMS_COUNT_LDTL+RESULTs', "");
|
return await defHttp.post(
|
{ url: Api.urlQueryEnum, params: usParams },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
//apiUrl: globSetting.taskApiUrl
|
},
|
);
|
};
|
//汇总结果
|
export const optionsListApiSumResult = async (params: Recordable) => {
|
const usParams = genAction('WMS_COUNT_SUM+RESULTs', "");
|
return await defHttp.post(
|
{ url: Api.urlQueryEnum, params: usParams },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
//apiUrl: globSetting.taskApiUrl
|
},
|
);
|
};
|