import { buildUUID } from '../../../../utils/uuid';
|
//import { ApiAction, ApiActionPage } from '../../model/baseModel';
|
import { genAction, Api } from '../../system';
|
import { useUserStore } from '/@/store/modules/user';
|
import { defHttp } from '/@/utils/http/axios';
|
import { isNullOrEmpty } from '/@/utils/is';
|
import { formatToDateTime } from '/@/utils/dateUtil';
|
|
/*
|
* 获取飞达信息
|
*/
|
|
export const getListByPage = async (params: any) => {
|
let order = ''
|
if (params.order != undefined) {
|
order = params.order == 'descend' ? (params.field + ' desc') : params.field
|
}
|
let sqlcmd = '1=1';
|
if (params?.TOOL_CODE != undefined && params?.TOOL_CODE != '') {
|
sqlcmd += " And TOOL_CODE like '%" + params?.TOOL_CODE + "%'";
|
}
|
|
let option = {
|
UserId: useUserStore().getUserInfo.userId as string,
|
ByOrg: true,
|
OrgCode: useUserStore().getUserInfo.orgCode as string
|
}
|
if (!isNullOrEmpty(params.page)) {
|
const usParams = genAction('SMT_MAINTAIN', {
|
QueryAble_T: '',
|
where: sqlcmd,
|
order: order,
|
page: {
|
pageAble_T: 'string',
|
draw: 1,
|
pageIndex: params.page,
|
pageSize: params.pageSize,
|
}
|
});
|
return getListByPageAsync(usParams);
|
} else {
|
const usParams = genAction('SMT_MAINTAIN', {
|
QueryAble_T: '',
|
where: sqlcmd
|
});
|
return getListByPageAsync(usParams);
|
}
|
// const rParams = genActionPage('BIZ_ERP_PROD_IN', sqlcmd, params.page, params.pageSize,option);
|
// return getFinishedwarehouseListByPageAsync(rParams);
|
};
|
async function getListByPageAsync(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;
|
}
|
//新增飞达信息
|
export const Save = async (params: Recordable, isUpdate: boolean, isbaofei: boolean) => {
|
const item: any = {
|
ID: params.ID,
|
CREATE_TIME: params?.CREATE_TIME,
|
CREATE_USER: params?.CREATE_USER,
|
UPDATE_TIME: params?.UPDATE_TIME,
|
UPDATE_USER: params?.UPDATE_USER,
|
GHOST_ROW: params?.GHOST_ROW,
|
AUTH_ORG: params?.AUTH_ORG,
|
AUTH_PROD: params?.AUTH_PROD,
|
AUTH_WH: params?.AUTH_WH,
|
TOOL_CODE: params?.TOOL_CODE,
|
PROJ_CODE: params?.PROJ_CODE,
|
RESULT: params?.RESULT,
|
REMARK: params?.REMARK,
|
};
|
let data;
|
|
if (isUpdate) {
|
if (isbaofei) {
|
item.STATUS = 5;
|
}
|
const time = new Date();
|
item.UPDATE_TIME = formatToDateTime(time);
|
item.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('SMT_MAINTAIN', item) },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
},
|
);
|
} else {
|
// const usParams = genAction(
|
// 'SMT_SOLDER',
|
// "REGION_CODE='" + params.REGION_CODE + "'AND AUTH_ORG='" + regionitem.ORG_CODE + "'",
|
// );
|
//var check = await isExist(usParams);
|
//console.log('check',check)
|
//if (!check.Data) {
|
item.ID = buildUUID(); //生成GUID
|
item.UPDATE_TIME = formatToDateTime(new Date());
|
item.CREATE_USER = useUserStore().getUserInfo.userId as string;
|
item.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('SMT_MAINTAIN', item) },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
},
|
);
|
//} else {
|
// return check.Message;
|
//return '重复了';
|
//}
|
}
|
return data;
|
};
|
//删除
|
export const Delete = async (Tool_Id: string) => {
|
const usParams = genAction('SMT_MAINTAIN', `ID='${Tool_Id}'`)
|
return await defHttp.post(
|
{ url: Api.DeleteWhere, params: usParams },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false
|
}
|
)
|
}
|
|
//单据详情
|
export const getDetailListByPage = async (params: any) => {
|
let order = ''
|
if (params.order != undefined) {
|
order = params.order == 'descend' ? (params.field + ' desc') : params.field
|
}
|
let sqlcmd = '1=1';
|
if (params?.ID != undefined && params?.ID != '') {
|
sqlcmd += " And MT_ID like '%" + params?.ID + "%'";
|
}
|
if (params?.TOOL_CODE != undefined && params?.TOOL_CODE != '') {
|
sqlcmd += " And TOOL_CODE like '%" + params?.TOOL_CODE + "%'";
|
}
|
// if (params?.OUTWAREHOUSECODE != undefined && params?.OUTWAREHOUSECODE != '') {
|
// sqlcmd += " And OUTWAREHOUSECODE = '" + params?.OUTWAREHOUSECODE + "'";
|
// }
|
// if (params?.INWAREHOUSECODE != undefined && params?.INWAREHOUSECODE != '') {
|
// sqlcmd += " And INWAREHOUSECODE = '" + params?.INWAREHOUSECODE + "'";
|
// }
|
// if (!isNullOrEmpty(params?.LINESTATUS)) {
|
// sqlcmd += " And LINESTATUS = '" + params?.LINESTATUS + "'";
|
// }
|
var option ={
|
UserId:useUserStore().getUserInfo.userId as string,
|
ByOrg:true,
|
OrgCode:useUserStore().getUserInfo.orgCode as string
|
}
|
// const rParams = genActionPage('BIZ_WMS_TRANSFER_DTL', sqlcmd, params.page, params.pageSize,option);
|
|
if(!isNullOrEmpty(params.page)){
|
const usParams = genAction('SMT_MT_DTL', {
|
QueryAble_T: '',
|
where: sqlcmd,
|
page: {
|
pageAble_T: 'string',
|
draw: 1,
|
pageIndex: params.page,
|
pageSize: params.pageSize,
|
}
|
});
|
return getDetailListByPageAsync(usParams);
|
}else{
|
const usParams = genAction('SMT_MT_DTL', {
|
QueryAble_T: '',
|
where: sqlcmd,
|
});
|
return getDetailListByPageAsync(usParams);
|
}
|
};
|
async function getDetailListByPageAsync(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 单据状态
|
export const optionsListApi = async (params: Recordable) => {
|
const usParams = genAction('SMT_MAINTAIN+RESULTs', '');
|
return await defHttp.post(
|
{ url: Api.urlQueryEnum, params: usParams },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
// apiUrl: globSetting.taskApiUrl
|
},
|
);
|
};
|
//类型
|
export const optionsListApiType = async (params: Recordable) => {
|
const usParams = genAction('V_SMT_TOOL+TYPEs', '');
|
return await defHttp.post(
|
{ url: Api.urlQueryEnum, params: usParams },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
// apiUrl: globSetting.taskApiUrl
|
},
|
);
|
};
|