feat: 新增银行卡检查插件及相关依赖与配置文件
This commit is contained in:
@@ -1,86 +1,127 @@
|
||||
<template>
|
||||
<div class="sched-page">
|
||||
<PageHead eyebrow="SCHEDULE · 计划" title="定时任务" sub="客户端内置定时:场景与流程都能按 cron 到点自动执行,场景任务的配置会自动备份到中心机">
|
||||
<template #actions>
|
||||
<el-button type="primary" :icon="Plus" @click="openCreate">新建任务</el-button>
|
||||
</template>
|
||||
</PageHead>
|
||||
|
||||
<!-- 本周分布:按每周几聚合启用中的任务 -->
|
||||
<section v-if="list.length" class="card week-card">
|
||||
<div class="wc-head">
|
||||
<div class="wc-titles">
|
||||
<span class="sec-eyebrow">WEEK</span>
|
||||
<b class="wc-title">本周分布</b>
|
||||
</div>
|
||||
<span class="wc-note">启用中 {{ enabledCount }} / {{ list.length }} 个任务</span>
|
||||
<!-- 页头:统计概览 + 批量/新建入口 -->
|
||||
<header class="pg-head">
|
||||
<div class="pg-titles">
|
||||
<span class="pg-crumb">计划</span>
|
||||
<h1 class="pg-title">计划任务</h1>
|
||||
<p class="pg-sub">
|
||||
<b class="on">{{ statActive }}</b> 个启用 ·
|
||||
<b>{{ statPaused }}</b> 个暂停 ·
|
||||
下次执行 {{ statNext }} ·
|
||||
平均用时 {{ statAvg }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="wc-bars">
|
||||
<div v-for="(d, i) in weekDist" :key="i" class="wc-col">
|
||||
<span class="wc-n">{{ d.n || '' }}</span>
|
||||
<div class="wc-track"><i class="wc-bar" :style="{ height: barH(d.n) }"></i></div>
|
||||
<span class="wc-label" :class="{ today: i === todayIdx }">{{ d.label }}</span>
|
||||
<div class="pg-actions">
|
||||
<button class="btn-ghost" :disabled="!statActive || pausingAll" @click="pauseAll">暂停全部</button>
|
||||
<el-button type="primary" :icon="Plus" @click="openCreate">新建计划</el-button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- 本周运行分布:按本机运行记录聚合(周一起) -->
|
||||
<section v-if="list.length" class="week">
|
||||
<div class="week-head">
|
||||
<h2>本周运行分布</h2>
|
||||
<span class="week-note">共 {{ weekTotal }} 次 · 峰值 {{ peakText }}</span>
|
||||
</div>
|
||||
<div class="week-bars">
|
||||
<div v-for="(d, i) in weekChart" :key="i" class="wb-col">
|
||||
<div class="wb-slot">
|
||||
<i class="wb-bar" :class="{ today: d.isToday, empty: !d.count }" :style="{ height: barH(d.count) }">
|
||||
<span v-if="d.count" class="wb-tip">{{ d.count }} 次</span>
|
||||
</i>
|
||||
</div>
|
||||
<span class="wb-label" :class="{ today: d.isToday }">{{ d.label }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<el-empty v-if="!list.length" description="暂无定时任务,点击右上角「新建任务」创建" />
|
||||
|
||||
<!-- 时间队列:按下次执行时间组织的任务行 -->
|
||||
<div v-else class="sched-wrap">
|
||||
<div class="sec-head">
|
||||
<div class="wc-titles">
|
||||
<span class="sec-eyebrow">QUEUE</span>
|
||||
<b class="wc-title">时间队列</b>
|
||||
</div>
|
||||
<span class="head-note">共 {{ list.length }} 个任务</span>
|
||||
<!-- 计划表:卡片容器(与总览「最近运行场景」同一套表格样式) -->
|
||||
<section class="tbl-card">
|
||||
<div class="tbl-head">
|
||||
<h2>计划列表</h2>
|
||||
<span class="tbl-stat">启用 {{ statActive }} · 暂停 {{ statPaused }}</span>
|
||||
</div>
|
||||
<div class="sched-list card">
|
||||
<div v-for="row in pagedList" :key="row.id" class="sched-row" :class="{ off: !row.enabled }">
|
||||
<div class="sr-when" :class="{ today: nextWhen(row).today }">
|
||||
<b>{{ nextWhen(row).main }}</b>
|
||||
<span>{{ nextWhen(row).sub }}</span>
|
||||
</div>
|
||||
<div class="sr-main">
|
||||
<b>
|
||||
<span class="kind-pill" :class="row.kind">{{ row.kind === 'flow' ? '流程' : '场景' }}</span>
|
||||
{{ row.name }}<em v-if="!row.enabled" class="off-pill">停用</em>
|
||||
</b>
|
||||
<span v-if="row.kind === 'flow'">{{ row.node_count }} 个节点 · 按依赖串行执行</span>
|
||||
<span v-else>{{ pluginName(row.plugin_id) }}</span>
|
||||
</div>
|
||||
<code class="cron-chip">{{ row.cron }}</code>
|
||||
<div class="sr-last">
|
||||
<!-- 队列态优先:本次触发的运行还排在队列里时,比"上次成功 · 3 天前"更有信息量 -->
|
||||
<template v-if="queueState(row)">
|
||||
<span class="st-pill mid">
|
||||
<i class="dot"></i>{{ queueState(row).text }}
|
||||
</span>
|
||||
<span class="sr-last-time">{{ queueState(row).sub }}</span>
|
||||
</template>
|
||||
<template v-else-if="row.last_run_at">
|
||||
<span class="st-pill" :class="row.last_status === 'ok' ? 'ok' : (row.last_status === 'error' ? 'err' : 'mid')">
|
||||
<i class="dot"></i>
|
||||
<template v-if="row.last_status === 'ok'">成功<template v-if="row.last_duration"> · {{ row.last_duration }}s</template></template>
|
||||
<template v-else-if="row.last_status === 'error'">失败</template>
|
||||
<template v-else>执行中</template>
|
||||
</span>
|
||||
<span class="sr-last-time">上次 {{ fmtShort(row.last_run_at) }}</span>
|
||||
</template>
|
||||
<span v-else class="st-pill none"><i class="dot"></i>从未执行</span>
|
||||
</div>
|
||||
<div class="sr-acts">
|
||||
<el-switch :model-value="row.enabled" size="small" @change="(v) => onToggle(row, v)" />
|
||||
<el-button v-if="row.kind === 'flow'" link type="primary" @click="onRunFlow(row)">运行</el-button>
|
||||
<el-button link type="primary" @click="openEdit(row)">编辑</el-button>
|
||||
<el-button link type="danger" @click="onDelete(row)">删除</el-button>
|
||||
</div>
|
||||
<div class="tbl-body">
|
||||
<table v-if="list.length" class="tbl">
|
||||
<!-- 用比例分配列宽:窗口变窄时各列等比收缩,「场景」列不会被挤到 0 与「频率」贴在一起 -->
|
||||
<colgroup>
|
||||
<col style="width: 8%" />
|
||||
<col style="width: 7%" />
|
||||
<col style="width: 15%" />
|
||||
<col style="width: 23%" />
|
||||
<col style="width: 12%" />
|
||||
<col style="width: 12%" />
|
||||
<col style="width: 9%" />
|
||||
<col style="width: 14%" />
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>时间</th>
|
||||
<th>类型</th>
|
||||
<th>频率</th>
|
||||
<th class="c-scene">场景</th>
|
||||
<th>上次结果</th>
|
||||
<th>下次执行</th>
|
||||
<th class="c-state">状态</th>
|
||||
<th class="c-acts">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="row in pagedList" :key="row.id" :class="{ off: !row.enabled }">
|
||||
<td class="c-time" :class="{ sm: row.cols.timeText, today: row.enabled && nextWhen(row).today }">{{ row.cols.time }}</td>
|
||||
<td class="c-type">
|
||||
<span class="kind-pill" :class="row.kind">{{ row.kind === 'flow' ? '流程' : '场景' }}</span>
|
||||
</td>
|
||||
<td class="c-freq">
|
||||
<code v-if="row.cols.freqCron" class="cron-chip" :title="row.cron">{{ row.cols.freq }}</code>
|
||||
<template v-else>{{ row.cols.freq }}</template>
|
||||
</td>
|
||||
<!-- 名称单行显示,补充说明(节点数/插件名)收进 i 里 -->
|
||||
<td class="c-scene">
|
||||
<span class="name-wrap">
|
||||
<b class="nm">{{ row.name }}</b>
|
||||
<el-tooltip :content="row.kind === 'flow' ? `${row.node_count} 个节点 · 按依赖串行执行` : pluginName(row.plugin_id)" placement="top">
|
||||
<i class="info-dot">i</i>
|
||||
</el-tooltip>
|
||||
</span>
|
||||
</td>
|
||||
<!-- 队列态优先:本次触发的运行还排在队列里时,比"上次成功"更有信息量 -->
|
||||
<td class="c-res">
|
||||
<span v-if="queueState(row)" class="res-live">{{ queueState(row).text }}</span>
|
||||
<span v-else-if="row.last_run_at"
|
||||
:class="row.last_status === 'ok' ? 'res-ok' : (row.last_status === 'error' ? 'res-bad' : 'res-live')"
|
||||
:title="'上次执行 ' + fmtShort(row.last_run_at)">
|
||||
{{ row.last_status === 'ok' ? '成功' : (row.last_status === 'error' ? '失败' : '执行中') }}<i v-if="row.last_duration"> · {{ fmtDur(row.last_duration) }}</i>
|
||||
</span>
|
||||
<span v-else class="res-idle">从未执行</span>
|
||||
</td>
|
||||
<td class="c-next" :class="{ muted: !row.enabled, today: row.enabled && nextWhen(row).today }">
|
||||
{{ row.enabled ? nextWhen(row).main : '暂停中' }}
|
||||
</td>
|
||||
<td class="c-state">
|
||||
<button type="button" class="state-btn" :class="row.enabled ? 'on' : 'off'"
|
||||
:title="row.enabled ? '点击暂停该计划' : '点击恢复执行'" @click="onToggle(row, !row.enabled)">
|
||||
<i></i>{{ row.enabled ? '启用' : '暂停' }}
|
||||
</button>
|
||||
</td>
|
||||
<td class="c-acts">
|
||||
<el-button v-if="row.kind === 'flow'" link type="primary" @click="onRunFlow(row)">运行</el-button>
|
||||
<el-button link type="primary" @click="openEdit(row)">编辑</el-button>
|
||||
<el-button link type="danger" @click="onDelete(row)">删除</el-button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div v-else class="tbl-empty">暂无定时任务,点击右上角「新建计划」创建</div>
|
||||
</div>
|
||||
</div>
|
||||
<el-pagination v-if="list.length > pageSize" class="sched-pager" size="small" background
|
||||
layout="total, prev, pager, next" :total="list.length" :page-size="pageSize"
|
||||
:current-page="page" @current-change="(p) => page = p" />
|
||||
</div>
|
||||
<footer class="pg-foot">
|
||||
<span>共 {{ list.length }} 个计划 · 调度器每 30 秒轮询一次</span>
|
||||
<el-pagination v-if="list.length > pageSize" size="small" layout="prev, pager, next"
|
||||
:total="list.length" :page-size="pageSize" :current-page="page"
|
||||
@current-change="(p) => page = p" />
|
||||
</footer>
|
||||
</section>
|
||||
|
||||
<el-dialog v-model="dlg" :title="editing ? '编辑定时任务' : '新建定时任务'" width="min(780px, 94vw)" align-center
|
||||
class="sched-dlg">
|
||||
@@ -198,12 +239,11 @@ import { computed, ref, watch } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { Plus } from '@element-plus/icons-vue'
|
||||
import { store } from '../store'
|
||||
import PageHead from './PageHead.vue'
|
||||
import {
|
||||
listSchedules, createSchedule, updateSchedule, deleteSchedule, toggleSchedule,
|
||||
listPluginConfigs, listFlows, updateFlow, runFlow,
|
||||
listPluginConfigs, listFlows, updateFlow, runFlow, fetchRuns,
|
||||
} from '../api'
|
||||
import { fmtShort } from '../utils/format'
|
||||
import { fmtShort, durText } from '../utils/format'
|
||||
|
||||
const list = ref([])
|
||||
// 计划页是"通用定时"入口:场景(插件)与流程(编排)都能在这里排期
|
||||
@@ -245,30 +285,105 @@ watch(() => list.value.length, (n) => {
|
||||
if (page.value > max) page.value = max
|
||||
})
|
||||
|
||||
// ---- 本周分布:按每周几聚合启用中的任务(cron 第5段 dow;dom 固定日的任务不计入周分布) ----
|
||||
const enabledCount = computed(() => list.value.filter((r) => r.enabled).length)
|
||||
const todayIdx = computed(() => (new Date().getDay() + 6) % 7) // 周一=0
|
||||
const weekDist = computed(() => {
|
||||
const labels = ['一', '二', '三', '四', '五', '六', '日']
|
||||
const counts = Array(7).fill(0)
|
||||
for (const r of list.value) {
|
||||
if (!r.enabled) continue
|
||||
const parts = String(r.cron || '').trim().split(/\s+/)
|
||||
if (parts.length !== 5) continue
|
||||
const [dom, , dow] = [parts[2], parts[3], parts[4]]
|
||||
if (dom !== '*') continue // 每月固定日:不落到本周分布
|
||||
if (dow === '*') { for (let i = 0; i < 7; i++) counts[i] += 1; continue } // 每天/每隔N小时
|
||||
for (const seg of dow.split(',')) {
|
||||
const mm = seg.match(/^(\d+)(?:-(\d+))?$/)
|
||||
if (mm) {
|
||||
const a = +mm[1], b = mm[2] ? +mm[2] : a
|
||||
for (let x = a; x <= b; x++) { const i = x === 0 ? 6 : x - 1; if (i >= 0 && i < 7) counts[i] += 1 }
|
||||
}
|
||||
}
|
||||
// ---- 页头统计:启用 / 暂停 / 下次执行 / 平均用时 ----
|
||||
const statActive = computed(() => list.value.filter((r) => r.enabled).length)
|
||||
const statPaused = computed(() => list.value.length - statActive.value)
|
||||
|
||||
// ---- 本周运行分布:按本机运行记录聚合(周一为起点),不是"任务配置了几次" ----
|
||||
const weekRuns = ref([])
|
||||
const WD = ['一', '二', '三', '四', '五', '六', '日']
|
||||
|
||||
async function loadRuns() {
|
||||
try {
|
||||
const r = await fetchRuns(200)
|
||||
// 取消/中断不算一次真实运行
|
||||
weekRuns.value = (r.runs || []).filter((x) => x.started && x.status !== 'cancelled' && x.status !== 'interrupted')
|
||||
} catch (_) { weekRuns.value = [] }
|
||||
}
|
||||
|
||||
const weekChart = computed(() => {
|
||||
const now = new Date()
|
||||
const dow = (now.getDay() + 6) % 7 // 周一=0
|
||||
const monday = new Date(now.getFullYear(), now.getMonth(), now.getDate() - dow)
|
||||
const days = []
|
||||
for (let i = 0; i < 7; i++) {
|
||||
const d = new Date(monday)
|
||||
d.setDate(monday.getDate() + i)
|
||||
days.push({
|
||||
key: `${d.getFullYear()}-${d.getMonth()}-${d.getDate()}`,
|
||||
label: i === dow ? `今天 ${d.getDate()}` : `周${WD[i]} ${d.getDate()}`,
|
||||
count: 0,
|
||||
isToday: i === dow,
|
||||
})
|
||||
}
|
||||
return labels.map((label, i) => ({ label, n: counts[i] }))
|
||||
const keyOf = (sec) => {
|
||||
const d = new Date(sec * 1000)
|
||||
return `${d.getFullYear()}-${d.getMonth()}-${d.getDate()}`
|
||||
}
|
||||
for (const r of weekRuns.value) {
|
||||
const d = days.find((x) => x.key === keyOf(r.started))
|
||||
if (d) d.count++
|
||||
}
|
||||
return days
|
||||
})
|
||||
function barH(n) { return n ? Math.max(14, Math.round((n / Math.max(1, Math.max(...weekDist.value.map((d) => d.n)))) * 46)) + 'px' : '3px' }
|
||||
const weekTotal = computed(() => weekChart.value.reduce((s, d) => s + d.count, 0))
|
||||
const peakText = computed(() => {
|
||||
const max = Math.max(0, ...weekChart.value.map((d) => d.count))
|
||||
if (!max) return '—'
|
||||
const day = weekChart.value.find((d) => d.count === max)
|
||||
return `${day.isToday ? '今天' : day.label.slice(0, 2)} ${max} 次`
|
||||
})
|
||||
function barH(n) {
|
||||
const max = Math.max(1, ...weekChart.value.map((d) => d.count))
|
||||
return n ? Math.max(10, Math.round((n / max) * 72)) + 'px' : '4px'
|
||||
}
|
||||
|
||||
const statNext = computed(() => {
|
||||
const ns = list.value.filter((r) => r.enabled && r.next_run_at).map((r) => String(r.next_run_at)).sort()
|
||||
if (!ns.length) return '—'
|
||||
const d = new Date(ns[0].replace(' ', 'T'))
|
||||
if (isNaN(d.getTime())) return ns[0]
|
||||
const now = new Date()
|
||||
const t0 = new Date(now.getFullYear(), now.getMonth(), now.getDate())
|
||||
const diff = Math.round((new Date(d.getFullYear(), d.getMonth(), d.getDate()) - t0) / 86400000)
|
||||
const hm = pad2(d.getHours()) + ':' + pad2(d.getMinutes())
|
||||
if (diff === 0) return `今天 ${hm}`
|
||||
if (diff === 1) return `明天 ${hm}`
|
||||
return `${pad2(d.getMonth() + 1)}-${pad2(d.getDate())} ${hm}`
|
||||
})
|
||||
const statAvg = computed(() => {
|
||||
const done = weekRuns.value.filter((r) => (r.duration_sec || 0) > 0)
|
||||
if (!done.length) return '—'
|
||||
const avg = done.reduce((s, r) => s + r.duration_sec, 0) / done.length
|
||||
return durText(Math.round(avg))
|
||||
})
|
||||
|
||||
// ---- 暂停全部:逐个关掉启用中的计划(流程的定时挂在流程记录上,走 updateFlow)----
|
||||
const pausingAll = ref(false)
|
||||
async function pauseAll() {
|
||||
const targets = list.value.filter((r) => r.enabled)
|
||||
if (!targets.length) return
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确定暂停全部 ${targets.length} 个启用中的计划?之后可在列表中逐个恢复。`,
|
||||
'暂停全部',
|
||||
{ type: 'warning', confirmButtonText: '全部暂停', cancelButtonText: '取消' }
|
||||
)
|
||||
} catch (_) { return }
|
||||
pausingAll.value = true
|
||||
try {
|
||||
for (const r of targets) {
|
||||
if (r.kind === 'flow') await updateFlow(r.flow_id, { schedule: { enabled: false, cron: r.cron } })
|
||||
else await toggleSchedule(r.id, false)
|
||||
}
|
||||
ElMessage.success(`已暂停 ${targets.length} 个计划`)
|
||||
await load()
|
||||
} catch (e) {
|
||||
ElMessage.error('操作失败:' + (e.message || e))
|
||||
} finally {
|
||||
pausingAll.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// ---- 闹钟式触发时间选择状态 ----
|
||||
// freq: daily=每天 weekdays=工作日 weekly=每周 monthly=每月 hourly=每隔N小时 advanced=高级cron
|
||||
@@ -338,6 +453,38 @@ function syncCron() {
|
||||
if (freq.value !== 'advanced') form.value.cron = buildCron()
|
||||
}
|
||||
|
||||
// ---- 表格列派生:cron → 时间/频率两列的人话展示 ----
|
||||
const WEEK_CN = ['一', '二', '三', '四', '五', '六', '日']
|
||||
function rowCols(row) {
|
||||
const st = cronToState(row.cron)
|
||||
const parts = String(row.cron || '').trim().split(/\s+/)
|
||||
const isNum = (x) => /^\d+$/.test(x || '')
|
||||
// timeText=true 表示时间列不是时分钟点(如"整点"),用中文字体展示
|
||||
let time = '—', timeText = false, freq = '自定义', freqCron = false
|
||||
switch (st.freq) {
|
||||
case 'daily': time = st.timeStr; freq = '每天'; break
|
||||
case 'weekdays': time = st.timeStr; freq = '工作日'; break
|
||||
case 'weekly': time = st.timeStr; freq = '每周' + st.weekdays.map((d) => WEEK_CN[d - 1]).join('、'); break
|
||||
case 'monthly': time = st.timeStr; freq = `每月 ${st.monthDay} 号`; break
|
||||
case 'hourly': time = '整点'; timeText = true; freq = st.hourlyStep > 1 ? `每隔 ${st.hourlyStep} 小时` : '每小时'; break
|
||||
default:
|
||||
// 高级 cron:频率列直接给原始表达式;能取出固定时分时时间列照常显示
|
||||
if (parts.length === 5 && parts[0] === '0' && parts.slice(1).join(' ') === '* * * *') {
|
||||
time = '整点'; timeText = true; freq = '每小时' // 每小时整点(0 * * * *)反解不进 hourly
|
||||
} else {
|
||||
freq = row.cron; freqCron = true
|
||||
if (parts.length === 5 && isNum(parts[0]) && isNum(parts[1])) time = pad2(+parts[1]) + ':' + pad2(+parts[0])
|
||||
}
|
||||
}
|
||||
return { time, timeText, freq, freqCron }
|
||||
}
|
||||
|
||||
// 上次耗时:秒 → mm:ss(与设计稿"成功 · 02:14"一致)
|
||||
function fmtDur(sec) {
|
||||
const s = parseInt(sec, 10) || 0
|
||||
return pad2(Math.floor(s / 60)) + ':' + pad2(s % 60)
|
||||
}
|
||||
|
||||
// 选择状态变化时自动重写 form.cron
|
||||
watch([freq, timeStr, weekdays, monthDay, hourlyStep], syncCron)
|
||||
watch(advancedCron, (v) => {
|
||||
@@ -429,11 +576,13 @@ async function load() {
|
||||
next_run_at: f.next_run_at || '',
|
||||
node_count: (f.nodes || []).length,
|
||||
}))
|
||||
// 启用中的按下次触发时间靠前,停用的沉底
|
||||
list.value = [...taskRows, ...flowRows].sort((a, b) => {
|
||||
if (!!a.enabled !== !!b.enabled) return a.enabled ? -1 : 1
|
||||
return String(a.next_run_at || '9999').localeCompare(String(b.next_run_at || '9999'))
|
||||
})
|
||||
// 启用中的按下次触发时间靠前,停用的沉底;并预派生时间/频率两列的展示
|
||||
list.value = [...taskRows, ...flowRows]
|
||||
.map((r) => ({ ...r, cols: rowCols(r) }))
|
||||
.sort((a, b) => {
|
||||
if (!!a.enabled !== !!b.enabled) return a.enabled ? -1 : 1
|
||||
return String(a.next_run_at || '9999').localeCompare(String(b.next_run_at || '9999'))
|
||||
})
|
||||
} catch (e) {
|
||||
ElMessage.error('加载定时任务失败:' + (e.message || e))
|
||||
}
|
||||
@@ -484,6 +633,8 @@ function openEdit(row) {
|
||||
}
|
||||
|
||||
async function onSave() {
|
||||
const nm = (form.value.name || '').trim()
|
||||
if (!nm) { ElMessage.warning('请填写任务名称'); return }
|
||||
if (target.value === 'flow') {
|
||||
if (!flowId.value) { ElMessage.warning('请选择要定时执行的流程'); return }
|
||||
} else if (!form.value.plugin_id) {
|
||||
@@ -494,8 +645,10 @@ async function onSave() {
|
||||
saving.value = true
|
||||
try {
|
||||
if (target.value === 'flow') {
|
||||
// 流程的定时保存在流程自己身上(flows.json),与流程编辑器里的开关是同一份数据
|
||||
// 流程的定时保存在流程自己身上(flows.json),与流程编辑器里的开关是同一份数据。
|
||||
// ⚠️ 名称就是流程名:改名必须一起提交,否则只写了 schedule,名字改了也不生效
|
||||
await updateFlow(flowId.value, {
|
||||
name: nm,
|
||||
schedule: { enabled: !!form.value.enabled, cron: form.value.cron },
|
||||
})
|
||||
ElMessage.success(editing.value ? '已保存' : '已创建')
|
||||
@@ -571,92 +724,197 @@ async function onRunFlow(row) {
|
||||
}
|
||||
|
||||
load()
|
||||
loadRuns()
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.sched-page {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-4);
|
||||
padding: var(--page-pad);
|
||||
flex-shrink: 0; /* 自然高度,超出由中栏上下文区整体滚动 */
|
||||
flex-direction: column; /* 页头/图表/底栏固定,中间表格区自己滚 */
|
||||
}
|
||||
|
||||
/* ---------- 本周分布 ---------- */
|
||||
.week-card {
|
||||
padding-bottom: var(--space-3);
|
||||
background: linear-gradient(160deg, var(--brand-soft-2) 0%, var(--surface) 62%);
|
||||
border-color: var(--brand-track);
|
||||
/* ---------- 页头 ---------- */
|
||||
.pg-head {
|
||||
flex-shrink: 0; display: flex; align-items: flex-end; justify-content: space-between;
|
||||
gap: var(--space-4); padding: 20px 24px;
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
.wc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-4) 0; }
|
||||
.wc-titles { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
|
||||
.wc-title { font: 600 14px/20px var(--f-cn); color: var(--t1); }
|
||||
.wc-note { font: 400 10.5px/15px var(--f-num); color: var(--t4); }
|
||||
.head-note { font: 400 10.5px/15px var(--f-num); color: var(--t4); }
|
||||
.sec-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-3); padding: 0 var(--space-1); }
|
||||
.wc-bars { display: flex; gap: var(--space-1-5); padding: var(--space-3) var(--space-4) 0; }
|
||||
.wc-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: var(--space-1); min-width: 0; }
|
||||
.wc-n { font: 500 10px/13px var(--f-num); color: var(--t3); min-height: 13px; }
|
||||
.wc-track { width: 100%; max-width: 44px; height: 56px; display: flex; align-items: flex-end; justify-content: center; background: var(--field); border-radius: var(--r-row); overflow: hidden; }
|
||||
.wc-bar { width: 60%; border-radius: var(--space-1) var(--space-1) 0 0; background: var(--brand); transition: height .3s var(--ease); }
|
||||
.wc-label { font: 400 10px/14px var(--f-cn); color: var(--t4); }
|
||||
.wc-label.today { color: var(--brand-ink); font-weight: 600; }
|
||||
.pg-titles { display: flex; flex-direction: column; min-width: 0; }
|
||||
.pg-crumb { font: 400 12px/16px var(--f-cn); color: var(--t4); margin-bottom: 6px; }
|
||||
.pg-title { margin: 0 0 4px; font: 700 24px/32px var(--f-cn); color: var(--t1); letter-spacing: -.3px; }
|
||||
.pg-sub { margin: 0; font: 400 12px/17px var(--f-cn); color: var(--t3); }
|
||||
.pg-sub b { font-family: var(--f-num); font-weight: 600; color: var(--t1); }
|
||||
.pg-sub b.on { color: var(--brand); }
|
||||
.pg-actions { display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0; }
|
||||
.btn-ghost {
|
||||
height: 32px; padding: 0 var(--space-3);
|
||||
border: 1px solid var(--line-btn); border-radius: var(--r-row);
|
||||
background: var(--surface); color: var(--t2); cursor: pointer;
|
||||
font: 500 12.5px/1 var(--f-cn);
|
||||
transition: background var(--dur), color var(--dur);
|
||||
}
|
||||
.btn-ghost:hover:not(:disabled) { background: var(--field); color: var(--t1); }
|
||||
.btn-ghost:disabled { opacity: .5; cursor: not-allowed; }
|
||||
|
||||
/* ---------- 时间队列列表 ---------- */
|
||||
.sched-wrap { display: flex; flex-direction: column; gap: var(--space-2-5); }
|
||||
.sched-list { display: flex; flex-direction: column; overflow: hidden; }
|
||||
.sched-row {
|
||||
display: flex; align-items: center; gap: var(--space-3);
|
||||
padding: var(--space-3) var(--space-4);
|
||||
/* ---------- 本周运行分布 ---------- */
|
||||
.week { flex-shrink: 0; padding: 16px 24px 14px; border-bottom: 1px solid var(--line-soft); }
|
||||
.week-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: 12px; }
|
||||
.week-head h2 { margin: 0; font: 600 13.5px/20px var(--f-cn); color: var(--t1); }
|
||||
.week-note { font: 400 11px/16px var(--f-num); color: var(--t4); }
|
||||
.week-bars { display: flex; align-items: flex-end; gap: 8px; height: 98px; padding: 0 4px; }
|
||||
.wb-col {
|
||||
flex: 1; height: 100%; min-width: 0;
|
||||
display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px;
|
||||
}
|
||||
.wb-slot { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
|
||||
.wb-bar {
|
||||
position: relative; width: 32px; max-width: 62%;
|
||||
border-radius: 6px 6px 0 0; background: var(--field);
|
||||
transition: height .3s var(--ease), background var(--dur), opacity var(--dur);
|
||||
}
|
||||
.wb-bar.today { background: var(--brand); }
|
||||
.wb-bar:not(.empty):hover { opacity: .85; }
|
||||
.wb-tip {
|
||||
position: absolute; left: 50%; top: -26px; transform: translateX(-50%);
|
||||
padding: 1px 6px; border-radius: 4px; white-space: nowrap;
|
||||
background: var(--t1); color: var(--on-primary); font: 500 10px/16px var(--f-num);
|
||||
opacity: 0; pointer-events: none; transition: opacity var(--dur);
|
||||
}
|
||||
.wb-bar:hover .wb-tip { opacity: 1; }
|
||||
.wb-label { font: 400 11px/14px var(--f-cn); color: var(--t4); white-space: nowrap; }
|
||||
.wb-label.today { color: var(--brand); font-weight: 700; }
|
||||
|
||||
/* ---------- 计划表:卡片容器 + 表格(同总览「最近运行场景」) ---------- */
|
||||
.tbl-card {
|
||||
flex: 1; min-height: 0; margin: 14px 24px 14px;
|
||||
display: flex; flex-direction: column;
|
||||
background: var(--surface); border: 1px solid var(--line);
|
||||
border-radius: var(--r-sub); overflow: hidden;
|
||||
}
|
||||
.tbl-head {
|
||||
flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
|
||||
gap: var(--space-3); padding: 12px 16px;
|
||||
border-bottom: 1px solid var(--line); background: var(--subtle);
|
||||
}
|
||||
.tbl-head h2 { margin: 0; font: 600 13.5px/20px var(--f-cn); color: var(--t1); }
|
||||
.tbl-stat { font: 400 11.5px/16px var(--f-num); color: var(--t4); }
|
||||
.tbl-body { flex: 1; min-height: 0; overflow-y: auto; }
|
||||
.tbl { width: 100%; border-collapse: collapse; table-layout: fixed; }
|
||||
.tbl th {
|
||||
position: sticky; top: 0; z-index: 1;
|
||||
padding: 10px 16px; text-align: center;
|
||||
font: 500 11px/16px var(--f-cn); color: var(--t3);
|
||||
background: var(--surface); border-bottom: 1px solid var(--line);
|
||||
}
|
||||
.tbl td {
|
||||
padding: 10px 16px; text-align: center;
|
||||
border-bottom: 1px solid var(--line-soft);
|
||||
transition: background var(--dur);
|
||||
font: 400 12px/18px var(--f-cn); color: var(--t2);
|
||||
}
|
||||
.sched-row:last-child { border-bottom: none; }
|
||||
.sched-row:hover { background: var(--field); }
|
||||
.sr-when { width: 112px; flex-shrink: 0; }
|
||||
.sr-when b { display: block; font: 700 14px/18px var(--f-num); color: var(--t1); }
|
||||
.sr-when.today b { color: var(--brand-ink); }
|
||||
.sr-when span { font: 400 10.5px/15px var(--f-num); color: var(--t4); }
|
||||
.sr-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
|
||||
.sr-main b { display: flex; align-items: center; gap: var(--space-1-5); font: 600 12.5px/18px var(--f-cn); color: var(--t1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.sr-main span { font-size: 11px; color: var(--t4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.sched-row.off .sr-when, .sched-row.off .sr-main span, .sched-row.off .cron-chip { opacity: .55; }
|
||||
.tbl tbody tr { transition: background var(--dur); }
|
||||
.tbl tbody tr:hover { background: var(--field); }
|
||||
.tbl tbody tr:last-child td { border-bottom: 0; }
|
||||
/* 场景名称长短不一:这一列(含表头)左对齐并再往右让一点,其余列居中 */
|
||||
.tbl th.c-scene, .tbl td.c-scene { text-align: left; padding-left: 22px; }
|
||||
|
||||
/* 时间列:等宽数字,整点类用中文字体 */
|
||||
.c-time { font: 700 14px/20px var(--f-num); color: var(--t1); font-variant-numeric: tabular-nums; }
|
||||
.c-time.sm { font: 600 12.5px/20px var(--f-cn); }
|
||||
.c-time.today { color: var(--brand); }
|
||||
.c-freq {
|
||||
color: var(--t3); min-width: 0;
|
||||
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
/* 类型列(居中胶囊) / 场景列(名称单行 + i 提示) */
|
||||
.c-type { text-align: center; }
|
||||
.c-scene .name-wrap { display: flex; align-items: center; gap: 5px; min-width: 0; }
|
||||
/* 与总览「最近运行场景」的场景名称完全同款:600 / 12px / t1 */
|
||||
.c-scene .nm {
|
||||
min-width: 0; font: 600 12px/18px var(--f-cn); color: var(--t1);
|
||||
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
||||
}
|
||||
.info-dot {
|
||||
flex-shrink: 0; width: 13px; height: 13px; border-radius: 50%;
|
||||
display: inline-grid; place-items: center; cursor: help;
|
||||
border: 1px solid var(--line-btn); color: var(--t4);
|
||||
font: 600 9px/1 var(--f-num); font-style: normal;
|
||||
transition: color var(--dur), border-color var(--dur);
|
||||
}
|
||||
.info-dot:hover { color: var(--brand); border-color: var(--brand-track); }
|
||||
|
||||
/* 上次结果 / 下次执行 */
|
||||
.c-res { white-space: nowrap; }
|
||||
.res-ok { color: var(--good-ink); font-weight: 500; }
|
||||
.res-bad { color: var(--danger-ink); font-weight: 500; }
|
||||
.res-live { color: var(--brand-ink); font-weight: 500; }
|
||||
.res-idle { color: var(--t4); }
|
||||
.c-res i { font-style: normal; font-weight: 400; opacity: .78; }
|
||||
.c-next { color: var(--t2); white-space: nowrap; }
|
||||
.c-next.today { color: var(--brand-ink); font-weight: 600; }
|
||||
.c-next.muted { color: var(--t4); }
|
||||
|
||||
/* 执行对象标签:场景 / 流程 */
|
||||
.kind-pill {
|
||||
flex-shrink: 0; font: 500 9.5px/15px var(--f-cn);
|
||||
flex-shrink: 0; font: 500 9.5px/16px var(--f-cn);
|
||||
color: var(--t3); background: var(--field);
|
||||
border-radius: var(--r-pill); padding: 0 var(--space-1-5);
|
||||
}
|
||||
.kind-pill.flow { color: var(--brand-ink); background: var(--brand-soft); }
|
||||
.off-pill {
|
||||
flex-shrink: 0; font-style: normal; font: 500 10px/17px var(--f-cn);
|
||||
color: var(--t3); background: var(--field);
|
||||
border: 1px solid var(--line); border-radius: var(--r-pill);
|
||||
padding: 0 var(--space-2);
|
||||
}
|
||||
/* 长 cron 表达式必须自己裁切,否则会顶出频率列、压到右边「场景」列上 */
|
||||
.cron-chip {
|
||||
flex-shrink: 0;
|
||||
display: inline-block; max-width: 100%; box-sizing: border-box;
|
||||
overflow: hidden; text-overflow: ellipsis; vertical-align: middle; white-space: nowrap;
|
||||
font-family: var(--f-mono); font-size: 11px; color: var(--brand-ink);
|
||||
background: var(--brand-soft); border: 1px solid var(--brand-track);
|
||||
border-radius: var(--r-row); padding: 2px var(--space-2);
|
||||
border-radius: var(--r-row); padding: 1px var(--space-1-5);
|
||||
}
|
||||
.sr-last { width: 150px; flex-shrink: 0; display: flex; flex-direction: column; gap: var(--space-1); }
|
||||
.st-pill {
|
||||
display: inline-flex; align-items: center; gap: var(--space-1); width: fit-content;
|
||||
padding: 1px var(--space-2); border-radius: var(--r-pill);
|
||||
font: 600 10.5px/17px var(--f-cn);
|
||||
background: var(--field); color: var(--t3);
|
||||
border: 1px solid var(--line);
|
||||
|
||||
/* 暂停中的行压灰 */
|
||||
.tbl tbody tr.off .c-time, .tbl tbody tr.off .c-freq, .tbl tbody tr.off .c-scene .nm { color: var(--t4); }
|
||||
.tbl tbody tr.off .kind-pill { color: var(--t4); background: var(--field); }
|
||||
.tbl tbody tr.off .cron-chip { opacity: .7; }
|
||||
|
||||
/* 行内操作:低饱和次级文字按钮,悬停点题 */
|
||||
.c-acts :deep(.el-button) {
|
||||
font-size: 11.5px; font-weight: 500; padding: 2px 4px;
|
||||
margin-left: 0; color: var(--t3);
|
||||
}
|
||||
.c-acts :deep(.el-button + .el-button) { margin-left: 0; }
|
||||
.c-acts :deep(.el-button--primary.is-link):hover { color: var(--brand-ink); }
|
||||
.c-acts :deep(.el-button--danger.is-link):hover { color: var(--danger-ink); }
|
||||
|
||||
/* 状态胶囊:点击即暂停/恢复 */
|
||||
.state-btn {
|
||||
height: 22px; padding: 0 10px;
|
||||
border: 1px solid transparent; border-radius: 6px; box-sizing: border-box;
|
||||
display: inline-flex; align-items: center; justify-content: center; gap: 5px;
|
||||
font: 500 11px/1 var(--f-cn); white-space: nowrap; cursor: pointer;
|
||||
transition: filter var(--dur);
|
||||
}
|
||||
.state-btn:hover { filter: brightness(.97); }
|
||||
.state-btn i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex: 0 0 5px; }
|
||||
.state-btn.on { background: var(--good-soft); color: var(--good-ink); border-color: var(--good-line); }
|
||||
.state-btn.on i { background: var(--good); }
|
||||
.state-btn.off { background: var(--field); color: var(--t3); border-color: var(--line); }
|
||||
.state-btn.off i { background: var(--t5); }
|
||||
|
||||
.tbl-empty { padding: 48px 20px; text-align: center; font: 400 12px/20px var(--f-cn); color: var(--t4); }
|
||||
|
||||
/* 表尾(在卡片内,与总览表格一致) */
|
||||
.pg-foot {
|
||||
flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
|
||||
gap: var(--space-3); padding: 10px 16px;
|
||||
border-top: 1px solid var(--line);
|
||||
font: 400 11.5px/16px var(--f-cn); color: var(--t4);
|
||||
}
|
||||
.pg-foot :deep(.el-pagination) {
|
||||
--el-pagination-button-width: 24px;
|
||||
--el-pagination-button-height: 24px;
|
||||
--el-pagination-font-size: 11.5px;
|
||||
}
|
||||
.st-pill .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
|
||||
.st-pill.ok { color: var(--good-ink); background: var(--good-soft); border-color: transparent; }
|
||||
.st-pill.err { color: var(--danger-ink); background: var(--danger-soft); border-color: transparent; }
|
||||
.st-pill.mid { color: var(--brand-ink); background: var(--brand-soft); border-color: transparent; }
|
||||
.st-pill.none { color: var(--t4); }
|
||||
.sr-last-time { font: 400 10.5px/15px var(--f-num); color: var(--t4); }
|
||||
.sr-acts { flex-shrink: 0; display: flex; align-items: center; gap: var(--space-2); }
|
||||
.sr-acts .el-button + .el-button { margin-left: 0; }
|
||||
.sched-pager { justify-content: center; }
|
||||
|
||||
.cron-row {
|
||||
display: flex;
|
||||
|
||||
Reference in New Issue
Block a user