2026-05-07 17:53:48 +08:00
|
|
|
|
import { defHttp } from '/@/utils/http/axios';
|
|
|
|
|
|
import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
|
|
|
|
|
|
|
|
|
const { createConfirm } = useMessage();
|
|
|
|
|
|
|
|
|
|
|
|
enum Api {
|
|
|
|
|
|
list = '/xslmes/mesXslRawMaterialEntry/list',
|
|
|
|
|
|
save = '/xslmes/mesXslRawMaterialEntry/add',
|
|
|
|
|
|
edit = '/xslmes/mesXslRawMaterialEntry/edit',
|
|
|
|
|
|
deleteOne = '/xslmes/mesXslRawMaterialEntry/delete',
|
|
|
|
|
|
deleteBatch = '/xslmes/mesXslRawMaterialEntry/deleteBatch',
|
2026-05-12 14:06:07 +08:00
|
|
|
|
batchStockIn = '/xslmes/mesXslRawMaterialEntry/batchStockIn',
|
2026-05-07 17:53:48 +08:00
|
|
|
|
importExcel = '/xslmes/mesXslRawMaterialEntry/importExcel',
|
|
|
|
|
|
exportXls = '/xslmes/mesXslRawMaterialEntry/exportXls',
|
2026-05-13 17:25:13 +08:00
|
|
|
|
queryPrinters = '/xslmes/mesXslRawMaterialEntry/queryPrinters',
|
|
|
|
|
|
prepareNativePrint = '/xslmes/mesXslRawMaterialEntry/prepareNativePrint',
|
|
|
|
|
|
printPdf = '/xslmes/mesXslRawMaterialEntry/printPdf',
|
2026-05-07 17:53:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export const getExportUrl = Api.exportXls;
|
|
|
|
|
|
export const getImportUrl = Api.importExcel;
|
|
|
|
|
|
|
|
|
|
|
|
export const list = (params) => defHttp.get({ url: Api.list, params });
|
|
|
|
|
|
|
|
|
|
|
|
export const deleteOne = (params, handleSuccess) => {
|
|
|
|
|
|
return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
|
|
|
|
|
|
handleSuccess();
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export const batchDelete = (params, handleSuccess) => {
|
|
|
|
|
|
createConfirm({
|
|
|
|
|
|
iconType: 'warning',
|
|
|
|
|
|
title: '确认删除',
|
|
|
|
|
|
content: '是否删除选中数据',
|
|
|
|
|
|
okText: '确认',
|
|
|
|
|
|
cancelText: '取消',
|
|
|
|
|
|
onOk: () => {
|
|
|
|
|
|
return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
|
|
|
|
|
|
handleSuccess();
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-05-12 14:06:07 +08:00
|
|
|
|
export const batchStockIn = (ids: string) =>
|
|
|
|
|
|
defHttp.put({ url: Api.batchStockIn, params: { ids } }, { joinParamsToUrl: true });
|
|
|
|
|
|
|
2026-05-07 17:53:48 +08:00
|
|
|
|
export const saveOrUpdate = (params, isUpdate) => {
|
|
|
|
|
|
let url = isUpdate ? Api.edit : Api.save;
|
|
|
|
|
|
return defHttp.post({ url: url, params });
|
|
|
|
|
|
};
|
2026-05-13 17:25:13 +08:00
|
|
|
|
|
|
|
|
|
|
export const queryPrinters = () => defHttp.get({ url: Api.queryPrinters });
|
|
|
|
|
|
|
|
|
|
|
|
export const prepareNativePrint = (id: string) =>
|
|
|
|
|
|
defHttp.get({
|
|
|
|
|
|
url: Api.prepareNativePrint,
|
|
|
|
|
|
params: { id, _t: Date.now() },
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
/** id + 前端生成的 pdfBase64;printerName 空则用默认队列 */
|
|
|
|
|
|
export const printPdf = (data: { id: string; printerName?: string; pdfBase64: string; fileName?: string }) =>
|
|
|
|
|
|
defHttp.post({ url: Api.printPdf, data, timeout: 3 * 60 * 1000 });
|