fix: 管理页改成和 EunivTools 一样的页头和表格
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from "vue";
|
||||
import { NButton, NDataTable, NInput, NInputNumber, NModal, NSelect, NSwitch, NTooltip } from "naive-ui";
|
||||
import { NButton, NInput, NInputNumber, NModal, NSelect, NSwitch } from "naive-ui";
|
||||
import Shell from "../../shell/Shell.vue";
|
||||
import { api } from "../../shared/http";
|
||||
|
||||
@@ -28,12 +28,6 @@ const password = ref("");
|
||||
const path = ref("");
|
||||
const url = ref("");
|
||||
const errorText = ref("");
|
||||
const columns = [
|
||||
{ title: "名称", key: "name" },
|
||||
{ title: "来源", key: "kindLabel" },
|
||||
{ title: "周期(天)", key: "periodDays" },
|
||||
{ title: "状态", key: "stateLabel" },
|
||||
];
|
||||
|
||||
function reset(source?: Source) {
|
||||
editing.value = source || null;
|
||||
@@ -54,11 +48,7 @@ function reset(source?: Source) {
|
||||
|
||||
async function load() {
|
||||
const result = await api<{ sources: Source[] }>("/api/admin/sources");
|
||||
sources.value = result.sources.map((item) => ({
|
||||
...item,
|
||||
kindLabel: item.kind === "nqi" ? "NQI" : "FTP/SFTP",
|
||||
stateLabel: item.lastError || (item.enabled ? "启用" : "停用"),
|
||||
}));
|
||||
sources.value = result.sources;
|
||||
}
|
||||
|
||||
async function save() {
|
||||
@@ -91,46 +81,54 @@ 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="reset()">添加采集</n-button>
|
||||
</header>
|
||||
<div class="content">
|
||||
<n-data-table :columns="columns" :data="sources" :bordered="false" />
|
||||
<div v-for="source in sources" :key="source.id" class="row-actions" style="margin-top: 8px">
|
||||
<n-button size="small" @click="reset(source)">编辑</n-button>
|
||||
<n-button size="small" @click="remove(source.id)">删除</n-button>
|
||||
<section class="page admin-page">
|
||||
<header class="page-head">
|
||||
<h2>采集</h2>
|
||||
<n-button type="primary" @click="reset()">添加采集</n-button>
|
||||
</header>
|
||||
<div class="admin-scroll">
|
||||
<table v-if="sources.length" class="admin-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>名称</th>
|
||||
<th>来源</th>
|
||||
<th>周期(天)</th>
|
||||
<th>状态</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="source in sources" :key="source.id">
|
||||
<td>{{ source.name }}</td>
|
||||
<td>{{ source.kind === "nqi" ? "NQI" : "FTP/SFTP" }}</td>
|
||||
<td>{{ source.periodDays }}</td>
|
||||
<td>{{ source.lastError || (source.enabled ? "启用" : "停用") }}</td>
|
||||
<td>
|
||||
<n-button size="small" quaternary @click="reset(source)">编辑</n-button>
|
||||
<n-button size="small" quaternary @click="remove(source.id)">删除</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="save">
|
||||
<div class="form-grid">
|
||||
<label>名称</label>
|
||||
<n-input v-model:value="name" />
|
||||
<label>来源</label>
|
||||
<n-select v-model:value="kind" :options="[{ label: 'FTP/SFTP', value: 'ftp' }, { label: 'NQI', value: 'nqi' }]" />
|
||||
<label>周期(天)</label>
|
||||
<n-input-number v-model:value="periodDays" :min="1" :max="31" />
|
||||
<label>启用</label>
|
||||
<n-switch v-model:value="enabled" />
|
||||
<template v-if="kind === 'ftp'">
|
||||
<label>协议</label>
|
||||
<n-select v-model:value="protocol" :options="[{ label: 'SFTP', value: 'sftp' }, { label: 'FTP', value: 'ftp' }]" />
|
||||
<label>主机</label>
|
||||
<n-input v-model:value="host" />
|
||||
<label>端口</label>
|
||||
<n-input-number v-model:value="port" />
|
||||
<label>账号</label>
|
||||
<n-input v-model:value="username" />
|
||||
<label>密码</label>
|
||||
<n-input v-model:value="password" type="password" />
|
||||
<label>路径</label>
|
||||
<n-input v-model:value="path" />
|
||||
</template>
|
||||
<template v-else>
|
||||
<label>地址</label>
|
||||
<n-input v-model:value="url" />
|
||||
</template>
|
||||
</div>
|
||||
<div class="form-row"><label>名称</label><n-input v-model:value="name" /></div>
|
||||
<div class="form-row"><label>来源</label><n-select v-model:value="kind" :options="[{ label: 'FTP/SFTP', value: 'ftp' }, { label: 'NQI', value: 'nqi' }]" /></div>
|
||||
<div class="form-row"><label>周期(天)</label><n-input-number v-model:value="periodDays" :min="1" :max="31" :show-button="false" /></div>
|
||||
<div class="form-row"><label>启用</label><n-switch v-model:value="enabled" /></div>
|
||||
<template v-if="kind === 'ftp'">
|
||||
<div class="form-row"><label>协议</label><n-select v-model:value="protocol" :options="[{ label: 'SFTP', value: 'sftp' }, { label: 'FTP', value: 'ftp' }]" /></div>
|
||||
<div class="form-row"><label>主机</label><n-input v-model:value="host" /></div>
|
||||
<div class="form-row"><label>端口</label><n-input-number v-model:value="port" :show-button="false" /></div>
|
||||
<div class="form-row"><label>账号</label><n-input v-model:value="username" /></div>
|
||||
<div class="form-row"><label>密码</label><n-input v-model:value="password" type="password" /></div>
|
||||
<div class="form-row"><label>路径</label><n-input v-model:value="path" /></div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="form-row"><label>地址</label><n-input v-model:value="url" /></div>
|
||||
</template>
|
||||
<p v-if="errorText" style="color: var(--danger)">{{ errorText }}</p>
|
||||
</n-modal>
|
||||
</Shell>
|
||||
|
||||
Reference in New Issue
Block a user