feat(equipment-acceptance): 设备验收预警
This commit is contained in:
1 parent
239d373503
commit
86fc8a2c06
48 files changed
+6196
-82
No files matched your search
@@ -4,12 +4,12 @@
|
||||
|
||||
* 用途:对话页主区域,组合侧栏、消息列表、输入栏、货代会话 Workflow 时间线与内置浏览器。
|
||||
|
||||
* 依赖:ChatSidebar、ChatMessageList、ChatInputBar、ShippingWorkflowTimeline、ContractPaymentChatPanel、VoucherCheckChatPanel、chunkLoadRecovery、chat.context。
|
||||
* 依赖:ChatSidebar、ChatMessageList、ChatInputBar、ShippingWorkflowTimeline、ContractPaymentChatPanel、EquipmentAcceptanceChatPanel、VoucherCheckChatPanel、chunkLoadRecovery、chat.context。
|
||||
|
||||
* 逻辑:本文件只做页面结构编排;货代 Chat 仅上传/进度通知,履约写操作不在本页;
|
||||
* 货代会话主区域:有会话即全屏批次进度中心(常驻),无会话为欢迎页+输入框;会话标题取自侧栏历史并传给中心;
|
||||
* 右侧「本次处理」由 conversationId 驱动 Workflow projection,extractionRunNo 仅作进度装饰;
|
||||
* 订单复核工作台异步分包,避免普通对话首屏拉取 PDF.js;合同付款预警、立账凭证 Agent 用 Tab 作业面替换消息列表与输入框。
|
||||
* 订单复核工作台异步分包,避免普通对话首屏拉取 PDF.js;合同付款预警、设备验收预警、立账凭证 Agent 用作业面替换消息列表与输入框。
|
||||
|
||||
*/
|
||||
|
||||
@@ -47,7 +47,7 @@ import { useChatPageContext } from '@/features/chat/composables/chat.context';
|
||||
|
||||
import { matchesTrainingAgent } from '@/features/chat/training/trainingWorkspace.utils';
|
||||
|
||||
import { agentHasIntentUiProfile, resolveAgentCode, AGENT_CODE_IN_TRANSIT_TRANSFER, isContractPaymentAgent, isVoucherCheckAgent } from '@/shared/utils/agent-registry.utils';
|
||||
import { agentHasIntentUiProfile, resolveAgentCode, AGENT_CODE_IN_TRANSIT_TRANSFER, isContractPaymentAgent, isEquipmentAcceptanceAgent, isVoucherCheckAgent } from '@/shared/utils/agent-registry.utils';
|
||||
|
||||
import {
|
||||
SHIPPING_WORKFLOW_KEY,
|
||||
@@ -79,6 +79,10 @@ const ContractPaymentChatPanel = defineRecoverableAsyncComponent(
|
||||
() => import('@/features/contract-payment/components/ContractPaymentChatPanel.vue'),
|
||||
);
|
||||
|
||||
const EquipmentAcceptanceChatPanel = defineRecoverableAsyncComponent(
|
||||
() => import('@/features/equipment-acceptance/components/EquipmentAcceptanceChatPanel.vue'),
|
||||
);
|
||||
|
||||
const VoucherCheckChatPanel = defineRecoverableAsyncComponent(
|
||||
() => import('@/features/voucher-check/components/VoucherCheckChatPanel.vue'),
|
||||
);
|
||||
@@ -130,11 +134,14 @@ const isInTransitTransferAgent = computed(() => resolveAgentCode(page.currentAge
|
||||
/** 合同付款预警 Agent:主区嵌台账 Tab,隐藏对话输入与历史。 */
|
||||
const isContractPaymentAgentPage = computed(() => isContractPaymentAgent(page.currentAgent));
|
||||
|
||||
/** 设备验收预警 Agent:主区嵌停留列表,隐藏对话输入与历史。 */
|
||||
const isEquipmentAcceptanceAgentPage = computed(() => isEquipmentAcceptanceAgent(page.currentAgent));
|
||||
|
||||
/** 立账凭证 Agent:主区嵌检核任务 / 企微发送记录 Tab,隐藏对话输入与历史。 */
|
||||
const isVoucherCheckAgentPage = computed(() => isVoucherCheckAgent(page.currentAgent));
|
||||
|
||||
/** builtin 作业面 Agent 共用:隐藏新会话、历史列表与输入框。 */
|
||||
const hideTaskChatSessionUi = computed(() => isContractPaymentAgentPage.value || isVoucherCheckAgentPage.value);
|
||||
const hideTaskChatSessionUi = computed(() => isContractPaymentAgentPage.value || isEquipmentAcceptanceAgentPage.value || isVoucherCheckAgentPage.value);
|
||||
|
||||
/** 在途仓自动调拨业务流激活(来源选择/待处理等子视图)时隐藏聊天输入框,模拟业务页。 */
|
||||
const transferFlowActive = ref(false);
|
||||
@@ -489,6 +496,8 @@ watch(() => page.currentAgentId, () => {
|
||||
|
||||
<ContractPaymentChatPanel v-else-if="isContractPaymentAgentPage" />
|
||||
|
||||
<EquipmentAcceptanceChatPanel v-else-if="isEquipmentAcceptanceAgentPage" />
|
||||
|
||||
<VoucherCheckChatPanel v-else-if="isVoucherCheckAgentPage" />
|
||||
|
||||
<div v-else class="flex min-h-0 min-w-0 flex-1">
|
||||
|
||||
@@ -0,0 +1,227 @@
|
||||
/**
|
||||
* features/equipment-acceptance/api/equipment-acceptance.api.ts
|
||||
* 用途:设备验收预警同步列表、详情和手动同步。
|
||||
* 依赖:统一 requestJson;后端 /api/equipment-acceptance。
|
||||
* 逻辑:Chat 作业面调用。同步只读 E10。配置只保存天数和系统用户,不保存发送时刻。
|
||||
* 发送记录只读已落库的行,扫描尚未写入时列表为空。
|
||||
*/
|
||||
import { requestJson } from '@/shared/api/client';
|
||||
|
||||
export interface EquipmentAcceptanceNode {
|
||||
node_id?: string | null;
|
||||
node_name?: string | null;
|
||||
node_type?: number | null;
|
||||
}
|
||||
|
||||
export interface EquipmentAcceptanceOperator {
|
||||
node_id?: string | null;
|
||||
user_id?: string | null;
|
||||
handler_name?: string | null;
|
||||
handler_job_num?: string | null;
|
||||
}
|
||||
|
||||
export interface EquipmentAcceptanceOrder {
|
||||
id: number;
|
||||
acceptance_no?: string | null;
|
||||
purchase_order_no?: string | null;
|
||||
contract_no?: string | null;
|
||||
timer_started_at?: string | null;
|
||||
dwell_days?: number | null;
|
||||
can_accept?: number | null;
|
||||
cannot_accept_note?: string | null;
|
||||
is_returned?: number | null;
|
||||
flow_status_raw?: number | null;
|
||||
finished_at?: string | null;
|
||||
request_id?: string | null;
|
||||
request_match_count: number;
|
||||
owner_name?: string | null;
|
||||
owner_job_num?: string | null;
|
||||
applicant_name?: string | null;
|
||||
applicant_job_num?: string | null;
|
||||
monitor_status: string;
|
||||
overdue?: boolean;
|
||||
present_in_source: boolean;
|
||||
synced_at?: string | null;
|
||||
nodes: EquipmentAcceptanceNode[];
|
||||
operators: EquipmentAcceptanceOperator[];
|
||||
}
|
||||
|
||||
export interface EquipmentAcceptanceSummary {
|
||||
watching: number;
|
||||
overdue: number;
|
||||
stopped: number;
|
||||
not_started: number;
|
||||
}
|
||||
|
||||
export interface EquipmentAcceptanceListResponse {
|
||||
items: EquipmentAcceptanceOrder[];
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
pages: number;
|
||||
summary?: EquipmentAcceptanceSummary;
|
||||
}
|
||||
|
||||
export interface EquipmentAcceptanceSyncResult {
|
||||
upserted: number;
|
||||
skipped_without_request_id: number;
|
||||
absent: number;
|
||||
by_status: Record<string, number>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询已同步的验收单。
|
||||
* 核心逻辑:focus 对应原型分组。空或 all 不过滤。
|
||||
* @param params.focus - watching、overdue、stopped、not_started
|
||||
* @param params.page - 页码,从 1 开始
|
||||
* @param params.pageSize - 每页条数
|
||||
* @returns 分页快照和全部单据汇总
|
||||
*/
|
||||
export function listEquipmentAcceptanceOrders(params?: {
|
||||
focus?: string;
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
}) {
|
||||
const query = new URLSearchParams();
|
||||
if (params?.focus && params.focus !== 'all') query.set('focus', params.focus);
|
||||
if (params?.page) query.set('page', String(params.page));
|
||||
if (params?.pageSize) query.set('page_size', String(params.pageSize));
|
||||
const suffix = query.toString() ? `?${query.toString()}` : '';
|
||||
return requestJson<EquipmentAcceptanceListResponse>(`/api/equipment-acceptance/orders${suffix}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取一张验收单的节点和操作人。
|
||||
* @param orderId - 本地快照主键
|
||||
* @returns 快照详情
|
||||
*/
|
||||
export function getEquipmentAcceptanceOrder(orderId: number) {
|
||||
return requestJson<EquipmentAcceptanceOrder>(`/api/equipment-acceptance/orders/${orderId}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 E10 拉取验收单并更新本地快照。仅平台管理员可调用。
|
||||
* @returns 本次写入、跳过和未见条数
|
||||
*/
|
||||
export function syncEquipmentAcceptance() {
|
||||
return requestJson<EquipmentAcceptanceSyncResult>('/api/equipment-acceptance/sync', { method: 'POST' });
|
||||
}
|
||||
|
||||
export interface EquipmentAcceptanceScanResult {
|
||||
created: number;
|
||||
updated: number;
|
||||
cancelled: number;
|
||||
}
|
||||
|
||||
export interface EquipmentAcceptanceSendResult {
|
||||
sent: number;
|
||||
failed: number;
|
||||
records_sent: number;
|
||||
records_failed: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员立即同步 E10 并生成待发送记录。
|
||||
* @returns 新增、更新和取消条数
|
||||
*/
|
||||
export function scanEquipmentAcceptanceAlerts() {
|
||||
return requestJson<EquipmentAcceptanceScanResult>('/api/equipment-acceptance/alerts/scan', { method: 'POST' });
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员立即把待发送记录按收件人发到企业微信。
|
||||
* @returns 成功和失败的收件人数
|
||||
*/
|
||||
export function sendEquipmentAcceptanceAlerts() {
|
||||
return requestJson<EquipmentAcceptanceSendResult>('/api/equipment-acceptance/alerts/send', { method: 'POST' });
|
||||
}
|
||||
|
||||
export interface EquipmentAcceptanceSendRecord {
|
||||
id: number;
|
||||
order_id?: number | null;
|
||||
acceptance_no?: string | null;
|
||||
purchase_order_no?: string | null;
|
||||
tier: number;
|
||||
threshold_days: number;
|
||||
to_text?: string | null;
|
||||
cc_text?: string | null;
|
||||
status: string;
|
||||
sent_at?: string | null;
|
||||
error_message?: string | null;
|
||||
created_at?: string | null;
|
||||
}
|
||||
|
||||
export interface EquipmentAcceptanceSendListResponse {
|
||||
items: EquipmentAcceptanceSendRecord[];
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页读取发送记录。
|
||||
* 核心逻辑:按创建时间倒序。还没有扫描写入时 items 为空。
|
||||
* @param params.page - 从 1 开始
|
||||
* @param params.pageSize - 每页条数
|
||||
* @returns 当前页记录和总数
|
||||
*/
|
||||
export function listEquipmentAcceptanceSends(params?: { page?: number; pageSize?: number }) {
|
||||
const search = new URLSearchParams();
|
||||
if (params?.page) search.set('page', String(params.page));
|
||||
if (params?.pageSize) search.set('page_size', String(params.pageSize));
|
||||
const suffix = search.toString() ? `?${search.toString()}` : '';
|
||||
return requestJson<EquipmentAcceptanceSendListResponse>(`/api/equipment-acceptance/sends${suffix}`);
|
||||
}
|
||||
|
||||
export interface EquipmentAcceptanceConfigUser {
|
||||
id: number;
|
||||
username: string;
|
||||
real_name?: string | null;
|
||||
employee_id?: string | null;
|
||||
department?: string | null;
|
||||
wecom_bound?: boolean;
|
||||
}
|
||||
|
||||
export interface EquipmentAcceptanceConfig {
|
||||
days: number[];
|
||||
buyer_manager_user_id?: number | null;
|
||||
coo_user_id?: number | null;
|
||||
executive_user_id?: number | null;
|
||||
selected_users: EquipmentAcceptanceConfigUser[];
|
||||
users: EquipmentAcceptanceConfigUser[];
|
||||
updated_at?: string | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取四档天数和三个固定岗位。管理员响应里带候选人。
|
||||
* @returns 当前配置
|
||||
*/
|
||||
export function getEquipmentAcceptanceConfig() {
|
||||
return requestJson<EquipmentAcceptanceConfig>('/api/equipment-acceptance/config');
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存四档天数和三个岗位的系统用户。仅平台管理员。
|
||||
* 核心逻辑:岗位传用户主键或 null,不传姓名。
|
||||
* @param payload.days - 四个逐档增大的天数
|
||||
* @param payload.buyerManagerUserId - 采购经副理
|
||||
* @param payload.cooUserId - COO
|
||||
* @param payload.executiveUserId - 廖总对应岗位
|
||||
* @returns 保存后的配置
|
||||
*/
|
||||
export function saveEquipmentAcceptanceConfig(payload: {
|
||||
days: number[];
|
||||
buyerManagerUserId: number | null;
|
||||
cooUserId: number | null;
|
||||
executiveUserId: number | null;
|
||||
}) {
|
||||
return requestJson<EquipmentAcceptanceConfig>('/api/equipment-acceptance/config', {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({
|
||||
days: payload.days,
|
||||
buyer_manager_user_id: payload.buyerManagerUserId,
|
||||
coo_user_id: payload.cooUserId,
|
||||
executive_user_id: payload.executiveUserId,
|
||||
}),
|
||||
});
|
||||
}
|
||||
+225
@@ -0,0 +1,225 @@
|
||||
<!--
|
||||
features/equipment-acceptance/components/EquipmentAcceptanceChatPanel.vue
|
||||
用途:设备验收预警 Chat 主区:停留列表、详情、发送记录、预警配置,以及管理员同步、扫描和发送。
|
||||
依赖:停留列表、详情、发送记录、配置页、auth.store、equipment-acceptance.api、DeleteConfirmDialog、vue-router query。
|
||||
逻辑:由 ChatViewContent 在 agent_code=equipment_acceptance 时替换消息列表与输入框。
|
||||
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 { useI18n } from 'vue-i18n';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import { useAuthStore } from '@/features/auth/stores/auth.store';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import {
|
||||
scanEquipmentAcceptanceAlerts,
|
||||
sendEquipmentAcceptanceAlerts,
|
||||
syncEquipmentAcceptance,
|
||||
} from '../api/equipment-acceptance.api';
|
||||
import EquipmentAcceptanceConfigPage from '../views/EquipmentAcceptanceConfigPage.vue';
|
||||
import EquipmentAcceptanceDetailPage from '../views/EquipmentAcceptanceDetailPage.vue';
|
||||
import EquipmentAcceptancePage from '../views/EquipmentAcceptancePage.vue';
|
||||
import EquipmentAcceptanceSendsPage from '../views/EquipmentAcceptanceSendsPage.vue';
|
||||
|
||||
type WorkspaceView = 'ledger' | 'sends' | 'config';
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const auth = useAuthStore();
|
||||
const msg = useMessage();
|
||||
const syncing = ref(false);
|
||||
const alertRunning = ref(false);
|
||||
const pendingAlert = ref<'scan' | 'send' | null>(null);
|
||||
const listPage = ref<{ reload: () => Promise<void> } | null>(null);
|
||||
const sendsPage = ref<{ reload: () => Promise<void> } | null>(null);
|
||||
|
||||
const isAdmin = computed(() => Boolean(auth.isAdmin));
|
||||
const activeView = computed<WorkspaceView>(() => {
|
||||
if (route.query.view === 'config') return 'config';
|
||||
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);
|
||||
return Number.isInteger(raw) && raw > 0 ? raw : null;
|
||||
});
|
||||
const tabs = computed(() => ([
|
||||
{ key: 'ledger' as const, label: t('admin.equipmentAcceptance.tabLedger') },
|
||||
{ key: 'sends' as const, label: t('admin.equipmentAcceptance.tabSends') },
|
||||
{ key: 'config' as const, label: t('admin.equipmentAcceptance.tabConfig') },
|
||||
]));
|
||||
|
||||
/**
|
||||
* 把当前 Tab 和详情写入 Chat 路由。
|
||||
* 核心逻辑:配置和发送记录清掉 orderId。停留列表不写 view,避免旧链接被改掉。
|
||||
* @param view - ledger、sends 或 config
|
||||
* @param orderId - 本地快照主键,空表示列表
|
||||
*/
|
||||
async function syncQuery(view: WorkspaceView, orderId: number | null): Promise<void> {
|
||||
const query = { ...route.query };
|
||||
if (view === 'config' || view === 'sends') {
|
||||
query.view = view;
|
||||
delete query.orderId;
|
||||
} else {
|
||||
delete query.view;
|
||||
if (orderId) query.orderId = String(orderId);
|
||||
else delete query.orderId;
|
||||
}
|
||||
const sameView = String(route.query.view || '') === String(query.view || '');
|
||||
const sameOrder = String(route.query.orderId || '') === String(query.orderId || '');
|
||||
if (sameView && sameOrder) return;
|
||||
await router.replace({ params: { ...route.params }, query });
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换停留列表、发送记录和预警配置。
|
||||
* @param view - 目标 Tab
|
||||
*/
|
||||
function selectView(view: WorkspaceView): void {
|
||||
void syncQuery(view, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员在发送记录页立即扫描或发送。
|
||||
* 核心逻辑:公共确认框点确定后才调用。先取出动作再关掉弹窗,避免关闭时把待执行动作清掉。
|
||||
*/
|
||||
function confirmAlertAction(): void {
|
||||
const action = pendingAlert.value;
|
||||
pendingAlert.value = null;
|
||||
if (action) void runAlertAction(action);
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行已经确认的扫描或发送。
|
||||
* 核心逻辑:扫描会同步 E10;发送把待发送记录推到企业微信。
|
||||
* @param action - scan 或 send
|
||||
*/
|
||||
async function runAlertAction(action: 'scan' | 'send'): Promise<void> {
|
||||
if (alertRunning.value) return;
|
||||
alertRunning.value = true;
|
||||
try {
|
||||
if (action === 'scan') {
|
||||
const result = await scanEquipmentAcceptanceAlerts();
|
||||
msg.success(t('admin.equipmentAcceptance.scanDone', {
|
||||
created: result.created,
|
||||
updated: result.updated,
|
||||
cancelled: result.cancelled,
|
||||
}));
|
||||
} else {
|
||||
const result = await sendEquipmentAcceptanceAlerts();
|
||||
msg.success(t('admin.equipmentAcceptance.sendDone', {
|
||||
sent: result.sent,
|
||||
failed: result.failed,
|
||||
}));
|
||||
}
|
||||
await sendsPage.value?.reload();
|
||||
} catch (error) {
|
||||
msg.error(error instanceof BusinessError ? error.message : t('admin.equipmentAcceptance.syncFailed'));
|
||||
} finally {
|
||||
alertRunning.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员从 E10 同步后刷新列表。
|
||||
* 核心逻辑:成功提示写入、跳过和本次未见条数。失败展示业务错误。
|
||||
*/
|
||||
async function runSync(): Promise<void> {
|
||||
if (syncing.value) return;
|
||||
syncing.value = true;
|
||||
try {
|
||||
const result = await syncEquipmentAcceptance();
|
||||
msg.success(t('admin.equipmentAcceptance.syncDone', {
|
||||
upserted: result.upserted,
|
||||
skipped: result.skipped_without_request_id,
|
||||
absent: result.absent,
|
||||
}));
|
||||
await listPage.value?.reload();
|
||||
} catch (error) {
|
||||
msg.error(error instanceof BusinessError ? error.message : t('admin.equipmentAcceptance.syncFailed'));
|
||||
} finally {
|
||||
syncing.value = false;
|
||||
}
|
||||
}
|
||||
</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>
|
||||
</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>
|
||||
</template>
|
||||
@@ -0,0 +1,272 @@
|
||||
<!--
|
||||
features/equipment-acceptance/views/EquipmentAcceptanceConfigPage.vue
|
||||
用途:设备验收预警配置页。编辑四档天数,并为三个固定岗位选择系统用户。
|
||||
依赖:equipment-acceptance.api、UserPickerDialog、userPicker.utils、vue-i18n。
|
||||
逻辑:由 Chat 作业面的「预警配置」Tab 嵌入。姓名只用于展示。
|
||||
发送时刻不在本页,由排程 Cron 配置。非管理员只能查看。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import UserPickerDialog from '@/shared/components/UserPickerDialog.vue';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { userPickerLabel } from '@/shared/utils/userPicker.utils';
|
||||
import type { UserPickerPerson } from '@/shared/types/userPicker.types';
|
||||
import {
|
||||
getEquipmentAcceptanceConfig,
|
||||
saveEquipmentAcceptanceConfig,
|
||||
} from '../api/equipment-acceptance.api';
|
||||
|
||||
const props = defineProps<{
|
||||
editable: boolean;
|
||||
}>();
|
||||
|
||||
type RoleKey = 'buyer_manager' | 'coo' | 'executive';
|
||||
|
||||
const ROLE_FIELDS: RoleKey[] = ['buyer_manager', 'coo', 'executive'];
|
||||
const TIER_WHO = ['tierWho1', 'tierWho2', 'tierWho3', 'tierWho4'] as const;
|
||||
|
||||
const { t } = useI18n();
|
||||
const msg = useMessage();
|
||||
const loading = ref(false);
|
||||
const saving = ref(false);
|
||||
const days = ref<number[]>([30, 37, 44, 51]);
|
||||
const roleIds = ref<Record<RoleKey, number | null>>({
|
||||
buyer_manager: null,
|
||||
coo: null,
|
||||
executive: null,
|
||||
});
|
||||
const candidates = ref<UserPickerPerson[]>([]);
|
||||
const knownUsers = ref<UserPickerPerson[]>([]);
|
||||
const pickerOpen = ref(false);
|
||||
const pickerRole = ref<RoleKey | null>(null);
|
||||
|
||||
const people = computed(() => {
|
||||
const map = new Map<number, UserPickerPerson>();
|
||||
for (const user of candidates.value) map.set(user.id, user);
|
||||
for (const user of knownUsers.value) map.set(user.id, user);
|
||||
return map;
|
||||
});
|
||||
|
||||
const pickerSelectedIds = computed(() => {
|
||||
const id = pickerRole.value ? roleIds.value[pickerRole.value] : null;
|
||||
return id ? [id] : [];
|
||||
});
|
||||
|
||||
const ruleRows = computed(() => ([
|
||||
{ to: 'ruleTo1', cc: 'ruleCc1' },
|
||||
{ to: 'ruleTo2', cc: 'ruleCc2' },
|
||||
{ to: 'ruleTo3', cc: 'ruleCc3' },
|
||||
{ to: 'ruleTo4', cc: 'ruleCc4' },
|
||||
]));
|
||||
|
||||
/**
|
||||
* 读取当前配置。管理员响应里包含候选人。
|
||||
* 核心逻辑:失败时保留页面上的默认天数,并用统一错误提示。
|
||||
*/
|
||||
async function load(): Promise<void> {
|
||||
loading.value = true;
|
||||
try {
|
||||
const result = await getEquipmentAcceptanceConfig();
|
||||
days.value = result.days?.length === 4 ? [...result.days] : [30, 37, 44, 51];
|
||||
roleIds.value = {
|
||||
buyer_manager: result.buyer_manager_user_id ?? null,
|
||||
coo: result.coo_user_id ?? null,
|
||||
executive: result.executive_user_id ?? null,
|
||||
};
|
||||
candidates.value = result.users || [];
|
||||
knownUsers.value = result.selected_users || [];
|
||||
} catch (error) {
|
||||
msg.error(error instanceof BusinessError ? error.message : t('admin.equipmentAcceptance.configLoadFailed'));
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开某个岗位的选人弹窗。每个岗位只保留最后选中的一人。
|
||||
* @param role - buyer_manager、coo、executive
|
||||
*/
|
||||
function openPicker(role: RoleKey): void {
|
||||
if (!props.editable) return;
|
||||
pickerRole.value = role;
|
||||
pickerOpen.value = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 把弹窗结果写回当前岗位。选了多人时只留最后一人。
|
||||
* @param ids - 弹窗确定时的用户主键
|
||||
*/
|
||||
function applyPicker(ids: number[]): void {
|
||||
const role = pickerRole.value;
|
||||
if (!role) return;
|
||||
roleIds.value[role] = ids[ids.length - 1] ?? null;
|
||||
pickerRole.value = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空一个岗位,保存后表示该岗位未配置。
|
||||
* @param role - 岗位键
|
||||
*/
|
||||
function clearRole(role: RoleKey): void {
|
||||
roleIds.value[role] = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存天数和三个岗位。天数须逐档增大。
|
||||
* 核心逻辑:先在页面拦住空值和倒序,服务端再校验用户是否存在。
|
||||
*/
|
||||
async function save(): Promise<void> {
|
||||
if (!props.editable || saving.value) return;
|
||||
const nextDays = days.value.map((day) => Number(day));
|
||||
const [first, second, third, fourth] = nextDays;
|
||||
const increases = first !== undefined && second !== undefined && third !== undefined && fourth !== undefined
|
||||
&& first < second && second < third && third < fourth;
|
||||
if (nextDays.some((day) => !Number.isInteger(day) || day < 1) || !increases) {
|
||||
msg.error(t('admin.equipmentAcceptance.configDaysInvalid'));
|
||||
return;
|
||||
}
|
||||
saving.value = true;
|
||||
try {
|
||||
const result = await saveEquipmentAcceptanceConfig({
|
||||
days: nextDays,
|
||||
buyerManagerUserId: roleIds.value.buyer_manager,
|
||||
cooUserId: roleIds.value.coo,
|
||||
executiveUserId: roleIds.value.executive,
|
||||
});
|
||||
days.value = [...result.days];
|
||||
knownUsers.value = result.selected_users || [];
|
||||
candidates.value = result.users || [];
|
||||
msg.success(t('admin.equipmentAcceptance.configSaved'));
|
||||
} catch (error) {
|
||||
msg.error(error instanceof BusinessError ? error.message : t('admin.equipmentAcceptance.configSaveFailed'));
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 岗位上已选用户的展示名。没有选择时返回空串,模板改显示未选择。
|
||||
* @param role - 岗位键
|
||||
* @returns 姓名,有工号时附在后面
|
||||
*/
|
||||
function roleLabel(role: RoleKey): string {
|
||||
const id = roleIds.value[role];
|
||||
if (!id) return '';
|
||||
return userPickerLabel(people.value.get(id), id);
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void load();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="min-h-0 flex-1 overflow-auto px-5 pb-6 pt-3">
|
||||
<p class="mb-3 text-sm text-[#64748b]">{{ t('admin.equipmentAcceptance.configLead') }}</p>
|
||||
<p v-if="loading" class="text-sm text-[#64748b]">{{ t('admin.equipmentAcceptance.loading') }}</p>
|
||||
<template v-else>
|
||||
<div class="grid grid-cols-4 gap-3">
|
||||
<label
|
||||
v-for="(who, index) in TIER_WHO"
|
||||
:key="who"
|
||||
class="rounded-xl border border-[#dce4ef] border-t-[3px] bg-white px-3 py-3"
|
||||
:class="index === 0 ? 'border-t-[#93c5fd]' : index === 1 ? 'border-t-[#2563eb]' : index === 2 ? 'border-t-[#d97706]' : 'border-t-[#dc2626]'"
|
||||
>
|
||||
<span class="block text-xs font-bold text-[#64748b]">{{ t(`admin.equipmentAcceptance.tier${index + 1}`) }}</span>
|
||||
<span class="mt-2 flex items-center gap-2">
|
||||
<input
|
||||
v-model.number="days[index]"
|
||||
class="h-11 w-16 rounded-lg border border-[#d7dee8] bg-[#f8fafc] text-center text-xl font-bold text-[#142033] disabled:opacity-70"
|
||||
type="number"
|
||||
min="1"
|
||||
:disabled="!editable"
|
||||
/>
|
||||
<span class="text-sm font-semibold text-[#94a3b8]">{{ t('admin.equipmentAcceptance.dayUnit') }}</span>
|
||||
</span>
|
||||
<span class="mt-2 block text-xs font-bold text-[#334155]">{{ t(`admin.equipmentAcceptance.${who}`) }}</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="mt-3 grid gap-3 lg:grid-cols-2">
|
||||
<article class="rounded-xl border border-[#dce4ef] bg-white">
|
||||
<h2 class="px-4 pt-4 text-sm font-bold text-[#142033]">{{ t('admin.equipmentAcceptance.fixedRoles') }}</h2>
|
||||
<div class="px-4 pb-2">
|
||||
<div
|
||||
v-for="role in ROLE_FIELDS"
|
||||
:key="role"
|
||||
class="grid grid-cols-[108px_minmax(0,1fr)] items-center gap-3 border-b border-[#dce4ef] py-3 last:border-b-0"
|
||||
>
|
||||
<span class="text-sm font-bold text-[#334155]">{{ t(`admin.equipmentAcceptance.role.${role}`) }}</span>
|
||||
<div class="flex min-w-0 flex-wrap items-center gap-2">
|
||||
<span v-if="roleLabel(role)" class="truncate text-sm text-[#142033]">{{ roleLabel(role) }}</span>
|
||||
<span v-else class="text-sm text-[#94a3b8]">{{ t('admin.equipmentAcceptance.roleEmpty') }}</span>
|
||||
<button
|
||||
v-if="editable"
|
||||
class="ml-auto rounded-lg border border-[#bfdbfe] bg-[#eaf2ff] px-2.5 py-1 text-xs font-bold text-[#1d4ed8]"
|
||||
type="button"
|
||||
@click="openPicker(role)"
|
||||
>
|
||||
{{ t('admin.equipmentAcceptance.selectUser') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="editable && roleIds[role]"
|
||||
class="text-xs font-bold text-[#64748b]"
|
||||
type="button"
|
||||
@click="clearRole(role)"
|
||||
>
|
||||
{{ t('admin.equipmentAcceptance.clearUser') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center justify-between gap-3 border-t border-[#dce4ef] bg-[#fafbfd] px-4 py-3">
|
||||
<span class="text-xs text-[#64748b]">{{ editable ? t('admin.equipmentAcceptance.configSaveHint') : t('admin.equipmentAcceptance.configReadOnly') }}</span>
|
||||
<button
|
||||
v-if="editable"
|
||||
class="rounded-lg bg-[#2563eb] px-3 py-1.5 text-xs font-bold text-white disabled:opacity-50"
|
||||
type="button"
|
||||
:disabled="saving"
|
||||
@click="save"
|
||||
>
|
||||
{{ t('admin.equipmentAcceptance.saveConfig') }}
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<article class="overflow-hidden rounded-xl border border-[#dce4ef] bg-white">
|
||||
<div class="px-4 pt-4">
|
||||
<h2 class="text-sm font-bold text-[#142033]">{{ t('admin.equipmentAcceptance.rulesTitle') }}</h2>
|
||||
<p class="mt-1 text-xs text-[#64748b]">{{ t('admin.equipmentAcceptance.rulesLead') }}</p>
|
||||
</div>
|
||||
<table class="mt-3 w-full border-collapse text-left text-xs">
|
||||
<thead class="bg-[#f8fbff] text-[#64748b]">
|
||||
<tr>
|
||||
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.ruleTier') }}</th>
|
||||
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.ruleTo') }}</th>
|
||||
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.ruleCc') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(row, index) in ruleRows" :key="row.to" class="border-t border-[#dce4ef]">
|
||||
<td class="px-3 py-2.5 font-bold text-[#142033]">{{ t('admin.equipmentAcceptance.ruleOver', { days: days[index] || '—' }) }}</td>
|
||||
<td class="px-3 py-2.5">{{ t(`admin.equipmentAcceptance.${row.to}`) }}</td>
|
||||
<td class="px-3 py-2.5">{{ t(`admin.equipmentAcceptance.${row.cc}`) }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</article>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<UserPickerDialog
|
||||
v-model="pickerOpen"
|
||||
:users="candidates"
|
||||
:selected-ids="pickerSelectedIds"
|
||||
:title="t('admin.equipmentAcceptance.selectUser')"
|
||||
:subtitle="t('admin.equipmentAcceptance.configPickOne')"
|
||||
@confirm="applyPicker"
|
||||
/>
|
||||
</section>
|
||||
</template>
|
||||
@@ -0,0 +1,314 @@
|
||||
<!--
|
||||
features/equipment-acceptance/views/EquipmentAcceptanceDetailPage.vue
|
||||
用途:一张验收单的详情卡片,展示状态徽章、停留进度、当前节点和操作人。
|
||||
依赖:equipment-acceptance.api、vue-i18n、统一消息提示。
|
||||
逻辑:由 Chat 作业面在选中某行后展示。操作人只显示姓名和工号。
|
||||
进度条只按签核天数画到 30/37/44/51,不表示已经发送。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import {
|
||||
getEquipmentAcceptanceOrder,
|
||||
type EquipmentAcceptanceOrder,
|
||||
} from '../api/equipment-acceptance.api';
|
||||
|
||||
const props = defineProps<{
|
||||
orderId: number;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
back: [];
|
||||
}>();
|
||||
|
||||
type BadgeTone = 'red' | 'green' | 'gray';
|
||||
|
||||
const STOPPED_STATUSES = new Set([
|
||||
'stopped_returned',
|
||||
'stopped_cannot_accept',
|
||||
'stopped_archived',
|
||||
'stopped_force_finished',
|
||||
'stopped_voided',
|
||||
'stopped_revoked',
|
||||
]);
|
||||
|
||||
const FLOW_STATUS_KEYS: Record<number, string> = {
|
||||
0: 'draft',
|
||||
1: 'approving',
|
||||
3: 'archived',
|
||||
4: 'forceFinished',
|
||||
5: 'voided',
|
||||
6: 'pendingSubmit',
|
||||
7: 'withdrawn',
|
||||
8: 'withdrawn',
|
||||
99: 'withdrawn',
|
||||
[-99]: 'withdrawn',
|
||||
};
|
||||
|
||||
const REMINDER_DAYS = [30, 37, 44, 51];
|
||||
|
||||
const { t } = useI18n();
|
||||
const msg = useMessage();
|
||||
const loading = ref(false);
|
||||
const order = ref<EquipmentAcceptanceOrder | null>(null);
|
||||
|
||||
/**
|
||||
* 读取当前验收单详情。
|
||||
* 核心逻辑:orderId 变化时重新请求。失败清空详情,避免上一张单残留。
|
||||
*/
|
||||
async function load(): Promise<void> {
|
||||
loading.value = true;
|
||||
try {
|
||||
order.value = await getEquipmentAcceptanceOrder(props.orderId);
|
||||
} catch (error) {
|
||||
order.value = null;
|
||||
msg.error(error instanceof BusinessError ? error.message : t('admin.equipmentAcceptance.detailLoadFailed'));
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 只取日期部分。没有值时显示横线。
|
||||
* @param value - 接口时间字符串
|
||||
* @returns 日期文本
|
||||
*/
|
||||
function dateText(value?: string | null): string {
|
||||
if (!value) return '—';
|
||||
return value.slice(0, 10);
|
||||
}
|
||||
|
||||
/**
|
||||
* 把 0/1 写成否/是。可以验收为空时显示未标明,退回在同步时已把空收成否。
|
||||
* @param value - 标准 0 否、1 是
|
||||
* @param emptyLabel - 空值文案
|
||||
* @returns 展示文案
|
||||
*/
|
||||
function yesNo(value: number | null | undefined, emptyLabel: string): string {
|
||||
if (value === 1) return t('common.yes');
|
||||
if (value === 0) return t('common.no');
|
||||
return emptyLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* 把流程状态原值写成名称。7、8、99、-99 都显示为撤销,字典没有的数字仍显示原值。
|
||||
* @param value - flowstatus
|
||||
* @returns 流程状态文案
|
||||
*/
|
||||
function flowText(value?: number | null): string {
|
||||
if (value === undefined || value === null) return '—';
|
||||
const key = FLOW_STATUS_KEYS[value];
|
||||
return key ? t(`admin.equipmentAcceptance.flowStatusName.${key}`) : String(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 未开始或没有天数时显示横线,其余显示「N 天」。
|
||||
* @param item - 当前验收单
|
||||
* @returns 签核天数文案
|
||||
*/
|
||||
function dwellText(item: EquipmentAcceptanceOrder): string {
|
||||
if (item.monitor_status === 'not_started' || item.dwell_days == null) return '—';
|
||||
return t('admin.equipmentAcceptance.daysValue', { days: item.dwell_days });
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前节点名称。没有节点时为空,模板改显示横线。
|
||||
* @param item - 当前验收单
|
||||
* @returns 节点名称列表
|
||||
*/
|
||||
function nodeNames(item: EquipmentAcceptanceOrder): string[] {
|
||||
return (item.nodes || []).map((node) => node.node_name).filter((name): name is string => Boolean(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前处理人去重后拼成一行。
|
||||
* @param item - 当前验收单
|
||||
* @returns 处理人姓名
|
||||
*/
|
||||
function handlerNames(item: EquipmentAcceptanceOrder): string {
|
||||
const names = Array.from(new Set(
|
||||
(item.operators || []).map((person) => person.handler_name).filter((name): name is string => Boolean(name)),
|
||||
));
|
||||
return names.length ? names.join('、') : '—';
|
||||
}
|
||||
|
||||
/**
|
||||
* 与列表相同的徽章颜色。红是已逾期,绿是不再提醒,灰是未开始和未超时。
|
||||
* @param item - 当前验收单
|
||||
* @returns 文案和颜色
|
||||
*/
|
||||
function statusBadge(item: EquipmentAcceptanceOrder): { label: string; tone: BadgeTone } {
|
||||
if (item.monitor_status === 'watching' && item.overdue) {
|
||||
return { label: t('admin.equipmentAcceptance.badgeOverdue'), tone: 'red' };
|
||||
}
|
||||
if (item.monitor_status === 'watching') {
|
||||
return { label: t('admin.equipmentAcceptance.badgeOnTime'), tone: 'gray' };
|
||||
}
|
||||
return {
|
||||
label: t(`admin.equipmentAcceptance.statusLabel.${item.monitor_status}`),
|
||||
tone: STOPPED_STATUSES.has(item.monitor_status) ? 'green' : 'gray',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 徽章底色。
|
||||
* @param tone - 徽章颜色
|
||||
* @returns Tailwind 类名
|
||||
*/
|
||||
function badgeClass(tone: BadgeTone): string {
|
||||
if (tone === 'red') return 'bg-[#fff0ef] text-[#b42318]';
|
||||
if (tone === 'green') return 'bg-[#eafaf1] text-[#067647]';
|
||||
return 'bg-[#edf1f6] text-[#475569]';
|
||||
}
|
||||
|
||||
/**
|
||||
* 按签核天数在 0 到第 4 档之间画进度。没有天数时不画。
|
||||
* 核心逻辑:刻度至少到 60 天,避免 51 天贴在条的尽头。
|
||||
*/
|
||||
const track = computed(() => {
|
||||
const days = order.value?.dwell_days;
|
||||
if (order.value?.monitor_status === 'not_started' || days == null) return null;
|
||||
const lastMark = REMINDER_DAYS[REMINDER_DAYS.length - 1] ?? 51;
|
||||
const scale = Math.max(60, lastMark + 9, days);
|
||||
return {
|
||||
width: `${Math.min(100, Math.round((days / scale) * 100))}%`,
|
||||
marks: [0, ...REMINDER_DAYS, scale].map((day) => ({
|
||||
day,
|
||||
left: `${(day / scale) * 100}%`,
|
||||
label: day === scale ? t('admin.equipmentAcceptance.daysValue', { days: scale }) : String(day),
|
||||
})),
|
||||
};
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
void load();
|
||||
});
|
||||
|
||||
watch(() => props.orderId, () => {
|
||||
void load();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="min-h-0 flex-1 overflow-auto px-5 pb-6 pt-3">
|
||||
<button
|
||||
class="mb-3 rounded-lg border border-[#dce4ef] bg-white px-3 py-1.5 text-xs font-bold text-[#142033]"
|
||||
type="button"
|
||||
@click="emit('back')"
|
||||
>
|
||||
{{ t('admin.equipmentAcceptance.back') }}
|
||||
</button>
|
||||
<p v-if="loading && !order" class="text-sm text-[#64748b]">{{ t('admin.equipmentAcceptance.loading') }}</p>
|
||||
<article v-else-if="order" class="overflow-hidden rounded-xl border border-[#dce4ef] bg-white">
|
||||
<div class="flex items-start justify-between gap-3 px-4 pt-4">
|
||||
<h2 class="text-lg font-bold text-[#142033]">{{ order.acceptance_no || '—' }}</h2>
|
||||
<span
|
||||
class="inline-flex shrink-0 rounded-full px-2 py-0.5 text-[11px] font-extrabold"
|
||||
:class="badgeClass(statusBadge(order).tone)"
|
||||
>
|
||||
{{ statusBadge(order).label }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div v-if="track" class="px-7 pt-5">
|
||||
<div class="h-2 overflow-hidden rounded-full bg-[#e7edf5]">
|
||||
<i class="block h-full rounded-full bg-gradient-to-r from-[#93c5fd] to-[#2563eb]" :style="{ width: track.width }"></i>
|
||||
</div>
|
||||
<div class="relative mt-1 h-4 text-[11px] text-[#64748b]">
|
||||
<span
|
||||
v-for="mark in track.marks"
|
||||
:key="mark.day"
|
||||
class="absolute -translate-x-1/2 whitespace-nowrap"
|
||||
:style="{ left: mark.left }"
|
||||
>
|
||||
{{ mark.label }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap gap-1.5 px-4 pb-1 pt-4">
|
||||
<span
|
||||
v-for="(name, index) in nodeNames(order)"
|
||||
:key="`${name}-${index}`"
|
||||
class="rounded-full bg-[#dbeafe] px-2 py-1 text-[11px] font-extrabold text-[#1d4ed8]"
|
||||
>
|
||||
{{ name }}
|
||||
</span>
|
||||
<span v-if="!nodeNames(order).length" class="text-sm text-[#64748b]">—</span>
|
||||
</div>
|
||||
|
||||
<dl class="mt-3 grid border-t border-[#dce4ef] px-4 sm:grid-cols-2">
|
||||
<div class="grid grid-cols-[108px_minmax(0,1fr)] gap-2 border-b border-[#dce4ef] py-2.5 text-xs">
|
||||
<dt class="font-bold text-[#64748b]">{{ t('admin.equipmentAcceptance.purchaseOrderNo') }}</dt>
|
||||
<dd class="text-[#142033]">{{ order.purchase_order_no || '—' }}</dd>
|
||||
</div>
|
||||
<div class="grid grid-cols-[108px_minmax(0,1fr)] gap-2 border-b border-[#dce4ef] py-2.5 text-xs sm:pl-4">
|
||||
<dt class="font-bold text-[#64748b]">{{ t('admin.equipmentAcceptance.applicant') }}</dt>
|
||||
<dd class="text-[#142033]">{{ order.applicant_name || '—' }}</dd>
|
||||
</div>
|
||||
<div class="grid grid-cols-[108px_minmax(0,1fr)] gap-2 border-b border-[#dce4ef] py-2.5 text-xs">
|
||||
<dt class="font-bold text-[#64748b]">{{ t('admin.equipmentAcceptance.dwellDays') }}</dt>
|
||||
<dd class="text-[#142033]">{{ dwellText(order) }}</dd>
|
||||
</div>
|
||||
<div class="grid grid-cols-[108px_minmax(0,1fr)] gap-2 border-b border-[#dce4ef] py-2.5 text-xs sm:pl-4">
|
||||
<dt class="font-bold text-[#64748b]">{{ t('admin.equipmentAcceptance.timerStart') }}</dt>
|
||||
<dd class="text-[#142033]">{{ dateText(order.timer_started_at) }}</dd>
|
||||
</div>
|
||||
<div class="grid grid-cols-[108px_minmax(0,1fr)] gap-2 border-b border-[#dce4ef] py-2.5 text-xs sm:col-span-2">
|
||||
<dt class="font-bold text-[#64748b]">{{ t('admin.equipmentAcceptance.currentHandlers') }}</dt>
|
||||
<dd class="text-[#142033]">{{ handlerNames(order) }}</dd>
|
||||
</div>
|
||||
<div class="grid grid-cols-[108px_minmax(0,1fr)] gap-2 border-b border-[#dce4ef] py-2.5 text-xs">
|
||||
<dt class="font-bold text-[#64748b]">{{ t('admin.equipmentAcceptance.canAccept') }}</dt>
|
||||
<dd class="text-[#142033]">{{ yesNo(order.can_accept, t('admin.equipmentAcceptance.unspecified')) }}</dd>
|
||||
</div>
|
||||
<div class="grid grid-cols-[108px_minmax(0,1fr)] gap-2 border-b border-[#dce4ef] py-2.5 text-xs sm:col-span-2">
|
||||
<dt class="font-bold text-[#64748b]">{{ t('admin.equipmentAcceptance.cannotAcceptNote') }}</dt>
|
||||
<dd class="whitespace-pre-wrap text-[#142033]">{{ order.cannot_accept_note || '—' }}</dd>
|
||||
</div>
|
||||
<div class="grid grid-cols-[108px_minmax(0,1fr)] gap-2 border-b border-[#dce4ef] py-2.5 text-xs sm:pl-4">
|
||||
<dt class="font-bold text-[#64748b]">{{ t('admin.equipmentAcceptance.returnFlag') }}</dt>
|
||||
<dd class="text-[#142033]">{{ yesNo(order.is_returned, t('common.no')) }}</dd>
|
||||
</div>
|
||||
<div class="grid grid-cols-[108px_minmax(0,1fr)] gap-2 border-b border-[#dce4ef] py-2.5 text-xs">
|
||||
<dt class="font-bold text-[#64748b]">{{ t('admin.equipmentAcceptance.flowStatus') }}</dt>
|
||||
<dd class="text-[#142033]">{{ flowText(order.flow_status_raw) }}</dd>
|
||||
</div>
|
||||
<div class="grid grid-cols-[108px_minmax(0,1fr)] gap-2 border-b border-[#dce4ef] py-2.5 text-xs sm:pl-4">
|
||||
<dt class="font-bold text-[#64748b]">{{ t('admin.equipmentAcceptance.finishedAt') }}</dt>
|
||||
<dd class="text-[#142033]">{{ dateText(order.finished_at) }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
|
||||
<div class="px-4 pb-4 pt-4">
|
||||
<h3 class="text-sm font-bold text-[#142033]">{{ t('admin.equipmentAcceptance.operators') }}</h3>
|
||||
<p class="mt-1 text-xs text-[#64748b]">{{ t('admin.equipmentAcceptance.operatorsNote') }}</p>
|
||||
<div class="mt-3 overflow-auto rounded-xl border border-[#dce4ef]">
|
||||
<table class="w-full min-w-[640px] border-collapse text-left text-xs">
|
||||
<thead class="bg-[#f8fbff] text-[#64748b]">
|
||||
<tr>
|
||||
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.operatorName') }}</th>
|
||||
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.jobNum') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="(item, index) in order.operators"
|
||||
:key="`${item.user_id}-${item.node_id}-${index}`"
|
||||
class="border-t border-[#dce4ef]"
|
||||
>
|
||||
<td class="px-3 py-2.5 font-bold text-[#142033]">{{ item.handler_name || '—' }}</td>
|
||||
<td class="px-3 py-2.5">{{ item.handler_job_num || '—' }}</td>
|
||||
</tr>
|
||||
<tr v-if="!order.operators.length">
|
||||
<td colspan="2" class="px-3 py-6 text-center text-[#64748b]">—</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
</section>
|
||||
</template>
|
||||
@@ -0,0 +1,264 @@
|
||||
<!--
|
||||
features/equipment-acceptance/views/EquipmentAcceptancePage.vue
|
||||
用途:设备验收预警停留列表,对齐原型的汇总卡、分组筛选和状态徽章。
|
||||
依赖:equipment-acceptance.api、PaginationBar、统一消息提示、vue-i18n。
|
||||
逻辑:由 Chat 作业面嵌入。点「查看详情」交给父级下钻。
|
||||
已逾期只看接口给出的 overdue。发送结果在「发送记录」页,这里不显示第几档。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import PaginationBar from '@/shared/components/PaginationBar.vue';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import {
|
||||
listEquipmentAcceptanceOrders,
|
||||
type EquipmentAcceptanceOrder,
|
||||
type EquipmentAcceptanceSummary,
|
||||
} from '../api/equipment-acceptance.api';
|
||||
|
||||
const emit = defineEmits<{
|
||||
'open-detail': [orderId: number];
|
||||
}>();
|
||||
|
||||
type FocusKey = 'all' | 'watching' | 'overdue' | 'stopped' | 'not_started';
|
||||
type BadgeTone = 'red' | 'green' | 'gray';
|
||||
|
||||
const STOPPED_STATUSES = new Set([
|
||||
'stopped_returned',
|
||||
'stopped_cannot_accept',
|
||||
'stopped_archived',
|
||||
'stopped_force_finished',
|
||||
'stopped_voided',
|
||||
'stopped_revoked',
|
||||
]);
|
||||
|
||||
const filters: Array<{ key: FocusKey; label: string }> = [
|
||||
{ key: 'all', label: 'filterAll' },
|
||||
{ key: 'watching', label: 'filterWatching' },
|
||||
{ key: 'overdue', label: 'filterOverdue' },
|
||||
{ key: 'stopped', label: 'filterStopped' },
|
||||
{ key: 'not_started', label: 'filterNotStarted' },
|
||||
];
|
||||
|
||||
const { t } = useI18n();
|
||||
const msg = useMessage();
|
||||
const loading = ref(false);
|
||||
const orders = ref<EquipmentAcceptanceOrder[]>([]);
|
||||
const focus = ref<FocusKey>('all');
|
||||
const page = ref(1);
|
||||
const pageSize = ref(20);
|
||||
const total = ref(0);
|
||||
const pages = ref(1);
|
||||
const summary = ref<EquipmentAcceptanceSummary>({
|
||||
watching: 0,
|
||||
overdue: 0,
|
||||
stopped: 0,
|
||||
not_started: 0,
|
||||
});
|
||||
|
||||
/**
|
||||
* 加载当前分组的验收单,并刷新全部单据的汇总数字。
|
||||
* 核心逻辑:汇总不受当前筛选影响,由接口的 summary 给出。
|
||||
* @param resetPage - 为 true 时回到第一页,用于更换筛选。
|
||||
*/
|
||||
async function load(resetPage = false): Promise<void> {
|
||||
if (resetPage) page.value = 1;
|
||||
loading.value = true;
|
||||
try {
|
||||
const result = await listEquipmentAcceptanceOrders({
|
||||
focus: focus.value,
|
||||
page: page.value,
|
||||
pageSize: pageSize.value,
|
||||
});
|
||||
orders.value = result.items || [];
|
||||
total.value = result.total || 0;
|
||||
pages.value = result.pages || 1;
|
||||
if (result.summary) summary.value = result.summary;
|
||||
} catch (error) {
|
||||
msg.error(error instanceof BusinessError ? error.message : t('admin.equipmentAcceptance.loadFailed'));
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换原型分组并回到第一页。
|
||||
* @param next - all、watching、overdue、stopped、not_started
|
||||
*/
|
||||
function selectFocus(next: FocusKey): void {
|
||||
if (focus.value === next) return;
|
||||
focus.value = next;
|
||||
void load(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 把节点名称拼成一格。没有节点时显示横线。
|
||||
* @param order - 列表行
|
||||
* @returns 节点名称
|
||||
*/
|
||||
function nodeNames(order: EquipmentAcceptanceOrder): string {
|
||||
const names = (order.nodes || []).map((node) => node.node_name).filter((name): name is string => Boolean(name));
|
||||
return names.length ? names.join('、') : '—';
|
||||
}
|
||||
|
||||
/**
|
||||
* 把当前处理人姓名去重后拼成一格。这些人不一定是未办。
|
||||
* @param order - 列表行
|
||||
* @returns 处理人姓名
|
||||
*/
|
||||
function handlerNames(order: EquipmentAcceptanceOrder): string {
|
||||
const names = Array.from(new Set(
|
||||
(order.operators || []).map((item) => item.handler_name).filter((name): name is string => Boolean(name)),
|
||||
));
|
||||
return names.length ? names.join('、') : '—';
|
||||
}
|
||||
|
||||
/**
|
||||
* 只取日期部分展示计时起点。
|
||||
* @param value - 接口返回的时间字符串
|
||||
* @returns 日期或横线
|
||||
*/
|
||||
function dateText(value?: string | null): string {
|
||||
if (!value) return '—';
|
||||
return value.slice(0, 10);
|
||||
}
|
||||
|
||||
/**
|
||||
* 未开始或没有天数时显示横线,其余显示「N 天」。
|
||||
* @param order - 列表行
|
||||
* @returns 签核天数文案
|
||||
*/
|
||||
function dwellText(order: EquipmentAcceptanceOrder): string {
|
||||
if (order.monitor_status === 'not_started' || order.dwell_days == null) return '—';
|
||||
return t('admin.equipmentAcceptance.daysValue', { days: order.dwell_days });
|
||||
}
|
||||
|
||||
/**
|
||||
* 按监控状态收成徽章。已逾期用红色,表示还要提醒。不再提醒用绿色,未开始和未超时用灰色。
|
||||
* @param order - 列表行
|
||||
* @returns 文案和颜色
|
||||
*/
|
||||
function statusBadge(order: EquipmentAcceptanceOrder): { label: string; tone: BadgeTone } {
|
||||
if (order.monitor_status === 'watching' && order.overdue) {
|
||||
return { label: t('admin.equipmentAcceptance.badgeOverdue'), tone: 'red' };
|
||||
}
|
||||
if (order.monitor_status === 'watching') {
|
||||
return { label: t('admin.equipmentAcceptance.badgeOnTime'), tone: 'gray' };
|
||||
}
|
||||
return {
|
||||
label: t(`admin.equipmentAcceptance.statusLabel.${order.monitor_status}`),
|
||||
tone: STOPPED_STATUSES.has(order.monitor_status) ? 'green' : 'gray',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 徽章底色。红是已逾期,绿是不再提醒,灰是未超时、未开始和不在监控范围。
|
||||
* @param tone - 徽章颜色
|
||||
* @returns Tailwind 类名
|
||||
*/
|
||||
function badgeClass(tone: BadgeTone): string {
|
||||
if (tone === 'red') return 'bg-[#fff0ef] text-[#b42318]';
|
||||
if (tone === 'green') return 'bg-[#eafaf1] text-[#067647]';
|
||||
return 'bg-[#edf1f6] text-[#475569]';
|
||||
}
|
||||
|
||||
defineExpose({ reload: () => load(false) });
|
||||
|
||||
onMounted(() => {
|
||||
void load();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="flex min-h-0 flex-1 flex-col gap-3 px-5 pb-4 pt-3">
|
||||
<div class="grid grid-cols-4 gap-3">
|
||||
<article class="rounded-xl border border-[#dce4ef] bg-white px-4 py-3.5">
|
||||
<b class="block text-[26px] font-bold leading-none text-[#142033]">{{ summary.watching }}</b>
|
||||
<span class="mt-1 block text-xs text-[#64748b]">{{ t('admin.equipmentAcceptance.kpiWatching') }}</span>
|
||||
</article>
|
||||
<article class="rounded-xl border border-[#dce4ef] bg-white px-4 py-3.5">
|
||||
<b class="block text-[26px] font-bold leading-none text-[#142033]">{{ summary.overdue }}</b>
|
||||
<span class="mt-1 block text-xs text-[#64748b]">{{ t('admin.equipmentAcceptance.kpiOverdue') }}</span>
|
||||
</article>
|
||||
<article class="rounded-xl border border-[#dce4ef] bg-white px-4 py-3.5">
|
||||
<b class="block text-[26px] font-bold leading-none text-[#142033]">{{ summary.stopped }}</b>
|
||||
<span class="mt-1 block text-xs text-[#64748b]">{{ t('admin.equipmentAcceptance.kpiStopped') }}</span>
|
||||
</article>
|
||||
<article class="rounded-xl border border-[#dce4ef] bg-white px-4 py-3.5">
|
||||
<b class="block text-[26px] font-bold leading-none text-[#142033]">{{ summary.not_started }}</b>
|
||||
<span class="mt-1 block text-xs text-[#64748b]">{{ t('admin.equipmentAcceptance.filterNotStarted') }}</span>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
<div class="flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-[#dce4ef] bg-white">
|
||||
<div class="flex flex-wrap gap-2 p-3">
|
||||
<button
|
||||
v-for="item in filters"
|
||||
:key="item.key"
|
||||
type="button"
|
||||
class="rounded-full border px-2.5 py-1 text-xs font-bold"
|
||||
:class="focus === item.key
|
||||
? 'border-[#bfdbfe] bg-[#eaf2ff] text-[#1d4ed8]'
|
||||
: 'border-[#dce4ef] bg-white text-[#475569]'"
|
||||
@click="selectFocus(item.key)"
|
||||
>
|
||||
{{ t(`admin.equipmentAcceptance.${item.label}`) }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="min-h-0 flex-1 overflow-auto">
|
||||
<table class="min-w-[960px] w-full border-collapse text-left text-xs">
|
||||
<thead class="sticky top-0 bg-[#f8fbff] text-[#64748b]">
|
||||
<tr>
|
||||
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.acceptanceNo') }}</th>
|
||||
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.purchaseOrderNo') }}</th>
|
||||
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.applicant') }}</th>
|
||||
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.currentNodes') }}</th>
|
||||
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.currentHandlers') }}</th>
|
||||
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.timerStart') }}</th>
|
||||
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.dwellDays') }}</th>
|
||||
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.status') }}</th>
|
||||
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="item in orders" :key="item.id" class="border-b border-[#dce4ef] hover:bg-[#f3f7ff]">
|
||||
<td class="px-3 py-2.5 font-bold text-[#142033]">{{ item.acceptance_no || '—' }}</td>
|
||||
<td class="px-3 py-2.5">{{ item.purchase_order_no || '—' }}</td>
|
||||
<td class="px-3 py-2.5">{{ item.applicant_name || '—' }}</td>
|
||||
<td class="px-3 py-2.5">{{ nodeNames(item) }}</td>
|
||||
<td class="px-3 py-2.5">{{ handlerNames(item) }}</td>
|
||||
<td class="px-3 py-2.5">{{ dateText(item.timer_started_at) }}</td>
|
||||
<td class="px-3 py-2.5">{{ dwellText(item) }}</td>
|
||||
<td class="px-3 py-2.5">
|
||||
<span
|
||||
class="inline-flex rounded-full px-2 py-0.5 text-[11px] font-extrabold"
|
||||
:class="badgeClass(statusBadge(item).tone)"
|
||||
>
|
||||
{{ statusBadge(item).label }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-3 py-2.5">
|
||||
<button class="font-extrabold text-[#175cd3]" type="button" @click="emit('open-detail', item.id)">
|
||||
{{ t('admin.equipmentAcceptance.detail') }}
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="!loading && !orders.length">
|
||||
<td colspan="9" class="px-3 py-9 text-center text-[#64748b]">{{ t('admin.equipmentAcceptance.empty') }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<PaginationBar
|
||||
class="shrink-0"
|
||||
v-model:page="page"
|
||||
v-model:page-size="pageSize"
|
||||
:total="total"
|
||||
:pages="pages"
|
||||
@update:page="() => load()"
|
||||
@update:page-size="() => load()"
|
||||
/>
|
||||
</section>
|
||||
</template>
|
||||
@@ -0,0 +1,137 @@
|
||||
<!--
|
||||
features/equipment-acceptance/views/EquipmentAcceptanceSendsPage.vue
|
||||
用途:设备验收预警发送记录页,列出每张验收单某一档的主送、抄送和结果。
|
||||
依赖:equipment-acceptance.api、PaginationBar、统一消息提示、vue-i18n。
|
||||
逻辑:由 Chat 作业面的「发送记录」Tab 嵌入。只读已落库记录。扫描尚未写入时显示空状态。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import PaginationBar from '@/shared/components/PaginationBar.vue';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { formatLocalDateTime } from '@/shared/utils/dateTime';
|
||||
import {
|
||||
listEquipmentAcceptanceSends,
|
||||
type EquipmentAcceptanceSendRecord,
|
||||
} from '../api/equipment-acceptance.api';
|
||||
|
||||
const { t, te } = useI18n();
|
||||
const msg = useMessage();
|
||||
const records = ref<EquipmentAcceptanceSendRecord[]>([]);
|
||||
const loading = ref(false);
|
||||
const page = ref(1);
|
||||
const pageSize = ref(20);
|
||||
const total = ref(0);
|
||||
const pages = ref(1);
|
||||
|
||||
/**
|
||||
* 拉取当前页发送记录。
|
||||
* 核心逻辑:失败时清空表格并提示。空列表留给模板显示「还没有发送记录」。
|
||||
*/
|
||||
async function load(): Promise<void> {
|
||||
loading.value = true;
|
||||
try {
|
||||
const result = await listEquipmentAcceptanceSends({ page: page.value, pageSize: pageSize.value });
|
||||
records.value = result.items || [];
|
||||
total.value = result.total || 0;
|
||||
pages.value = Math.max(1, Math.ceil(total.value / pageSize.value));
|
||||
} catch (error) {
|
||||
records.value = [];
|
||||
total.value = 0;
|
||||
pages.value = 1;
|
||||
msg.error(error instanceof BusinessError ? error.message : t('admin.equipmentAcceptance.sendsFailed'));
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 轮次列写成「超过 N 天」。
|
||||
* @param item - 一条发送记录
|
||||
* @returns 轮次文案
|
||||
*/
|
||||
function tierText(item: EquipmentAcceptanceSendRecord): string {
|
||||
return t('admin.equipmentAcceptance.ruleOver', { days: item.threshold_days });
|
||||
}
|
||||
|
||||
/**
|
||||
* 结果用已知状态文案。未知状态保留原值。
|
||||
* @param status - pending、sent、failed、cancelled
|
||||
* @returns 结果文案
|
||||
*/
|
||||
function statusText(status: string): string {
|
||||
const key = `admin.equipmentAcceptance.sendStatus.${status}`;
|
||||
return te(key) ? t(key) : status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 已发送显示本地时间,待发送没有时间时显示横线。
|
||||
* @param value - 接口返回的发送时间
|
||||
* @returns 时间或横线
|
||||
*/
|
||||
function sentText(value?: string | null): string {
|
||||
if (!value) return '—';
|
||||
const text = formatLocalDateTime(value);
|
||||
return text === '-' ? '—' : text;
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void load();
|
||||
});
|
||||
|
||||
defineExpose({ reload: load });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="flex min-h-0 flex-1 flex-col gap-3 px-5 pb-4 pt-3">
|
||||
<p class="text-xs text-[#64748b]">{{ t('admin.equipmentAcceptance.sendsLead') }}</p>
|
||||
<div class="flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-[#dce4ef] bg-white">
|
||||
<div class="min-h-0 flex-1 overflow-auto">
|
||||
<table class="min-w-[960px] w-full border-collapse text-left text-xs">
|
||||
<thead class="sticky top-0 bg-[#f8fbff] text-[#64748b]">
|
||||
<tr>
|
||||
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.acceptanceNo') }}</th>
|
||||
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.purchaseOrderNo') }}</th>
|
||||
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.ruleTier') }}</th>
|
||||
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.ruleTo') }}</th>
|
||||
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.ruleCc') }}</th>
|
||||
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.sendResult') }}</th>
|
||||
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.sentAt') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="item in records" :key="item.id" class="border-b border-[#dce4ef]">
|
||||
<td class="px-3 py-2.5 font-bold text-[#142033]">{{ item.acceptance_no || '—' }}</td>
|
||||
<td class="px-3 py-2.5">{{ item.purchase_order_no || '—' }}</td>
|
||||
<td class="px-3 py-2.5">{{ tierText(item) }}</td>
|
||||
<td class="px-3 py-2.5">{{ item.to_text || '—' }}</td>
|
||||
<td class="px-3 py-2.5">{{ item.cc_text || '—' }}</td>
|
||||
<td class="px-3 py-2.5">
|
||||
{{ statusText(item.status) }}
|
||||
<span v-if="item.error_message" class="mt-1 block text-[#b42318]">
|
||||
{{ item.error_message }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-3 py-2.5">{{ sentText(item.sent_at) }}</td>
|
||||
</tr>
|
||||
<tr v-if="!loading && !records.length">
|
||||
<td colspan="7" class="px-3 py-10 text-center text-[#64748b]">
|
||||
{{ t('admin.equipmentAcceptance.sendsEmpty') }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<PaginationBar
|
||||
class="shrink-0"
|
||||
v-model:page="page"
|
||||
v-model:page-size="pageSize"
|
||||
:total="total"
|
||||
:pages="pages"
|
||||
@update:page="() => load()"
|
||||
@update:page-size="() => load()"
|
||||
/>
|
||||
</section>
|
||||
</template>
|
||||
Reference in new issue
Block a user