import { buildUUID } from '../../../utils/uuid';
|
import { ApiAction, ApiActionPage } from '../../model/baseModel';
|
import {
|
MesWolistPageParams,
|
BIZ_MES_WOPageListGetResultModel,
|
BIZ_MES_WO,
|
SaveWoBatchInput,
|
BizMesWoInput,
|
} from '../model/mesModel';
|
import { genAction, Api, genActionPage } from '../system';
|
import { defHttp } from '/@/utils/http/axios';
|
import { useUserStore } from '../../../store/modules/user';
|
import { isNullOrEmpty } from '/@/utils/is';
|
import { mesApi } from './mesApi';
|
|
/*
|
* 获取工单分页列表
|
*/
|
export const getWoListByPage = async (params: MesWolistPageParams) => {
|
let sqlcmd = '';
|
if (!isNullOrEmpty(params?.ORDER_NO)) {
|
sqlcmd += `And ORDER_NO like '%${params?.ORDER_NO}%'`;
|
}
|
if (!isNullOrEmpty(params?.ITEM_CODE)) {
|
sqlcmd += `And ITEM_CODE like '${params?.ITEM_CODE}%'`;
|
}
|
if (!isNullOrEmpty(params?.STATUS)) {
|
sqlcmd += `And STATUS = '${params?.STATUS}'`;
|
}
|
if (!isNullOrEmpty(params?.ORDER_TYPE)) {
|
sqlcmd += `And ORDER_TYPE = '${params?.ORDER_TYPE}'`;
|
}
|
const rParams = genActionPage('BIZ_MES_WO', sqlcmd, params.page, params.pageSize);
|
return getWoListByPageAsync(rParams);
|
};
|
async function getWoListByPageAsync(params: ApiActionPage) {
|
const data = await defHttp.post<ApiActionPage>(
|
{ url: Api.EntityPageList, params },
|
{
|
isTransformResponse: false,
|
},
|
);
|
const model: BIZ_MES_WOPageListGetResultModel = {
|
items: data.Data.data,
|
total: data.Data.totals,
|
};
|
return model;
|
}
|
|
/**
|
* @description: 保存工单普通方法
|
* @param {BIZ_MES_WO} params
|
* @return {*}
|
*/
|
export const SaveMesWo = async (params: BIZ_MES_WO) => {
|
params.CREATE_USER = useUserStore().getUserInfo.userId as string;
|
params.UPDATE_USER = useUserStore().getUserInfo.userId as string;
|
const data = await defHttp.post(
|
{ url: mesApi.SaveMesWo, params: genAction('BIZ_MES_WO', params) },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
},
|
);
|
return data;
|
};
|
|
/**
|
* @description: 下发保存批次工单信息
|
* @param {SaveWoBatchInput} params
|
* @return {*}
|
*/
|
export const SaveMesBatchWo = async (params: SaveWoBatchInput) => {
|
params.Wo.UPDATE_USER = useUserStore().getUserInfo.userId as string;
|
params.WoBatch.CREATE_USER = useUserStore().getUserInfo.userId as string;
|
params.WoBatch.UPDATE_USER = useUserStore().getUserInfo.userId as string;
|
const data = await defHttp.post(
|
{ url: mesApi.SaveMesBatchWo, params: genAction('BIZ_MES_WO_BATCH', params) },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
},
|
);
|
return data;
|
};
|
|
/**
|
* @description: 工单状态更新
|
* @param {BizMesWoInput} params
|
* @return {*}
|
*/
|
export const UpdateWoStatus = async (params: BizMesWoInput) => {
|
const data = await defHttp.post(
|
{ url: mesApi.UpdateWoStatus, params: genAction('', params) },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
},
|
);
|
return data;
|
};
|
|
/*
|
* 删除工单
|
*/
|
export const DeleteMesWo = async (params: string) => {
|
const usParams = genAction('BIZ_MES_WO', params);
|
return await defHttp.post(
|
{ url: mesApi.DeleteMesWo, params: usParams },
|
{
|
errorMessageMode: 'none',
|
isTransformResponse: false,
|
},
|
);
|
};
|