import { buildUUID } from '../../../utils/uuid';
|
import { ApiAction, ApiActionPage } from '../../model/baseModel';
|
import {
|
PurchaseListItem,
|
PurchasePageListGetResultModel,
|
PurchasePageDetailListGetResultModel,
|
PurchasePageParams,
|
PurchasePageDetailParams
|
} from '../model/warehoueseModel';
|
import { genAction, Api, genActionPage } from '../system';
|
import { useUserStore } from '/@/store/modules/user';
|
import { defHttp } from '/@/utils/http/axios';
|
import { isNullOrEmpty } from '/@/utils/is';
|
|
/*
|
* 获取采购单分页列表
|
*/
|
export const getPurchaseListByPage = async (params: PurchasePageParams) => {
|
let order = ''
|
if (params.order != undefined) {
|
order = params.order == 'descend' ? (params.field + ' desc') : params.field
|
}
|
let sqlcmd = '1=1';
|
if (params?.BILLCODE != undefined && params?.BILLCODE != '') {
|
sqlcmd += " And BILLCODE like '%" + params?.BILLCODE + "%'";
|
}
|
if (params?.BILLDATE != undefined && params?.BILLDATE != '') {
|
sqlcmd += " And BILLDATE > '" + params?.BILLDATE[0] + "'";
|
}
|
if (params?.BILLDATE != undefined && params?.BILLDATE != '') {
|
sqlcmd += " And BILLDATE < '" + params?.BILLDATE[1] + "'";
|
}
|
if (params?.STATUS != undefined && params?.STATUS != '') {
|
sqlcmd += " And STATUS = '" + params?.STATUS + "'";
|
}
|
if (params?.BIZTYPE != undefined && params?.BIZTYPE != '') {
|
sqlcmd += " And BIZTYPE = '" + params?.BIZTYPE + "'";
|
}
|
var option ={
|
UserId:useUserStore().getUserInfo.userId as string,
|
ByOrg:true,
|
OrgCode:useUserStore().getUserInfo.orgCode as string
|
}
|
// if (params?.BILLDATE != undefined && params?.BILLDATE != '') {
|
// sqlcmd += "And BILLDATE like '%" + params?.BILLDATE + "%'";
|
// }
|
const usParams = genAction('BIZ_ERP_PO', {
|
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 getPurchaseListByPageAsync(usParams);
|
};
|
async function getPurchaseListByPageAsync(params: any) {
|
const data = await defHttp.post(
|
{ url: Api.QueryUrl, params },
|
{
|
isTransformResponse: false,
|
},
|
);
|
const model = {
|
items: data.Data.page.data,
|
total: data.Data.page.totals,
|
};
|
return model;
|
}
|
/*
|
* 获取采购单明细分页列表
|
*/
|
export const getPurchaseDetailListByPage = async (params: PurchasePageDetailParams) => {
|
let order = ''
|
if (params.order != undefined) {
|
order = params.order == 'descend' ? (params.field + ' desc') : params.field
|
}
|
let sqlcmd = '1=1';
|
if (params?.BILLCODE != undefined && params?.BILLCODE != '') {
|
sqlcmd += " And BILLCODE like '%" + params?.BILLCODE + "%'";
|
}
|
if (!isNullOrEmpty(params?.LINESTATUS)) {
|
sqlcmd += " And LINESTATUS = '" + params?.LINESTATUS + "'";
|
}
|
if (params?.MATERIALCODE != undefined && params?.MATERIALCODE != '') {
|
sqlcmd += " And MATERIALCODE = '" + params?.MATERIALCODE + "'";
|
}
|
var option ={
|
UserId:useUserStore().getUserInfo.userId as string,
|
ByOrg:true,
|
OrgCode:useUserStore().getUserInfo.orgCode as string
|
}
|
// if (params?.BILLDATE != undefined && params?.BILLDATE != '') {
|
// sqlcmd += "And BILLDATE like '%" + params?.BILLDATE + "%'";
|
// }
|
if (!isNullOrEmpty(params.page)) {
|
const usParams = genAction('BIZ_ERP_PO_DTL', {
|
QueryAble_T: '',
|
where: sqlcmd,
|
order: 'BILLLINE*1 '+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 getPurchaseDetailListByPageAsync(usParams);
|
} else {
|
const usParams = genAction('BIZ_ERP_PO_DTL', {
|
QueryAble_T: '',
|
where: sqlcmd,
|
order: 'BILLLINE*1',
|
option
|
},option);
|
//const rParams = genActionPage('V_BIZ_ERP_OTH_OUT_DTL', sqlcmd, params.page, params.pageSize,option);
|
return getPurchaseDetailListByPageAsync(usParams);
|
}
|
};
|
async function getPurchaseDetailListByPageAsync(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;
|
}
|
|
//下拉列表
|
// STATUSs 单据状态
|
// BIZTYPEs 单据类型
|
export const optionsListApi = async (params: Recordable) => {
|
const usParams = genAction('BIZ_ERP_PO+STATUSs', '');
|
return await defHttp.post(
|
{ url: Api.urlQueryEnum, params: usParams },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
// apiUrl: globSetting.taskApiUrl
|
},
|
);
|
};
|
export const optionTypeListApi = async (params: Recordable) => {
|
const usParams = genAction('BIZ_ERP_PO+BIZTYPEs', '');
|
return await defHttp.post(
|
{ url: Api.urlQueryEnum, params: usParams },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
// apiUrl: globSetting.taskApiUrl
|
},
|
);
|
};
|