feat(equipment-acceptance): 设备验收预警
This commit is contained in:
1 parent
239d373503
commit
86fc8a2c06
48 files changed
+6196
-82
No files matched your search
@@ -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