|
|
@@ -0,0 +1,1088 @@
|
|
|
+<template>
|
|
|
+ <div :class="prefixCls" class="case-eds-upload-page">
|
|
|
+ <!-- 清洗流程公共顶栏:品牌 / 案件 / 模板库 / 下载管理 / 窗口控制 -->
|
|
|
+ <CaseFlowTopBar />
|
|
|
+
|
|
|
+ <div class="page-body">
|
|
|
+ <div class="page-header">
|
|
|
+ <div class="page-header__left">
|
|
|
+ <Tooltip title="返回" placement="bottom" :mouseEnterDelay="0.5">
|
|
|
+ <button type="button" class="back-btn" aria-label="返回" @click="handleBack">
|
|
|
+ <LeftOutlined />
|
|
|
+ </button>
|
|
|
+ </Tooltip>
|
|
|
+ <span class="page-header__divider" aria-hidden="true"></span>
|
|
|
+ <div class="page-title-block">
|
|
|
+ <div class="page-title">电子数据上传</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="upload-layout">
|
|
|
+ <aside class="left-panel">
|
|
|
+ <!-- 只能选 zip:电子数据包统一格式,表格文件请走「表格数据」入口 -->
|
|
|
+ <input
|
|
|
+ ref="fileInputRef"
|
|
|
+ type="file"
|
|
|
+ multiple
|
|
|
+ accept=".zip"
|
|
|
+ style="display: none"
|
|
|
+ @change="handleFileInputChange"
|
|
|
+ />
|
|
|
+
|
|
|
+ <div
|
|
|
+ class="upload-dropzone"
|
|
|
+ :class="{ 'is-dragover': dragOver }"
|
|
|
+ @dragover.prevent="handleDragOver"
|
|
|
+ @dragleave="handleDragLeave"
|
|
|
+ @drop.prevent="handleDrop"
|
|
|
+ >
|
|
|
+ <div class="upload-dragger-content">
|
|
|
+ <div class="upload-dragger-icon">
|
|
|
+ <Icon icon="i-ant-design:file-zip-outlined" :size="15" />
|
|
|
+ </div>
|
|
|
+ <div class="upload-dragger-title">拖拽电子数据包到这里,或点击选择文件</div>
|
|
|
+ <Button type="primary" class="upload-action-btn" :disabled="isUploading" @click="handleTriggerFileSelect">
|
|
|
+ 选择文件
|
|
|
+ </Button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- 已选文件列表(加入后自动上传,成功即移除) -->
|
|
|
+ <div v-if="selectedFiles.length" class="upload-file-list">
|
|
|
+ <div class="upload-file-list__header">
|
|
|
+ <span>待上传 {{ selectedFiles.length }} 个文件</span>
|
|
|
+ <Button type="link" size="small" :disabled="isUploading" @click="clearSelectedFiles"> 清空 </Button>
|
|
|
+ </div>
|
|
|
+ <div class="upload-file-list__body">
|
|
|
+ <div
|
|
|
+ v-for="file in selectedFiles"
|
|
|
+ :key="file.name + file.size + file.lastModified"
|
|
|
+ class="upload-file-item"
|
|
|
+ >
|
|
|
+ <div class="upload-file-item__info">
|
|
|
+ <span class="upload-file-item__name">{{ file.name }}</span>
|
|
|
+ <span class="upload-file-item__size">{{ formatFileSize(file.size) }}</span>
|
|
|
+ </div>
|
|
|
+ <div class="upload-file-item__status">
|
|
|
+ <template v-if="uploadStatuses.get(file) === 'error'">
|
|
|
+ <span class="upload-file-item__error">✗</span>
|
|
|
+ </template>
|
|
|
+ <template v-else-if="uploadStatuses.get(file) === 'uploading'">
|
|
|
+ <span class="upload-file-item__progress-text">{{ uploadProgressMap.get(file) || 0 }}%</span>
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
+ <span class="upload-file-item__pending">待上传</span>
|
|
|
+ </template>
|
|
|
+ </div>
|
|
|
+ <button
|
|
|
+ v-if="!isUploading && (uploadStatuses.get(file) || 'pending') === 'pending'"
|
|
|
+ type="button"
|
|
|
+ class="upload-file-item__remove"
|
|
|
+ aria-label="移除文件"
|
|
|
+ @click="removeSelectedFile(file)"
|
|
|
+ >
|
|
|
+ <CloseOutlined />
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <!-- 整体进度 -->
|
|
|
+ <div v-if="isUploading" class="upload-overall-progress">
|
|
|
+ <div class="upload-overall-progress__bar">
|
|
|
+ <div class="upload-overall-progress__fill" :style="{ width: overallProgress + '%' }"></div>
|
|
|
+ </div>
|
|
|
+ <span class="upload-overall-progress__text">总进度 {{ overallProgress }}%</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div v-else class="upload-file-list upload-file-list--empty">
|
|
|
+ <div class="upload-empty">暂无待上传文件,选择 zip 后将自动上传并开始解压</div>
|
|
|
+ </div>
|
|
|
+ </aside>
|
|
|
+
|
|
|
+ <section class="right-panel">
|
|
|
+ <div class="panel-header">
|
|
|
+ <div>
|
|
|
+ <div class="panel-title">数据包列表(实时)</div>
|
|
|
+ <div class="panel-desc">上传完成后在右侧查看解压提取进度;失败原因显示在「消息」列</div>
|
|
|
+ </div>
|
|
|
+ <div class="panel-header__actions">
|
|
|
+ <Button size="small" :loading="listLoading" @click="handleManualRefresh">
|
|
|
+ <template #icon><ReloadOutlined /></template>
|
|
|
+ 刷新
|
|
|
+ </Button>
|
|
|
+ </div>
|
|
|
+ <div class="panel-stats">共 {{ rows.length }} 个数据包</div>
|
|
|
+ </div>
|
|
|
+ <div class="table-wrapper">
|
|
|
+ <Table
|
|
|
+ class="eds-process-table"
|
|
|
+ :columns="tableColumns"
|
|
|
+ :data-source="rows"
|
|
|
+ :loading="initialLoading"
|
|
|
+ :pagination="false"
|
|
|
+ row-key="id"
|
|
|
+ size="small"
|
|
|
+ :scroll="{ x: 950 }"
|
|
|
+ :locale="{ emptyText: '暂无电子数据包,先在左侧上传 zip' }"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </section>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script lang="ts" setup name="ViewsDataEdsUpload">
|
|
|
+ import { computed, h, onBeforeUnmount, onMounted, ref } from 'vue';
|
|
|
+ import { onBeforeRouteLeave } from 'vue-router';
|
|
|
+ import { CloseOutlined, LeftOutlined, ReloadOutlined } from '@ant-design/icons-vue';
|
|
|
+ import { Button, Modal, Progress, Table, Tooltip, type TableColumnsType } from 'ant-design-vue';
|
|
|
+ import { Icon } from '@/core/components/Icon';
|
|
|
+ import { useDesign } from '@/core/hooks/web/useDesign';
|
|
|
+ import { useGo } from '@/core/hooks/web/usePage';
|
|
|
+ import { PageEnum } from '@/core/enums/pageEnum';
|
|
|
+ import { useMessage } from '@/core/hooks/web/useMessage';
|
|
|
+ import { useEmitter } from '@/core/store/modules/case';
|
|
|
+ import { edsProcessList, uploadEdsPackage, clearEdsProcess, type EdsMaterialProcessRow } from '@/case/api/eds/edsApi';
|
|
|
+ import CaseFlowTopBar from './components/CaseFlowTopBar.vue';
|
|
|
+
|
|
|
+ const { prefixCls } = useDesign('case-eds-upload');
|
|
|
+ const go = useGo();
|
|
|
+ const emitter = useEmitter();
|
|
|
+ const { createMessage } = useMessage();
|
|
|
+ const CASE_DATA_REFRESH_EVENT = 'case-data:refresh';
|
|
|
+
|
|
|
+ /** 进度轮询间隔:页面存活期间每 2 秒刷新一次,离开页面立即停止 */
|
|
|
+ const POLL_INTERVAL_MS = 2000;
|
|
|
+ /** 后端 status 口径:1 上传中 / 2 上传完成 / 3 上传失败 / 4 解析中 / 5 解析失败 / 6 解析完成 */
|
|
|
+ const STATUS_UPLOADING = 1;
|
|
|
+ const STATUS_UPLOADED = 2;
|
|
|
+ const STATUS_UPLOAD_FAILED = 3;
|
|
|
+ const STATUS_PARSING = 4;
|
|
|
+ const STATUS_PARSE_FAILED = 5;
|
|
|
+ const STATUS_PARSE_SUCCESS = 6;
|
|
|
+ /** 进行中的任务:上传中 / 排队等待解析 / 解析中 */
|
|
|
+ const ACTIVE_STATUSES = new Set([STATUS_UPLOADING, STATUS_UPLOADED, STATUS_PARSING]);
|
|
|
+
|
|
|
+ const fileInputRef = ref<HTMLInputElement | null>(null);
|
|
|
+ const selectedFiles = ref<File[]>([]);
|
|
|
+ const uploadProgressMap = ref<Map<File, number>>(new Map());
|
|
|
+ const uploadStatuses = ref<Map<File, 'pending' | 'uploading' | 'done' | 'error'>>(new Map());
|
|
|
+ const isUploading = ref(false);
|
|
|
+ const overallProgress = ref(0);
|
|
|
+ const dragOver = ref(false);
|
|
|
+
|
|
|
+ const rows = ref<EdsMaterialProcessRow[]>([]);
|
|
|
+ /** 手动点「刷新」时才显示的 loading(定时轮询不能让它每 2 秒闪一次) */
|
|
|
+ const listLoading = ref(false);
|
|
|
+ /** 首次加载:只在第一帧展示表格 loading,之后轮询完全静默 */
|
|
|
+ const initialLoading = ref(true);
|
|
|
+ let pollTimer: ReturnType<typeof setInterval> | undefined;
|
|
|
+ let listRequesting = false;
|
|
|
+
|
|
|
+ const formatFileSize = (bytes?: number | null) => {
|
|
|
+ if (bytes == null || bytes === 0) return '0 B';
|
|
|
+ const k = 1024;
|
|
|
+ const sizes = ['B', 'KB', 'MB', 'GB'];
|
|
|
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
|
+ return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${sizes[i]}`;
|
|
|
+ };
|
|
|
+
|
|
|
+ const progressStatusOf = (status?: number | null) => {
|
|
|
+ const value = Number(status);
|
|
|
+ if (value === STATUS_UPLOAD_FAILED || value === STATUS_PARSE_FAILED) return 'exception';
|
|
|
+ if (value === STATUS_PARSE_SUCCESS) return 'success';
|
|
|
+ if (value === STATUS_PARSING) return 'active';
|
|
|
+ return 'normal';
|
|
|
+ };
|
|
|
+
|
|
|
+ const tableColumns: TableColumnsType<EdsMaterialProcessRow> = [
|
|
|
+ {
|
|
|
+ title: '序号',
|
|
|
+ key: 'index',
|
|
|
+ width: 70,
|
|
|
+ align: 'center',
|
|
|
+ customRender: ({ index }: { index: number }) => h('span', { class: 'cell-index' }, String(index + 1)),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '文件名',
|
|
|
+ key: 'fileName',
|
|
|
+ width: 300,
|
|
|
+ // 关闭 antd 自动加的 title(浏览器原生提示),统一用 Tooltip
|
|
|
+ ellipsis: { showTitle: false },
|
|
|
+ customRender: ({ record }: { record: EdsMaterialProcessRow }) => {
|
|
|
+ const name = record.fileName || '未命名数据包';
|
|
|
+ return h(
|
|
|
+ Tooltip,
|
|
|
+ { title: name, placement: 'topLeft', mouseEnterDelay: 0.3, overlayClassName: 'eds-cell-tooltip' },
|
|
|
+ () => h('span', { class: 'cell-file-name' }, name),
|
|
|
+ );
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '上传进度条',
|
|
|
+ key: 'progress',
|
|
|
+ width: 260,
|
|
|
+ customRender: ({ record }: { record: EdsMaterialProcessRow }) => {
|
|
|
+ const percent = Math.min(100, Math.max(0, Number(record.progress ?? 0)));
|
|
|
+ return h(Progress, {
|
|
|
+ percent,
|
|
|
+ size: 'small',
|
|
|
+ strokeWidth: 8,
|
|
|
+ status: progressStatusOf(record.status),
|
|
|
+ });
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '消息',
|
|
|
+ key: 'message',
|
|
|
+ width: 320,
|
|
|
+ // 关闭 antd 自动加的 title(浏览器原生提示),统一用 Tooltip
|
|
|
+ ellipsis: { showTitle: false },
|
|
|
+ customRender: ({ record }: { record: EdsMaterialProcessRow }) => {
|
|
|
+ const message = String(record.errorMessage ?? '').trim();
|
|
|
+ if (!message) {
|
|
|
+ return h('span', { class: 'cell-message' }, '');
|
|
|
+ }
|
|
|
+ return h(
|
|
|
+ Tooltip,
|
|
|
+ { title: message, placement: 'topLeft', mouseEnterDelay: 0.3, overlayClassName: 'eds-cell-tooltip' },
|
|
|
+ () => h('span', { class: 'cell-message is-error' }, message),
|
|
|
+ );
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ];
|
|
|
+
|
|
|
+ // ------------------------------------------------------------------
|
|
|
+ // 列表轮询
|
|
|
+ // ------------------------------------------------------------------
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 行数据签名:id + 会变化的展示字段。
|
|
|
+ * 定时轮询大多时候数据没变,签名一致就不替换数组,表格不重渲染,界面无感知。
|
|
|
+ */
|
|
|
+ const rowsSignature = (list: EdsMaterialProcessRow[]) =>
|
|
|
+ list
|
|
|
+ .map(
|
|
|
+ (row) =>
|
|
|
+ `${row.id ?? ''}:${row.status ?? ''}:${row.progress ?? ''}:${row.cti ?? ''}:${
|
|
|
+ row.materialType ?? ''
|
|
|
+ }:${row.errorMessage ?? ''}`,
|
|
|
+ )
|
|
|
+ .join('|');
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 拉取数据包列表。
|
|
|
+ *
|
|
|
+ * @param silent true(默认)= 定时轮询:不显示任何 loading,且数据未变化时不动表格;
|
|
|
+ * false = 用户手动点刷新:按钮转圈并强制替换
|
|
|
+ */
|
|
|
+ const refreshRows = async (silent = true) => {
|
|
|
+ if (listRequesting) return;
|
|
|
+ listRequesting = true;
|
|
|
+ if (!silent) listLoading.value = true;
|
|
|
+ try {
|
|
|
+ const list = await edsProcessList();
|
|
|
+ const next = Array.isArray(list) ? list : [];
|
|
|
+ if (!silent || rowsSignature(next) !== rowsSignature(rows.value)) {
|
|
|
+ rows.value = next;
|
|
|
+ }
|
|
|
+ } catch (error: any) {
|
|
|
+ // 轮询失败不打断页面,也不每 2 秒弹一次提示;控制台留痕即可
|
|
|
+ console.warn('[eds-upload] 刷新电子数据包列表失败', error?.message || error);
|
|
|
+ } finally {
|
|
|
+ listRequesting = false;
|
|
|
+ initialLoading.value = false;
|
|
|
+ if (!silent) listLoading.value = false;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ /** 手动刷新入口:只有用户主动点击时才给 loading 反馈 */
|
|
|
+ const handleManualRefresh = () => {
|
|
|
+ void refreshRows(false);
|
|
|
+ };
|
|
|
+
|
|
|
+ const stopPolling = () => {
|
|
|
+ if (pollTimer !== undefined) {
|
|
|
+ clearInterval(pollTimer);
|
|
|
+ pollTimer = undefined;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // ------------------------------------------------------------------
|
|
|
+ // 上传
|
|
|
+ // ------------------------------------------------------------------
|
|
|
+
|
|
|
+ const handleDragOver = () => {
|
|
|
+ dragOver.value = true;
|
|
|
+ };
|
|
|
+
|
|
|
+ const handleDragLeave = () => {
|
|
|
+ dragOver.value = false;
|
|
|
+ };
|
|
|
+
|
|
|
+ const handleTriggerFileSelect = () => {
|
|
|
+ fileInputRef.value?.click();
|
|
|
+ };
|
|
|
+
|
|
|
+ const clearSelectedFiles = () => {
|
|
|
+ selectedFiles.value = [];
|
|
|
+ uploadProgressMap.value = new Map();
|
|
|
+ uploadStatuses.value = new Map();
|
|
|
+ overallProgress.value = 0;
|
|
|
+ };
|
|
|
+
|
|
|
+ const removeSelectedFile = (target: File) => {
|
|
|
+ if (isUploading.value) return;
|
|
|
+ const index = selectedFiles.value.indexOf(target);
|
|
|
+ if (index === -1) return;
|
|
|
+ if ((uploadStatuses.value.get(target) || 'pending') !== 'pending') return;
|
|
|
+ selectedFiles.value.splice(index, 1);
|
|
|
+ uploadProgressMap.value.delete(target);
|
|
|
+ uploadStatuses.value.delete(target);
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 加入待上传列表并自动开始上传;只收 zip,其它格式直接跳过并提示。
|
|
|
+ */
|
|
|
+ const addFiles = (files: File[]) => {
|
|
|
+ const zips = files.filter((file) => (file.name.split('.').pop() || '').toLowerCase() === 'zip');
|
|
|
+ const skipped = files.length - zips.length;
|
|
|
+ if (skipped > 0) {
|
|
|
+ createMessage.warning(`${skipped} 个文件不是 zip,已跳过`);
|
|
|
+ }
|
|
|
+ if (!zips.length) return;
|
|
|
+ selectedFiles.value = [...selectedFiles.value, ...zips];
|
|
|
+ void startUpload();
|
|
|
+ };
|
|
|
+
|
|
|
+ const handleFileInputChange = (event: Event) => {
|
|
|
+ const target = event.target as HTMLInputElement;
|
|
|
+ if (!target.files?.length) return;
|
|
|
+ addFiles(Array.from(target.files));
|
|
|
+ target.value = '';
|
|
|
+ };
|
|
|
+
|
|
|
+ const handleDrop = (event: DragEvent) => {
|
|
|
+ dragOver.value = false;
|
|
|
+ const files = Array.from(event.dataTransfer?.files || []);
|
|
|
+ if (files.length) addFiles(files);
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 自动上传队列:按序上传,成功后从待上传列表移除并刷新右侧表格。
|
|
|
+ * 上传本身只负责落盘与登记,解压提取由后端后台执行,进度通过轮询获取。
|
|
|
+ */
|
|
|
+ const startUpload = async () => {
|
|
|
+ if (isUploading.value) return;
|
|
|
+ isUploading.value = true;
|
|
|
+
|
|
|
+ try {
|
|
|
+ while (true) {
|
|
|
+ const index = selectedFiles.value.findIndex(
|
|
|
+ (file) => (uploadStatuses.value.get(file) || 'pending') === 'pending',
|
|
|
+ );
|
|
|
+ if (index === -1) break;
|
|
|
+ const file = selectedFiles.value[index];
|
|
|
+ uploadStatuses.value.set(file, 'uploading');
|
|
|
+
|
|
|
+ const onProgress = (percent: number) => {
|
|
|
+ uploadProgressMap.value.set(file, percent);
|
|
|
+ const list = selectedFiles.value;
|
|
|
+ const total = list.length || 1;
|
|
|
+ const sum = list.reduce((acc, item) => {
|
|
|
+ const status = uploadStatuses.value.get(item);
|
|
|
+ if (status === 'uploading') return acc + (uploadProgressMap.value.get(item) || 0);
|
|
|
+ if (status === 'error') return acc + 100;
|
|
|
+ return acc;
|
|
|
+ }, 0);
|
|
|
+ overallProgress.value = Math.round(sum / total);
|
|
|
+ };
|
|
|
+
|
|
|
+ try {
|
|
|
+ const res = await uploadEdsPackage(file, onProgress);
|
|
|
+ // errorMessageMode=none 时网络异常会被响应拦截器 resolve 成空值,这里兜底
|
|
|
+ if (!res?.data) {
|
|
|
+ throw new Error('网络异常或服务不可用');
|
|
|
+ }
|
|
|
+ if (Number(res.data.code) !== 200) {
|
|
|
+ throw new Error(res.data.message || '上传失败');
|
|
|
+ }
|
|
|
+ uploadProgressMap.value.delete(file);
|
|
|
+ uploadStatuses.value.delete(file);
|
|
|
+ const currentIndex = selectedFiles.value.indexOf(file);
|
|
|
+ if (currentIndex !== -1) selectedFiles.value.splice(currentIndex, 1);
|
|
|
+ onProgress(100);
|
|
|
+ // 上传成功即刷新一次,新记录立刻出现在右侧(后台进度继续轮询)
|
|
|
+ void refreshRows();
|
|
|
+ } catch (error: any) {
|
|
|
+ uploadStatuses.value.set(file, 'error');
|
|
|
+ uploadProgressMap.value.set(file, 100);
|
|
|
+ createMessage.error(`「${file.name}」上传失败:${error?.message || '未知错误'}`);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ overallProgress.value = 100;
|
|
|
+ } finally {
|
|
|
+ isUploading.value = false;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // ------------------------------------------------------------------
|
|
|
+ // 页面出口
|
|
|
+ // ------------------------------------------------------------------
|
|
|
+
|
|
|
+ /** 进行中的数据包数量(上传中 / 排队等待解析 / 解析中) */
|
|
|
+ const activeTaskCount = computed(() => rows.value.filter((row) => ACTIVE_STATUSES.has(Number(row.status))).length);
|
|
|
+ /** 已确认退出:避免路由守卫重复弹确认框 */
|
|
|
+ const allowedToLeave = ref(false);
|
|
|
+
|
|
|
+ /** 退出前清空进度表(完成 / 失败记录也一并删除) */
|
|
|
+ const clearProcessRows = async () => {
|
|
|
+ stopPolling();
|
|
|
+ try {
|
|
|
+ await clearEdsProcess();
|
|
|
+ rows.value = [];
|
|
|
+ } catch (error: any) {
|
|
|
+ console.warn('[eds-upload] 清空电子数据进度表失败', error?.message || error);
|
|
|
+ createMessage.warning('清空电子数据进度记录失败,可稍后重试');
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ const leavePage = async () => {
|
|
|
+ allowedToLeave.value = true;
|
|
|
+ await clearProcessRows();
|
|
|
+ go(PageEnum.BASE_HOME, true);
|
|
|
+ emitter.emit(CASE_DATA_REFRESH_EVENT);
|
|
|
+ };
|
|
|
+
|
|
|
+ const handleBack = () => {
|
|
|
+ const active = activeTaskCount.value;
|
|
|
+ if (!isUploading.value && active === 0) {
|
|
|
+ void leavePage();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const parts: string[] = [];
|
|
|
+ if (isUploading.value) parts.push('仍有文件正在上传');
|
|
|
+ if (active > 0) parts.push(`${active} 个数据包正在上传或解析`);
|
|
|
+ Modal.confirm({
|
|
|
+ title: '存在进行中的任务',
|
|
|
+ content: `${parts.join(',')}。退出将清空进度记录(已完成 / 失败记录也会删除),是否继续?`,
|
|
|
+ okText: '退出并清空',
|
|
|
+ okType: 'danger',
|
|
|
+ cancelText: '留在本页',
|
|
|
+ onOk: () => leavePage(),
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ onMounted(() => {
|
|
|
+ void refreshRows();
|
|
|
+ // 页面存活期间轮询;onBeforeUnmount / 路由离开时清除,避免后台空转请求
|
|
|
+ pollTimer = setInterval(() => void refreshRows(), POLL_INTERVAL_MS);
|
|
|
+ });
|
|
|
+
|
|
|
+ onBeforeUnmount(() => {
|
|
|
+ stopPolling();
|
|
|
+ });
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 浏览器返回等非页面按钮的离开路径同样执行「提示 + 清空」,
|
|
|
+ * 保证每次退出电子数据上传页都会清空进度表。
|
|
|
+ */
|
|
|
+ onBeforeRouteLeave((_to, _from, next) => {
|
|
|
+ if (allowedToLeave.value) {
|
|
|
+ next();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const active = activeTaskCount.value;
|
|
|
+ if (!isUploading.value && active === 0) {
|
|
|
+ allowedToLeave.value = true;
|
|
|
+ stopPolling();
|
|
|
+ void clearEdsProcess()
|
|
|
+ .catch((error: any) => console.warn('[eds-upload] 清空电子数据进度表失败', error?.message || error))
|
|
|
+ .finally(() => next());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Modal.confirm({
|
|
|
+ title: '存在进行中的任务',
|
|
|
+ content: '当前仍有数据包正在上传或解析,退出将清空进度记录(已完成 / 失败记录也会删除),是否继续?',
|
|
|
+ okText: '退出并清空',
|
|
|
+ okType: 'danger',
|
|
|
+ cancelText: '留在本页',
|
|
|
+ onOk: () => {
|
|
|
+ allowedToLeave.value = true;
|
|
|
+ stopPolling();
|
|
|
+ void clearEdsProcess()
|
|
|
+ .catch((error: any) => console.warn('[eds-upload] 清空电子数据进度表失败', error?.message || error))
|
|
|
+ .finally(() => next());
|
|
|
+ },
|
|
|
+ onCancel: () => next(false),
|
|
|
+ });
|
|
|
+ });
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less">
|
|
|
+ @prefix-cls: ~'jeesite-case-eds-upload';
|
|
|
+
|
|
|
+ .@{prefix-cls}.case-eds-upload-page {
|
|
|
+ width: 100%;
|
|
|
+ height: 100vh;
|
|
|
+ background: #f0f2f5;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ box-sizing: border-box;
|
|
|
+ overflow: hidden;
|
|
|
+
|
|
|
+ .page-body {
|
|
|
+ flex: 1 1 auto;
|
|
|
+ min-height: 0;
|
|
|
+ padding: 8px 12px;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ gap: 8px;
|
|
|
+ box-sizing: border-box;
|
|
|
+ overflow: hidden;
|
|
|
+ }
|
|
|
+
|
|
|
+ .page-header {
|
|
|
+ flex-shrink: 0;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
+ gap: 16px;
|
|
|
+ padding: 10px 14px;
|
|
|
+ border: 1px solid #e2e8f0;
|
|
|
+ border-radius: 10px;
|
|
|
+ background: #fff;
|
|
|
+ box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
|
|
|
+ }
|
|
|
+
|
|
|
+ .page-header__left {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ gap: 12px;
|
|
|
+ min-width: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .page-header__divider {
|
|
|
+ flex: 0 0 auto;
|
|
|
+ width: 1px;
|
|
|
+ height: 22px;
|
|
|
+ background: #e2e8f0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .back-btn {
|
|
|
+ display: inline-flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ flex: 0 0 auto;
|
|
|
+ width: 32px;
|
|
|
+ height: 32px;
|
|
|
+ padding: 0;
|
|
|
+ border: 1px solid #e2e8f0;
|
|
|
+ border-radius: 8px;
|
|
|
+ background: #f8fafc;
|
|
|
+ color: #475569;
|
|
|
+ font-size: 14px;
|
|
|
+ line-height: 1;
|
|
|
+ cursor: pointer;
|
|
|
+ transition:
|
|
|
+ color 0.2s ease,
|
|
|
+ border-color 0.2s ease,
|
|
|
+ background-color 0.2s ease;
|
|
|
+
|
|
|
+ &:hover,
|
|
|
+ &:focus,
|
|
|
+ &:focus-visible {
|
|
|
+ color: #2563eb;
|
|
|
+ border-color: #bfdbfe;
|
|
|
+ background: #eff6ff;
|
|
|
+ outline: none;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .page-title-block {
|
|
|
+ min-width: 0;
|
|
|
+ overflow: hidden;
|
|
|
+ }
|
|
|
+
|
|
|
+ .page-title {
|
|
|
+ font-size: 16px;
|
|
|
+ line-height: 1.4;
|
|
|
+ font-weight: 600;
|
|
|
+ color: #111827;
|
|
|
+ }
|
|
|
+
|
|
|
+ .upload-layout {
|
|
|
+ flex: 1 1 auto;
|
|
|
+ min-height: 0;
|
|
|
+ display: flex;
|
|
|
+ gap: 8px;
|
|
|
+ align-items: stretch;
|
|
|
+ }
|
|
|
+
|
|
|
+ .left-panel,
|
|
|
+ .right-panel {
|
|
|
+ border: 1px solid #e2e8f0;
|
|
|
+ border-radius: 10px;
|
|
|
+ background: #fff;
|
|
|
+ overflow: hidden;
|
|
|
+ }
|
|
|
+
|
|
|
+ .left-panel {
|
|
|
+ flex: 0 0 460px;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ gap: 10px;
|
|
|
+ padding: 12px;
|
|
|
+ box-sizing: border-box;
|
|
|
+ overflow-y: auto;
|
|
|
+ }
|
|
|
+
|
|
|
+ .right-panel {
|
|
|
+ flex: 1 1 auto;
|
|
|
+ min-width: 0;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ }
|
|
|
+
|
|
|
+ .panel-header {
|
|
|
+ flex-shrink: 0;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
+ gap: 12px;
|
|
|
+ padding: 10px 14px 8px;
|
|
|
+ border-bottom: 1px solid #eef2f7;
|
|
|
+ }
|
|
|
+
|
|
|
+ .panel-title {
|
|
|
+ position: relative;
|
|
|
+ padding-left: 11px;
|
|
|
+ font-size: 15px;
|
|
|
+ font-weight: 600;
|
|
|
+ line-height: 22px;
|
|
|
+ color: #111827;
|
|
|
+
|
|
|
+ &::before {
|
|
|
+ content: '';
|
|
|
+ position: absolute;
|
|
|
+ top: 4px;
|
|
|
+ bottom: 4px;
|
|
|
+ left: 0;
|
|
|
+ width: 3px;
|
|
|
+ border-radius: 2px;
|
|
|
+ background: #2a50ec;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .panel-desc {
|
|
|
+ margin-top: 2px;
|
|
|
+ font-size: 12px;
|
|
|
+ color: #6b7280;
|
|
|
+ line-height: 1.5;
|
|
|
+ }
|
|
|
+
|
|
|
+ .panel-header__actions {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ gap: 8px;
|
|
|
+ margin-left: auto;
|
|
|
+ }
|
|
|
+
|
|
|
+ .panel-stats {
|
|
|
+ font-size: 12px;
|
|
|
+ color: #64748b;
|
|
|
+ white-space: nowrap;
|
|
|
+ }
|
|
|
+
|
|
|
+ .table-wrapper {
|
|
|
+ flex: 1 1 auto;
|
|
|
+ min-height: 0;
|
|
|
+ padding: 2px 10px 10px;
|
|
|
+ overflow: auto;
|
|
|
+ }
|
|
|
+
|
|
|
+ .eds-process-table {
|
|
|
+ .ant-table-thead > tr > th {
|
|
|
+ padding: 6px 8px;
|
|
|
+ font-size: 12px;
|
|
|
+ font-weight: 600;
|
|
|
+ color: #6b7280;
|
|
|
+ background: #fafbfc;
|
|
|
+ border-bottom: 1px solid #eef2f7;
|
|
|
+ }
|
|
|
+
|
|
|
+ .ant-table-tbody > tr > td {
|
|
|
+ padding: 8px;
|
|
|
+ font-size: 13px;
|
|
|
+ border-bottom: 1px solid #f6f8fa;
|
|
|
+ }
|
|
|
+
|
|
|
+ .ant-table-tbody > tr:hover > td {
|
|
|
+ background: #f8fafc;
|
|
|
+ }
|
|
|
+
|
|
|
+ .ant-progress {
|
|
|
+ margin: 0;
|
|
|
+ max-width: 220px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .cell-index {
|
|
|
+ color: #64748b;
|
|
|
+ font-variant-numeric: tabular-nums;
|
|
|
+ }
|
|
|
+
|
|
|
+ .cell-file-name {
|
|
|
+ color: #1e293b;
|
|
|
+ font-size: 13px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .cell-message {
|
|
|
+ color: #64748b;
|
|
|
+ font-size: 12px;
|
|
|
+
|
|
|
+ &.is-error {
|
|
|
+ color: #dc2626;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .upload-dropzone {
|
|
|
+ flex: 0 0 auto;
|
|
|
+ min-height: 180px;
|
|
|
+ border-radius: 8px;
|
|
|
+ /* 2px 虚线:1px 虚线在非整数像素位置时顶部边框可能不渲染 */
|
|
|
+ border: 2px dashed #cbd5e1;
|
|
|
+ background: #fafbfc;
|
|
|
+ transition: all 0.2s ease;
|
|
|
+ cursor: pointer;
|
|
|
+
|
|
|
+ &:hover,
|
|
|
+ &.is-dragover {
|
|
|
+ border-color: #3b82f6;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .upload-dragger-content {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ gap: 6px;
|
|
|
+ min-height: 176px;
|
|
|
+ padding: 24px 0;
|
|
|
+ box-sizing: border-box;
|
|
|
+ color: #475569;
|
|
|
+ }
|
|
|
+
|
|
|
+ .upload-dragger-icon {
|
|
|
+ width: 28px;
|
|
|
+ height: 28px;
|
|
|
+ border-radius: 8px;
|
|
|
+ background: rgba(59, 130, 246, 0.1);
|
|
|
+ color: #2563eb;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ font-size: 14px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .upload-dragger-title {
|
|
|
+ font-size: 13px;
|
|
|
+ font-weight: 600;
|
|
|
+ color: #334155;
|
|
|
+ }
|
|
|
+
|
|
|
+ .upload-action-btn {
|
|
|
+ margin-top: 2px;
|
|
|
+ height: 26px;
|
|
|
+ padding: 0 14px;
|
|
|
+ border-radius: 6px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .upload-file-list {
|
|
|
+ flex: 1 1 auto;
|
|
|
+ min-height: 0;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ border: 1px solid #e2e8f0;
|
|
|
+ border-radius: 12px;
|
|
|
+ background: #ffffff;
|
|
|
+ overflow: hidden;
|
|
|
+
|
|
|
+ &__header {
|
|
|
+ flex-shrink: 0;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
+ padding: 8px 12px;
|
|
|
+ background: #f8fafc;
|
|
|
+ border-bottom: 1px solid #e2e8f0;
|
|
|
+ font-size: 13px;
|
|
|
+ color: #475569;
|
|
|
+ font-weight: 500;
|
|
|
+ }
|
|
|
+
|
|
|
+ &__body {
|
|
|
+ flex: 1 1 auto;
|
|
|
+ min-height: 0;
|
|
|
+ overflow-y: auto;
|
|
|
+ padding: 4px 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ &--empty {
|
|
|
+ flex: 1 1 auto;
|
|
|
+ border-style: dashed;
|
|
|
+ background: #fafafa;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .upload-empty {
|
|
|
+ margin: auto;
|
|
|
+ padding: 24px 12px;
|
|
|
+ color: #9ca3af;
|
|
|
+ font-size: 13px;
|
|
|
+ text-align: center;
|
|
|
+ }
|
|
|
+
|
|
|
+ .upload-file-item {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
+ padding: 6px 12px;
|
|
|
+ gap: 12px;
|
|
|
+ transition: background 0.15s ease;
|
|
|
+
|
|
|
+ &:hover {
|
|
|
+ background: #f8fafc;
|
|
|
+ }
|
|
|
+
|
|
|
+ &__info {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ gap: 10px;
|
|
|
+ min-width: 0;
|
|
|
+ flex: 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ &__name {
|
|
|
+ font-size: 13px;
|
|
|
+ color: #1e293b;
|
|
|
+ white-space: nowrap;
|
|
|
+ overflow: hidden;
|
|
|
+ text-overflow: ellipsis;
|
|
|
+ max-width: 300px;
|
|
|
+ }
|
|
|
+
|
|
|
+ &__size {
|
|
|
+ font-size: 12px;
|
|
|
+ color: #94a3b8;
|
|
|
+ flex-shrink: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ &__status {
|
|
|
+ flex-shrink: 0;
|
|
|
+ font-size: 12px;
|
|
|
+ min-width: 48px;
|
|
|
+ text-align: right;
|
|
|
+ }
|
|
|
+
|
|
|
+ &__remove {
|
|
|
+ flex-shrink: 0;
|
|
|
+ display: inline-flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ width: 22px;
|
|
|
+ height: 22px;
|
|
|
+ padding: 0;
|
|
|
+ border: none;
|
|
|
+ border-radius: 6px;
|
|
|
+ background: transparent;
|
|
|
+ color: #9ca3af;
|
|
|
+ font-size: 11px;
|
|
|
+ cursor: pointer;
|
|
|
+ transition:
|
|
|
+ background 0.15s ease,
|
|
|
+ color 0.15s ease;
|
|
|
+
|
|
|
+ &:hover {
|
|
|
+ background: #fef2f2;
|
|
|
+ color: #dc2626;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ &__error {
|
|
|
+ color: #dc2626;
|
|
|
+ font-weight: 600;
|
|
|
+ }
|
|
|
+
|
|
|
+ &__progress-text {
|
|
|
+ color: #2563eb;
|
|
|
+ font-weight: 500;
|
|
|
+ }
|
|
|
+
|
|
|
+ &__pending {
|
|
|
+ color: #94a3b8;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .upload-overall-progress {
|
|
|
+ flex-shrink: 0;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ gap: 10px;
|
|
|
+ padding: 8px 12px;
|
|
|
+ border-top: 1px solid #e2e8f0;
|
|
|
+
|
|
|
+ &__bar {
|
|
|
+ flex: 1;
|
|
|
+ height: 5px;
|
|
|
+ border-radius: 3px;
|
|
|
+ background: #e2e8f0;
|
|
|
+ overflow: hidden;
|
|
|
+ }
|
|
|
+
|
|
|
+ &__fill {
|
|
|
+ height: 100%;
|
|
|
+ border-radius: 3px;
|
|
|
+ background: #2563eb;
|
|
|
+ transition: width 0.3s ease;
|
|
|
+ }
|
|
|
+
|
|
|
+ &__text {
|
|
|
+ font-size: 12px;
|
|
|
+ color: #475569;
|
|
|
+ font-weight: 500;
|
|
|
+ white-space: nowrap;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @media (max-width: 1080px) {
|
|
|
+ .upload-layout {
|
|
|
+ flex-direction: column;
|
|
|
+ }
|
|
|
+
|
|
|
+ .left-panel {
|
|
|
+ flex: 0 0 auto;
|
|
|
+ width: auto;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ html[data-theme='dark'] {
|
|
|
+ .@{prefix-cls}.case-eds-upload-page {
|
|
|
+ background: #0f172a;
|
|
|
+
|
|
|
+ .page-header {
|
|
|
+ border-color: #1f2937;
|
|
|
+ background: #111827;
|
|
|
+ box-shadow: none;
|
|
|
+ }
|
|
|
+
|
|
|
+ .page-header__divider {
|
|
|
+ background: #1f2937;
|
|
|
+ }
|
|
|
+
|
|
|
+ .back-btn {
|
|
|
+ border-color: #334155;
|
|
|
+ background: #0f172a;
|
|
|
+ color: #cbd5e1;
|
|
|
+
|
|
|
+ &:hover,
|
|
|
+ &:focus,
|
|
|
+ &:focus-visible {
|
|
|
+ border-color: #3b82f6;
|
|
|
+ background: #1e293b;
|
|
|
+ color: #93c5fd;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .page-title,
|
|
|
+ .panel-title,
|
|
|
+ .upload-dragger-title,
|
|
|
+ .upload-file-item__name,
|
|
|
+ .cell-file-name {
|
|
|
+ color: #e5e7eb;
|
|
|
+ }
|
|
|
+
|
|
|
+ .panel-desc,
|
|
|
+ .panel-stats,
|
|
|
+ .upload-file-item__size,
|
|
|
+ .upload-file-item__pending,
|
|
|
+ .cell-index,
|
|
|
+ .cell-message {
|
|
|
+ color: #9ca3af;
|
|
|
+ }
|
|
|
+
|
|
|
+ .cell-message.is-error {
|
|
|
+ color: #f87171;
|
|
|
+ }
|
|
|
+
|
|
|
+ .left-panel,
|
|
|
+ .right-panel,
|
|
|
+ .upload-file-list {
|
|
|
+ background: #111827;
|
|
|
+ border-color: #1f2937;
|
|
|
+ }
|
|
|
+
|
|
|
+ .panel-header,
|
|
|
+ .upload-file-list__header,
|
|
|
+ .upload-overall-progress {
|
|
|
+ border-color: #1f2937;
|
|
|
+ }
|
|
|
+
|
|
|
+ .upload-file-list__header {
|
|
|
+ background: #0f172a;
|
|
|
+ color: #cbd5e1;
|
|
|
+ }
|
|
|
+
|
|
|
+ .upload-file-item:hover {
|
|
|
+ background: #1f2937;
|
|
|
+ }
|
|
|
+
|
|
|
+ .upload-dropzone {
|
|
|
+ border-color: #334155;
|
|
|
+ background: #0f172a;
|
|
|
+ }
|
|
|
+
|
|
|
+ .upload-overall-progress__bar {
|
|
|
+ background: #1f2937;
|
|
|
+ }
|
|
|
+
|
|
|
+ .eds-process-table {
|
|
|
+ :deep(.ant-table-thead > tr > th) {
|
|
|
+ background: #0f172a;
|
|
|
+ color: #94a3b8;
|
|
|
+ border-bottom-color: #1f2937;
|
|
|
+ }
|
|
|
+
|
|
|
+ :deep(.ant-table-tbody > tr > td) {
|
|
|
+ border-bottom-color: #111827;
|
|
|
+ }
|
|
|
+
|
|
|
+ :deep(.ant-table-tbody > tr:hover > td) {
|
|
|
+ background: #1f2937;
|
|
|
+ }
|
|
|
+
|
|
|
+ :deep(.ant-table-empty .ant-table-tbody > tr > td) {
|
|
|
+ color: #9ca3af;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /* 超长单元格 Tooltip:限宽 + 自动换行,替代浏览器原生 title 提示 */
|
|
|
+ .eds-cell-tooltip {
|
|
|
+ max-width: 520px;
|
|
|
+
|
|
|
+ .ant-tooltip-inner {
|
|
|
+ max-width: 520px;
|
|
|
+ max-height: 220px;
|
|
|
+ overflow-y: auto;
|
|
|
+ white-space: normal;
|
|
|
+ word-break: break-all;
|
|
|
+ line-height: 1.6;
|
|
|
+ font-size: 12px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+</style>
|