feat: 评估页改成页面内提交,任务列表放在下面,去掉两个弹窗
- 单个提交直接在页面上填:左边评估对象(按小区或按站点),右边拆除信息 - 导入清单在页面上传:左边选文件和地市,右边是填写说明或预览 - 提交后不再弹出详情,新任务排到列表最前面并短暂标亮;单个提交后保留拆除信息 - 从表格粘贴 CGI 和小区名两列时名称一起带上,表头行和重复的 CGI 跳过 - 列表里下载按钮带文字;只有一个站点的任务显示正在做哪一步(接口新增 stage) - 窗口不够宽时提交时间并到评估对象下面,再窄换成卡片,表格不再横向滚动
This commit is contained in:
@@ -1,255 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from "vue";
|
||||
import { NAlert, NButton, NCheckbox, NIcon, NInput, NModal, NSpin } from "naive-ui";
|
||||
import { CloudUploadOutline, DocumentTextOutline } from "@vicons/ionicons5";
|
||||
import { api } from "../../shared/http";
|
||||
import { useToast } from "../../shared/toast";
|
||||
import { downloadFile } from "./eval";
|
||||
import type { EvalJob, EvalOptions } from "./eval";
|
||||
|
||||
interface PreviewRow {
|
||||
line: number;
|
||||
cgi: string;
|
||||
orderType: string;
|
||||
needDate: string | null;
|
||||
cellName: string;
|
||||
county: string;
|
||||
}
|
||||
|
||||
interface Preview {
|
||||
sheet: string;
|
||||
rows: PreviewRow[];
|
||||
total: number;
|
||||
errors: { line: number; cgi: string; message: string }[];
|
||||
errorCount: number;
|
||||
summary: { sites: number; pinduan: number; dixiao: number; cells: number };
|
||||
}
|
||||
|
||||
const props = defineProps<{ show: boolean; options: EvalOptions | null }>();
|
||||
const emit = defineEmits<{ (event: "update:show", value: boolean): void; (event: "submitted", job: EvalJob): void }>();
|
||||
|
||||
const toast = useToast();
|
||||
const picker = ref<HTMLInputElement | null>(null);
|
||||
const file = ref<File | null>(null);
|
||||
const preview = ref<Preview | null>(null);
|
||||
const reading = ref(false);
|
||||
const saving = ref(false);
|
||||
const dragging = ref(false);
|
||||
const city = ref("");
|
||||
const skipErrors = ref(false);
|
||||
const readError = ref("");
|
||||
|
||||
const visible = computed({
|
||||
get: () => props.show,
|
||||
set: (value: boolean) => emit("update:show", value),
|
||||
});
|
||||
const canSubmit = computed(() => Boolean(preview.value && preview.value.total && (!preview.value.errorCount || skipErrors.value) && city.value.trim()));
|
||||
|
||||
watch(
|
||||
() => props.show,
|
||||
(open) => {
|
||||
if (!open) return;
|
||||
file.value = null;
|
||||
preview.value = null;
|
||||
readError.value = "";
|
||||
skipErrors.value = false;
|
||||
city.value = props.options?.city || "";
|
||||
},
|
||||
);
|
||||
|
||||
function choose() {
|
||||
picker.value?.click();
|
||||
}
|
||||
|
||||
function onPicked(event: Event) {
|
||||
const input = event.target as HTMLInputElement;
|
||||
const picked = input.files?.[0];
|
||||
input.value = "";
|
||||
if (picked) void read(picked);
|
||||
}
|
||||
|
||||
function onDrop(event: DragEvent) {
|
||||
dragging.value = false;
|
||||
const picked = event.dataTransfer?.files?.[0];
|
||||
if (picked) void read(picked);
|
||||
}
|
||||
|
||||
async function read(picked: File) {
|
||||
if (!/\.(xlsx|xlsm|csv)$/i.test(picked.name)) {
|
||||
readError.value = "清单只支持 xlsx 或 csv";
|
||||
return;
|
||||
}
|
||||
file.value = picked;
|
||||
preview.value = null;
|
||||
readError.value = "";
|
||||
skipErrors.value = false;
|
||||
reading.value = true;
|
||||
try {
|
||||
const body = new FormData();
|
||||
body.append("file", picked);
|
||||
preview.value = await api<Preview>("/api/eval/preview", { method: "POST", body });
|
||||
} catch (error) {
|
||||
readError.value = error instanceof Error ? error.message : "清单没有读出来";
|
||||
} finally {
|
||||
reading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function downloadTemplate() {
|
||||
try {
|
||||
await downloadFile("/api/eval/template", "拆站清单模板.xlsx");
|
||||
} catch (error) {
|
||||
toast.error(error instanceof Error ? error.message : "下载失败");
|
||||
}
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
if (!file.value || !canSubmit.value) return;
|
||||
saving.value = true;
|
||||
try {
|
||||
const body = new FormData();
|
||||
body.append("file", file.value);
|
||||
body.append("city", city.value.trim());
|
||||
body.append("skipErrors", skipErrors.value ? "true" : "false");
|
||||
const result = await api<{ job: EvalJob }>("/api/eval/jobs/list", { method: "POST", body });
|
||||
toast.success(`已提交 ${result.job.total} 个站点,后台开始评估`);
|
||||
emit("submitted", result.job);
|
||||
visible.value = false;
|
||||
} catch (error) {
|
||||
toast.error(error instanceof Error ? error.message : "提交失败");
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<n-modal v-model:show="visible" class="app-dialog app-dialog-import" preset="card" title="导入清单" :mask-closable="!saving">
|
||||
<div class="import-body">
|
||||
<div
|
||||
class="drop"
|
||||
:class="{ dragging, picked: Boolean(file) }"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
@click="choose"
|
||||
@keydown.enter.prevent="choose"
|
||||
@dragover.prevent="dragging = true"
|
||||
@dragleave.prevent="dragging = false"
|
||||
@drop.prevent="onDrop"
|
||||
>
|
||||
<n-icon :size="26" :component="file ? DocumentTextOutline : CloudUploadOutline" />
|
||||
<div v-if="file" class="drop-text">
|
||||
<strong>{{ file.name }}</strong>
|
||||
<span>点击或拖入另一份清单可重新选择</span>
|
||||
</div>
|
||||
<div v-else class="drop-text">
|
||||
<strong>点击选择或拖入拆站清单</strong>
|
||||
<span>支持 xlsx、csv;优先读取「拆站清单」工作表</span>
|
||||
</div>
|
||||
<input ref="picker" type="file" accept=".xlsx,.xlsm,.csv" hidden @change="onPicked" />
|
||||
</div>
|
||||
<div class="template-line">
|
||||
<span>第一次使用可以先下载模板,按表头填写。</span>
|
||||
<n-button text type="primary" @click="downloadTemplate">下载清单模板</n-button>
|
||||
</div>
|
||||
|
||||
<n-spin :show="reading">
|
||||
<n-alert v-if="readError" type="error" :show-icon="false">{{ readError }}</n-alert>
|
||||
<template v-if="preview">
|
||||
<div class="summary">
|
||||
<div><span>小区</span><strong>{{ preview.total }}</strong></div>
|
||||
<div><span>逻辑站点</span><strong>{{ preview.summary.sites }}</strong></div>
|
||||
<div><span>频段清退</span><strong>{{ preview.summary.pinduan }}</strong></div>
|
||||
<div><span>低效拆除</span><strong>{{ preview.summary.dixiao }}</strong></div>
|
||||
<div :class="{ bad: preview.errorCount }"><span>有问题的行</span><strong>{{ preview.errorCount }}</strong></div>
|
||||
</div>
|
||||
<div v-if="preview.errorCount" class="error-box">
|
||||
<table class="mini-table">
|
||||
<thead><tr><th class="col-line">行</th><th>CGI</th><th>问题</th></tr></thead>
|
||||
<tbody>
|
||||
<tr v-for="item in preview.errors" :key="item.line">
|
||||
<td class="col-line">{{ item.line }}</td>
|
||||
<td>{{ item.cgi || "—" }}</td>
|
||||
<td class="status-bad">{{ item.message }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div v-if="preview.total" class="rows-box">
|
||||
<table class="mini-table">
|
||||
<thead><tr><th class="col-line">行</th><th>CGI</th><th>小区名</th><th>需求日期</th><th>退网工单类型</th><th>区县</th></tr></thead>
|
||||
<tbody>
|
||||
<tr v-for="row in preview.rows" :key="row.line">
|
||||
<td class="col-line">{{ row.line }}</td>
|
||||
<td class="nowrap">{{ row.cgi }}</td>
|
||||
<td class="clip" :title="row.cellName">{{ row.cellName || "按 CGI 从工参补齐" }}</td>
|
||||
<td class="nowrap">{{ row.needDate }}</td>
|
||||
<td class="nowrap">{{ row.orderType }}</td>
|
||||
<td class="nowrap">{{ row.county }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p v-if="preview.total > preview.rows.length" class="more">只显示前 {{ preview.rows.length }} 行,提交时按全部 {{ preview.total }} 行评估。</p>
|
||||
</div>
|
||||
<div class="form-row city-row">
|
||||
<label>地市</label>
|
||||
<n-input v-model:value="city" maxlength="32" />
|
||||
</div>
|
||||
<n-checkbox v-if="preview.errorCount" v-model:checked="skipErrors">跳过有问题的 {{ preview.errorCount }} 行,其余照常评估</n-checkbox>
|
||||
</template>
|
||||
</n-spin>
|
||||
</div>
|
||||
<template #footer>
|
||||
<div class="dialog-actions">
|
||||
<n-button :disabled="saving" @click="visible = false">取消</n-button>
|
||||
<n-button type="primary" :loading="saving" :disabled="!canSubmit" @click="submit">
|
||||
{{ preview ? `提交 ${preview.summary.sites} 个站点` : "提交" }}
|
||||
</n-button>
|
||||
</div>
|
||||
</template>
|
||||
</n-modal>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.import-body { display: grid; gap: 14px; min-width: 0; }
|
||||
.drop {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
padding: 18px 20px;
|
||||
border: 1px dashed var(--line);
|
||||
border-radius: 8px;
|
||||
color: var(--muted);
|
||||
cursor: pointer;
|
||||
transition: border-color 0.15s, background 0.15s;
|
||||
}
|
||||
.drop:hover,
|
||||
.drop.dragging { border-color: var(--accent); background: var(--accent-soft); }
|
||||
.drop.picked { border-style: solid; color: var(--accent); }
|
||||
.drop-text { display: grid; gap: 2px; min-width: 0; }
|
||||
.drop-text strong { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.drop-text span { font-size: 12px; }
|
||||
.template-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12px; }
|
||||
.summary { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
|
||||
.summary > div { padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-2); }
|
||||
.summary span { display: block; color: var(--muted); font-size: 12px; }
|
||||
.summary strong { display: block; margin-top: 2px; font-size: 18px; font-weight: 650; }
|
||||
.summary .bad strong { color: var(--danger); }
|
||||
.error-box,
|
||||
.rows-box { max-height: 220px; overflow: auto; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 6px; }
|
||||
.mini-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px; }
|
||||
.mini-table th,
|
||||
.mini-table td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; }
|
||||
.mini-table th { position: sticky; top: 0; background: var(--panel-2); font-weight: 650; }
|
||||
.mini-table tbody tr:last-child td { border-bottom: 0; }
|
||||
.col-line { width: 48px; color: var(--muted); }
|
||||
.nowrap { white-space: nowrap; }
|
||||
.clip { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.more { margin: 0; padding: 6px 10px; color: var(--muted); font-size: 12px; }
|
||||
.city-row { margin: 0 0 10px; }
|
||||
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
|
||||
@media (max-width: 640px) {
|
||||
.summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
||||
.template-line { flex-direction: column; align-items: flex-start; }
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,305 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from "vue";
|
||||
import { NAlert, NButton, NCheckbox, NIcon, NInput, NSpin } from "naive-ui";
|
||||
import { CloudUploadOutline, DocumentTextOutline } from "@vicons/ionicons5";
|
||||
import { api } from "../../shared/http";
|
||||
import { useToast } from "../../shared/toast";
|
||||
import { downloadFile } from "./eval";
|
||||
import type { EvalJob, EvalOptions } from "./eval";
|
||||
|
||||
interface PreviewRow {
|
||||
line: number;
|
||||
cgi: string;
|
||||
orderType: string;
|
||||
needDate: string | null;
|
||||
cellName: string;
|
||||
county: string;
|
||||
}
|
||||
|
||||
interface Preview {
|
||||
sheet: string;
|
||||
rows: PreviewRow[];
|
||||
total: number;
|
||||
errors: { line: number; cgi: string; message: string }[];
|
||||
errorCount: number;
|
||||
summary: { sites: number; pinduan: number; dixiao: number; cells: number };
|
||||
}
|
||||
|
||||
const props = defineProps<{ options: EvalOptions | null }>();
|
||||
const emit = defineEmits<{ (event: "submitted", job: EvalJob): void }>();
|
||||
|
||||
const toast = useToast();
|
||||
const picker = ref<HTMLInputElement | null>(null);
|
||||
const file = ref<File | null>(null);
|
||||
const preview = ref<Preview | null>(null);
|
||||
const reading = ref(false);
|
||||
const saving = ref(false);
|
||||
const dragging = ref(false);
|
||||
const city = ref("");
|
||||
const skipErrors = ref(false);
|
||||
const readError = ref("");
|
||||
let readSeq = 0;
|
||||
|
||||
const canSubmit = computed(() => Boolean(preview.value && preview.value.total && (!preview.value.errorCount || skipErrors.value) && city.value.trim()));
|
||||
const footHint = computed(() => {
|
||||
const data = preview.value;
|
||||
if (reading.value) return "正在读取清单…";
|
||||
if (!data) return "选好清单后先看预览,确认无误再提交。";
|
||||
if (!data.total) return "清单里没有可评估的行。";
|
||||
if (data.errorCount && !skipErrors.value) return `有 ${data.errorCount} 行有问题:改好清单重新选择,或勾选跳过这些行。`;
|
||||
if (!city.value.trim()) return "请填写地市。";
|
||||
return `共 ${data.total} 个小区,按 ${data.summary.sites} 个逻辑站点评估。`;
|
||||
});
|
||||
|
||||
// 默认地市等接口返回后再补,已经填过的不覆盖。
|
||||
watch(
|
||||
() => props.options,
|
||||
(value) => {
|
||||
if (value && !city.value) city.value = value.city || "";
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
function choose() {
|
||||
picker.value?.click();
|
||||
}
|
||||
|
||||
function onPicked(event: Event) {
|
||||
const input = event.target as HTMLInputElement;
|
||||
const picked = input.files?.[0];
|
||||
input.value = "";
|
||||
if (picked) void read(picked);
|
||||
}
|
||||
|
||||
function onDrop(event: DragEvent) {
|
||||
dragging.value = false;
|
||||
const picked = event.dataTransfer?.files?.[0];
|
||||
if (picked) void read(picked);
|
||||
}
|
||||
|
||||
async function read(picked: File) {
|
||||
if (saving.value) return;
|
||||
if (!/\.(xlsx|xlsm|csv)$/i.test(picked.name)) {
|
||||
readError.value = "清单只支持 xlsx 或 csv";
|
||||
return;
|
||||
}
|
||||
const seq = ++readSeq;
|
||||
file.value = picked;
|
||||
preview.value = null;
|
||||
readError.value = "";
|
||||
skipErrors.value = false;
|
||||
reading.value = true;
|
||||
try {
|
||||
const body = new FormData();
|
||||
body.append("file", picked);
|
||||
const result = await api<Preview>("/api/eval/preview", { method: "POST", body });
|
||||
if (seq === readSeq) preview.value = result;
|
||||
} catch (error) {
|
||||
if (seq === readSeq) readError.value = error instanceof Error ? error.message : "清单没有读出来";
|
||||
} finally {
|
||||
if (seq === readSeq) reading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function clear() {
|
||||
readSeq += 1;
|
||||
file.value = null;
|
||||
preview.value = null;
|
||||
readError.value = "";
|
||||
skipErrors.value = false;
|
||||
reading.value = false;
|
||||
}
|
||||
|
||||
async function downloadTemplate() {
|
||||
try {
|
||||
await downloadFile("/api/eval/template", "拆站清单模板.xlsx");
|
||||
} catch (error) {
|
||||
toast.error(error instanceof Error ? error.message : "下载失败");
|
||||
}
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
if (!file.value || !canSubmit.value || saving.value) return;
|
||||
saving.value = true;
|
||||
try {
|
||||
const body = new FormData();
|
||||
body.append("file", file.value);
|
||||
body.append("city", city.value.trim());
|
||||
body.append("skipErrors", skipErrors.value ? "true" : "false");
|
||||
const result = await api<{ job: EvalJob }>("/api/eval/jobs/list", { method: "POST", body });
|
||||
toast.success(`已提交 ${result.job.total} 个站点,后台开始评估`);
|
||||
emit("submitted", result.job);
|
||||
clear();
|
||||
} catch (error) {
|
||||
toast.error(error instanceof Error ? error.message : "提交失败");
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="eval-panel">
|
||||
<div class="import-grid">
|
||||
<section class="import-side">
|
||||
<div
|
||||
class="drop"
|
||||
:class="{ dragging, picked: Boolean(file) }"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
:aria-label="file ? `已选择 ${file.name},点击重新选择` : '选择拆站清单'"
|
||||
@click="choose"
|
||||
@keydown.enter.prevent="choose"
|
||||
@keydown.space.prevent="choose"
|
||||
@dragover.prevent="dragging = true"
|
||||
@dragleave.prevent="dragging = false"
|
||||
@drop.prevent="onDrop"
|
||||
>
|
||||
<n-icon :size="28" :component="file ? DocumentTextOutline : CloudUploadOutline" />
|
||||
<template v-if="file">
|
||||
<strong :title="file.name">{{ file.name }}</strong>
|
||||
<span>点击或拖入另一份清单重新选择</span>
|
||||
</template>
|
||||
<template v-else>
|
||||
<strong>点击选择或拖入拆站清单</strong>
|
||||
<span>支持 xlsx、csv</span>
|
||||
</template>
|
||||
<input ref="picker" type="file" accept=".xlsx,.xlsm,.csv" hidden @change="onPicked" />
|
||||
</div>
|
||||
<p class="template-line">
|
||||
第一次用先<n-button text type="primary" @click="downloadTemplate">下载清单模板</n-button>,按表头填好再上传。
|
||||
</p>
|
||||
<div class="form-row city-row">
|
||||
<label for="eval-import-city">地市</label>
|
||||
<n-input v-model:value="city" maxlength="32" :input-props="{ id: 'eval-import-city' }" />
|
||||
</div>
|
||||
<n-checkbox v-if="preview?.errorCount" v-model:checked="skipErrors">跳过有问题的 {{ preview.errorCount }} 行,其余照常评估</n-checkbox>
|
||||
</section>
|
||||
|
||||
<section class="import-main">
|
||||
<n-spin :show="reading">
|
||||
<n-alert v-if="readError" type="error" :show-icon="false">{{ readError }}</n-alert>
|
||||
<template v-else-if="preview">
|
||||
<div class="summary">
|
||||
<div><span>小区</span><strong>{{ preview.total }}</strong></div>
|
||||
<div><span>逻辑站点</span><strong>{{ preview.summary.sites }}</strong></div>
|
||||
<div><span>频段清退</span><strong>{{ preview.summary.pinduan }}</strong></div>
|
||||
<div><span>低效拆除</span><strong>{{ preview.summary.dixiao }}</strong></div>
|
||||
<div :class="{ bad: preview.errorCount }"><span>有问题的行</span><strong>{{ preview.errorCount }}</strong></div>
|
||||
</div>
|
||||
<div v-if="preview.errorCount" class="error-box">
|
||||
<table class="mini-table">
|
||||
<thead><tr><th class="col-line">行</th><th>CGI</th><th>问题</th></tr></thead>
|
||||
<tbody>
|
||||
<tr v-for="item in preview.errors" :key="item.line">
|
||||
<td class="col-line">{{ item.line }}</td>
|
||||
<td class="nowrap">{{ item.cgi || "—" }}</td>
|
||||
<td class="status-bad">{{ item.message }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p v-if="preview.errorCount > preview.errors.length" class="more">只显示前 {{ preview.errors.length }} 行问题,一共 {{ preview.errorCount }} 行。</p>
|
||||
</div>
|
||||
<div v-if="preview.total" class="rows-box">
|
||||
<table class="mini-table">
|
||||
<thead><tr><th class="col-line">行</th><th>CGI</th><th>小区名</th><th>需求日期</th><th>退网工单类型</th><th>区县</th></tr></thead>
|
||||
<tbody>
|
||||
<tr v-for="row in preview.rows" :key="row.line">
|
||||
<td class="col-line">{{ row.line }}</td>
|
||||
<td class="nowrap">{{ row.cgi }}</td>
|
||||
<td class="clip" :class="{ faint: !row.cellName }" :title="row.cellName">{{ row.cellName || "按 CGI 从工参补齐" }}</td>
|
||||
<td class="nowrap">{{ row.needDate }}</td>
|
||||
<td class="nowrap">{{ row.orderType }}</td>
|
||||
<td class="nowrap">{{ row.county }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p v-if="preview.total > preview.rows.length" class="more">只显示前 {{ preview.rows.length }} 行,提交时按全部 {{ preview.total }} 行评估。</p>
|
||||
</div>
|
||||
</template>
|
||||
<div v-else class="guide">
|
||||
<h3>清单怎么填</h3>
|
||||
<dl>
|
||||
<div><dt>必填的列</dt><dd>CGI、退网工单类型、需求日期</dd></div>
|
||||
<div><dt>可填的列</dt><dd>小区名(建议填)、区县、发起人、退网原因(模板里叫「是否已发邮件安排拆除」)</dd></div>
|
||||
<div><dt>一行一个小区</dt><dd>小区名去掉末尾「-数字」后相同的几行算一个逻辑站点,一起评估;没写小区名的按基站归到一起。</dd></div>
|
||||
<div><dt>出哪份结果表</dt><dd>工单类型含「低效拆除」的出低效拆除评估,其余出频段清退评估。</dd></div>
|
||||
<div><dt>文件大小</dt><dd>10 MB、5000 行、1000 个逻辑站点以内;xlsx 优先读「拆站清单」工作表。</dd></div>
|
||||
</dl>
|
||||
</div>
|
||||
</n-spin>
|
||||
</section>
|
||||
</div>
|
||||
<footer class="eval-foot">
|
||||
<span class="eval-foot-hint" :class="{ 'status-bad': Boolean(preview?.errorCount) && !skipErrors }">{{ footHint }}</span>
|
||||
<div class="eval-foot-actions">
|
||||
<n-button v-if="file" :disabled="saving" @click="clear">清空</n-button>
|
||||
<n-button type="primary" :loading="saving" :disabled="!canSubmit" @click="submit">
|
||||
{{ preview?.total ? `提交 ${preview.summary.sites} 个站点` : "提交评估" }}
|
||||
</n-button>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.import-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr); }
|
||||
.import-side { display: grid; align-content: start; gap: 12px; min-width: 0; padding: 20px 24px 20px 20px; border-right: 1px solid var(--line); }
|
||||
.import-main { min-width: 0; padding: 20px 20px 20px 24px; }
|
||||
.drop {
|
||||
display: grid;
|
||||
justify-items: center;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
padding: 22px 16px;
|
||||
border: 1px dashed var(--line);
|
||||
border-radius: 8px;
|
||||
color: var(--muted);
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.15s, background 0.15s;
|
||||
}
|
||||
.drop:hover,
|
||||
.drop.dragging { border-color: var(--accent); background: var(--accent-soft); }
|
||||
.drop.picked { border-style: solid; color: var(--accent); }
|
||||
.drop strong { max-width: 100%; overflow: hidden; color: var(--ink); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.drop span { color: var(--muted); font-size: 12px; }
|
||||
.template-line { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
|
||||
.template-line .n-button { margin: 0 2px; font-size: 12px; }
|
||||
.city-row { grid-template-columns: 3em minmax(0, 1fr); margin: 4px 0 0; }
|
||||
.guide h3 { margin: 0 0 12px; font-size: 13px; font-weight: 650; }
|
||||
.guide dl { display: grid; gap: 10px; margin: 0; max-width: 860px; }
|
||||
.guide dl > div { display: grid; grid-template-columns: 7em minmax(0, 1fr); gap: 14px; line-height: 1.6; }
|
||||
.guide dt { color: var(--muted); }
|
||||
.guide dd { margin: 0; }
|
||||
.summary { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
|
||||
.summary > div { padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-2); }
|
||||
.summary span { display: block; color: var(--muted); font-size: 12px; }
|
||||
.summary strong { display: block; margin-top: 2px; font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; }
|
||||
.summary .bad strong { color: var(--danger); }
|
||||
.error-box,
|
||||
.rows-box { overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
|
||||
.error-box { max-height: 150px; margin-bottom: 12px; }
|
||||
.rows-box { max-height: 230px; }
|
||||
.mini-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px; }
|
||||
.mini-table th,
|
||||
.mini-table td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; }
|
||||
.mini-table th { position: sticky; top: 0; background: var(--panel-2); font-weight: 650; white-space: nowrap; }
|
||||
.mini-table tbody tr:last-child td { border-bottom: 0; }
|
||||
.col-line { width: 48px; color: var(--muted); }
|
||||
.nowrap { white-space: nowrap; }
|
||||
.clip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.faint { color: var(--muted); }
|
||||
.more { margin: 0; padding: 6px 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
|
||||
@media (max-width: 1000px) {
|
||||
.import-grid { grid-template-columns: minmax(0, 1fr); }
|
||||
.import-side { padding: 20px 20px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
|
||||
.import-main { padding: 16px 20px 20px; }
|
||||
}
|
||||
@media (max-width: 640px) {
|
||||
.import-side,
|
||||
.import-main { padding-left: 14px; padding-right: 14px; }
|
||||
.summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
||||
.guide dl > div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
|
||||
}
|
||||
</style>
|
||||
@@ -1,210 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, reactive, ref, watch } from "vue";
|
||||
import { NButton, NDatePicker, NIcon, NInput, NModal, NRadioButton, NRadioGroup, NSelect } from "naive-ui";
|
||||
import { AddOutline, CloseOutline } from "@vicons/ionicons5";
|
||||
import { api } from "../../shared/http";
|
||||
import { useToast } from "../../shared/toast";
|
||||
import type { EvalJob, EvalOptions } from "./eval";
|
||||
|
||||
const props = defineProps<{ show: boolean; options: EvalOptions | null }>();
|
||||
const emit = defineEmits<{ (event: "update:show", value: boolean): void; (event: "submitted", job: EvalJob): void }>();
|
||||
|
||||
const CGI = /^\d{3}-\d{2}-\d+-\d+$/;
|
||||
const toast = useToast();
|
||||
const saving = ref(false);
|
||||
const mode = ref<"cells" | "site">("cells");
|
||||
const form = reactive({ orderType: "", removalDate: null as string | null, city: "", county: "", applicant: "", retireReason: "", site: "" });
|
||||
const cells = ref<{ cgi: string; cellName: string }[]>([{ cgi: "", cellName: "" }]);
|
||||
const errors = reactive<Record<string, string>>({});
|
||||
|
||||
const orderOptions = computed(() => (props.options?.orderTypes || ["频段清退", "低效拆除"]).map((value) => ({ label: value, value })));
|
||||
const visible = computed({
|
||||
get: () => props.show,
|
||||
set: (value: boolean) => emit("update:show", value),
|
||||
});
|
||||
|
||||
watch(
|
||||
() => props.show,
|
||||
(open) => {
|
||||
if (!open) return;
|
||||
mode.value = "cells";
|
||||
Object.assign(form, {
|
||||
orderType: props.options?.orderTypes[0] || "频段清退",
|
||||
removalDate: null,
|
||||
city: props.options?.city || "",
|
||||
county: "",
|
||||
applicant: props.options?.applicant || "",
|
||||
retireReason: "",
|
||||
site: "",
|
||||
});
|
||||
cells.value = [{ cgi: "", cellName: "" }];
|
||||
for (const key of Object.keys(errors)) delete errors[key];
|
||||
},
|
||||
);
|
||||
|
||||
function addCell() {
|
||||
cells.value.push({ cgi: "", cellName: "" });
|
||||
}
|
||||
|
||||
function removeCell(index: number) {
|
||||
cells.value.splice(index, 1);
|
||||
if (!cells.value.length) addCell();
|
||||
}
|
||||
|
||||
function onPaste(event: ClipboardEvent, index: number) {
|
||||
const parts = (event.clipboardData?.getData("text") || "").split(/[\s,,;;]+/).map((part) => part.trim()).filter(Boolean);
|
||||
if (parts.length < 2) return;
|
||||
event.preventDefault();
|
||||
cells.value[index].cgi = parts[0];
|
||||
const existing = new Set(cells.value.map((cell) => cell.cgi));
|
||||
const extra = parts.slice(1).filter((part) => !existing.has(part)).map((cgi) => ({ cgi, cellName: "" }));
|
||||
cells.value.splice(index + 1, 0, ...extra);
|
||||
}
|
||||
|
||||
function validate() {
|
||||
for (const key of Object.keys(errors)) delete errors[key];
|
||||
if (!form.orderType.trim()) errors.orderType = "请选择退网工单类型";
|
||||
if (!form.removalDate) errors.removalDate = "请选择拆除日期";
|
||||
if (!form.city.trim()) errors.city = "请填写地市";
|
||||
if (mode.value === "site") {
|
||||
if (!form.site.trim()) errors.site = "请填写站点名称";
|
||||
} else {
|
||||
const filled = cells.value.filter((cell) => cell.cgi.trim());
|
||||
const bad = filled.find((cell) => !CGI.test(cell.cgi.trim()));
|
||||
const seen = new Set<string>();
|
||||
const dup = filled.find((cell) => (seen.has(cell.cgi.trim()) ? true : (seen.add(cell.cgi.trim()), false)));
|
||||
if (!filled.length) errors.cells = "请至少填写一个小区 CGI";
|
||||
else if (bad) errors.cells = `CGI 格式不对:${bad.cgi}`;
|
||||
else if (dup) errors.cells = `CGI 重复:${dup.cgi}`;
|
||||
}
|
||||
return !Object.keys(errors).length;
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
if (!validate()) return;
|
||||
saving.value = true;
|
||||
try {
|
||||
const result = await api<{ job: EvalJob }>("/api/eval/jobs/single", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
...form,
|
||||
mode: mode.value,
|
||||
cells: mode.value === "cells" ? cells.value.filter((cell) => cell.cgi.trim()).map((cell) => ({ cgi: cell.cgi.trim(), cellName: cell.cellName.trim() })) : [],
|
||||
}),
|
||||
});
|
||||
toast.success("已提交,后台开始评估");
|
||||
emit("submitted", result.job);
|
||||
visible.value = false;
|
||||
} catch (error) {
|
||||
toast.error(error instanceof Error ? error.message : "提交失败");
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<n-modal v-model:show="visible" class="app-dialog app-dialog-eval" preset="card" title="单个提交" :mask-closable="!saving">
|
||||
<div class="eval-form">
|
||||
<div class="form-row">
|
||||
<label>提交方式</label>
|
||||
<n-radio-group v-model:value="mode">
|
||||
<n-radio-button value="cells">按小区</n-radio-button>
|
||||
<n-radio-button value="site">按站点</n-radio-button>
|
||||
</n-radio-group>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label>退网工单类型</label>
|
||||
<div>
|
||||
<n-select v-model:value="form.orderType" :options="orderOptions" filterable tag />
|
||||
<p v-if="errors.orderType" class="field-error">{{ errors.orderType }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label>拆除日期</label>
|
||||
<div>
|
||||
<n-date-picker v-model:formatted-value="form.removalDate" type="date" value-format="yyyy-MM-dd" clearable />
|
||||
<p v-if="errors.removalDate" class="field-error">{{ errors.removalDate }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label>地市</label>
|
||||
<div>
|
||||
<n-input v-model:value="form.city" maxlength="32" />
|
||||
<p v-if="errors.city" class="field-error">{{ errors.city }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row form-pair">
|
||||
<label>区县</label>
|
||||
<div class="pair">
|
||||
<n-input v-model:value="form.county" maxlength="64" />
|
||||
<span class="pair-label">申请人</span>
|
||||
<n-input v-model:value="form.applicant" maxlength="64" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row"><label>退网原因</label><n-input v-model:value="form.retireReason" maxlength="255" /></div>
|
||||
|
||||
<div v-if="mode === 'site'" class="form-row form-row-top">
|
||||
<label>站点名称</label>
|
||||
<div>
|
||||
<n-input v-model:value="form.site" maxlength="128" placeholder="如 江门台山市现代技术学校" />
|
||||
<p class="field-hint">按工参里的站点名称取这个站的全部小区。</p>
|
||||
<p v-if="errors.site" class="field-error">{{ errors.site }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="form-row form-row-top">
|
||||
<label>小区</label>
|
||||
<div class="cell-list">
|
||||
<div class="cell-head"><span>CGI</span><span>小区名称(可不填)</span><span /></div>
|
||||
<div v-for="(cell, index) in cells" :key="index" class="cell-row" @paste="onPaste($event, index)">
|
||||
<n-input v-model:value="cell.cgi" placeholder="460-00-679584-1" />
|
||||
<n-input v-model:value="cell.cellName" />
|
||||
<n-button quaternary circle size="small" aria-label="去掉这一行" @click="removeCell(index)">
|
||||
<template #icon><n-icon :component="CloseOutline" /></template>
|
||||
</n-button>
|
||||
</div>
|
||||
<div class="cell-foot">
|
||||
<n-button size="small" dashed @click="addCell">
|
||||
<template #icon><n-icon :component="AddOutline" /></template>
|
||||
添加小区
|
||||
</n-button>
|
||||
<span class="field-hint">同一站点的几个小区一起提交;可以粘贴多个 CGI。</span>
|
||||
</div>
|
||||
<p v-if="errors.cells" class="field-error">{{ errors.cells }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<div class="dialog-actions">
|
||||
<n-button :disabled="saving" @click="visible = false">取消</n-button>
|
||||
<n-button type="primary" :loading="saving" @click="submit">提交</n-button>
|
||||
</div>
|
||||
</template>
|
||||
</n-modal>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.eval-form { display: grid; gap: 12px; min-width: 0; }
|
||||
.eval-form .form-row { margin-bottom: 0; }
|
||||
.form-row-top { align-items: start; }
|
||||
.form-row-top > label { padding-top: 7px; }
|
||||
.pair { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 10px; align-items: center; }
|
||||
.pair-label { white-space: nowrap; }
|
||||
.cell-list { display: grid; gap: 8px; min-width: 0; }
|
||||
.cell-head,
|
||||
.cell-row { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) 28px; gap: 8px; align-items: center; }
|
||||
.cell-head { color: var(--muted); font-size: 12px; }
|
||||
.cell-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
|
||||
.field-hint { margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
|
||||
.cell-foot .field-hint { margin: 0; }
|
||||
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
|
||||
@media (max-width: 560px) {
|
||||
.eval-form .form-row { grid-template-columns: minmax(0, 1fr); gap: 6px; }
|
||||
.form-row-top > label { padding-top: 0; }
|
||||
.pair { grid-template-columns: minmax(0, 1fr); gap: 6px; }
|
||||
.pair-label { margin-top: 6px; }
|
||||
.cell-head { display: none; }
|
||||
.cell-row { grid-template-columns: minmax(0, 1fr) 28px; }
|
||||
.cell-row > :nth-child(2) { grid-column: 1; grid-row: 2; }
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,326 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, reactive, ref, watch } from "vue";
|
||||
import { NButton, NDatePicker, NIcon, NInput, NRadioButton, NRadioGroup, NSelect } from "naive-ui";
|
||||
import { AddOutline, CloseOutline } from "@vicons/ionicons5";
|
||||
import { api } from "../../shared/http";
|
||||
import { useToast } from "../../shared/toast";
|
||||
import type { EvalJob, EvalOptions } from "./eval";
|
||||
|
||||
interface CellRow {
|
||||
id: number;
|
||||
cgi: string;
|
||||
cellName: string;
|
||||
}
|
||||
|
||||
const props = defineProps<{ options: EvalOptions | null }>();
|
||||
const emit = defineEmits<{ (event: "submitted", job: EvalJob): void }>();
|
||||
|
||||
const CGI = /^\d{3}-\d{2}-\d+-\d+$/;
|
||||
const MAX_CELLS = 100;
|
||||
const toast = useToast();
|
||||
const saving = ref(false);
|
||||
const mode = ref<"cells" | "site">("cells");
|
||||
const form = reactive({ orderType: "", removalDate: null as string | null, city: "", county: "", applicant: "", retireReason: "", site: "" });
|
||||
const errors = reactive<Record<string, string>>({});
|
||||
const rowsEl = ref<HTMLElement | null>(null);
|
||||
let nextId = 1;
|
||||
|
||||
function blankRow(cgi = "", cellName = ""): CellRow {
|
||||
return { id: nextId++, cgi, cellName };
|
||||
}
|
||||
|
||||
const cells = ref<CellRow[]>([blankRow()]);
|
||||
const orderOptions = computed(() => (props.options?.orderTypes || ["频段清退", "低效拆除"]).map((value) => ({ label: value, value })));
|
||||
const filled = computed(() => cells.value.filter((cell) => cell.cgi.trim()));
|
||||
|
||||
// 默认值等接口返回后再补,已经填过的不覆盖。
|
||||
watch(
|
||||
() => props.options,
|
||||
(value) => {
|
||||
if (!form.orderType) form.orderType = value?.orderTypes[0] || "频段清退";
|
||||
if (!value) return;
|
||||
if (!form.city) form.city = value.city || "";
|
||||
if (!form.applicant) form.applicant = value.applicant || "";
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
watch(() => form.orderType, () => delete errors.orderType);
|
||||
watch(() => form.removalDate, () => delete errors.removalDate);
|
||||
watch(() => form.city, () => delete errors.city);
|
||||
watch(() => form.site, () => delete errors.site);
|
||||
watch(cells, () => delete errors.cells, { deep: true });
|
||||
watch(mode, () => {
|
||||
delete errors.cells;
|
||||
delete errors.site;
|
||||
});
|
||||
|
||||
function focusRow(index: number) {
|
||||
void nextTick(() => {
|
||||
const inputs = rowsEl.value?.querySelectorAll<HTMLInputElement>(".cgi input");
|
||||
inputs?.[index]?.focus();
|
||||
});
|
||||
}
|
||||
|
||||
function addCell(after = cells.value.length - 1) {
|
||||
cells.value.splice(after + 1, 0, blankRow());
|
||||
focusRow(after + 1);
|
||||
}
|
||||
|
||||
function removeCell(index: number) {
|
||||
cells.value.splice(index, 1);
|
||||
if (!cells.value.length) cells.value.push(blankRow());
|
||||
}
|
||||
|
||||
/** 回车跳到下一行;已经在最后一行并且填了 CGI 时新加一行。 */
|
||||
function nextRow(index: number) {
|
||||
if (index < cells.value.length - 1) focusRow(index + 1);
|
||||
else if (cells.value[index].cgi.trim()) addCell(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* 粘贴的文字拆成多行小区。
|
||||
* 从表格复制的(单元格之间是制表符):一行里只有一个 CGI 时,旁边那一格当作小区名称,表头行跳过。
|
||||
* 其余按空格、逗号、分号拆,每一段是一个 CGI。
|
||||
*/
|
||||
function parsePaste(text: string): { cgi: string; cellName: string }[] {
|
||||
const rows: { cgi: string; cellName: string }[] = [];
|
||||
for (const line of text.split(/\r?\n/)) {
|
||||
if (!line.includes("\t")) {
|
||||
for (const part of line.split(/[\s,,;;]+/).filter(Boolean)) rows.push({ cgi: part, cellName: "" });
|
||||
continue;
|
||||
}
|
||||
const cols = line.split("\t").map((item) => item.trim()).filter(Boolean);
|
||||
const found = cols.filter((item) => CGI.test(item));
|
||||
if (found.length === 1) rows.push({ cgi: found[0], cellName: cols.find((item) => item !== found[0]) || "" });
|
||||
else if (found.length) rows.push(...found.map((cgi) => ({ cgi, cellName: "" })));
|
||||
// 没有一格像 CGI:只留下写错的 CGI(全是数字和横线),提交时会指出来。
|
||||
else rows.push(...cols.filter((item) => /^[\d-]+$/.test(item)).map((cgi) => ({ cgi, cellName: "" })));
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
function onPaste(event: ClipboardEvent, index: number) {
|
||||
const rows = parsePaste(event.clipboardData?.getData("text") || "");
|
||||
if (!rows.length || (rows.length === 1 && !rows[0].cellName)) return;
|
||||
event.preventDefault();
|
||||
const current = cells.value[index];
|
||||
current.cgi = rows[0].cgi;
|
||||
if (rows[0].cellName) current.cellName = rows[0].cellName;
|
||||
const existing = new Set(cells.value.map((cell) => cell.cgi.trim()));
|
||||
const extra: CellRow[] = [];
|
||||
for (const row of rows.slice(1)) {
|
||||
if (existing.has(row.cgi)) continue;
|
||||
existing.add(row.cgi);
|
||||
extra.push(blankRow(row.cgi, row.cellName));
|
||||
}
|
||||
cells.value.splice(index + 1, 0, ...extra);
|
||||
}
|
||||
|
||||
/** 提交没通过时,哪几行的 CGI 要标红:没填的第一行、格式不对的、重复的。 */
|
||||
function badCgi(cell: CellRow, index: number) {
|
||||
if (!errors.cells) return false;
|
||||
const value = cell.cgi.trim();
|
||||
if (!filled.value.length) return index === 0;
|
||||
if (!value) return false;
|
||||
return !CGI.test(value) || filled.value.some((other) => other !== cell && other.cgi.trim() === value);
|
||||
}
|
||||
|
||||
function validate() {
|
||||
for (const key of Object.keys(errors)) delete errors[key];
|
||||
if (!form.orderType.trim()) errors.orderType = "请选择退网工单类型";
|
||||
if (!form.removalDate) errors.removalDate = "请选择拆除日期";
|
||||
if (!form.city.trim()) errors.city = "请填写地市";
|
||||
if (mode.value === "site") {
|
||||
if (!form.site.trim()) errors.site = "请填写站点名称";
|
||||
} else {
|
||||
const bad = filled.value.find((cell) => !CGI.test(cell.cgi.trim()));
|
||||
const seen = new Set<string>();
|
||||
const dup = filled.value.find((cell) => (seen.has(cell.cgi.trim()) ? true : (seen.add(cell.cgi.trim()), false)));
|
||||
if (!filled.value.length) errors.cells = "请至少填写一个小区 CGI";
|
||||
else if (bad) errors.cells = `CGI 格式不对:${bad.cgi.trim()}`;
|
||||
else if (dup) errors.cells = `CGI 重复:${dup.cgi.trim()}`;
|
||||
else if (filled.value.length > MAX_CELLS) errors.cells = `单个提交最多 ${MAX_CELLS} 个小区,更多请用导入清单`;
|
||||
}
|
||||
return !Object.keys(errors).length;
|
||||
}
|
||||
|
||||
function reset() {
|
||||
Object.assign(form, {
|
||||
orderType: props.options?.orderTypes[0] || "频段清退",
|
||||
removalDate: null,
|
||||
city: props.options?.city || "",
|
||||
county: "",
|
||||
applicant: props.options?.applicant || "",
|
||||
retireReason: "",
|
||||
site: "",
|
||||
});
|
||||
cells.value = [blankRow()];
|
||||
void nextTick(() => {
|
||||
for (const key of Object.keys(errors)) delete errors[key];
|
||||
});
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
if (saving.value || !validate()) return;
|
||||
saving.value = true;
|
||||
try {
|
||||
const result = await api<{ job: EvalJob }>("/api/eval/jobs/single", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
...form,
|
||||
mode: mode.value,
|
||||
cells: mode.value === "cells" ? filled.value.map((cell) => ({ cgi: cell.cgi.trim(), cellName: cell.cellName.trim() })) : [],
|
||||
}),
|
||||
});
|
||||
toast.success("已提交,后台开始评估");
|
||||
emit("submitted", result.job);
|
||||
// 评估对象清掉,拆除信息留着,接着填同一批的下一个站点。
|
||||
cells.value = [blankRow()];
|
||||
form.site = "";
|
||||
void nextTick(() => {
|
||||
for (const key of Object.keys(errors)) delete errors[key];
|
||||
});
|
||||
} catch (error) {
|
||||
toast.error(error instanceof Error ? error.message : "提交失败");
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="eval-panel">
|
||||
<div class="single-grid">
|
||||
<section class="target">
|
||||
<header class="eval-block-head">
|
||||
<h3>评估对象</h3>
|
||||
<n-radio-group v-model:value="mode" size="small" aria-label="提交方式">
|
||||
<n-radio-button value="cells">按小区</n-radio-button>
|
||||
<n-radio-button value="site">按站点</n-radio-button>
|
||||
</n-radio-group>
|
||||
</header>
|
||||
<div v-if="mode === 'cells'" class="target-body">
|
||||
<div class="cell-head"><span>CGI</span><span>小区名称</span><span /></div>
|
||||
<div ref="rowsEl" class="cell-rows">
|
||||
<div v-for="(cell, index) in cells" :key="cell.id" class="cell-row">
|
||||
<div class="cgi" @paste="onPaste($event, index)">
|
||||
<n-input
|
||||
v-model:value="cell.cgi"
|
||||
placeholder="如 460-00-679584-1"
|
||||
:input-props="{ 'aria-label': `第 ${index + 1} 个小区的 CGI` }"
|
||||
:status="badCgi(cell, index) ? 'error' : undefined"
|
||||
@keydown.enter.prevent="nextRow(index)"
|
||||
/>
|
||||
</div>
|
||||
<n-input v-model:value="cell.cellName" maxlength="128" placeholder="小区名称,可不填" :input-props="{ 'aria-label': `第 ${index + 1} 个小区的名称` }" />
|
||||
<n-button quaternary circle size="small" aria-label="去掉这一行" :disabled="cells.length === 1 && !cell.cgi && !cell.cellName" @click="removeCell(index)">
|
||||
<template #icon><n-icon :component="CloseOutline" /></template>
|
||||
</n-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell-foot">
|
||||
<n-button size="small" dashed @click="addCell()">
|
||||
<template #icon><n-icon :component="AddOutline" /></template>
|
||||
添加小区
|
||||
</n-button>
|
||||
<span class="field-hint">
|
||||
<template v-if="filled.length > 1">已填 {{ filled.length }} 个小区。</template>同一站点的小区一起填,可以一次粘贴多个 CGI。
|
||||
</span>
|
||||
</div>
|
||||
<p v-if="errors.cells" class="field-error">{{ errors.cells }}</p>
|
||||
</div>
|
||||
<div v-else class="target-body">
|
||||
<n-input
|
||||
v-model:value="form.site"
|
||||
maxlength="128"
|
||||
placeholder="如 江门台山市现代技术学校"
|
||||
:input-props="{ 'aria-label': '站点名称' }"
|
||||
:status="errors.site ? 'error' : undefined"
|
||||
@keydown.enter.prevent="submit"
|
||||
/>
|
||||
<p class="field-hint">按工参里的站点名称取这个站的全部小区。</p>
|
||||
<p v-if="errors.site" class="field-error">{{ errors.site }}</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="fields">
|
||||
<header class="eval-block-head"><h3>拆除信息</h3></header>
|
||||
<div class="field-grid">
|
||||
<div class="form-row">
|
||||
<label>退网工单类型</label>
|
||||
<div>
|
||||
<n-select v-model:value="form.orderType" :options="orderOptions" filterable tag :status="errors.orderType ? 'error' : undefined" />
|
||||
<p v-if="errors.orderType" class="field-error">{{ errors.orderType }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label>拆除日期</label>
|
||||
<div>
|
||||
<n-date-picker v-model:formatted-value="form.removalDate" type="date" value-format="yyyy-MM-dd" clearable :status="errors.removalDate ? 'error' : undefined" />
|
||||
<p v-if="errors.removalDate" class="field-error">{{ errors.removalDate }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="eval-single-city">地市</label>
|
||||
<div>
|
||||
<n-input v-model:value="form.city" maxlength="32" :input-props="{ id: 'eval-single-city' }" :status="errors.city ? 'error' : undefined" />
|
||||
<p v-if="errors.city" class="field-error">{{ errors.city }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="eval-single-county">区县</label>
|
||||
<n-input v-model:value="form.county" maxlength="64" placeholder="可不填" :input-props="{ id: 'eval-single-county' }" />
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="eval-single-applicant">申请人</label>
|
||||
<n-input v-model:value="form.applicant" maxlength="64" :input-props="{ id: 'eval-single-applicant' }" />
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="eval-single-reason">退网原因</label>
|
||||
<n-input v-model:value="form.retireReason" maxlength="255" placeholder="可不填" :input-props="{ id: 'eval-single-reason' }" />
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<footer class="eval-foot">
|
||||
<span class="eval-foot-hint">要评估的站点比较多时,用「导入清单」一次上传。</span>
|
||||
<div class="eval-foot-actions">
|
||||
<n-button :disabled="saving" @click="reset">清空</n-button>
|
||||
<n-button type="primary" :loading="saving" @click="submit">提交评估</n-button>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.single-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
|
||||
.target { min-width: 0; padding: 16px 24px 20px 20px; border-right: 1px solid var(--line); }
|
||||
.fields { min-width: 0; padding: 16px 20px 20px 24px; }
|
||||
.target-body { max-width: 640px; }
|
||||
.cell-head,
|
||||
.cell-row { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) 28px; gap: 8px; align-items: center; }
|
||||
.cell-head { margin-bottom: 6px; color: var(--muted); font-size: 12px; }
|
||||
/* 行多了在里面滚动;留 3px 给输入框的聚焦外框,不然会被裁掉。 */
|
||||
.cell-rows { display: grid; gap: 8px; max-height: 250px; margin: -3px; padding: 3px; overflow: auto; }
|
||||
.cell-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-top: 10px; }
|
||||
.cell-foot .field-hint { margin: 0; }
|
||||
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 24px; }
|
||||
.field-grid .form-row { margin: 0; align-items: start; }
|
||||
.field-grid .form-row > label { min-height: 34px; }
|
||||
@media (max-width: 1180px) {
|
||||
.single-grid { grid-template-columns: minmax(0, 1fr); }
|
||||
.target { padding: 16px 20px 20px; border-right: 0; border-bottom: 1px solid var(--line); }
|
||||
.fields { padding: 16px 20px 20px; }
|
||||
}
|
||||
@media (max-width: 640px) {
|
||||
.target,
|
||||
.fields { padding-left: 14px; padding-right: 14px; }
|
||||
.field-grid { grid-template-columns: minmax(0, 1fr); }
|
||||
.field-grid .form-row { grid-template-columns: minmax(0, 1fr); gap: 6px; }
|
||||
.field-grid .form-row > label { min-height: 0; }
|
||||
.cell-head { display: none; }
|
||||
.cell-row { grid-template-columns: minmax(0, 1fr) 28px; }
|
||||
.cell-row > :nth-child(2) { grid-column: 1; grid-row: 2; }
|
||||
}
|
||||
</style>
|
||||
+237
-114
@@ -1,27 +1,39 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, onUnmounted, ref } from "vue";
|
||||
import { computed, nextTick, onMounted, onUnmounted, ref } from "vue";
|
||||
import { NAlert, NButton, NIcon, NProgress, NTooltip, useDialog } from "naive-ui";
|
||||
import { CloudUploadOutline, DownloadOutline, EyeOutline, TrashOutline } from "@vicons/ionicons5";
|
||||
import { DownloadOutline, EyeOutline, TrashOutline } from "@vicons/ionicons5";
|
||||
import Shell from "../../shell/Shell.vue";
|
||||
import { api } from "../../shared/http";
|
||||
import { useToast } from "../../shared/toast";
|
||||
import EvalImportDialog from "./EvalImportDialog.vue";
|
||||
import EvalImportForm from "./EvalImportForm.vue";
|
||||
import EvalJobDrawer from "./EvalJobDrawer.vue";
|
||||
import EvalSingleDialog from "./EvalSingleDialog.vue";
|
||||
import EvalSingleForm from "./EvalSingleForm.vue";
|
||||
import { downloadFile, isFinal, kindsText, percent, statusClass, statusLabel, timeText } from "./eval";
|
||||
import type { EvalJob, EvalOptions, EvalResult } from "./eval";
|
||||
|
||||
type TabKey = "single" | "list";
|
||||
|
||||
const FRESH_MS = 2400;
|
||||
const TABS: { key: TabKey; label: string; hint: string }[] = [
|
||||
{ key: "single", label: "单个提交", hint: "填一个站点或它的几个小区,直接提交" },
|
||||
{ key: "list", label: "导入清单", hint: "多个站点填进清单,一次上传" },
|
||||
];
|
||||
const toast = useToast();
|
||||
const dialog = useDialog();
|
||||
const tab = ref<TabKey>("single");
|
||||
const tabList = ref<HTMLElement | null>(null);
|
||||
const jobs = ref<EvalJob[]>([]);
|
||||
const loaded = ref(false);
|
||||
const loadError = ref("");
|
||||
const options = ref<EvalOptions | null>(null);
|
||||
const metricsNote = computed(() => (options.value?.metricsNote || "").replace(/^模拟数据:/, ""));
|
||||
const singleOpen = ref(false);
|
||||
const importOpen = ref(false);
|
||||
const active = computed(() => jobs.value.filter((job) => !isFinal(job.status)).length);
|
||||
const drawerOpen = ref(false);
|
||||
const drawerJob = ref<number | null>(null);
|
||||
const freshJob = ref<number | null>(null);
|
||||
const jobsHead = ref<HTMLElement | null>(null);
|
||||
let timer = 0;
|
||||
let freshTimer = 0;
|
||||
|
||||
function stopPoll() {
|
||||
window.clearInterval(timer);
|
||||
@@ -40,9 +52,10 @@ async function load(quiet = false) {
|
||||
try {
|
||||
const result = await api<{ jobs: EvalJob[] }>("/api/eval/jobs");
|
||||
jobs.value = result.jobs;
|
||||
loadError.value = "";
|
||||
schedulePoll();
|
||||
} catch (error) {
|
||||
if (!quiet) toast.error(error instanceof Error ? error.message : "任务没有获取到");
|
||||
if (!quiet) loadError.value = error instanceof Error ? error.message : "任务没有获取到";
|
||||
} finally {
|
||||
loaded.value = true;
|
||||
}
|
||||
@@ -56,15 +69,27 @@ async function loadOptions() {
|
||||
}
|
||||
}
|
||||
|
||||
/** 左右方向键在两个页签之间切换,焦点跟着走。 */
|
||||
function switchTab() {
|
||||
tab.value = tab.value === "single" ? "list" : "single";
|
||||
void nextTick(() => tabList.value?.querySelector<HTMLElement>(".submit-tab.active")?.focus());
|
||||
}
|
||||
|
||||
function openDetail(job: EvalJob) {
|
||||
drawerJob.value = job.id;
|
||||
drawerOpen.value = true;
|
||||
}
|
||||
|
||||
/** 提交后不弹详情:新任务排到列表最前面,短暂标亮,需要时把列表滚进视野。 */
|
||||
function onSubmitted(job: EvalJob) {
|
||||
jobs.value = [job, ...jobs.value.filter((item) => item.id !== job.id)];
|
||||
schedulePoll();
|
||||
openDetail(job);
|
||||
freshJob.value = job.id;
|
||||
window.clearTimeout(freshTimer);
|
||||
freshTimer = window.setTimeout(() => {
|
||||
freshJob.value = null;
|
||||
}, FRESH_MS);
|
||||
void nextTick(() => jobsHead.value?.scrollIntoView({ block: "nearest", behavior: "smooth" }));
|
||||
}
|
||||
|
||||
function onChanged(job: EvalJob) {
|
||||
@@ -107,6 +132,15 @@ function subtitle(job: EvalJob) {
|
||||
return parts.filter(Boolean).join(" · ");
|
||||
}
|
||||
|
||||
/** 只有一个站点的任务在状态下面显示当前做到哪一步。 */
|
||||
function stageText(job: EvalJob) {
|
||||
return !isFinal(job.status) && job.stage ? job.stage : "";
|
||||
}
|
||||
|
||||
function shortLabel(result: EvalResult) {
|
||||
return result.label.replace("评估", "");
|
||||
}
|
||||
|
||||
function progressStatus(job: EvalJob) {
|
||||
if (job.status === "failed") return "error";
|
||||
if (job.failed) return "warning";
|
||||
@@ -117,7 +151,10 @@ onMounted(() => {
|
||||
void load();
|
||||
void loadOptions();
|
||||
});
|
||||
onUnmounted(stopPoll);
|
||||
onUnmounted(() => {
|
||||
stopPoll();
|
||||
window.clearTimeout(freshTimer);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -125,135 +162,221 @@ onUnmounted(stopPoll);
|
||||
<section class="page admin-page">
|
||||
<header class="page-head">
|
||||
<h2>评估</h2>
|
||||
<div class="page-head-actions">
|
||||
<n-button @click="importOpen = true">
|
||||
<template #icon><n-icon :component="CloudUploadOutline" /></template>
|
||||
导入清单
|
||||
</n-button>
|
||||
<n-button type="primary" @click="singleOpen = true">单个提交</n-button>
|
||||
</div>
|
||||
</header>
|
||||
<div class="admin-scroll">
|
||||
<n-alert v-if="metricsNote" class="admin-alert" type="warning" :show-icon="false">{{ metricsNote }}</n-alert>
|
||||
<div class="eval-body">
|
||||
<n-alert v-if="metricsNote" type="warning" :show-icon="false">{{ metricsNote }}</n-alert>
|
||||
|
||||
<div v-if="loaded && !jobs.length" class="surface empty-card">
|
||||
<div class="empty-guide">
|
||||
<strong>还没有评估任务</strong>
|
||||
<p>一次评估一个站点或小区用「单个提交」;有多个站点时下载清单模板填好后「导入清单」。</p>
|
||||
<div class="empty-actions">
|
||||
<n-button @click="importOpen = true">导入清单</n-button>
|
||||
<n-button type="primary" @click="singleOpen = true">单个提交</n-button>
|
||||
<section class="surface submit-card" aria-label="提交评估">
|
||||
<div ref="tabList" class="submit-tabs" role="tablist" aria-label="提交方式" @keydown.left.prevent="switchTab" @keydown.right.prevent="switchTab">
|
||||
<button
|
||||
v-for="item in TABS"
|
||||
:id="`eval-tab-${item.key}`"
|
||||
:key="item.key"
|
||||
type="button"
|
||||
role="tab"
|
||||
class="submit-tab"
|
||||
:class="{ active: tab === item.key }"
|
||||
:aria-selected="tab === item.key"
|
||||
:aria-controls="`eval-panel-${item.key}`"
|
||||
:tabindex="tab === item.key ? 0 : -1"
|
||||
@click="tab = item.key"
|
||||
>
|
||||
{{ item.label }}
|
||||
</button>
|
||||
<span class="tab-hint">{{ TABS.find((item) => item.key === tab)?.hint }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<EvalSingleForm v-show="tab === 'single'" id="eval-panel-single" role="tabpanel" aria-labelledby="eval-tab-single" :options="options" @submitted="onSubmitted" />
|
||||
<EvalImportForm v-show="tab === 'list'" id="eval-panel-list" role="tabpanel" aria-labelledby="eval-tab-list" :options="options" @submitted="onSubmitted" />
|
||||
</section>
|
||||
|
||||
<template v-else-if="jobs.length">
|
||||
<div class="surface table-card eval-table">
|
||||
<table class="admin-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>评估对象</th>
|
||||
<th>类型</th>
|
||||
<th class="col-progress">进度</th>
|
||||
<th>状态</th>
|
||||
<th>提交时间</th>
|
||||
<th class="col-actions">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="job in jobs" :key="job.id" class="row-link" @click="openDetail(job)">
|
||||
<td class="col-title">
|
||||
<strong class="title" :title="job.title">{{ job.title }}</strong>
|
||||
<span class="sub">{{ subtitle(job) }}</span>
|
||||
</td>
|
||||
<td>{{ kindsText(job.kinds) || "—" }}</td>
|
||||
<td class="col-progress">
|
||||
<n-progress type="line" :percentage="percent(job)" :status="progressStatus(job)" :show-indicator="false" :height="6" />
|
||||
<span class="sub">{{ job.finished }} / {{ job.total }} 个站点<template v-if="job.failed">,失败 {{ job.failed }}</template></span>
|
||||
</td>
|
||||
<td><span :class="statusClass(job.status)">{{ statusLabel(job.status) }}</span></td>
|
||||
<td class="nowrap">{{ timeText(job.createdAt) }}</td>
|
||||
<td class="col-actions" @click.stop>
|
||||
<div class="row-actions">
|
||||
<n-tooltip v-for="result in job.results" :key="result.kind">
|
||||
<template #trigger>
|
||||
<n-button size="small" quaternary circle :aria-label="`下载${result.label}`" @click="download(job, result)">
|
||||
<section class="jobs" aria-label="评估任务">
|
||||
<header ref="jobsHead" class="jobs-head">
|
||||
<h3>评估任务</h3>
|
||||
<span v-if="jobs.length" class="jobs-count">{{ jobs.length }} 个<template v-if="active">,{{ active }} 个进行中</template></span>
|
||||
</header>
|
||||
|
||||
<div v-if="loadError && !jobs.length" class="surface jobs-empty">
|
||||
<p class="status-bad">{{ loadError }}</p>
|
||||
<n-button size="small" @click="load()">重试</n-button>
|
||||
</div>
|
||||
<div v-else-if="loaded && !jobs.length" class="surface jobs-empty">
|
||||
<strong>还没有评估任务</strong>
|
||||
<p>提交后在这里看进度,完成后下载结果表。</p>
|
||||
</div>
|
||||
|
||||
<template v-else-if="jobs.length">
|
||||
<div class="surface table-card eval-table">
|
||||
<table class="admin-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>评估对象</th>
|
||||
<th>类型</th>
|
||||
<th class="col-progress">进度</th>
|
||||
<th>状态</th>
|
||||
<th class="col-time">提交时间</th>
|
||||
<th class="col-actions">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="job in jobs" :key="job.id" class="row-link" :class="{ fresh: freshJob === job.id }" @click="openDetail(job)">
|
||||
<td class="col-title">
|
||||
<strong class="title" :title="job.title">{{ job.title }}</strong>
|
||||
<span class="sub">{{ subtitle(job) }}<span class="sub-time"> · {{ timeText(job.createdAt) }}</span></span>
|
||||
</td>
|
||||
<td class="nowrap">{{ kindsText(job.kinds) || "—" }}</td>
|
||||
<td class="col-progress">
|
||||
<n-progress type="line" :percentage="percent(job)" :status="progressStatus(job)" :show-indicator="false" :height="6" />
|
||||
<span class="sub">{{ job.finished }} / {{ job.total }} 个站点<template v-if="job.failed">,失败 {{ job.failed }}</template></span>
|
||||
</td>
|
||||
<td class="col-status">
|
||||
<span :class="statusClass(job.status)">{{ statusLabel(job.status) }}</span>
|
||||
<span v-if="stageText(job)" class="sub">{{ stageText(job) }}</span>
|
||||
</td>
|
||||
<td class="col-time nowrap">{{ timeText(job.createdAt) }}</td>
|
||||
<td class="col-actions" @click.stop>
|
||||
<div class="row-actions">
|
||||
<n-button v-for="result in job.results" :key="result.kind" size="small" secondary type="primary" :title="`下载${result.label}`" @click="download(job, result)">
|
||||
<template #icon><n-icon :component="DownloadOutline" /></template>
|
||||
{{ shortLabel(result) }}
|
||||
</n-button>
|
||||
</template>
|
||||
下载{{ result.label }}
|
||||
</n-tooltip>
|
||||
<n-tooltip>
|
||||
<template #trigger>
|
||||
<n-button size="small" quaternary circle aria-label="详情" @click="openDetail(job)">
|
||||
<template #icon><n-icon :component="EyeOutline" /></template>
|
||||
</n-button>
|
||||
</template>
|
||||
详情
|
||||
</n-tooltip>
|
||||
<n-tooltip>
|
||||
<template #trigger>
|
||||
<n-button size="small" quaternary circle aria-label="删除" :disabled="!isFinal(job.status)" @click="confirmRemove(job)">
|
||||
<template #icon><n-icon :component="TrashOutline" /></template>
|
||||
</n-button>
|
||||
</template>
|
||||
{{ isFinal(job.status) ? "删除" : "结束后才能删除" }}
|
||||
</n-tooltip>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="eval-cards">
|
||||
<article v-for="job in jobs" :key="job.id" class="surface eval-card" @click="openDetail(job)">
|
||||
<header>
|
||||
<strong class="title">{{ job.title }}</strong>
|
||||
<span :class="statusClass(job.status)">{{ statusLabel(job.status) }}</span>
|
||||
</header>
|
||||
<span class="sub">{{ subtitle(job) }}<template v-if="kindsText(job.kinds)"> · {{ kindsText(job.kinds) }}</template></span>
|
||||
<n-progress type="line" :percentage="percent(job)" :status="progressStatus(job)" :show-indicator="false" :height="6" />
|
||||
<div class="card-foot">
|
||||
<span class="sub">{{ job.finished }} / {{ job.total }} 个站点 · {{ timeText(job.createdAt) }}</span>
|
||||
<div class="row-actions" @click.stop>
|
||||
<n-button v-for="result in job.results" :key="result.kind" size="small" secondary @click="download(job, result)">{{ result.label.replace("评估", "") }}</n-button>
|
||||
<n-button size="small" quaternary circle aria-label="删除" :disabled="!isFinal(job.status)" @click="confirmRemove(job)">
|
||||
<template #icon><n-icon :component="TrashOutline" /></template>
|
||||
</n-button>
|
||||
</div>
|
||||
<n-tooltip>
|
||||
<template #trigger>
|
||||
<n-button size="small" quaternary circle aria-label="详情" @click="openDetail(job)">
|
||||
<template #icon><n-icon :component="EyeOutline" /></template>
|
||||
</n-button>
|
||||
</template>
|
||||
详情
|
||||
</n-tooltip>
|
||||
<n-tooltip>
|
||||
<template #trigger>
|
||||
<n-button size="small" quaternary circle aria-label="删除" :disabled="!isFinal(job.status)" @click="confirmRemove(job)">
|
||||
<template #icon><n-icon :component="TrashOutline" /></template>
|
||||
</n-button>
|
||||
</template>
|
||||
{{ isFinal(job.status) ? "删除" : "结束后才能删除" }}
|
||||
</n-tooltip>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="eval-cards">
|
||||
<article v-for="job in jobs" :key="job.id" class="surface eval-card" :class="{ fresh: freshJob === job.id }" @click="openDetail(job)">
|
||||
<header>
|
||||
<strong class="title">{{ job.title }}</strong>
|
||||
<span :class="statusClass(job.status)">{{ stageText(job) || statusLabel(job.status) }}</span>
|
||||
</header>
|
||||
<span class="sub">{{ subtitle(job) }}<template v-if="kindsText(job.kinds)"> · {{ kindsText(job.kinds) }}</template></span>
|
||||
<n-progress type="line" :percentage="percent(job)" :status="progressStatus(job)" :show-indicator="false" :height="6" />
|
||||
<div class="card-foot">
|
||||
<span class="sub">{{ job.finished }} / {{ job.total }} 个站点 · {{ timeText(job.createdAt) }}</span>
|
||||
<div class="row-actions" @click.stop>
|
||||
<n-button v-for="result in job.results" :key="result.kind" size="small" secondary type="primary" @click="download(job, result)">
|
||||
<template #icon><n-icon :component="DownloadOutline" /></template>
|
||||
{{ shortLabel(result) }}
|
||||
</n-button>
|
||||
<n-button size="small" quaternary circle aria-label="删除" :disabled="!isFinal(job.status)" @click="confirmRemove(job)">
|
||||
<template #icon><n-icon :component="TrashOutline" /></template>
|
||||
</n-button>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</template>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<EvalSingleDialog v-model:show="singleOpen" :options="options" @submitted="onSubmitted" />
|
||||
<EvalImportDialog v-model:show="importOpen" :options="options" @submitted="onSubmitted" />
|
||||
<EvalJobDrawer v-model:show="drawerOpen" :job-id="drawerJob" @changed="onChanged" />
|
||||
</Shell>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.empty-guide { display: grid; justify-items: center; gap: 8px; max-width: 420px; text-align: center; }
|
||||
.empty-guide strong { font-size: 15px; font-weight: 650; }
|
||||
.empty-guide p { margin: 0; color: var(--muted); line-height: 1.6; }
|
||||
.empty-actions { display: flex; gap: 8px; margin-top: 8px; }
|
||||
.eval-body { display: grid; gap: 20px; max-width: 1480px; }
|
||||
.submit-card { min-width: 0; }
|
||||
.submit-tabs { display: flex; align-items: stretch; gap: 4px; padding: 0 8px; border-bottom: 1px solid var(--line); }
|
||||
.submit-tab {
|
||||
position: relative;
|
||||
height: 44px;
|
||||
padding: 0 12px;
|
||||
border: 0;
|
||||
background: none;
|
||||
color: var(--muted);
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
cursor: pointer;
|
||||
}
|
||||
.submit-tab:hover { color: var(--ink); }
|
||||
.submit-tab.active { color: var(--accent); }
|
||||
.submit-tab.active::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
left: 12px;
|
||||
right: 12px;
|
||||
bottom: -1px;
|
||||
height: 2px;
|
||||
background: var(--accent);
|
||||
}
|
||||
.submit-tab:focus-visible { outline-offset: -4px; }
|
||||
.tab-hint { min-width: 0; margin-left: auto; padding-right: 12px; align-self: center; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.jobs { min-width: 0; }
|
||||
.jobs-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; scroll-margin-top: 12px; }
|
||||
.jobs-head h3 { margin: 0; font-size: 14px; font-weight: 650; }
|
||||
.jobs-count { color: var(--muted); font-size: 12px; }
|
||||
.jobs-empty { display: grid; justify-items: center; gap: 6px; padding: 36px 24px; text-align: center; }
|
||||
.jobs-empty strong { font-weight: 650; }
|
||||
.jobs-empty p { margin: 0; color: var(--muted); }
|
||||
.jobs-empty .status-bad { color: var(--danger); }
|
||||
.row-link { cursor: pointer; }
|
||||
.col-title { max-width: 360px; }
|
||||
/* 评估对象这一列吃掉剩下的宽度,名字太长就省略,别的列按内容定宽,表格不会被撑出横向滚动。 */
|
||||
.eval-table th { white-space: nowrap; }
|
||||
.col-title { width: 100%; max-width: 0; min-width: 180px; }
|
||||
.col-title .sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
|
||||
.sub { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
|
||||
.col-progress { width: 200px; }
|
||||
.sub-time { display: none; }
|
||||
.col-progress { width: 200px; min-width: 160px; }
|
||||
.col-status { white-space: nowrap; }
|
||||
.nowrap { white-space: nowrap; }
|
||||
.eval-cards { display: none; }
|
||||
.eval-card { display: grid; gap: 8px; padding: 12px 14px; margin-bottom: 10px; cursor: pointer; }
|
||||
.eval-table .col-actions { text-align: right; }
|
||||
.eval-table .row-actions { justify-content: flex-end; }
|
||||
/* 刚提交的任务短暂标亮,方便在列表里找到。 */
|
||||
.fresh td { animation: fresh-row 2.4s ease-out; }
|
||||
.eval-card.fresh { animation: fresh-card 2.4s ease-out; }
|
||||
@keyframes fresh-row {
|
||||
from { background-color: var(--accent-soft); }
|
||||
to { background-color: transparent; }
|
||||
}
|
||||
@keyframes fresh-card {
|
||||
from { box-shadow: inset 0 0 0 999px var(--accent-soft); }
|
||||
to { box-shadow: inset 0 0 0 999px transparent; }
|
||||
}
|
||||
.eval-cards { display: none; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: 10px; }
|
||||
.eval-card { display: grid; align-content: start; gap: 8px; min-width: 0; padding: 12px 14px; cursor: pointer; }
|
||||
.eval-card header { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
|
||||
.eval-card header .title { min-width: 0; }
|
||||
.eval-card header span { flex: none; font-size: 12px; }
|
||||
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
|
||||
.card-foot .sub { margin: 0; }
|
||||
@media (max-width: 760px) {
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.fresh td,
|
||||
.eval-card.fresh { animation: none; }
|
||||
}
|
||||
/* 窗口不够宽:提交时间并到评估对象下面一行;再窄就换成卡片。 */
|
||||
@media (max-width: 1400px) {
|
||||
.col-time { display: none; }
|
||||
.sub-time { display: inline; }
|
||||
.col-progress { width: 160px; }
|
||||
}
|
||||
@media (max-width: 1100px) {
|
||||
.eval-table { display: none; }
|
||||
.eval-cards { display: block; }
|
||||
.eval-cards { display: grid; }
|
||||
}
|
||||
@media (max-width: 760px) {
|
||||
.tab-hint { display: none; }
|
||||
.page-head { padding: 0 16px; }
|
||||
.admin-scroll { padding: 14px 12px 20px; }
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@ export interface EvalJob {
|
||||
city: string;
|
||||
sourceName: string;
|
||||
status: string;
|
||||
/** 只有一个站点的任务正在做哪一步;其余情况是空串。 */
|
||||
stage?: string;
|
||||
total: number;
|
||||
finished: number;
|
||||
failed: number;
|
||||
|
||||
+28
-11
@@ -300,6 +300,7 @@ button, input, select { font: inherit; }
|
||||
.form-row > div { width: 100%; }
|
||||
.form-row:last-child { margin-bottom: 0; }
|
||||
.field-error { margin: 6px 0 0; color: var(--danger); font-size: 12px; line-height: 1.3; }
|
||||
.field-hint { margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
|
||||
.form-section {
|
||||
margin: 18px 0 10px;
|
||||
color: var(--muted);
|
||||
@@ -331,6 +332,33 @@ button, input, select { font: inherit; }
|
||||
.status-wait { color: var(--muted); }
|
||||
.status-warn { color: #BF8700; }
|
||||
|
||||
/* 评估页:提交卡片里的两个面板(单个提交、导入清单)共用的版式 */
|
||||
.eval-panel { min-width: 0; }
|
||||
.eval-block-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
min-height: 28px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.eval-block-head h3 { margin: 0; font-size: 13px; font-weight: 650; }
|
||||
.eval-foot {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 12px 20px;
|
||||
border-top: 1px solid var(--line);
|
||||
}
|
||||
.eval-foot-hint { min-width: 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
|
||||
.eval-foot-hint.status-bad { color: var(--danger); }
|
||||
.eval-foot-actions { display: flex; flex: none; gap: 8px; }
|
||||
@media (max-width: 640px) {
|
||||
.eval-foot { flex-direction: column; align-items: stretch; padding: 12px 14px; }
|
||||
.eval-foot-actions { justify-content: flex-end; }
|
||||
}
|
||||
|
||||
.settings-form {
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
@@ -548,17 +576,6 @@ button, input, select { font: inherit; }
|
||||
.n-card.app-dialog.app-dialog-collect .n-card__content {
|
||||
overflow-x: hidden;
|
||||
}
|
||||
.n-card.app-dialog.app-dialog-eval {
|
||||
width: min(620px, calc(100vw - 32px));
|
||||
}
|
||||
.n-card.app-dialog.app-dialog-import {
|
||||
width: min(820px, calc(100vw - 32px));
|
||||
}
|
||||
.n-card.app-dialog.app-dialog-eval .n-card__content,
|
||||
.n-card.app-dialog.app-dialog-import .n-card__content {
|
||||
max-height: min(72vh, 680px);
|
||||
overflow-x: hidden;
|
||||
}
|
||||
.n-dialog.app-dialog .n-dialog__content,
|
||||
.n-dialog.app-dialog-wide .n-dialog__content,
|
||||
.n-card.app-dialog .n-card__content,
|
||||
|
||||
Reference in New Issue
Block a user