feat(ui): 工作台界面全部替换为element plus

This commit is contained in:
sophie committed 2026-10-29 09:38:38 +08:00
1 parent 26d213c05b
commit d5f988a16c
38 files changed
+4501 -3087

No files matched your search

@@ -1,14 +1,15 @@
<!--
features/workspace/shipping-task-center/ShippingTaskTable.vue
用途:任务中心紧凑表格(一行一待办):编号/阶段/状态摘要/项次缺口/货代状态。
依赖:shippingTaskCenterShared(编号、阶段、批量可选口径)。
依赖:shippingTaskCenterShared(编号、阶段、批量可选口径)、element-plus。
逻辑:行点击向上冒泡选中;复选框仅「货代上传」阶段的正式 Notice 行存在;
勾选 ≥1 后浮出深色批量操作条(低频操作不常驻);分页由父级渲染。
勾选 ≥1 后浮出批量操作条(低频操作不常驻);分页由父级渲染。样式由任务中心页引入。
-->
<script setup lang="ts">
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
import { CheckSquare, Download, Upload, X } from 'lucide-vue-next';
import { Close, Download, Select, Upload } from '@element-plus/icons-vue';
import { ElButton, ElCheckbox, ElTable, ElTableColumn, ElTag, ElText } from 'element-plus';
import type { ShippingTaskSummary } from '@/features/chat/api/shipping.api';
import {
isBatchDownloadableRow,
@@ -54,7 +55,10 @@ const allSelectableChecked = computed(() => (
&& selectableRows.value.every((item) => selectedSet.value.has(String(item.business_no)))
));
/** 阶段徽章文案:优先本地化阶段名,后端 label 兜底。 */
/**
* 阶段徽章文案:优先本地化阶段名,后端 label 兜底。
* @param item - 待办行
*/
function stageLabel(item: ShippingTaskSummary): string {
const code = lifecycleStageCodeOf(item);
const key = code ? `workspace.shippingNotice.myTodos.lifecycleStages.${code}` : '';
@@ -62,180 +66,164 @@ function stageLabel(item: ShippingTaskSummary): string {
return String(item.ui_state?.stage?.label || '—');
}
/**
* 状态摘要主文案。
* @param item - 待办行
*/
function rowTitle(item: ShippingTaskSummary): string {
return todoTitleText(item);
}
/**
* 阻断原因。空字符串表示当前行没有阻断。
* @param item - 待办行
*/
function rowBlocker(item: ShippingTaskSummary): string {
return todoBlockerText(item, t, te);
}
/**
* 项次数量短句。没有行时显示占位。
* @param item - 待办行
*/
function lineBriefText(item: ShippingTaskSummary): string {
const brief = todoLineBrief(item);
if (!brief.total) return '—';
return `${brief.total} ${t('workspace.shippingNotice.myTodos.table.lineUnit')}`;
}
/** 全选或取消当前页可批量行。 */
function onToggleAll(): void {
emit('toggle-all');
}
/**
* 点击表格行打开抽屉。复选框点击已 stop,不会进到这里。
* @param row - 当前待办
*/
function onRowClick(row: ShippingTaskSummary): void {
emit('select', row);
}
/**
* 行角标:复核、解析、只读或终态。没有角标时返回空。
* @param item - 待办行
*/
function badgeOf(item: ShippingTaskSummary): { type: 'warning' | 'info' | 'success' | 'danger'; label: string } | null {
if (item.todo_category === 'review' || item.item_kind === 'review_case') {
return { type: 'warning', label: t('workspace.shippingNotice.myTodos.openReview') };
}
if (item.todo_category === 'intake_parse' || item.item_kind === 'order_intake') {
return { type: 'info', label: t('workspace.shippingNotice.myTodos.intakeParseBadge') };
}
if (item.can_handle === false) {
return { type: 'info', label: t('workspace.shippingNotice.todo.adminViewOnlyShort') };
}
if (props.terminalBadge === 'upload_complete') {
return { type: 'success', label: t('workspace.shippingNotice.myTodos.terminal.uploadComplete') };
}
if (props.terminalBadge === 'reject_void') {
return { type: 'danger', label: t('workspace.shippingNotice.myTodos.terminal.rejectVoid') };
}
return null;
}
</script>
<template>
<div class="overflow-hidden rounded-2xl border border-default bg-surface">
<div
v-if="hasSelection"
class="flex flex-wrap items-center gap-2 bg-[#1b2740] px-4 py-2.5 text-sm text-slate-100"
class="flex flex-wrap items-center gap-2 bg-[#1b2740] px-4 py-2.5"
data-testid="shipping-notice-batch-toolbar"
>
<span class="rounded-full bg-brand-600 px-3 py-0.5 text-xs font-semibold">
<ElTag type="primary" effect="dark">
{{ $t('workspace.shippingNotice.batch.selected', { count: selectedBusinessNos?.length || 0 }) }}
</span>
<button
type="button"
class="rounded-lg border border-white/20 px-2.5 py-1 text-xs hover:bg-white/10 disabled:opacity-50"
:disabled="Boolean(batchBusy)"
@click="emit('batch', 'download')"
>
<Download class="mr-1 inline h-3.5 w-3.5" />
</ElTag>
<ElButton :icon="Download" :disabled="Boolean(batchBusy)" @click="emit('batch', 'download')">
{{ $t('workspace.shippingNotice.batch.download') }}
</button>
<button
type="button"
class="rounded-lg border border-white/20 px-2.5 py-1 text-xs hover:bg-white/10 disabled:opacity-50"
:disabled="Boolean(batchBusy)"
@click="emit('batch', 'confirm')"
>
<CheckSquare class="mr-1 inline h-3.5 w-3.5" />
</ElButton>
<ElButton :icon="Select" :disabled="Boolean(batchBusy)" @click="emit('batch', 'confirm')">
{{ $t('workspace.shippingNotice.batch.confirm') }}
</button>
<button
type="button"
class="rounded-lg border border-white/20 px-2.5 py-1 text-xs hover:bg-white/10 disabled:opacity-50"
:disabled="Boolean(batchBusy)"
@click="emit('batch', 'rpa')"
>
<Upload class="mr-1 inline h-3.5 w-3.5" />
</ElButton>
<ElButton :icon="Upload" :disabled="Boolean(batchBusy)" @click="emit('batch', 'rpa')">
{{ $t('workspace.shippingNotice.batch.rpa') }}
</button>
</ElButton>
<span class="flex-1" />
<button
type="button"
class="rounded-lg px-2.5 py-1 text-xs text-slate-300 hover:text-white"
@click="emit('clear-selection')"
>
<X class="mr-1 inline h-3.5 w-3.5" />
<ElButton :icon="Close" @click="emit('clear-selection')">
{{ $t('workspace.shippingNotice.batch.clearSelection') }}
</button>
</ElButton>
</div>
<div class="overflow-x-auto">
<table class="w-full border-collapse text-sm">
<thead>
<tr class="border-b border-default bg-surface-soft/60 text-left text-xs text-muted">
<th v-if="selectable" class="w-10 px-3 py-2.5">
<input
type="checkbox"
:checked="allSelectableChecked"
:aria-label="$t('workspace.shippingNotice.batch.selectAll')"
@change="onToggleAll"
>
</th>
<th class="px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.table.no') }}</th>
<th class="w-24 px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.table.stage') }}</th>
<th class="px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.table.summary') }}</th>
<th class="w-28 px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.table.lines') }}</th>
<th class="w-24 px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.table.freightStatus') }}</th>
</tr>
</thead>
<tbody>
<tr
v-for="item in items"
:key="todoItemKey(item)"
class="cursor-pointer border-b border-[#f0f3f8] transition-colors hover:bg-brand-50/40"
:class="selectedKey === todoItemKey(item) ? 'bg-brand-50/70 dark:bg-brand-950/30' : ''"
:data-testid="`my-todos-row-${todoDisplayNo(item)}`"
@click="emit('select', item)"
<ElTable
:data="items"
:row-key="todoItemKey"
:current-row-key="selectedKey || undefined"
highlight-current-row
@row-click="onRowClick"
>
<ElTableColumn v-if="selectable" width="64">
<template #header>
<ElCheckbox
:model-value="allSelectableChecked"
:aria-label="t('workspace.shippingNotice.batch.selectAll')"
@change="onToggleAll"
/>
</template>
<template #default="{ row }">
<span v-if="isBatchDownloadableRow(row as ShippingTaskSummary)" @click.stop>
<ElCheckbox
:model-value="selectedSet.has(String((row as ShippingTaskSummary).business_no))"
:aria-label="String((row as ShippingTaskSummary).business_no)"
@change="emit('toggle', row as ShippingTaskSummary)"
/>
</span>
</template>
</ElTableColumn>
<ElTableColumn :label="t('workspace.shippingNotice.myTodos.table.no')" min-width="220">
<template #default="{ row }">
<div :data-testid="`my-todos-row-${todoDisplayNo(row as ShippingTaskSummary)}`">
<span>{{ todoDisplayNo(row as ShippingTaskSummary) }}</span>
<ElTag v-if="badgeOf(row as ShippingTaskSummary)" :type="badgeOf(row as ShippingTaskSummary)?.type" effect="light">
{{ badgeOf(row as ShippingTaskSummary)?.label }}
</ElTag>
</div>
<ElText type="info" size="small">{{ todoSubTitleText(row as ShippingTaskSummary) || '—' }}</ElText>
</template>
</ElTableColumn>
<ElTableColumn :label="t('workspace.shippingNotice.myTodos.table.stage')" min-width="120">
<template #default="{ row }">
<ElTag effect="light">{{ stageLabel(row as ShippingTaskSummary) }}</ElTag>
</template>
</ElTableColumn>
<ElTableColumn :label="t('workspace.shippingNotice.myTodos.table.summary')" min-width="180">
<template #default="{ row }">
<div>{{ rowTitle(row as ShippingTaskSummary) }}</div>
<ElText
v-if="rowBlocker(row as ShippingTaskSummary)"
type="danger"
size="small"
data-testid="my-todos-row-blocker"
>
<td v-if="selectable" class="px-3 py-2.5 align-middle">
<input
v-if="isBatchDownloadableRow(item)"
type="checkbox"
:checked="selectedSet.has(String(item.business_no))"
:aria-label="String(item.business_no)"
@click.stop
@change="emit('toggle', item)"
>
</td>
<td class="max-w-[22rem] px-3 py-2.5 align-middle">
<div class="flex items-center gap-2">
<span class="truncate font-mono text-[13px] font-semibold text-primary">{{ todoDisplayNo(item) }}</span>
<span
v-if="item.todo_category === 'review' || item.item_kind === 'review_case'"
class="shrink-0 rounded bg-amber-50 px-1.5 py-0.5 text-[10px] text-amber-700"
>
{{ $t('workspace.shippingNotice.myTodos.openReview') }}
</span>
<span
v-else-if="item.todo_category === 'intake_parse' || item.item_kind === 'order_intake'"
class="shrink-0 rounded bg-violet-50 px-1.5 py-0.5 text-[10px] text-violet-700"
>
{{ $t('workspace.shippingNotice.myTodos.intakeParseBadge') }}
</span>
<span
v-else-if="item.can_handle === false"
class="shrink-0 rounded bg-slate-100 px-1.5 py-0.5 text-[10px] text-slate-600"
>
{{ $t('workspace.shippingNotice.todo.adminViewOnlyShort') }}
</span>
<span
v-else-if="terminalBadge === 'upload_complete'"
class="shrink-0 rounded bg-emerald-50 px-1.5 py-0.5 text-[10px] text-emerald-700"
>
{{ $t('workspace.shippingNotice.myTodos.terminal.uploadComplete') }}
</span>
<span
v-else-if="terminalBadge === 'reject_void'"
class="shrink-0 rounded bg-red-50 px-1.5 py-0.5 text-[10px] text-red-700"
>
{{ $t('workspace.shippingNotice.myTodos.terminal.rejectVoid') }}
</span>
</div>
<div class="mt-0.5 truncate text-xs text-muted">{{ todoSubTitleText(item) || '—' }}</div>
</td>
<td class="px-3 py-2.5 align-middle">
<span class="whitespace-nowrap rounded-full bg-brand-50 px-2 py-0.5 text-xs text-brand-800">
{{ stageLabel(item) }}
</span>
</td>
<td class="max-w-[18rem] px-3 py-2.5 align-middle">
<div class="truncate text-[13px] text-secondary">{{ rowTitle(item) }}</div>
<div
v-if="rowBlocker(item)"
class="mt-0.5 truncate text-xs text-red-600"
data-testid="my-todos-row-blocker"
>
{{ rowBlocker(item) }}
</div>
</td>
<td class="px-3 py-2.5 align-middle text-xs">
<template v-if="item.business_no">
<span>{{ lineBriefText(item) }}</span>
<span
v-if="todoLineBrief(item).shortage"
class="ml-1 font-semibold text-red-600"
>
{{ $t('workspace.shippingNotice.myTodos.table.shortage', { count: todoLineBrief(item).shortage }) }}
</span>
</template>
<span v-else class="text-muted">—</span>
</td>
<td class="px-3 py-2.5 align-middle text-xs text-secondary">
{{ item.business_no ? (item.upload_status || '—') : '—' }}
</td>
</tr>
</tbody>
</table>
</div>
{{ rowBlocker(row as ShippingTaskSummary) }}
</ElText>
</template>
</ElTableColumn>
<ElTableColumn :label="t('workspace.shippingNotice.myTodos.table.lines')" min-width="120">
<template #default="{ row }">
<template v-if="(row as ShippingTaskSummary).business_no">
<span>{{ lineBriefText(row as ShippingTaskSummary) }}</span>
<ElText v-if="todoLineBrief(row as ShippingTaskSummary).shortage" type="danger">
{{ t('workspace.shippingNotice.myTodos.table.shortage', { count: todoLineBrief(row as ShippingTaskSummary).shortage }) }}
</ElText>
</template>
<span v-else>—</span>
</template>
</ElTableColumn>
<ElTableColumn :label="t('workspace.shippingNotice.myTodos.table.freightStatus')" min-width="120">
<template #default="{ row }">
{{ (row as ShippingTaskSummary).business_no ? ((row as ShippingTaskSummary).upload_status || '—') : '—' }}
</template>
</ElTableColumn>
</ElTable>
</div>
</template>