fix: 管理页改成和 EunivTools 一样的页头和表格

This commit is contained in:
2026-10-30 10:55:28 +08:00
parent 6b34fb438c
commit b052ce2ed0
6 changed files with 229 additions and 146 deletions
+32 -29
View File
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { onMounted, ref } from "vue";
import { NButton, NDataTable, NInput, NModal, NSelect, NTooltip } from "naive-ui";
import { NButton, NInput, NModal, NSelect } from "naive-ui";
import Shell from "../../shell/Shell.vue";
import { api, token } from "../../shared/http";
@@ -13,12 +13,6 @@ const start = ref("");
const end = ref("");
const errorText = ref("");
const formats = [{ label: "xlsx", value: "xlsx" }, { label: "xls", value: "xls" }, { label: "csv", value: "csv" }];
const columns = [
{ title: "小区", key: "cellKey" },
{ title: "格式", key: "format" },
{ title: "状态", key: "statusLabel" },
{ title: "结果", key: "action" },
];
function statusLabel(status: string) {
if (status === "queued") return "排队";
@@ -29,7 +23,7 @@ function statusLabel(status: string) {
async function load() {
const result = await api<{ tasks: Task[] }>("/api/tasks");
tasks.value = result.tasks.map((item) => ({ ...item, statusLabel: statusLabel(item.status) }));
tasks.value = result.tasks;
}
async function submit() {
@@ -62,29 +56,38 @@ onMounted(load);
<template>
<Shell>
<header class="topbar">
<h1>任务 <n-tooltip><template #trigger><span class="hint">?</span></template>按已入库的数据生成结果文件</n-tooltip></h1>
<n-button type="primary" @click="show = true">提交任务</n-button>
</header>
<div class="content">
<n-data-table :columns="columns" :data="tasks" :bordered="false">
<template #empty>还没有任务</template>
</n-data-table>
<div v-for="row in tasks.filter((item) => item.status === 'done')" :key="row.id" class="row-actions" style="margin-top: 8px">
<n-button size="small" @click="download(row)">下载 {{ row.cellKey || "全部" }}.{{ row.format }}</n-button>
<section class="page admin-page">
<header class="page-head">
<h2>任务</h2>
<n-button type="primary" @click="show = true">提交任务</n-button>
</header>
<div class="admin-scroll">
<table v-if="tasks.length" class="admin-table">
<thead>
<tr>
<th>小区</th>
<th>格式</th>
<th>状态</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr v-for="row in tasks" :key="row.id">
<td>{{ row.cellKey || "全部" }}</td>
<td>{{ row.format }}</td>
<td>{{ statusLabel(row.status) }}</td>
<td><n-button v-if="row.status === 'done'" size="small" quaternary @click="download(row)">下载</n-button></td>
</tr>
</tbody>
</table>
<p v-else class="admin-status">还没有任务</p>
</div>
</div>
</section>
<n-modal v-model:show="show" preset="dialog" title="提交任务" positive-text="提交" negative-text="取消" @positive-click="submit">
<div class="form-grid">
<label>格式</label>
<n-select v-model:value="format" :options="formats" />
<label>小区</label>
<n-input v-model:value="cellKey" placeholder="留空则导出全部" />
<label>开始</label>
<n-input v-model:value="start" placeholder="YYYY-MM-DD" />
<label>结束</label>
<n-input v-model:value="end" placeholder="YYYY-MM-DD" />
</div>
<div class="form-row"><label>格式</label><n-select v-model:value="format" :options="formats" /></div>
<div class="form-row"><label>小区</label><n-input v-model:value="cellKey" placeholder="留空则导出全部" /></div>
<div class="form-row"><label>开始</label><n-input v-model:value="start" placeholder="YYYY-MM-DD" /></div>
<div class="form-row"><label>结束</label><n-input v-model:value="end" placeholder="YYYY-MM-DD" /></div>
<p v-if="errorText" style="color: var(--danger)">{{ errorText }}</p>
</n-modal>
</Shell>