feat(ui): 工作台界面全部替换为element plus
This commit is contained in:
1 parent
26d213c05b
commit
d5f988a16c
38 files changed
+4501
-3087
No files matched your search
+166
-156
@@ -1,13 +1,25 @@
|
||||
/**
|
||||
* features/workspace/shipping-task-center/ShippingRunProgressTable.vue
|
||||
* 用途:任务中心「我的识别」续办表——展示用户自有抽取 Run 的阶段、耗时、取消态与续办动作。
|
||||
* 依赖:shipping.api 分页列表/取消/重试、vue-i18n、vue-router、orderExtractionProgressDisplay。
|
||||
* 逻辑:事实来自后端投影;打开会话/复核深链到 Chat;取消/重试复用工作台 API。
|
||||
* 依赖:shipping.api 分页列表/取消/重试、element-plus、vue-i18n、vue-router、orderExtractionProgressDisplay。
|
||||
* 逻辑:事实来自后端投影;打开会话/复核深链到 Chat;取消/重试复用工作台 API。样式由任务中心页引入。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRouter } from 'vue-router';
|
||||
import {
|
||||
ElButton,
|
||||
ElInput,
|
||||
ElLoading,
|
||||
ElOption,
|
||||
ElPagination,
|
||||
ElSelect,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
ElTag,
|
||||
ElText,
|
||||
} from 'element-plus';
|
||||
import {
|
||||
cancelWorkspaceShippingOrderExtractionRun,
|
||||
listShippingChatAgents,
|
||||
@@ -18,6 +30,7 @@ import {
|
||||
import type { ShippingOrderExtractionRun } from '@/features/chat/types/shipping.api.types';
|
||||
import { formatOrderExtractionElapsed, resolveOrderExtractionRunStageKey } from '@/features/chat/shipping/orderExtractionProgressDisplay';
|
||||
|
||||
const vLoading = ElLoading.directive;
|
||||
const { t, te } = useI18n();
|
||||
const router = useRouter();
|
||||
|
||||
@@ -32,6 +45,7 @@ const total = ref(0);
|
||||
const rows = ref<ShippingOrderExtractionRun[]>([]);
|
||||
const chatAgentId = ref<number | null>(null);
|
||||
const error = ref('');
|
||||
const statusOptions = ['queued', 'processing', 'completed', 'partially_completed', 'review_required', 'failed', 'cancelled'];
|
||||
|
||||
/**
|
||||
* 解析货代 Chat Agent,供会话深链。
|
||||
@@ -70,6 +84,7 @@ async function load() {
|
||||
/**
|
||||
* 用户可见阶段文案;无投影时回退状态文案。
|
||||
* v2:key 构造改走共享 resolveOrderExtractionRunStageKey(输出不变,仅事实解析同源)。
|
||||
* @param run - 识别 Run
|
||||
*/
|
||||
function stageLabel(run: ShippingOrderExtractionRun): string {
|
||||
const stage = String(run.current_activity?.user_visible_stage || '').trim();
|
||||
@@ -83,6 +98,7 @@ function stageLabel(run: ShippingOrderExtractionRun): string {
|
||||
|
||||
/**
|
||||
* 打开所属会话;活动 Run 进入聊天进度面。
|
||||
* @param run - 识别 Run
|
||||
*/
|
||||
async function openInChat(run: ShippingOrderExtractionRun) {
|
||||
const agentId = Number(run.agent_id || chatAgentId.value || 0);
|
||||
@@ -97,7 +113,11 @@ async function openInChat(run: ShippingOrderExtractionRun) {
|
||||
await router.push({ path: `/chat/${agentId}`, query });
|
||||
}
|
||||
|
||||
/** 请求取消整批;排队立即取消,执行中进入正在取消。 */
|
||||
/**
|
||||
* 请求取消整批;排队立即取消,执行中进入正在取消。
|
||||
* @param run - 识别 Run
|
||||
* @param reason - 可选取消原因
|
||||
*/
|
||||
async function submitCancelRun(run: ShippingOrderExtractionRun, reason?: string | null) {
|
||||
if (actingRunNo.value) return;
|
||||
actingRunNo.value = run.run_no;
|
||||
@@ -117,6 +137,7 @@ async function submitCancelRun(run: ShippingOrderExtractionRun, reason?: string
|
||||
|
||||
/**
|
||||
* 展开/收起单行取消表单。
|
||||
* @param run - 识别 Run
|
||||
*/
|
||||
function beginCancelRun(run: ShippingOrderExtractionRun) {
|
||||
if (pendingCancelRunNo.value === run.run_no) {
|
||||
@@ -130,6 +151,7 @@ function beginCancelRun(run: ShippingOrderExtractionRun) {
|
||||
|
||||
/**
|
||||
* 重试失败附件。
|
||||
* @param run - 识别 Run
|
||||
*/
|
||||
async function retryRun(run: ShippingOrderExtractionRun) {
|
||||
if (actingRunNo.value) return;
|
||||
@@ -144,6 +166,23 @@ async function retryRun(run: ShippingOrderExtractionRun) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态筛选。清空写回空字符串,接口仍查全部状态。
|
||||
* @param value - 状态码;清空为 undefined
|
||||
*/
|
||||
function onStatusChange(value: string | undefined): void {
|
||||
status.value = value ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 翻页并重新加载。
|
||||
* @param nextPage - 1-based 页码
|
||||
*/
|
||||
function onPageChange(nextPage: number): void {
|
||||
page.value = nextPage;
|
||||
void load();
|
||||
}
|
||||
|
||||
watch(status, () => {
|
||||
page.value = 1;
|
||||
void load();
|
||||
@@ -161,166 +200,137 @@ defineExpose({ reload: load });
|
||||
<section class="space-y-3" data-testid="shipping-run-progress-table">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<div>
|
||||
<h3 class="text-base font-semibold text-primary">{{ t('workspace.shippingNotice.myRuns.title') }}</h3>
|
||||
<p class="text-xs text-muted">{{ t('workspace.shippingNotice.myRuns.subtitle') }}</p>
|
||||
<h3>{{ t('workspace.shippingNotice.myRuns.title') }}</h3>
|
||||
<ElText type="info" size="small">{{ t('workspace.shippingNotice.myRuns.subtitle') }}</ElText>
|
||||
</div>
|
||||
<label class="flex items-center gap-2 text-sm text-secondary">
|
||||
{{ t('workspace.shippingNotice.myRuns.status') }}
|
||||
<select v-model="status" class="input-field py-1.5 text-sm">
|
||||
<option value="">{{ t('workspace.shippingNotice.myRuns.allStatuses') }}</option>
|
||||
<option
|
||||
v-for="value in ['queued', 'processing', 'completed', 'partially_completed', 'review_required', 'failed', 'cancelled']"
|
||||
:key="value"
|
||||
:value="value"
|
||||
>
|
||||
{{ t(`chat.shippingOrderExtractionCardTitle.${value}`) }}
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
<ElSelect
|
||||
class="run-status-select"
|
||||
:model-value="status || undefined"
|
||||
clearable
|
||||
:placeholder="t('workspace.shippingNotice.myRuns.allStatuses')"
|
||||
:aria-label="t('workspace.shippingNotice.myRuns.status')"
|
||||
@update:model-value="onStatusChange"
|
||||
>
|
||||
<ElOption
|
||||
v-for="value in statusOptions"
|
||||
:key="value"
|
||||
:value="value"
|
||||
:label="t(`chat.shippingOrderExtractionCardTitle.${value}`)"
|
||||
/>
|
||||
</ElSelect>
|
||||
</div>
|
||||
|
||||
<p v-if="error" class="rounded-lg border border-rose-200 bg-rose-50 p-3 text-sm text-rose-700">{{ error }}</p>
|
||||
<ElText v-if="error" type="danger">{{ error }}</ElText>
|
||||
|
||||
<div class="overflow-x-auto rounded-xl border border-default bg-surface">
|
||||
<table class="min-w-[860px] w-full text-left text-sm">
|
||||
<thead class="border-b border-default bg-surface-soft text-xs text-muted">
|
||||
<tr>
|
||||
<th class="px-3 py-2">{{ t('workspace.shippingNotice.myRuns.runNo') }}</th>
|
||||
<th class="px-3 py-2">{{ t('workspace.shippingNotice.myRuns.status') }}</th>
|
||||
<th class="px-3 py-2">{{ t('workspace.shippingNotice.myRuns.stage') }}</th>
|
||||
<th class="px-3 py-2">{{ t('workspace.shippingNotice.myRuns.summary') }}</th>
|
||||
<th class="px-3 py-2">{{ t('workspace.shippingNotice.myRuns.elapsed') }}</th>
|
||||
<th class="px-3 py-2">{{ t('workspace.shippingNotice.myRuns.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="loading">
|
||||
<td colspan="6" class="px-3 py-8 text-center text-muted">{{ t('workspace.shippingNotice.myRuns.loading') }}</td>
|
||||
</tr>
|
||||
<tr v-else-if="!rows.length">
|
||||
<td colspan="6" class="px-3 py-8 text-center text-muted">{{ t('workspace.shippingNotice.myRuns.empty') }}</td>
|
||||
</tr>
|
||||
<tr
|
||||
v-for="run in rows"
|
||||
:key="run.run_no"
|
||||
class="border-b border-default last:border-0"
|
||||
<ElTable
|
||||
v-loading="loading"
|
||||
:data="rows"
|
||||
row-key="run_no"
|
||||
:empty-text="t('workspace.shippingNotice.myRuns.empty')"
|
||||
>
|
||||
<ElTableColumn prop="run_no" :label="t('workspace.shippingNotice.myRuns.runNo')" min-width="160" />
|
||||
<ElTableColumn :label="t('workspace.shippingNotice.myRuns.status')" min-width="160">
|
||||
<template #default="{ row }">
|
||||
{{ t(`chat.shippingOrderExtractionCardTitle.${(row as ShippingOrderExtractionRun).status}`) }}
|
||||
<ElTag
|
||||
v-if="(row as ShippingOrderExtractionRun).cancellation?.requested && !(row as ShippingOrderExtractionRun).cancellation?.completed_at"
|
||||
type="warning"
|
||||
effect="light"
|
||||
>
|
||||
<td class="px-3 py-2 font-mono text-xs">{{ run.run_no }}</td>
|
||||
<td class="px-3 py-2">
|
||||
{{ t(`chat.shippingOrderExtractionCardTitle.${run.status}`) }}
|
||||
<span
|
||||
v-if="run.cancellation?.requested && !run.cancellation?.completed_at"
|
||||
class="ml-1 rounded-full bg-amber-100 px-1.5 py-0.5 text-[10px] text-amber-800"
|
||||
{{ t('chat.shippingOrderExtractionUserStage.cancellation_requested') }}
|
||||
</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('workspace.shippingNotice.myRuns.stage')" min-width="160">
|
||||
<template #default="{ row }">
|
||||
<div>{{ stageLabel(row as ShippingOrderExtractionRun) }}</div>
|
||||
<ElText v-if="(row as ShippingOrderExtractionRun).current_activity?.file_name" type="info" size="small">
|
||||
{{ (row as ShippingOrderExtractionRun).current_activity?.file_name }}
|
||||
</ElText>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('workspace.shippingNotice.myRuns.summary')" min-width="220">
|
||||
<template #default="{ row }">
|
||||
{{ t('workspace.shippingNotice.myRuns.summaryCounts', {
|
||||
total: (row as ShippingOrderExtractionRun).summary?.total_documents || 0,
|
||||
done: (row as ShippingOrderExtractionRun).summary?.completed_documents || 0,
|
||||
review: (row as ShippingOrderExtractionRun).summary?.review_required_documents || 0,
|
||||
failed: (row as ShippingOrderExtractionRun).summary?.failed_documents || 0,
|
||||
cancelled: (row as ShippingOrderExtractionRun).summary?.cancelled_documents || 0,
|
||||
}) }}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('workspace.shippingNotice.myRuns.elapsed')" min-width="100">
|
||||
<template #default="{ row }">
|
||||
{{ formatOrderExtractionElapsed((row as ShippingOrderExtractionRun).current_activity?.elapsed_seconds) || '—' }}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('workspace.shippingNotice.myRuns.actions')" min-width="220" align="right">
|
||||
<template #default="{ row }">
|
||||
<ElButton link type="primary" @click="openInChat(row as ShippingOrderExtractionRun)">
|
||||
{{ t('workspace.shippingNotice.myRuns.openChat') }}
|
||||
</ElButton>
|
||||
<template v-if="((row as ShippingOrderExtractionRun).available_actions || []).includes('cancel_run')">
|
||||
<div v-if="pendingCancelRunNo === (row as ShippingOrderExtractionRun).run_no">
|
||||
<div>{{ t('chat.shippingOrderExtractionCancel.reasonOptional') }}</div>
|
||||
<ElInput v-model="cancelReason" type="textarea" :rows="2" />
|
||||
<ElButton
|
||||
link
|
||||
type="danger"
|
||||
:loading="actingRunNo === (row as ShippingOrderExtractionRun).run_no"
|
||||
@click="submitCancelRun(row as ShippingOrderExtractionRun, cancelReason)"
|
||||
>
|
||||
{{ t('chat.shippingOrderExtractionUserStage.cancellation_requested') }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-3 py-2">
|
||||
<div>{{ stageLabel(run) }}</div>
|
||||
<div v-if="run.current_activity?.file_name" class="text-[11px] text-muted">
|
||||
{{ run.current_activity.file_name }}
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-3 py-2 text-xs text-secondary">
|
||||
{{ t('workspace.shippingNotice.myRuns.summaryCounts', {
|
||||
total: run.summary?.total_documents || 0,
|
||||
done: run.summary?.completed_documents || 0,
|
||||
review: run.summary?.review_required_documents || 0,
|
||||
failed: run.summary?.failed_documents || 0,
|
||||
cancelled: run.summary?.cancelled_documents || 0,
|
||||
}) }}
|
||||
</td>
|
||||
<td class="px-3 py-2 text-xs">
|
||||
{{ formatOrderExtractionElapsed(run.current_activity?.elapsed_seconds) || '—' }}
|
||||
</td>
|
||||
<td class="px-3 py-2">
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="text-xs font-medium text-brand-700 hover:underline"
|
||||
@click="openInChat(run)"
|
||||
>
|
||||
{{ t('workspace.shippingNotice.myRuns.openChat') }}
|
||||
</button>
|
||||
<template v-if="(run.available_actions || []).includes('cancel_run')">
|
||||
<div
|
||||
v-if="pendingCancelRunNo === run.run_no"
|
||||
class="w-full min-w-[220px] space-y-1.5 rounded-md border border-rose-200 bg-rose-50/60 p-2 dark:border-rose-900/40 dark:bg-rose-950/20"
|
||||
>
|
||||
<label class="block text-[11px] text-secondary">
|
||||
{{ t('chat.shippingOrderExtractionCancel.reasonOptional') }}
|
||||
</label>
|
||||
<textarea
|
||||
v-model="cancelReason"
|
||||
rows="2"
|
||||
class="input-field w-full py-1 text-xs"
|
||||
/>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="text-xs font-medium text-rose-700 hover:underline"
|
||||
:disabled="actingRunNo === run.run_no"
|
||||
@click="submitCancelRun(run, cancelReason)"
|
||||
>
|
||||
{{ actingRunNo === run.run_no
|
||||
? t('chat.shippingOrderExtractionCancel.submitting')
|
||||
: t('chat.shippingOrderExtractionAction.cancel_run') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="text-xs text-muted hover:underline"
|
||||
:disabled="actingRunNo === run.run_no"
|
||||
@click="pendingCancelRunNo = ''; cancelReason = ''"
|
||||
>
|
||||
{{ t('chat.shippingOrderExtractionCancel.dismiss') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
v-else
|
||||
type="button"
|
||||
class="text-xs font-medium text-rose-700 hover:underline"
|
||||
:disabled="actingRunNo === run.run_no"
|
||||
@click="beginCancelRun(run)"
|
||||
>
|
||||
{{ t('chat.shippingOrderExtractionAction.cancel_run') }}
|
||||
</button>
|
||||
</template>
|
||||
<button
|
||||
v-if="(run.available_actions || []).includes('retry_failed_attachments')"
|
||||
type="button"
|
||||
class="text-xs font-medium text-secondary hover:underline"
|
||||
:disabled="actingRunNo === run.run_no"
|
||||
@click="retryRun(run)"
|
||||
>
|
||||
{{ t('chat.shippingOrderExtractionAction.retry_failed_attachments') }}
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{{ actingRunNo === (row as ShippingOrderExtractionRun).run_no
|
||||
? t('chat.shippingOrderExtractionCancel.submitting')
|
||||
: t('chat.shippingOrderExtractionAction.cancel_run') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
link
|
||||
:disabled="actingRunNo === (row as ShippingOrderExtractionRun).run_no"
|
||||
@click="pendingCancelRunNo = ''; cancelReason = ''"
|
||||
>
|
||||
{{ t('chat.shippingOrderExtractionCancel.dismiss') }}
|
||||
</ElButton>
|
||||
</div>
|
||||
<ElButton
|
||||
v-else
|
||||
link
|
||||
type="danger"
|
||||
:disabled="actingRunNo === (row as ShippingOrderExtractionRun).run_no"
|
||||
@click="beginCancelRun(row as ShippingOrderExtractionRun)"
|
||||
>
|
||||
{{ t('chat.shippingOrderExtractionAction.cancel_run') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
<ElButton
|
||||
v-if="((row as ShippingOrderExtractionRun).available_actions || []).includes('retry_failed_attachments')"
|
||||
link
|
||||
:disabled="actingRunNo === (row as ShippingOrderExtractionRun).run_no"
|
||||
@click="retryRun(row as ShippingOrderExtractionRun)"
|
||||
>
|
||||
{{ t('chat.shippingOrderExtractionAction.retry_failed_attachments') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
|
||||
<div class="flex items-center justify-end gap-3 text-sm">
|
||||
<span class="text-xs text-muted">{{ t('workspace.shippingNotice.myRuns.total', { count: total }) }}</span>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded border border-default px-3 py-1.5 disabled:opacity-50"
|
||||
:disabled="page <= 1 || loading"
|
||||
@click="page -= 1; load()"
|
||||
>
|
||||
{{ t('workspace.shippingNotice.myRuns.previous') }}
|
||||
</button>
|
||||
<span>{{ page }}</span>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded border border-default px-3 py-1.5 disabled:opacity-50"
|
||||
:disabled="page * pageSize >= total || loading"
|
||||
@click="page += 1; load()"
|
||||
>
|
||||
{{ t('workspace.shippingNotice.myRuns.next') }}
|
||||
</button>
|
||||
<div class="flex items-center justify-end gap-3">
|
||||
<ElText type="info" size="small">{{ t('workspace.shippingNotice.myRuns.total', { count: total }) }}</ElText>
|
||||
<ElPagination
|
||||
:current-page="page"
|
||||
:page-size="pageSize"
|
||||
:total="total"
|
||||
layout="prev, pager, next"
|
||||
background
|
||||
:disabled="loading"
|
||||
@current-change="onPageChange"
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.run-status-select {
|
||||
width: 12rem;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user