import { buildUUID } from '../../../utils/uuid';
|
import { ApiActionPage } from '../../model/baseModel';
|
import { WmsItemPageListGetResultModel, WmsItemPageParams } from '../model/warehoueseModel';
|
import { Api, genAction, genActionPage } from '../system';
|
import { useUserStore } from '/@/store/modules/user';
|
import { defHttp } from '/@/utils/http/axios';
|
import { isNullOrEmpty } from '/@/utils/is';
|
|
/*
|
* 获取库位库存查询分页列表
|
*/
|
export const getWmsItemListByPage = async (params: any) => {
|
let order = '';
|
const option = {
|
UserId: useUserStore().getUserInfo.userId as string,
|
ByOrg: true,
|
OrgCode: useUserStore().getUserInfo.orgCode as string,
|
};
|
if (params.order != undefined) {
|
order = params.order == 'descend' ? params.field + ' desc' : params.field;
|
}
|
let sqlcmd = '1=1';
|
if (params?.WH_CODE != undefined && params?.WH_CODE != '') {
|
sqlcmd += " And WH_CODE = '" + params?.WH_CODE + "'";
|
if (option.OrgCode != undefined && option.OrgCode != '') {
|
sqlcmd += " And AUTH_ORG = '" + option.OrgCode + "'";
|
}
|
|
// const rParams = genActionPage('V_WMS_ITEM', sqlcmd, params.page, params.pageSize,option);
|
// return getWmsItemListByPageAsync(rParams);
|
if (!isNullOrEmpty(params.page)) {
|
const usParams = genAction(
|
'V_WH_ITEM_SUM',
|
{
|
QueryAble_T: '',
|
where: sqlcmd,
|
order: order,
|
page: {
|
pageAble_T: 'string',
|
draw: 1,
|
pageIndex: params.page,
|
pageSize: params.pageSize,
|
},
|
option,
|
},
|
option,
|
);
|
//const rParams = genActionPage('V_BIZ_ERP_OTH_OUT_DTL', sqlcmd, params.page, params.pageSize,option);
|
return getWmsItemListByPageAsync(usParams);
|
} else {
|
const usParams = genAction(
|
'V_WH_ITEM_SUM',
|
{
|
QueryAble_T: '',
|
where: sqlcmd,
|
option,
|
},
|
option,
|
);
|
//const rParams = genActionPage('V_BIZ_ERP_OTH_OUT_DTL', sqlcmd, params.page, params.pageSize,option);
|
return getWmsItemListByPageAsync(usParams);
|
}
|
}
|
|
};
|
async function getWmsItemListByPageAsync(params: any) {
|
const data = await defHttp.post(
|
{ url: Api.QueryUrl, params, timeout: 10000 * 30 },
|
{
|
isTransformResponse: false,
|
},
|
);
|
let model = {};
|
if (isNullOrEmpty(data.Data.page)) {
|
model = {
|
items: data.Data.Items,
|
};
|
} else {
|
model = {
|
items: data.Data.page.data,
|
total: data.Data.page.totals,
|
};
|
}
|
|
return model;
|
}
|
/*
|
* 获取库存汇总分页列表
|
*/
|
export const getWmsItemSumByPage = async (params: any) => {
|
let order = '';
|
if (params.order != undefined) {
|
order = params.order == 'descend' ? params.field + ' desc' : params.field;
|
}
|
let sqlcmd = '1=1';
|
if (params?.WH_CODE != undefined && params?.WH_CODE != '') {
|
sqlcmd += " And WH_CODE like '%" + params?.WH_CODE + "%'";
|
}
|
if (params?.ITEM_CODE != undefined && params?.ITEM_CODE != '') {
|
sqlcmd += " And ITEM_CODE like '%" + params?.ITEM_CODE + "%'";
|
}
|
const option = {
|
UserId: useUserStore().getUserInfo.userId as string,
|
ByOrg: true,
|
OrgCode: useUserStore().getUserInfo.orgCode as string,
|
};
|
if (!isNullOrEmpty(params.page)) {
|
const usParams = genAction(
|
'V_WMS_ITEM_SUM',
|
{
|
QueryAble_T: '',
|
where: sqlcmd,
|
order: order,
|
page: {
|
pageAble_T: 'string',
|
draw: 1,
|
pageIndex: params.page,
|
pageSize: params.pageSize,
|
},
|
option,
|
},
|
option,
|
);
|
return getWmsItemSumByPageAsync(usParams);
|
} else {
|
const usParams = genAction(
|
'V_WMS_ITEM_SUM',
|
{
|
QueryAble_T: '',
|
where: sqlcmd,
|
option,
|
},
|
option,
|
);
|
return getWmsItemSumByPageAsync(usParams);
|
}
|
// const rParams = genActionPage('V_WMS_ITEM_SUM', sqlcmd, params.page, params.pageSize,option);
|
// return getWmsItemSumByPageAsync(rParams);
|
};
|
async function getWmsItemSumByPageAsync(params: any) {
|
const data = await defHttp.post(
|
{ url: Api.QueryUrl, params },
|
{
|
isTransformResponse: false,
|
},
|
);
|
let model = {};
|
if (isNullOrEmpty(data.Data.page)) {
|
model = {
|
items: data.Data.Items,
|
};
|
} else {
|
model = {
|
items: data.Data.page.data,
|
total: data.Data.page.totals,
|
};
|
}
|
|
return model;
|
}
|