|
|
@@ -113,12 +113,20 @@
|
|
|
</el-table>
|
|
|
<PaginationPage :total="bookTotal" @getList="pageBookList" />
|
|
|
</el-dialog>
|
|
|
+
|
|
|
+ <CommonProgress
|
|
|
+ :percentage="percentage"
|
|
|
+ :visible.sync="visible"
|
|
|
+ title="导出离线包"
|
|
|
+ :text="`正在导出离线包,请稍候...`"
|
|
|
+ />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import ProjectMenu from '@/views/project_manage/common/ProjectMenu.vue';
|
|
|
import PaginationPage from '@/components/PaginationPage.vue';
|
|
|
+import CommonProgress from '@/components/CommonProgress.vue';
|
|
|
|
|
|
import { PageQueryYSJBookList_OrgManager } from '@/api/list';
|
|
|
import {
|
|
|
@@ -136,6 +144,7 @@ export default {
|
|
|
components: {
|
|
|
ProjectMenu,
|
|
|
PaginationPage,
|
|
|
+ CommonProgress,
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
@@ -170,7 +179,6 @@ export default {
|
|
|
],
|
|
|
effective_end_date: [{ required: true, message: '请选择有效截止日期', trigger: 'blur' }],
|
|
|
},
|
|
|
- loadingInstance: null, // 加载中实例
|
|
|
tempDir: '', // 临时目录,用于存放下载的文件
|
|
|
savePath: '', // 保存离线包的路径
|
|
|
packageName: 'EEP 离线包', // 离线包名称
|
|
|
@@ -178,6 +186,8 @@ export default {
|
|
|
downloadTotal: 0, // 下载总数
|
|
|
downloadCompleted: 0, // 已下载数量
|
|
|
downloadWatcher: null, // 下载进度监听器
|
|
|
+ visible: false,
|
|
|
+ percentage: 0,
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
|
@@ -208,12 +218,6 @@ export default {
|
|
|
this.downloadWatcher();
|
|
|
this.downloadWatcher = null;
|
|
|
}
|
|
|
-
|
|
|
- // 关闭加载中实例
|
|
|
- if (this.loadingInstance) {
|
|
|
- this.loadingInstance.close();
|
|
|
- this.loadingInstance = null;
|
|
|
- }
|
|
|
},
|
|
|
methods: {
|
|
|
queryList() {
|
|
|
@@ -330,12 +334,7 @@ export default {
|
|
|
this.tempDir = window.fileAPI.createTempDir(); // 创建临时保存目录
|
|
|
}
|
|
|
|
|
|
- this.loadingInstance = this.$loading({
|
|
|
- lock: true,
|
|
|
- text: '正在下载离线包,请稍候...',
|
|
|
- spinner: 'el-icon-loading',
|
|
|
- background: 'rgba(255, 255, 255, 0.7)',
|
|
|
- });
|
|
|
+ this.visible = true;
|
|
|
|
|
|
for (const { dir_name, file_name, file_url } of this.file_info_list) {
|
|
|
const dirPath = dir_name.length > 0 ? `${this.tempDir}\\${dir_name}` : this.tempDir;
|
|
|
@@ -359,8 +358,10 @@ export default {
|
|
|
this.downloadWatcher();
|
|
|
this.startCompress();
|
|
|
} else {
|
|
|
- // 显示下载进度,预留 10% 的压缩进度
|
|
|
- this.loadingInstance.text = `正在下载离线包,进度:${((this.downloadCompleted / (this.downloadTotal + this.downloadTotal * 0.1)) * 100).toFixed(2)}%`;
|
|
|
+ this.percentage = (
|
|
|
+ (this.downloadCompleted / (this.downloadTotal + this.downloadTotal * 0.1)) *
|
|
|
+ 100
|
|
|
+ ).toFixed(2);
|
|
|
}
|
|
|
},
|
|
|
{ immediate: true },
|
|
|
@@ -421,14 +422,14 @@ export default {
|
|
|
} catch (e) {
|
|
|
console.error('压缩失败:', e);
|
|
|
this.$message.error('离线包下载失败,请重试!');
|
|
|
- this.loadingInstance.close();
|
|
|
- this.loadingInstance = null;
|
|
|
this.tempDir = '';
|
|
|
+ this.visible = false;
|
|
|
return;
|
|
|
+ } finally {
|
|
|
+ this.percentage = 100;
|
|
|
+ this.visible = false;
|
|
|
}
|
|
|
|
|
|
- this.loadingInstance.text = `正在下载离线包,进度:100%`;
|
|
|
-
|
|
|
// 删除临时目录及其内容
|
|
|
try {
|
|
|
await window.fileAPI.deleteTempDir(this.tempDir);
|
|
|
@@ -436,11 +437,10 @@ export default {
|
|
|
} catch (e) {
|
|
|
console.error('删除临时目录失败:', e);
|
|
|
this.tempDir = '';
|
|
|
+ } finally {
|
|
|
+ this.percentage = 0;
|
|
|
}
|
|
|
|
|
|
- this.loadingInstance.close();
|
|
|
- this.loadingInstance = null;
|
|
|
-
|
|
|
this.$message.success('离线包下载并保存成功!');
|
|
|
},
|
|
|
|