no message

main
HUOJIN\92525 2025-05-12 11:41:34 +08:00
parent efb8bc00f8
commit fb50787fcd
6 changed files with 52 additions and 40 deletions

View File

@ -5,7 +5,7 @@
* @Date: 2024-12-26 15:35:23 * @Date: 2024-12-26 15:35:23
* @Copyright * @Copyright
*/ */
import {postRequest, getRequest, getDownload2} from '/@/lib/axios'; import {postRequest, getRequest, postDownload2} from '/@/lib/axios';
export const addressApi = { export const addressApi = {
@ -59,20 +59,11 @@ export const addressApi = {
return postRequest('/address/importAddress', file); return postRequest('/address/importAddress', file);
}, },
createExportTask: () => {
return postRequest('/address/createExportTask', {});
},
getExportProgress: (taskId: string) => {
return getRequest(`/address/progress/${taskId}`, {});
},
/** /**
* @author hj * @author hj
*/ */
exportAddress: (taskId: string,signal?: AbortSignal) => { exportAddress: (taskId: string, param: any, signal?: AbortSignal) => {
return getDownload2(`/address/exportAddress/${taskId}`, {},signal); return postDownload2(`/address/exportAddress/${taskId}`, param, signal);
} }
}; };

View File

@ -5,7 +5,7 @@
* @Date: 2024-11-25 17:08:18 * @Date: 2024-11-25 17:08:18
* @Copyright * @Copyright
*/ */
import {postRequest, getRequest, getDownload2} from '/@/lib/axios'; import {postRequest, getRequest, postDownload2} from '/@/lib/axios';
export const itemApi = { export const itemApi = {
@ -62,8 +62,7 @@ export const itemApi = {
/** /**
* @author hj * @author hj
*/ */
exportItems: (taskId: string,signal?: AbortSignal) => { exportItems: (taskId: string, param: any, signal?: AbortSignal) => {
return getDownload2(`/item/exportItems/${taskId}`,{},signal); return postDownload2(`/item/exportItems/${taskId}`, param, signal);
}, },
}; };

View File

@ -0,0 +1,14 @@
import {postRequest, getRequest,} from '/@/lib/axios';
export const exportApi = {
createExportTask: () => {
return postRequest('/export/createExportTask', {});
},
getExportProgress: (taskId: string) => {
return getRequest(`/export/progress/${taskId}`, {});
},
}

View File

@ -184,6 +184,22 @@ export const postDownload = function (url, data) {
}); });
}; };
export const postDownload2 = function (url: string, data: any, signal?: AbortSignal) {
request({
method: 'post',
url,
data,
responseType: 'blob',
signal
})
.then((data) => {
handleDownloadData(data);
})
.catch((error) => {
handleDownloadError(error);
});
};
/** /**
* *
*/ */
@ -201,23 +217,6 @@ export const getDownload = function (url, params) {
handleDownloadError(error); handleDownloadError(error);
}); });
}; };
export const getDownload2 = function (url: string, params: any, signal?: AbortSignal) {
request({
method: 'get',
url,
params,
responseType: 'blob',
signal // 注入取消信号
})
.then((data) => {
handleDownloadData(data);
})
.catch((error) => {
message.success('取消成功');
});
};
function handleDownloadError(error) { function handleDownloadError(error) {
if (error instanceof Blob) { if (error instanceof Blob) {
const fileReader = new FileReader(); const fileReader = new FileReader();

View File

@ -197,6 +197,7 @@ import {message, Modal, UploadFile} from 'ant-design-vue';
import {LoadingOutlined} from '@ant-design/icons-vue'; import {LoadingOutlined} from '@ant-design/icons-vue';
import {SmartLoading} from '/@/components/framework/smart-loading'; import {SmartLoading} from '/@/components/framework/smart-loading';
import {addressApi} from '/@/api/business/wms/base/address/address-api'; import {addressApi} from '/@/api/business/wms/base/address/address-api';
import {exportApi} from '/@/api/business/wms/export/export-api'
import {PAGE_SIZE_OPTIONS} from '/@/constants/common-const'; import {PAGE_SIZE_OPTIONS} from '/@/constants/common-const';
import {smartSentry} from '/@/lib/smart-sentry'; import {smartSentry} from '/@/lib/smart-sentry';
import TableOperator from '/@/components/support/table-operator/index.vue'; import TableOperator from '/@/components/support/table-operator/index.vue';
@ -462,12 +463,12 @@ const onExportAddress = async () => {
resetProgressState(); // resetProgressState(); //
// //
const {data: taskId} = await addressApi.createExportTask(); const {data: taskId} = await exportApi.createExportTask();
currentTaskId.value = taskId; currentTaskId.value = taskId;
// //
try { try {
addressApi.exportAddress(taskId, abortController.value.signal) addressApi.exportAddress(taskId, queryForm, abortController.value.signal)
} catch (error) { } catch (error) {
handleExportError(); handleExportError();
} }
@ -480,7 +481,11 @@ const onExportAddress = async () => {
// //
timerId.value = setInterval(async () => { timerId.value = setInterval(async () => {
try { try {
const {data: progress} = await addressApi.getExportProgress(currentTaskId.value); const {data: progress} = await exportApi.getExportProgress(currentTaskId.value);
if (progress == -1) {
handleExportError();
}
progressPercent.value = progress; progressPercent.value = progress;

View File

@ -204,6 +204,7 @@ import {reactive, ref, onMounted} from 'vue';
import {message, Modal} from 'ant-design-vue'; import {message, Modal} from 'ant-design-vue';
import {SmartLoading} from '/@/components/framework/smart-loading'; import {SmartLoading} from '/@/components/framework/smart-loading';
import {itemApi} from '/@/api/business/wms/base/item/item-api.js'; import {itemApi} from '/@/api/business/wms/base/item/item-api.js';
import {exportApi} from '/@/api/business/wms/export/export-api'
import {PAGE_SIZE_OPTIONS} from '/@/constants/common-const'; import {PAGE_SIZE_OPTIONS} from '/@/constants/common-const';
import {smartSentry} from '/@/lib/smart-sentry'; import {smartSentry} from '/@/lib/smart-sentry';
import TableOperator from '/@/components/support/table-operator/index.vue'; import TableOperator from '/@/components/support/table-operator/index.vue';
@ -213,7 +214,6 @@ import ItemSelect from "/@/views/business/wms/base/item/item-select.vue";
import {UploadFile} from 'ant-design-vue'; import {UploadFile} from 'ant-design-vue';
import {fileApi} from "/@/api/support/file-api"; import {fileApi} from "/@/api/support/file-api";
import DictLabel from "/@/components/support/dict-label/index.vue"; import DictLabel from "/@/components/support/dict-label/index.vue";
import {addressApi} from "/@/api/business/wms/base/address/address-api";
import {LoadingOutlined} from "@ant-design/icons-vue"; import {LoadingOutlined} from "@ant-design/icons-vue";
// ---------------------------- ---------------------------- // ---------------------------- ----------------------------
let columns = ref([ let columns = ref([
@ -517,12 +517,12 @@ const onExportItems = async () => {
resetProgressState(); // resetProgressState(); //
// //
const {data: taskId} = await addressApi.createExportTask(); const {data: taskId} = await exportApi.createExportTask();
currentTaskId.value = taskId; currentTaskId.value = taskId;
// //
try { try {
itemApi.exportItems(taskId, abortController.value.signal) itemApi.exportItems(taskId, queryForm, abortController.value.signal)
} catch (error) { } catch (error) {
handleExportError(); handleExportError();
} }
@ -535,7 +535,11 @@ const onExportItems = async () => {
// //
timerId.value = setInterval(async () => { timerId.value = setInterval(async () => {
try { try {
const {data: progress} = await addressApi.getExportProgress(currentTaskId.value); const {data: progress} = await exportApi.getExportProgress(currentTaskId.value);
if (progress == -1) {
handleExportError();
}
progressPercent.value = progress; progressPercent.value = progress;