no message
							parent
							
								
									fb50787fcd
								
							
						
					
					
						commit
						6bd3ddb555
					
				| 
						 | 
					@ -5,7 +5,7 @@
 | 
				
			||||||
 * @Date:      2024-11-18 14:17:31
 | 
					 * @Date:      2024-11-18 14:17:31
 | 
				
			||||||
 * @Copyright  友仓
 | 
					 * @Copyright  友仓
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
import {postRequest, getRequest, getDownload} from '/@/lib/axios';
 | 
					import {postRequest, getRequest, postDownload2} from '/@/lib/axios';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const locationApi = {
 | 
					export const locationApi = {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -76,7 +76,7 @@ export const locationApi = {
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 导出  @author  hj
 | 
					     * 导出  @author  hj
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    exportLocations : () =>{
 | 
					    exportLocations: (taskId: string, param: any, signal?: AbortSignal) => {
 | 
				
			||||||
        return getDownload('/location/exportLocations',{});
 | 
					        return postDownload2(`/location/exportLocations/${taskId}`, param, signal);
 | 
				
			||||||
    }
 | 
					    },
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,7 +5,7 @@
 | 
				
			||||||
 * @Date:      2024-11-26 11:37:48
 | 
					 * @Date:      2024-11-26 11:37:48
 | 
				
			||||||
 * @Copyright  友仓
 | 
					 * @Copyright  友仓
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
import {postRequest, getRequest,getDownload} from '/@/lib/axios';
 | 
					import {postRequest, getRequest,postDownload2} from '/@/lib/axios';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const stockApi = {
 | 
					export const stockApi = {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -61,9 +61,9 @@ export const stockApi = {
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 导出  @author  hj
 | 
					     * 导出  @author  hj
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    exportStocks: () => {
 | 
					    exportStocks: (taskId: string, param: any, signal?: AbortSignal) => {
 | 
				
			||||||
        return getDownload('/stock/exportStocks', {});
 | 
					        return postDownload2(`/stock/exportStocks/${taskId}`, param, signal);
 | 
				
			||||||
    }
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -544,6 +544,7 @@ const onCancel = () => {
 | 
				
			||||||
    abortController.value.abort();
 | 
					    abortController.value.abort();
 | 
				
			||||||
    abortController.value = null;
 | 
					    abortController.value = null;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					  handleExportError();
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
onMounted(queryData);
 | 
					onMounted(queryData);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -598,6 +598,7 @@ const onCancel = () => {
 | 
				
			||||||
    abortController.value.abort();
 | 
					    abortController.value.abort();
 | 
				
			||||||
    abortController.value = null;
 | 
					    abortController.value = null;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					  handleExportError();
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
onMounted(queryData);
 | 
					onMounted(queryData);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -85,6 +85,28 @@
 | 
				
			||||||
          导入
 | 
					          导入
 | 
				
			||||||
        </a-button>
 | 
					        </a-button>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <a-modal
 | 
				
			||||||
 | 
					            v-model:open="open"
 | 
				
			||||||
 | 
					            @cancel="onCancel"
 | 
				
			||||||
 | 
					            :closable="false"
 | 
				
			||||||
 | 
					            :maskClosable="false"
 | 
				
			||||||
 | 
					            :destroyOnClose="true">
 | 
				
			||||||
 | 
					          <a-progress
 | 
				
			||||||
 | 
					              :percent="progressPercent"
 | 
				
			||||||
 | 
					              :status="progressStatus"
 | 
				
			||||||
 | 
					          />
 | 
				
			||||||
 | 
					          <template #title>
 | 
				
			||||||
 | 
					            <span style="display: inline-flex; align-items: center">
 | 
				
			||||||
 | 
					            <LoadingOutlined style="margin-right: 8px"/>
 | 
				
			||||||
 | 
					            {{ progressTitle }}
 | 
				
			||||||
 | 
					            </span>
 | 
				
			||||||
 | 
					          </template>
 | 
				
			||||||
 | 
					          <template #footer>
 | 
				
			||||||
 | 
					            <a-space>
 | 
				
			||||||
 | 
					              <a-button @click="onCancel">取消</a-button>
 | 
				
			||||||
 | 
					            </a-space>
 | 
				
			||||||
 | 
					          </template>
 | 
				
			||||||
 | 
					        </a-modal>
 | 
				
			||||||
        <a-button @click="onExportLocations" type="primary" v-privilege="'location:exportLocations'">
 | 
					        <a-button @click="onExportLocations" type="primary" v-privilege="'location:exportLocations'">
 | 
				
			||||||
          <template #icon>
 | 
					          <template #icon>
 | 
				
			||||||
            <ExportOutlined/>
 | 
					            <ExportOutlined/>
 | 
				
			||||||
| 
						 | 
					@ -226,6 +248,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 {locationApi} from '/@/api/business/wms/base/location/location-api';
 | 
					import {locationApi} from '/@/api/business/wms/base/location/location-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';
 | 
				
			||||||
| 
						 | 
					@ -239,6 +262,7 @@ import DictLabel from '/@/components/support/dict-label/index.vue';
 | 
				
			||||||
import MultipleInsert from "/@/views/business/wms/base/location/multiple-insert.vue";
 | 
					import MultipleInsert from "/@/views/business/wms/base/location/multiple-insert.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 {LoadingOutlined} from "@ant-design/icons-vue";
 | 
				
			||||||
// ---------------------------- 表格列 ----------------------------
 | 
					// ---------------------------- 表格列 ----------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let columns = ref([
 | 
					let columns = ref([
 | 
				
			||||||
| 
						 | 
					@ -554,9 +578,108 @@ async function onImportLocations() {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//导出
 | 
					//导出
 | 
				
			||||||
function onExportLocations() {
 | 
					const progressTitle = ref('文件下载中,请稍等...');//标题
 | 
				
			||||||
  locationApi.exportLocations();
 | 
					const progressPercent = ref(0);//进度百分比
 | 
				
			||||||
}
 | 
					const progressStatus = ref('active');
 | 
				
			||||||
 | 
					const currentTaskId = ref('');//当前任务ID
 | 
				
			||||||
 | 
					const open = ref(false);//打开进度条窗口
 | 
				
			||||||
 | 
					const timerId = ref<NodeJS.Timeout | null>(null); // 定时器引用
 | 
				
			||||||
 | 
					const isExporting = ref(false); // 防止重复提交
 | 
				
			||||||
 | 
					const abortController = ref<AbortController | null>(null);// 用于取消请求
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const onExportLocations = async () => {
 | 
				
			||||||
 | 
					  if (isExporting.value) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  try {
 | 
				
			||||||
 | 
					    isExporting.value = true;
 | 
				
			||||||
 | 
					    abortController.value = new AbortController(); // 创建控制器
 | 
				
			||||||
 | 
					    open.value = true;
 | 
				
			||||||
 | 
					    resetProgressState(); // 重置进度状态
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // 创建导出任务
 | 
				
			||||||
 | 
					    const {data: taskId} = await exportApi.createExportTask();
 | 
				
			||||||
 | 
					    currentTaskId.value = taskId;
 | 
				
			||||||
 | 
					    // 发起导出请求
 | 
				
			||||||
 | 
					    try {
 | 
				
			||||||
 | 
					      locationApi.exportLocations(taskId, queryForm, abortController.value.signal)
 | 
				
			||||||
 | 
					    } catch (error) {
 | 
				
			||||||
 | 
					      handleExportError();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // 清理之前的定时器
 | 
				
			||||||
 | 
					    if (timerId.value) {
 | 
				
			||||||
 | 
					      clearInterval(timerId.value);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // 启动轮询
 | 
				
			||||||
 | 
					    timerId.value = setInterval(async () => {
 | 
				
			||||||
 | 
					      try {
 | 
				
			||||||
 | 
					        const {data: progress} = await exportApi.getExportProgress(currentTaskId.value);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (progress == -1) {
 | 
				
			||||||
 | 
					          handleExportError();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        progressPercent.value = progress;
 | 
				
			||||||
 | 
					        console.log('progress', progress);
 | 
				
			||||||
 | 
					        if (progress >= 100) {
 | 
				
			||||||
 | 
					          handleExportSuccess();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      } catch (error) {
 | 
				
			||||||
 | 
					        handleExportError();
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }, 1000);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  } catch (error) {
 | 
				
			||||||
 | 
					    handleExportError();
 | 
				
			||||||
 | 
					  } finally {
 | 
				
			||||||
 | 
					    isExporting.value = false;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//  处理导出成功
 | 
				
			||||||
 | 
					const handleExportSuccess = () => {
 | 
				
			||||||
 | 
					  if (timerId.value) {
 | 
				
			||||||
 | 
					    clearInterval(timerId.value);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  progressStatus.value = 'success';
 | 
				
			||||||
 | 
					  progressTitle.value = '文件下载完成';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  setTimeout(() => {
 | 
				
			||||||
 | 
					    open.value = false;
 | 
				
			||||||
 | 
					    resetProgressState();
 | 
				
			||||||
 | 
					  }, 1000);
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 处理导出失败
 | 
				
			||||||
 | 
					const handleExportError = () => {
 | 
				
			||||||
 | 
					  if (timerId.value) clearInterval(timerId.value);
 | 
				
			||||||
 | 
					  progressStatus.value = 'exception';
 | 
				
			||||||
 | 
					  progressPercent.value = 0;
 | 
				
			||||||
 | 
					  open.value = false;
 | 
				
			||||||
 | 
					  resetProgressState();
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 重置进度状态
 | 
				
			||||||
 | 
					const resetProgressState = () => {
 | 
				
			||||||
 | 
					  progressPercent.value = 0;
 | 
				
			||||||
 | 
					  progressStatus.value = 'active';
 | 
				
			||||||
 | 
					  progressTitle.value = '文件下载中,请稍等...';
 | 
				
			||||||
 | 
					  currentTaskId.value = '';
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//取消
 | 
				
			||||||
 | 
					const onCancel = () => {
 | 
				
			||||||
 | 
					  // 中止进行中的请求
 | 
				
			||||||
 | 
					  open.value = false;
 | 
				
			||||||
 | 
					  if (abortController.value) {
 | 
				
			||||||
 | 
					    abortController.value.abort();
 | 
				
			||||||
 | 
					    abortController.value = null;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  handleExportError();
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
onMounted(queryData);
 | 
					onMounted(queryData);
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,10 +16,12 @@
 | 
				
			||||||
        <LocationSelect v-model:value="queryForm.locationId" :disabledFlag="true" @change="onSearch"/>
 | 
					        <LocationSelect v-model:value="queryForm.locationId" :disabledFlag="true" @change="onSearch"/>
 | 
				
			||||||
      </a-form-item>
 | 
					      </a-form-item>
 | 
				
			||||||
      <a-form-item label="状态" class="smart-query-form-item">
 | 
					      <a-form-item label="状态" class="smart-query-form-item">
 | 
				
			||||||
        <SmartEnumSelect style="width: 200px" enum-name="USAGE_STATUS_ENUM" v-model:value="queryForm.status" @change="onSearch"/>
 | 
					        <SmartEnumSelect style="width: 200px" enum-name="USAGE_STATUS_ENUM" v-model:value="queryForm.status"
 | 
				
			||||||
 | 
					                         @change="onSearch"/>
 | 
				
			||||||
      </a-form-item>
 | 
					      </a-form-item>
 | 
				
			||||||
      <a-form-item label="是否启用" class="smart-query-form-item">
 | 
					      <a-form-item label="是否启用" class="smart-query-form-item">
 | 
				
			||||||
        <a-select style="width: 200px" v-model:value="queryForm.disabledFlag" allowClear placeholder="请选择" @change="onSearch">
 | 
					        <a-select style="width: 200px" v-model:value="queryForm.disabledFlag" allowClear placeholder="请选择"
 | 
				
			||||||
 | 
					                  @change="onSearch">
 | 
				
			||||||
          <a-select-option :value="true">启用</a-select-option>
 | 
					          <a-select-option :value="true">启用</a-select-option>
 | 
				
			||||||
          <a-select-option :value="false">禁用</a-select-option>
 | 
					          <a-select-option :value="false">禁用</a-select-option>
 | 
				
			||||||
        </a-select>
 | 
					        </a-select>
 | 
				
			||||||
| 
						 | 
					@ -68,6 +70,28 @@
 | 
				
			||||||
          导入
 | 
					          导入
 | 
				
			||||||
        </a-button>
 | 
					        </a-button>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <a-modal
 | 
				
			||||||
 | 
					            v-model:open="open"
 | 
				
			||||||
 | 
					            @cancel="onCancel"
 | 
				
			||||||
 | 
					            :closable="false"
 | 
				
			||||||
 | 
					            :maskClosable="false"
 | 
				
			||||||
 | 
					            :destroyOnClose="true">
 | 
				
			||||||
 | 
					          <a-progress
 | 
				
			||||||
 | 
					              :percent="progressPercent"
 | 
				
			||||||
 | 
					              :status="progressStatus"
 | 
				
			||||||
 | 
					          />
 | 
				
			||||||
 | 
					          <template #title>
 | 
				
			||||||
 | 
					            <span style="display: inline-flex; align-items: center">
 | 
				
			||||||
 | 
					            <LoadingOutlined style="margin-right: 8px"/>
 | 
				
			||||||
 | 
					            {{ progressTitle }}
 | 
				
			||||||
 | 
					            </span>
 | 
				
			||||||
 | 
					          </template>
 | 
				
			||||||
 | 
					          <template #footer>
 | 
				
			||||||
 | 
					            <a-space>
 | 
				
			||||||
 | 
					              <a-button @click="onCancel">取消</a-button>
 | 
				
			||||||
 | 
					            </a-space>
 | 
				
			||||||
 | 
					          </template>
 | 
				
			||||||
 | 
					        </a-modal>
 | 
				
			||||||
        <a-button @click="onExportStocks" type="primary" v-privilege="'stock:exportStocks'">
 | 
					        <a-button @click="onExportStocks" type="primary" v-privilege="'stock:exportStocks'">
 | 
				
			||||||
          <template #icon>
 | 
					          <template #icon>
 | 
				
			||||||
            <ExportOutlined/>
 | 
					            <ExportOutlined/>
 | 
				
			||||||
| 
						 | 
					@ -200,6 +224,9 @@ import StockSelect from "/@/views/business/wms/base/stock/stock-select.vue";
 | 
				
			||||||
import SmartEnumSelect from "/@/components/framework/smart-enum-select/index.vue";
 | 
					import SmartEnumSelect from "/@/components/framework/smart-enum-select/index.vue";
 | 
				
			||||||
import LocationSelect from "/@/views/business/wms/base/location/location-select.vue";
 | 
					import LocationSelect from "/@/views/business/wms/base/location/location-select.vue";
 | 
				
			||||||
import DictLabel from "/@/components/support/dict-label/index.vue";
 | 
					import DictLabel from "/@/components/support/dict-label/index.vue";
 | 
				
			||||||
 | 
					import {LoadingOutlined} from "@ant-design/icons-vue";
 | 
				
			||||||
 | 
					import {exportApi} from "/@/api/business/wms/export/export-api";
 | 
				
			||||||
 | 
					import {itemApi} from "/@/api/business/wms/base/item/item-api";
 | 
				
			||||||
// ---------------------------- 表格列 ----------------------------
 | 
					// ---------------------------- 表格列 ----------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let columns = ref([
 | 
					let columns = ref([
 | 
				
			||||||
| 
						 | 
					@ -479,9 +506,109 @@ async function onImportStocks() {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//导出
 | 
					//导出
 | 
				
			||||||
function onExportStocks() {
 | 
					const progressTitle = ref('文件下载中,请稍等...');//标题
 | 
				
			||||||
  stockApi.exportStocks();
 | 
					const progressPercent = ref(0);//进度百分比
 | 
				
			||||||
}
 | 
					const progressStatus = ref('active');
 | 
				
			||||||
 | 
					const currentTaskId = ref('');//当前任务ID
 | 
				
			||||||
 | 
					const open = ref(false);//打开进度条窗口
 | 
				
			||||||
 | 
					const timerId = ref<NodeJS.Timeout | null>(null); // 定时器引用
 | 
				
			||||||
 | 
					const isExporting = ref(false); // 防止重复提交
 | 
				
			||||||
 | 
					const abortController = ref<AbortController | null>(null);// 用于取消请求
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const onExportStocks = async () => {
 | 
				
			||||||
 | 
					  if (isExporting.value) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  try {
 | 
				
			||||||
 | 
					    isExporting.value = true;
 | 
				
			||||||
 | 
					    abortController.value = new AbortController(); // 创建控制器
 | 
				
			||||||
 | 
					    open.value = true;
 | 
				
			||||||
 | 
					    resetProgressState(); // 重置进度状态
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // 创建导出任务
 | 
				
			||||||
 | 
					    const {data: taskId} = await exportApi.createExportTask();
 | 
				
			||||||
 | 
					    currentTaskId.value = taskId;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // 发起导出请求
 | 
				
			||||||
 | 
					    try {
 | 
				
			||||||
 | 
					      itemApi.exportItems(taskId, queryForm, abortController.value.signal)
 | 
				
			||||||
 | 
					    } catch (error) {
 | 
				
			||||||
 | 
					      handleExportError();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // 清理之前的定时器
 | 
				
			||||||
 | 
					    if (timerId.value) {
 | 
				
			||||||
 | 
					      clearInterval(timerId.value);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // 启动轮询
 | 
				
			||||||
 | 
					    timerId.value = setInterval(async () => {
 | 
				
			||||||
 | 
					      try {
 | 
				
			||||||
 | 
					        const {data: progress} = await exportApi.getExportProgress(currentTaskId.value);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (progress == -1) {
 | 
				
			||||||
 | 
					          handleExportError();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        progressPercent.value = progress;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (progress >= 100) {
 | 
				
			||||||
 | 
					          handleExportSuccess();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      } catch (error) {
 | 
				
			||||||
 | 
					        handleExportError();
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }, 1000);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  } catch (error) {
 | 
				
			||||||
 | 
					    handleExportError();
 | 
				
			||||||
 | 
					  } finally {
 | 
				
			||||||
 | 
					    isExporting.value = false;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//  处理导出成功
 | 
				
			||||||
 | 
					const handleExportSuccess = () => {
 | 
				
			||||||
 | 
					  if (timerId.value) {
 | 
				
			||||||
 | 
					    clearInterval(timerId.value);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  progressStatus.value = 'success';
 | 
				
			||||||
 | 
					  progressTitle.value = '文件下载完成';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  setTimeout(() => {
 | 
				
			||||||
 | 
					    open.value = false;
 | 
				
			||||||
 | 
					    resetProgressState();
 | 
				
			||||||
 | 
					  }, 1000);
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 处理导出失败
 | 
				
			||||||
 | 
					const handleExportError = () => {
 | 
				
			||||||
 | 
					  if (timerId.value) clearInterval(timerId.value);
 | 
				
			||||||
 | 
					  progressStatus.value = 'exception';
 | 
				
			||||||
 | 
					  progressPercent.value = 0;
 | 
				
			||||||
 | 
					  open.value = false;
 | 
				
			||||||
 | 
					  resetProgressState();
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 重置进度状态
 | 
				
			||||||
 | 
					const resetProgressState = () => {
 | 
				
			||||||
 | 
					  progressPercent.value = 0;
 | 
				
			||||||
 | 
					  progressStatus.value = 'active';
 | 
				
			||||||
 | 
					  progressTitle.value = '文件下载中,请稍等...';
 | 
				
			||||||
 | 
					  currentTaskId.value = '';
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//取消
 | 
				
			||||||
 | 
					const onCancel = () => {
 | 
				
			||||||
 | 
					  // 中止进行中的请求
 | 
				
			||||||
 | 
					  open.value = false;
 | 
				
			||||||
 | 
					  if (abortController.value) {
 | 
				
			||||||
 | 
					    abortController.value.abort();
 | 
				
			||||||
 | 
					    abortController.value = null;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  handleExportError();
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
onMounted(queryData);
 | 
					onMounted(queryData);
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue