feat: 采集按分组选表和固定时刻运行,号池可检查凭证,管理页不再退出
This commit is contained in:
@@ -1,22 +1,75 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from "vue";
|
||||
import { NButton, NModal, useDialog } from "naive-ui";
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
import { NButton, NIcon, NInput, NModal, NTooltip, useDialog } from "naive-ui";
|
||||
import { CheckmarkCircleOutline, TrashOutline } from "@vicons/ionicons5";
|
||||
import Shell from "../../shell/Shell.vue";
|
||||
import LoginView from "../auth/LoginView.vue";
|
||||
import { api } from "../../shared/http";
|
||||
import { useToast } from "../../shared/toast";
|
||||
|
||||
interface Account { id: number; loginId: string; userName: string; cityName: string; sessionOpen: boolean; credentialValid: boolean }
|
||||
interface Account {
|
||||
id: number;
|
||||
loginId: string;
|
||||
userName: string;
|
||||
cityName: string;
|
||||
credentialValid: boolean;
|
||||
savedAt: string;
|
||||
createdAt: string;
|
||||
}
|
||||
const accounts = ref<Account[]>([]);
|
||||
const keyword = ref("");
|
||||
const show = ref(false);
|
||||
const checkingAll = ref(false);
|
||||
const checkingId = ref<number | null>(null);
|
||||
const dialog = useDialog();
|
||||
const toast = useToast();
|
||||
const visible = computed(() => {
|
||||
const text = keyword.value.trim().toLowerCase();
|
||||
if (!text) return accounts.value;
|
||||
return accounts.value.filter((account) =>
|
||||
[account.loginId, account.userName, account.cityName].some((value) => value.toLowerCase().includes(text))
|
||||
);
|
||||
});
|
||||
|
||||
function clock(value: string) {
|
||||
const date = new Date(value);
|
||||
if (!value || Number.isNaN(date.getTime())) return "—";
|
||||
const pad = (part: number) => String(part).padStart(2, "0");
|
||||
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`;
|
||||
}
|
||||
|
||||
async function load() {
|
||||
const result = await api<{ accounts: Account[] }>("/api/admin/pool");
|
||||
accounts.value = result.accounts;
|
||||
}
|
||||
|
||||
async function check(account: Account) {
|
||||
checkingId.value = account.id;
|
||||
try {
|
||||
const result = await api<{ account: Account }>(`/api/admin/pool/${account.id}/check`, { method: "POST" });
|
||||
accounts.value = accounts.value.map((item) => item.id === result.account.id ? result.account : item);
|
||||
toast.success(result.account.credentialValid ? "凭证有效" : "凭证已失效");
|
||||
} catch (error) {
|
||||
toast.error(error instanceof Error ? error.message : "检查失败");
|
||||
} finally {
|
||||
checkingId.value = null;
|
||||
}
|
||||
}
|
||||
|
||||
async function checkAll() {
|
||||
checkingAll.value = true;
|
||||
try {
|
||||
const result = await api<{ accounts: Account[] }>("/api/admin/pool/check", { method: "POST" });
|
||||
accounts.value = result.accounts;
|
||||
const invalid = result.accounts.filter((item) => !item.credentialValid).length;
|
||||
toast.success(invalid ? `${invalid} 个凭证已失效` : "全部凭证有效");
|
||||
} catch (error) {
|
||||
toast.error(error instanceof Error ? error.message : "检查失败");
|
||||
} finally {
|
||||
checkingAll.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function remove(id: number) {
|
||||
try {
|
||||
await api(`/api/admin/pool/${id}`, { method: "DELETE" });
|
||||
@@ -30,7 +83,7 @@ async function remove(id: number) {
|
||||
function confirmRemove(account: Account) {
|
||||
dialog.warning({
|
||||
title: "删除账号",
|
||||
content: `从大数据账号池删除 ${account.loginId}?`,
|
||||
content: `从号池删除 ${account.loginId}?`,
|
||||
positiveText: "删除",
|
||||
negativeText: "取消",
|
||||
positiveButtonProps: { type: "error" },
|
||||
@@ -45,11 +98,15 @@ onMounted(load);
|
||||
<Shell>
|
||||
<section class="page admin-page">
|
||||
<header class="page-head">
|
||||
<h2>大数据账号池</h2>
|
||||
<n-button type="primary" @click="show = true">添加账号</n-button>
|
||||
<h2>号池</h2>
|
||||
<div class="page-head-actions">
|
||||
<n-input v-model:value="keyword" clearable placeholder="搜索账号、姓名或地市" />
|
||||
<n-button :loading="checkingAll" @click="checkAll">检查</n-button>
|
||||
<n-button type="primary" @click="show = true">添加账号</n-button>
|
||||
</div>
|
||||
</header>
|
||||
<div class="admin-scroll">
|
||||
<div v-if="accounts.length" class="surface table-card">
|
||||
<div v-if="visible.length" class="surface table-card">
|
||||
<table class="admin-table">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -57,24 +114,45 @@ onMounted(load);
|
||||
<th>姓名</th>
|
||||
<th>地市</th>
|
||||
<th>凭证</th>
|
||||
<th>登录</th>
|
||||
<th>刷新凭证时间</th>
|
||||
<th>加入时间</th>
|
||||
<th class="col-actions">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="account in accounts" :key="account.id">
|
||||
<tr v-for="account in visible" :key="account.id">
|
||||
<td>{{ account.loginId }}</td>
|
||||
<td>{{ account.userName }}</td>
|
||||
<td>{{ account.cityName }}</td>
|
||||
<td :class="account.credentialValid ? 'status-ok' : 'status-bad'">{{ account.credentialValid ? "有效" : "失效" }}</td>
|
||||
<td :class="account.sessionOpen ? 'status-run' : 'status-wait'">{{ account.sessionOpen ? "未退出" : "已退出" }}</td>
|
||||
<td class="col-actions"><n-button size="small" quaternary @click="confirmRemove(account)">删除</n-button></td>
|
||||
<td>{{ clock(account.savedAt) }}</td>
|
||||
<td>{{ clock(account.createdAt) }}</td>
|
||||
<td class="col-actions">
|
||||
<div class="row-actions">
|
||||
<n-tooltip>
|
||||
<template #trigger>
|
||||
<n-button size="small" quaternary circle aria-label="检查" :loading="checkingId === account.id" :disabled="checkingAll" @click="check(account)">
|
||||
<template #icon><n-icon :component="CheckmarkCircleOutline" /></template>
|
||||
</n-button>
|
||||
</template>
|
||||
检查
|
||||
</n-tooltip>
|
||||
<n-tooltip>
|
||||
<template #trigger>
|
||||
<n-button size="small" quaternary circle aria-label="删除" @click="confirmRemove(account)">
|
||||
<template #icon><n-icon :component="TrashOutline" /></template>
|
||||
</n-button>
|
||||
</template>
|
||||
删除
|
||||
</n-tooltip>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div v-else class="surface empty-card">
|
||||
<p class="admin-status">没有账号</p>
|
||||
<p class="admin-status">{{ keyword.trim() ? "没有匹配的账号" : "没有账号" }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -91,7 +91,7 @@ onMounted(load);
|
||||
</n-radio-group>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="refresh-seconds">凭证刷新间隔<n-tooltip><template #trigger><n-icon class="hint-mark" :size="16"><HelpCircleOutline /></n-icon></template>大数据账号池里的平台凭证按这个间隔刷新。</n-tooltip></label>
|
||||
<label for="refresh-seconds">凭证刷新间隔<n-tooltip><template #trigger><n-icon class="hint-mark" :size="16"><HelpCircleOutline /></n-icon></template>号池里的平台凭证按这个间隔刷新。</n-tooltip></label>
|
||||
<div class="setting-control setting-refresh">
|
||||
<n-input-number id="refresh-seconds" v-model:value="seconds" size="small" button-placement="both" :min="60" :max="86400" :precision="0" />
|
||||
<span class="setting-unit">秒</span>
|
||||
|
||||
@@ -1,47 +1,53 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
import { NButton, NInput, NInputNumber, NModal, NSelect, NSwitch, useDialog } from "naive-ui";
|
||||
import { computed, h, onMounted, ref } from "vue";
|
||||
import { NButton, NIcon, NInput, NInputNumber, NModal, NSelect, NSwitch, NTimePicker, NTooltip, useDialog } from "naive-ui";
|
||||
import type { SelectRenderTag } from "naive-ui";
|
||||
import { CreateOutline, TrashOutline } from "@vicons/ionicons5";
|
||||
import Shell from "../../shell/Shell.vue";
|
||||
import { api } from "../../shared/http";
|
||||
import { useToast } from "../../shared/toast";
|
||||
|
||||
interface Source {
|
||||
id: number;
|
||||
name: string;
|
||||
kind: string;
|
||||
periodDays: number;
|
||||
enabled: boolean;
|
||||
lastError: string;
|
||||
config: Record<string, unknown>;
|
||||
}
|
||||
interface QueryTable {
|
||||
code: number;
|
||||
category: string;
|
||||
tablename: string;
|
||||
name: string;
|
||||
}
|
||||
interface Schedule {
|
||||
mode: "weekly" | "monthly";
|
||||
weekday?: number;
|
||||
monthDay?: number;
|
||||
time: string;
|
||||
}
|
||||
interface Source {
|
||||
id: number;
|
||||
name: string;
|
||||
kind: string;
|
||||
enabled: boolean;
|
||||
lastError: string;
|
||||
config: { tables?: QueryTable[]; timeMode?: string; timeCount?: number; city?: string; schedule?: Schedule };
|
||||
}
|
||||
interface Group {
|
||||
code: number;
|
||||
name: string;
|
||||
tables: { tablename: string; name: string }[];
|
||||
}
|
||||
const sources = ref<Source[]>([]);
|
||||
const show = ref(false);
|
||||
const details = ref(false);
|
||||
const editing = ref<Source | null>(null);
|
||||
const name = ref("");
|
||||
const kind = ref("ftp");
|
||||
const periodDays = ref(1);
|
||||
const enabled = ref(true);
|
||||
const host = ref("");
|
||||
const port = ref(22);
|
||||
const protocol = ref("sftp");
|
||||
const username = ref("");
|
||||
const password = ref("");
|
||||
const path = ref("");
|
||||
const categories = ref<{ code: number; name: string }[]>([]);
|
||||
const categoryCode = ref<number | null>(null);
|
||||
const categoryTables = ref<{ tablename: string; name: string }[]>([]);
|
||||
const groups = ref<Group[]>([]);
|
||||
const chosen = ref<QueryTable[]>([]);
|
||||
const timeMode = ref("prev_month");
|
||||
const timeCount = ref(1);
|
||||
const city = ref("");
|
||||
const scheduleMode = ref<"weekly" | "monthly">("weekly");
|
||||
const weekday = ref(1);
|
||||
const monthDay = ref(1);
|
||||
const clock = ref("08:00");
|
||||
const catalogLoading = ref(false);
|
||||
const tablesLoading = ref(false);
|
||||
const dialog = useDialog();
|
||||
const toast = useToast();
|
||||
const timeOptions = [
|
||||
@@ -52,90 +58,50 @@ const timeOptions = [
|
||||
{ label: "前几月", value: "prev_months" },
|
||||
{ label: "前多少天", value: "prev_days" },
|
||||
];
|
||||
const weekdays = ["一", "二", "三", "四", "五", "六", "日"].map((label, index) => ({ label: `周${label}`, value: index + 1 }));
|
||||
const monthDays = Array.from({ length: 31 }, (_, index) => ({ label: `${index + 1} 日`, value: index + 1 }));
|
||||
const needsCount = computed(() => ["prev_weeks", "prev_months", "prev_days"].includes(timeMode.value));
|
||||
const countLabel = computed(() => (timeMode.value === "prev_weeks" ? "周数" : timeMode.value === "prev_months" ? "月数" : "天数"));
|
||||
const categoryOptions = computed(() => categories.value.map((item) => ({ label: item.name, value: item.code })));
|
||||
const tableOptions = computed(() => categoryTables.value.map((item) => ({ label: item.name, value: item.tablename })));
|
||||
const pickedNames = computed(() => chosen.value.filter((item) => item.code === categoryCode.value).map((item) => item.tablename));
|
||||
const tableOptions = computed(() => groups.value.map((group) => ({
|
||||
type: "group" as const,
|
||||
label: group.name,
|
||||
key: String(group.code),
|
||||
children: group.tables.map((table) => ({ label: table.name, value: table.tablename })),
|
||||
})));
|
||||
const picked = computed(() => chosen.value.map((item) => item.tablename));
|
||||
const pickedText = computed(() => chosen.value.length ? `已选 ${chosen.value.length}:${chosen.value.map((item) => item.name).join("、")}` : "");
|
||||
const renderTag: SelectRenderTag = () => h("span", { class: "picker-inline" }, pickedText.value || "请选择表");
|
||||
|
||||
function scheduleText(source: Source) {
|
||||
const schedule = source.config.schedule;
|
||||
if (!schedule) return "未设置";
|
||||
const clockText = schedule.time || "";
|
||||
if (schedule.mode === "monthly") return `每月 ${schedule.monthDay} 日 ${clockText}`;
|
||||
const label = weekdays.find((item) => item.value === schedule.weekday)?.label || "";
|
||||
return `每${label} ${clockText}`;
|
||||
}
|
||||
|
||||
function reset(source?: Source) {
|
||||
editing.value = source || null;
|
||||
name.value = source?.name || "";
|
||||
kind.value = source?.kind || "ftp";
|
||||
periodDays.value = source?.periodDays || 1;
|
||||
enabled.value = source?.enabled ?? true;
|
||||
host.value = String(source?.config.host || "");
|
||||
port.value = Number(source?.config.port || 22);
|
||||
protocol.value = String(source?.config.protocol || "sftp");
|
||||
username.value = String(source?.config.username || "");
|
||||
password.value = "";
|
||||
path.value = String(source?.config.path || "");
|
||||
const stored = Array.isArray(source?.config.tables) ? source.config.tables as QueryTable[] : [];
|
||||
chosen.value = stored.filter((item) => item && item.tablename).map((item) => ({
|
||||
const stored = Array.isArray(source?.config.tables) ? source.config.tables : [];
|
||||
chosen.value = stored.filter((item) => item?.tablename).map((item) => ({
|
||||
code: Number(item.code) || 0,
|
||||
category: String(item.category || ""),
|
||||
tablename: String(item.tablename),
|
||||
name: String(item.name || item.tablename),
|
||||
}));
|
||||
timeMode.value = String(source?.config.timeMode || "prev_month");
|
||||
timeMode.value = source?.config.timeMode || "prev_month";
|
||||
timeCount.value = Number(source?.config.timeCount || 1);
|
||||
city.value = String(source?.config.city || "");
|
||||
categoryCode.value = chosen.value[0]?.code || categories.value[0]?.code || null;
|
||||
categoryTables.value = [];
|
||||
city.value = source?.config.city || "";
|
||||
const schedule = source?.config.schedule;
|
||||
scheduleMode.value = schedule?.mode === "monthly" ? "monthly" : "weekly";
|
||||
weekday.value = Number(schedule?.weekday || 1);
|
||||
monthDay.value = Number(schedule?.monthDay || 1);
|
||||
clock.value = schedule?.time || "08:00";
|
||||
show.value = true;
|
||||
if (kind.value === "nqi") {
|
||||
void loadCategories();
|
||||
}
|
||||
}
|
||||
|
||||
async function changeKind(value: string) {
|
||||
kind.value = value;
|
||||
if (value === "nqi") await loadCategories();
|
||||
}
|
||||
|
||||
async function loadCategories() {
|
||||
catalogLoading.value = true;
|
||||
try {
|
||||
const result = await api<{ categories: { code: number; name: string }[] }>("/api/admin/nqi/catalog");
|
||||
categories.value = result.categories;
|
||||
if (categoryCode.value == null && categories.value.length) categoryCode.value = categories.value[0].code;
|
||||
if (categoryCode.value != null) await loadTables(categoryCode.value);
|
||||
} catch (error) {
|
||||
toast.error(error instanceof Error ? error.message : "查询分类没有获取到");
|
||||
} finally {
|
||||
catalogLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function loadTables(code: number) {
|
||||
categoryCode.value = code;
|
||||
tablesLoading.value = true;
|
||||
try {
|
||||
const result = await api<{ tables: { tablename: string; name: string }[] }>(`/api/admin/nqi/catalog?code=${code}`);
|
||||
categoryTables.value = result.tables;
|
||||
} catch (error) {
|
||||
categoryTables.value = [];
|
||||
toast.error(error instanceof Error ? error.message : "数据表没有获取到");
|
||||
} finally {
|
||||
tablesLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function setPicked(names: string[]) {
|
||||
const code = categoryCode.value;
|
||||
const category = categories.value.find((item) => item.code === code)?.name || "";
|
||||
const current = categoryTables.value
|
||||
.filter((item) => names.includes(item.tablename))
|
||||
.map((item) => ({ code: code || 0, category, tablename: item.tablename, name: item.name }));
|
||||
chosen.value = [...chosen.value.filter((item) => item.code !== code), ...current];
|
||||
}
|
||||
|
||||
function selectCategory() {
|
||||
setPicked(categoryTables.value.map((item) => item.tablename));
|
||||
}
|
||||
|
||||
function removeTable(tablename: string) {
|
||||
chosen.value = chosen.value.filter((item) => item.tablename !== tablename);
|
||||
if (!groups.value.length) void loadCatalog();
|
||||
}
|
||||
|
||||
async function load() {
|
||||
@@ -143,15 +109,56 @@ async function load() {
|
||||
sources.value = result.sources;
|
||||
}
|
||||
|
||||
async function loadCatalog() {
|
||||
catalogLoading.value = true;
|
||||
try {
|
||||
const result = await api<{ groups: Group[] }>("/api/admin/nqi/catalog?tree=true");
|
||||
groups.value = result.groups;
|
||||
} catch (error) {
|
||||
toast.error(error instanceof Error ? error.message : "数据表没有获取到");
|
||||
} finally {
|
||||
catalogLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function lookup(tablename: string) {
|
||||
for (const group of groups.value) {
|
||||
const table = group.tables.find((item) => item.tablename === tablename);
|
||||
if (table) return { code: group.code, category: group.name, tablename, name: table.name };
|
||||
}
|
||||
return chosen.value.find((item) => item.tablename === tablename) || null;
|
||||
}
|
||||
|
||||
function setPicked(names: string[]) {
|
||||
chosen.value = names.map(lookup).filter((item): item is QueryTable => Boolean(item));
|
||||
}
|
||||
|
||||
function removeTable(tablename: string) {
|
||||
chosen.value = chosen.value.filter((item) => item.tablename !== tablename);
|
||||
}
|
||||
|
||||
async function save() {
|
||||
if (kind.value === "nqi" && !chosen.value.length) {
|
||||
if (!name.value.trim()) {
|
||||
toast.error("请填写名称");
|
||||
return false;
|
||||
}
|
||||
if (!chosen.value.length) {
|
||||
toast.error("请选择要采集的表");
|
||||
return false;
|
||||
}
|
||||
const config = kind.value === "nqi"
|
||||
? { tables: chosen.value, timeMode: timeMode.value, timeCount: timeCount.value, city: city.value }
|
||||
: { protocol: protocol.value, host: host.value, port: port.value, username: username.value, password: password.value, path: path.value };
|
||||
const body = { name: name.value, kind: kind.value, periodDays: periodDays.value, enabled: enabled.value, config };
|
||||
if (!clock.value) {
|
||||
toast.error("请填写采集时间");
|
||||
return false;
|
||||
}
|
||||
const schedule = scheduleMode.value === "weekly"
|
||||
? { mode: "weekly", weekday: weekday.value, time: clock.value }
|
||||
: { mode: "monthly", monthDay: monthDay.value, time: clock.value };
|
||||
const body = {
|
||||
name: name.value,
|
||||
kind: "nqi",
|
||||
enabled: enabled.value,
|
||||
config: { tables: chosen.value, timeMode: timeMode.value, timeCount: timeCount.value, city: city.value, schedule },
|
||||
};
|
||||
try {
|
||||
if (editing.value) {
|
||||
await api(`/api/admin/sources/${editing.value.id}`, { method: "PUT", body: JSON.stringify(body) });
|
||||
@@ -204,8 +211,7 @@ onMounted(load);
|
||||
<thead>
|
||||
<tr>
|
||||
<th>名称</th>
|
||||
<th>来源</th>
|
||||
<th>周期(天)</th>
|
||||
<th>周期</th>
|
||||
<th>状态</th>
|
||||
<th class="col-actions">操作</th>
|
||||
</tr>
|
||||
@@ -213,16 +219,29 @@ onMounted(load);
|
||||
<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>{{ scheduleText(source) }}</td>
|
||||
<td>
|
||||
<span v-if="source.lastError" class="status-bad">{{ source.lastError }}</span>
|
||||
<span v-else :class="source.enabled ? 'status-ok' : 'status-wait'">{{ source.enabled ? "启用" : "停用" }}</span>
|
||||
</td>
|
||||
<td class="col-actions">
|
||||
<div class="row-actions">
|
||||
<n-button size="small" quaternary @click="reset(source)">编辑</n-button>
|
||||
<n-button size="small" quaternary @click="confirmRemove(source)">删除</n-button>
|
||||
<n-tooltip>
|
||||
<template #trigger>
|
||||
<n-button size="small" quaternary circle aria-label="编辑" @click="reset(source)">
|
||||
<template #icon><n-icon :component="CreateOutline" /></template>
|
||||
</n-button>
|
||||
</template>
|
||||
编辑
|
||||
</n-tooltip>
|
||||
<n-tooltip>
|
||||
<template #trigger>
|
||||
<n-button size="small" quaternary circle aria-label="删除" @click="confirmRemove(source)">
|
||||
<template #icon><n-icon :component="TrashOutline" /></template>
|
||||
</n-button>
|
||||
</template>
|
||||
删除
|
||||
</n-tooltip>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -234,56 +253,92 @@ onMounted(load);
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<n-modal v-model:show="show" class="app-dialog app-dialog-wide" preset="dialog" :show-icon="false" title="采集" positive-text="保存" negative-text="取消" @positive-click="save">
|
||||
<div class="form-row"><label>来源</label><n-select :value="kind" :options="[{ label: 'FTP/SFTP', value: 'ftp' }, { label: 'NQI', value: 'nqi' }]" @update:value="changeKind" /></div>
|
||||
<div class="form-row"><label>名称</label><n-input v-model:value="name" /></div>
|
||||
<p class="form-section">连接</p>
|
||||
<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-select :value="categoryCode" :options="categoryOptions" :loading="catalogLoading" @update:value="loadTables" /></div>
|
||||
<n-modal v-model:show="show" class="app-dialog app-dialog-collect" preset="card" :show-icon="false" title="采集">
|
||||
<div class="collect-form">
|
||||
<div class="form-row"><label>名称</label><n-input v-model:value="name" /></div>
|
||||
<div class="form-row">
|
||||
<label>数据表</label>
|
||||
<div>
|
||||
<n-select multiple filterable :value="pickedNames" :options="tableOptions" :loading="tablesLoading" @update:value="setPicked" />
|
||||
<n-button size="small" quaternary :disabled="!categoryTables.length" @click="selectCategory">分类全选</n-button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="chosen.length" class="form-row">
|
||||
<label>已选</label>
|
||||
<div class="picked-tables">
|
||||
<button v-for="item in chosen" :key="item.tablename" type="button" @click="removeTable(item.tablename)">{{ item.name }}</button>
|
||||
<div class="table-picker">
|
||||
<n-select
|
||||
class="table-select"
|
||||
multiple
|
||||
filterable
|
||||
placeholder="请选择表"
|
||||
:value="picked"
|
||||
:options="tableOptions"
|
||||
:loading="catalogLoading"
|
||||
:render-tag="renderTag"
|
||||
@update:value="setPicked"
|
||||
/>
|
||||
<div class="table-picker-meta">
|
||||
<span>已选 {{ chosen.length }}</span>
|
||||
<n-button text type="primary" :disabled="!chosen.length" @click="details = true">选择详情</n-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row"><label>数据时间</label><n-select v-model:value="timeMode" :options="timeOptions" /></div>
|
||||
<div v-if="needsCount" class="form-row"><label>{{ countLabel }}</label><n-input-number v-model:value="timeCount" :min="1" :max="366" :show-button="false" /></div>
|
||||
<div class="form-row"><label>城市</label><n-input v-model:value="city" placeholder="不填则不按城市过滤" /></div>
|
||||
<div class="form-row">
|
||||
<label>采集周期</label>
|
||||
<n-select v-model:value="scheduleMode" :options="[{ label: '每周', value: 'weekly' }, { label: '每月', value: 'monthly' }]" />
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label>{{ scheduleMode === 'weekly' ? '星期' : '日期' }}</label>
|
||||
<div class="schedule-time">
|
||||
<n-select v-if="scheduleMode === 'weekly'" v-model:value="weekday" :options="weekdays" />
|
||||
<n-select v-else v-model:value="monthDay" :options="monthDays" />
|
||||
<n-time-picker v-model:formatted-value="clock" format="HH:mm" value-format="HH:mm" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row"><label>启用</label><n-switch v-model:value="enabled" /></div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<div class="dialog-actions">
|
||||
<n-button @click="show = false">取消</n-button>
|
||||
<n-button type="primary" @click="save">保存</n-button>
|
||||
</div>
|
||||
</template>
|
||||
<p class="form-section">周期</p>
|
||||
<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>
|
||||
</n-modal>
|
||||
<n-modal v-model:show="details" class="app-dialog" preset="card" title="已选表格">
|
||||
<div v-if="chosen.length" class="picked-list">
|
||||
<div v-for="item in chosen" :key="item.tablename" class="picked-row">
|
||||
<div>
|
||||
<strong>{{ item.name }}</strong>
|
||||
<span>{{ item.category }}</span>
|
||||
</div>
|
||||
<n-tooltip>
|
||||
<template #trigger>
|
||||
<n-button size="small" quaternary circle aria-label="移除" @click="removeTable(item.tablename)">
|
||||
<template #icon><n-icon :component="TrashOutline" /></template>
|
||||
</n-button>
|
||||
</template>
|
||||
移除
|
||||
</n-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
<p v-else class="admin-status">还没有选择表格</p>
|
||||
</n-modal>
|
||||
</Shell>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.picked-tables {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
}
|
||||
.picked-tables button {
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 999px;
|
||||
background: transparent;
|
||||
color: var(--ink);
|
||||
padding: 2px 8px;
|
||||
cursor: pointer;
|
||||
.collect-form { display: grid; gap: 12px; }
|
||||
.table-picker { display: grid; gap: 6px; min-width: 0; }
|
||||
.table-picker-meta { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; }
|
||||
.table-select :deep(.n-base-selection-tags) { flex-wrap: nowrap; overflow: hidden; }
|
||||
.table-select :deep(.n-base-selection-tag-wrapper:not(:first-child)) { display: none; }
|
||||
.table-select :deep(.picker-inline) {
|
||||
display: block;
|
||||
max-width: 280px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.schedule-time { display: grid; grid-template-columns: minmax(0, 1fr) 128px; gap: 8px; }
|
||||
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
|
||||
.picked-list { display: grid; gap: 8px; }
|
||||
.picked-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
|
||||
.picked-row strong { display: block; }
|
||||
.picked-row span { color: var(--muted); font-size: 12px; }
|
||||
</style>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
import { NButton } from "naive-ui";
|
||||
import ThemeButton from "../../shell/ThemeButton.vue";
|
||||
</script>
|
||||
|
||||
@@ -13,9 +12,6 @@ import ThemeButton from "../../shell/ThemeButton.vue";
|
||||
</div>
|
||||
<h2 id="denied-title" class="gate-title">请从应用托管进入管理</h2>
|
||||
<p class="gate-text">管理页面不在这里登录。请回到应用托管,使用「管理」进入。</p>
|
||||
<div class="gate-actions">
|
||||
<n-button type="primary" tag="a" href="/hosting">返回应用托管</n-button>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, onUnmounted, ref } from "vue";
|
||||
import { NButton, NDatePicker, NInput, NModal, NSelect } from "naive-ui";
|
||||
import { NButton, NDatePicker, NIcon, NInput, NModal, NSelect, NTooltip } from "naive-ui";
|
||||
import { DownloadOutline } from "@vicons/ionicons5";
|
||||
import Shell from "../../shell/Shell.vue";
|
||||
import { appUrl } from "../../shared/base";
|
||||
import { api, token } from "../../shared/http";
|
||||
@@ -169,7 +170,16 @@ onUnmounted(stopPoll);
|
||||
<div v-if="row.error" class="status-bad">{{ row.error }}</div>
|
||||
</td>
|
||||
<td class="col-actions">
|
||||
<n-button v-if="row.status === 'done'" type="primary" size="small" @click="download(row)">下载结果</n-button>
|
||||
<div v-if="row.status === 'done'" class="row-actions">
|
||||
<n-tooltip>
|
||||
<template #trigger>
|
||||
<n-button size="small" quaternary circle aria-label="下载结果" @click="download(row)">
|
||||
<template #icon><n-icon :component="DownloadOutline" /></template>
|
||||
</n-button>
|
||||
</template>
|
||||
下载结果
|
||||
</n-tooltip>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
@@ -3,7 +3,7 @@ import { computed, h, onMounted, onUnmounted, ref } from "vue";
|
||||
import type { Component } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import { NButton, NIcon, NLayout, NLayoutSider, NMenu } from "naive-ui";
|
||||
import { AppsOutline, CloudDownloadOutline, HomeOutline, KeyOutline, ListOutline, LogOutOutline, PeopleOutline, PersonOutline, SettingsOutline } from "@vicons/ionicons5";
|
||||
import { CloudDownloadOutline, HomeOutline, KeyOutline, ListOutline, LogOutOutline, PeopleOutline, PersonOutline, SettingsOutline } from "@vicons/ionicons5";
|
||||
import { appUrl } from "../shared/base";
|
||||
import { api, clearSession, sessionInfo, token } from "../shared/http";
|
||||
import { hosted } from "../shared/installState";
|
||||
@@ -22,7 +22,7 @@ const items = computed(() => role === "admin"
|
||||
? [
|
||||
{ label: "首页", key: "/admin", icon: renderIcon(HomeOutline) },
|
||||
...(!hosted || loginMode.value === "local" ? [{ label: "用户", key: "/admin/users", icon: renderIcon(PeopleOutline) }] : []),
|
||||
{ label: "大数据账号池", key: "/admin/pool", icon: renderIcon(KeyOutline) },
|
||||
{ label: "号池", key: "/admin/pool", icon: renderIcon(KeyOutline) },
|
||||
{ label: "采集", key: "/admin/sources", icon: renderIcon(CloudDownloadOutline) },
|
||||
{ label: "设置", key: "/admin/settings", icon: renderIcon(SettingsOutline) },
|
||||
]
|
||||
@@ -79,10 +79,6 @@ async function logout() {
|
||||
:options="items"
|
||||
@update:value="(key) => router.push(String(key))"
|
||||
/>
|
||||
<a v-if="hosted && role === 'admin'" class="sider-back" :class="{ compact: collapsed }" href="/hosting" :title="collapsed ? '返回应用托管' : undefined" @click="clearSession()">
|
||||
<n-icon :size="collapsed ? 22 : 18"><AppsOutline /></n-icon>
|
||||
<span v-if="!collapsed">返回应用托管</span>
|
||||
</a>
|
||||
<div class="sider-user" :class="{ compact: collapsed }">
|
||||
<n-icon :size="18"><PersonOutline /></n-icon>
|
||||
<div v-if="!collapsed" class="who">
|
||||
@@ -90,7 +86,7 @@ async function logout() {
|
||||
<span>已登录</span>
|
||||
</div>
|
||||
<ThemeButton />
|
||||
<n-button class="logout-btn" quaternary circle size="small" aria-label="退出" @click="logout">
|
||||
<n-button v-if="!(hosted && role === 'admin')" class="logout-btn" quaternary circle size="small" aria-label="退出" @click="logout">
|
||||
<template #icon><n-icon><LogOutOutline /></n-icon></template>
|
||||
</n-button>
|
||||
</div>
|
||||
|
||||
+13
-2
@@ -226,17 +226,28 @@ button, input, select { font: inherit; }
|
||||
.admin-table .col-actions {
|
||||
width: 1%;
|
||||
white-space: nowrap;
|
||||
text-align: right;
|
||||
text-align: center;
|
||||
}
|
||||
.admin-table .col-format,
|
||||
.admin-table .col-role { width: 88px; }
|
||||
.admin-table .col-pick { width: 128px; }
|
||||
.row-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
.page-head-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
.page-head-actions .n-input { width: min(280px, 42vw); }
|
||||
.n-card.app-dialog-collect,
|
||||
.app-dialog-collect.app-dialog {
|
||||
width: min(640px, calc(100vw - 32px));
|
||||
}
|
||||
|
||||
/* forms: label left, control right */
|
||||
.form-row {
|
||||
|
||||
Reference in New Issue
Block a user