feat(equipment-acceptance): 补抓E8数据并更新需求文档

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
sophieandCursor committed 2026-10-28 10:55:09 +08:00
1 parent f0334e5d22
commit 02aa00e913
47 files changed
+4423 -1261

No files matched your search

@@ -1,19 +1,30 @@
<!--
features/equipment-acceptance/components/EquipmentAcceptanceChatPanel.vue
用途:设备验收预警 Chat 主区:停留列表、详情、发送记录、预警配置,以及管理员同步、扫描和发送。
依赖:停留列表、详情、发送记录、配置页、auth.store、equipment-acceptance.api、DeleteConfirmDialog、vue-router query。
依赖:停留列表、详情、发送记录、配置页、Element Plus、auth.store、equipment-acceptance.api、vue-router query。
逻辑:由 ChatViewContent 在 agent_code=equipment_acceptance 时替换消息列表与输入框。
本文件引入 Element 样式并包住 ElConfigProvider。标题和页签压到两行,下面整块留给当前页。
view=config 打开预警配置;view=sends 打开发送记录;orderId 只在停留列表下钻。
同步只在停留列表。扫描和发送只在发送记录,且仅平台管理员可见。
-->
<script setup lang="ts">
import { computed, ref } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { RefreshCw } from 'lucide-vue-next';
import { Refresh } from '@element-plus/icons-vue';
import { useI18n } from 'vue-i18n';
import {
ElButton,
ElConfigProvider,
ElMessageBox,
ElTabPane,
ElTabs,
} from 'element-plus';
import 'element-plus/dist/index.css';
import 'element-plus/theme-chalk/dark/css-vars.css';
import '@/features/admin/styles/element-trial.css';
import { BusinessError } from '@/shared/api/client';
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
import { useAuthStore } from '@/features/auth/stores/auth.store';
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
import { useMessage } from '@/shared/composables/useMessage';
import {
scanEquipmentAcceptanceAlerts,
@@ -32,9 +43,9 @@ const route = useRoute();
const router = useRouter();
const auth = useAuthStore();
const msg = useMessage();
const { elementLocale } = useElementProvider();
const syncing = ref(false);
const alertRunning = ref(false);
const pendingAlert = ref<'scan' | 'send' | null>(null);
const runningAction = ref<'scan' | 'send' | null>(null);
const listPage = ref<{ reload: () => Promise<void> } | null>(null);
const sendsPage = ref<{ reload: () => Promise<void> } | null>(null);
@@ -44,17 +55,6 @@ const activeView = computed<WorkspaceView>(() => {
if (route.query.view === 'sends') return 'sends';
return 'ledger';
});
const showAlertConfirm = computed({
get: () => pendingAlert.value !== null,
set: (open: boolean) => {
if (!open) pendingAlert.value = null;
},
});
const alertConfirmCopy = computed(() => (
pendingAlert.value === 'send'
? { title: t('admin.equipmentAcceptance.sendAlerts'), message: t('admin.equipmentAcceptance.sendConfirm') }
: { title: t('admin.equipmentAcceptance.scanAlerts'), message: t('admin.equipmentAcceptance.scanConfirm') }
));
const detailId = computed(() => {
if (activeView.value !== 'ledger') return null;
const raw = Number(route.query.orderId);
@@ -97,23 +97,33 @@ function selectView(view: WorkspaceView): void {
}
/**
* 管理员在发送记录页立即扫描或发送。
* 核心逻辑:公共确认框点确定后才调用。先取出动作再关掉弹窗,避免关闭时把待执行动作清掉。
* 只接受本页三个页签,避免 Element 回传任意字符串。
* @param name - 被点中的页签名
*/
function confirmAlertAction(): void {
const action = pendingAlert.value;
pendingAlert.value = null;
if (action) void runAlertAction(action);
function onTabChange(name: string | number): void {
if (name === 'ledger' || name === 'sends' || name === 'config') selectView(name);
}
/**
* 执行已经确认的扫描或发送。
* 核心逻辑:扫描会同步 E10;发送把待发送记录推到企业微信。
* 管理员在发送记录页确认后立即扫描或发送。
* 核心逻辑:确认框取消会拒绝,这里直接返回。扫描会同步 E10;发送把待发送记录推到企业微信。
* @param action - scan 或 send
*/
async function runAlertAction(action: 'scan' | 'send'): Promise<void> {
if (alertRunning.value) return;
alertRunning.value = true;
async function askAlert(action: 'scan' | 'send'): Promise<void> {
if (runningAction.value) return;
const copy = action === 'send'
? { title: t('admin.equipmentAcceptance.sendAlerts'), message: t('admin.equipmentAcceptance.sendConfirm') }
: { title: t('admin.equipmentAcceptance.scanAlerts'), message: t('admin.equipmentAcceptance.scanConfirm') };
try {
await ElMessageBox.confirm(copy.message, copy.title, {
type: 'warning',
confirmButtonText: t('common.deleteDialog.confirm'),
cancelButtonText: t('common.cancel'),
});
} catch {
return;
}
runningAction.value = action;
try {
if (action === 'scan') {
const result = await scanEquipmentAcceptanceAlerts();
@@ -133,12 +143,12 @@ async function runAlertAction(action: 'scan' | 'send'): Promise<void> {
} catch (error) {
msg.error(error instanceof BusinessError ? error.message : t('admin.equipmentAcceptance.syncFailed'));
} finally {
alertRunning.value = false;
runningAction.value = null;
}
}
/**
* 管理员从 E10 同步后刷新列表。
* 管理员从 OA 同步后刷新列表。
* 核心逻辑:成功提示写入、跳过和本次未见条数。失败展示业务错误。
*/
async function runSync(): Promise<void> {
@@ -161,65 +171,107 @@ async function runSync(): Promise<void> {
</script>
<template>
<section class="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-[var(--surface-muted,#f4f7fb)]">
<div class="flex flex-wrap items-center justify-between gap-2 px-5 pt-3">
<div class="min-w-0">
<h1 class="text-lg font-bold text-primary md:text-xl">{{ t('admin.equipmentAcceptance.title') }}</h1>
<ElConfigProvider :locale="elementLocale">
<section class="ea-workspace">
<header class="ea-workspace__bar">
<h1 class="section-title">{{ t('admin.equipmentAcceptance.title') }}</h1>
<div v-if="isAdmin && activeView === 'sends'" class="ea-workspace__actions">
<ElButton :loading="runningAction === 'scan'" :disabled="runningAction !== null" @click="askAlert('scan')">
{{ t('admin.equipmentAcceptance.scanAlerts') }}
</ElButton>
<ElButton :loading="runningAction === 'send'" :disabled="runningAction !== null" @click="askAlert('send')">
{{ t('admin.equipmentAcceptance.sendAlerts') }}
</ElButton>
</div>
<ElButton
v-else-if="isAdmin && activeView === 'ledger' && !detailId"
:icon="Refresh"
:loading="syncing"
@click="runSync"
>
{{ t('admin.equipmentAcceptance.sync') }}
</ElButton>
</header>
<ElTabs :model-value="activeView" class="ea-tabs" @tab-change="onTabChange">
<ElTabPane v-for="tab in tabs" :key="tab.key" :name="tab.key" :label="tab.label" />
</ElTabs>
<div class="ea-workspace__body">
<EquipmentAcceptanceDetailPage
v-if="detailId"
:order-id="detailId"
@back="syncQuery('ledger', null)"
/>
<EquipmentAcceptanceConfigPage
v-else-if="activeView === 'config'"
:editable="isAdmin"
/>
<EquipmentAcceptanceSendsPage v-else-if="activeView === 'sends'" ref="sendsPage" />
<EquipmentAcceptancePage
v-else
ref="listPage"
@open-detail="syncQuery('ledger', $event)"
/>
</div>
<div v-if="isAdmin && activeView === 'sends'" class="flex flex-wrap items-center gap-2">
<button class="btn-secondary-ds" type="button" :disabled="alertRunning" @click="pendingAlert = 'scan'">
{{ t('admin.equipmentAcceptance.scanAlerts') }}
</button>
<button class="btn-secondary-ds" type="button" :disabled="alertRunning" @click="pendingAlert = 'send'">
{{ t('admin.equipmentAcceptance.sendAlerts') }}
</button>
</div>
<button
v-if="isAdmin && activeView === 'ledger' && !detailId"
class="btn-secondary-ds"
type="button"
:disabled="syncing"
@click="runSync"
>
<RefreshCw class="h-4 w-4" aria-hidden="true" />{{ t('admin.equipmentAcceptance.sync') }}
</button>
</div>
<div class="mt-2 flex gap-0 border-b border-default px-5">
<button
v-for="tab in tabs"
:key="tab.key"
type="button"
class="mb-[-1px] border-b-2 px-3 py-2 text-sm font-bold"
:class="activeView === tab.key
? 'border-brand-500 text-brand-600'
: 'border-transparent text-muted hover:text-secondary'"
@click="selectView(tab.key)"
>
{{ tab.label }}
</button>
</div>
<EquipmentAcceptanceDetailPage
v-if="detailId"
:order-id="detailId"
@back="syncQuery('ledger', null)"
/>
<EquipmentAcceptanceConfigPage
v-else-if="activeView === 'config'"
:editable="isAdmin"
/>
<EquipmentAcceptanceSendsPage v-else-if="activeView === 'sends'" ref="sendsPage" />
<EquipmentAcceptancePage
v-else
ref="listPage"
@open-detail="syncQuery('ledger', $event)"
/>
<DeleteConfirmDialog
v-if="isAdmin"
v-model="showAlertConfirm"
:title="alertConfirmCopy.title"
:message="alertConfirmCopy.message"
confirm-tone="primary"
@confirm="confirmAlertAction"
/>
</section>
</section>
</ElConfigProvider>
</template>
<style scoped>
.ea-workspace {
display: flex;
flex: 1 1 auto;
flex-direction: column;
min-height: 0;
min-width: 0;
overflow: hidden;
background: var(--surface-muted, var(--el-fill-color-light));
}
.ea-workspace__bar {
display: flex;
flex: none;
align-items: center;
justify-content: space-between;
gap: 12px;
padding: 8px 16px 0;
}
.ea-workspace__actions {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.ea-tabs {
flex: none;
padding: 0 8px;
}
.ea-tabs :deep(.el-tabs__header) {
margin-bottom: 0;
}
.ea-tabs :deep(.el-tabs__nav-wrap::after) {
height: 1px;
background: var(--el-border-color-lighter);
}
.ea-tabs :deep(.el-tabs__content) {
display: none;
}
.ea-tabs :deep(.el-tabs__item) {
height: 36px;
padding: 0 12px;
font-size: var(--el-font-size-base);
line-height: 36px;
}
.ea-workspace__body {
display: flex;
flex: 1 1 auto;
flex-direction: column;
min-height: 0;
padding: 8px 12px 12px;
}
</style>