no message
							parent
							
								
									efb8bc00f8
								
							
						
					
					
						commit
						fb50787fcd
					
				| 
						 | 
					@ -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);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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);
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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}`, {});
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -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();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue