Initial commit: 公示系统集合 Flask 项目
This commit is contained in:
@@ -0,0 +1,141 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<title>{{ app_name }}</title>
|
||||
<style>
|
||||
* { box-sizing: border-box; }
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
|
||||
background: linear-gradient(180deg, #f2f7ff 0%, #f7f9fc 100%);
|
||||
color: #1c2740;
|
||||
}
|
||||
.shell {
|
||||
max-width: 1100px;
|
||||
margin: 0 auto;
|
||||
padding: 20px 16px 40px;
|
||||
}
|
||||
.hero {
|
||||
background: linear-gradient(135deg, #1f3a5f 0%, #2f80ff 100%);
|
||||
color: #fff;
|
||||
border-radius: 24px;
|
||||
padding: 24px 20px;
|
||||
box-shadow: 0 18px 40px rgba(31, 58, 95, 0.22);
|
||||
}
|
||||
.eyebrow {
|
||||
font-size: 13px;
|
||||
opacity: 0.86;
|
||||
letter-spacing: 0.08em;
|
||||
}
|
||||
h1 {
|
||||
margin: 10px 0 8px;
|
||||
font-size: 30px;
|
||||
line-height: 1.2;
|
||||
}
|
||||
.hero p {
|
||||
display: none;
|
||||
}
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 14px;
|
||||
margin-top: 18px;
|
||||
}
|
||||
.card {
|
||||
display: block;
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
background: rgba(255, 255, 255, 0.94);
|
||||
border: 1px solid rgba(47, 128, 255, 0.08);
|
||||
border-radius: 20px;
|
||||
padding: 18px;
|
||||
box-shadow: 0 12px 28px rgba(31, 58, 95, 0.08);
|
||||
transition: transform 0.16s ease, box-shadow 0.2s ease, border-color 0.2s ease;
|
||||
}
|
||||
.card:active {
|
||||
transform: scale(0.99);
|
||||
}
|
||||
.card:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 18px 36px rgba(31, 58, 95, 0.12);
|
||||
border-color: rgba(47, 128, 255, 0.2);
|
||||
}
|
||||
.card-top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
.card-title {
|
||||
margin: 0;
|
||||
font-size: 20px;
|
||||
font-weight: 700;
|
||||
}
|
||||
.card-tag {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 72px;
|
||||
padding: 6px 10px;
|
||||
border-radius: 999px;
|
||||
font-size: 12px;
|
||||
background: #eaf2ff;
|
||||
color: #1f5fff;
|
||||
}
|
||||
.card-desc {
|
||||
display: none;
|
||||
}
|
||||
.card-foot {
|
||||
margin-top: 14px;
|
||||
font-size: 13px;
|
||||
color: #7b89a6;
|
||||
}
|
||||
.note {
|
||||
display: none;
|
||||
}
|
||||
@media (min-width: 860px) {
|
||||
.shell {
|
||||
padding: 28px 20px 48px;
|
||||
}
|
||||
.hero {
|
||||
padding: 32px 30px;
|
||||
}
|
||||
.grid {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 18px;
|
||||
}
|
||||
.card {
|
||||
min-height: 220px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="shell">
|
||||
<section class="hero">
|
||||
<div class="eyebrow">TASK PUBLIC BOARD</div>
|
||||
<h1>公示系统集成</h1>
|
||||
<p>统一承载多个任务公示项目的入口页面。当前先提供导航首页和统一查询骨架,后续新增项目时只需补充数据库配置、表名和 SQL。</p>
|
||||
</section>
|
||||
|
||||
<section class="grid">
|
||||
{% for key, project in projects.items() %}
|
||||
<a class="card" href="/project/{{ key }}{% if user_uuid %}?uuid={{ user_uuid|urlencode }}{% endif %}">
|
||||
<div class="card-top">
|
||||
<h2 class="card-title">{{ project.title }}</h2>
|
||||
<span class="card-tag">{{ project.status }}</span>
|
||||
</div>
|
||||
<p class="card-desc">{{ project.subtitle }}</p>
|
||||
<div class="card-foot">进入统一查询页</div>
|
||||
</a>
|
||||
{% endfor %}
|
||||
</section>
|
||||
|
||||
<div class="note">
|
||||
后续接入新项目时,只需在 <strong>config.py</strong> 中补充项目配置,并为该项目填写数据库标识、表名和查询 SQL,即可复用统一项目页和统一查询接口。
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,173 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<title>{{ project.title }}</title>
|
||||
<style>
|
||||
* { box-sizing: border-box; }
|
||||
body { margin: 0; font-family: Arial, sans-serif; background: #f5f7fa; color: #222; }
|
||||
.wrap { max-width: 980px; margin: 0 auto; padding: 16px; }
|
||||
.card { background: #fff; border-radius: 10px; box-shadow: 0 4px 14px rgba(0,0,0,0.06); padding: 14px; margin-bottom: 12px; }
|
||||
h1 { margin: 0; font-size: 20px; }
|
||||
.toolbar { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; margin-top: 12px; }
|
||||
label { display: block; font-size: 13px; color: #666; margin-bottom: 6px; }
|
||||
input { width: 100%; border: 1px solid #d9d9d9; border-radius: 8px; padding: 10px; }
|
||||
button { border: none; border-radius: 8px; background: #1677ff; color: #fff; padding: 10px 14px; cursor: pointer; }
|
||||
.meta { font-size: 13px; color: #666; margin-top: 8px; line-height: 1.7; }
|
||||
table { width: 100%; border-collapse: collapse; }
|
||||
th, td { border-bottom: 1px solid #f0f0f0; padding: 10px 8px; text-align: left; font-size: 14px; }
|
||||
th { color: #555; font-weight: 600; background: #fafafa; }
|
||||
tr.current-user { border: 2px solid #52c41a; }
|
||||
tr.current-user td { background: #f6ffed; }
|
||||
.tag { display: inline-block; font-size: 12px; color: #237804; border: 1px solid #95de64; background: #f6ffed; border-radius: 999px; padding: 2px 8px; }
|
||||
.empty { color: #999; font-size: 14px; padding: 16px 0; }
|
||||
.ok-tip { color: #237804; font-size: 13px; margin-top: 8px; }
|
||||
.muted { color: #888; }
|
||||
.back-link { display:inline-block; margin-bottom:8px; color:#1677ff; text-decoration:none; font-size:13px; }
|
||||
.project-subtitle { font-size:13px; color:#666; margin-top:8px; line-height:1.7; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrap">
|
||||
<div class="card">
|
||||
<a class="back-link" href="/{% if user_uuid %}?uuid={{ user_uuid|urlencode }}{% endif %}">返回主页</a>
|
||||
<h1>{{ project.title }}</h1>
|
||||
<div class="project-subtitle">{{ project.subtitle }}</div>
|
||||
<div class="toolbar">
|
||||
<div>
|
||||
<label for="dateInput">选择日期</label>
|
||||
<input id="dateInput" type="date" value="{{ today }}">
|
||||
</div>
|
||||
<div>
|
||||
<label for="uuidInput">用户 UUID(从页面链接自动带入)</label>
|
||||
<input id="uuidInput" value="{{ user_uuid }}" placeholder="可手动输入查询定位">
|
||||
</div>
|
||||
<div style="display:flex; align-items:flex-end;">
|
||||
<button id="queryBtn" type="button">查询</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="meta" id="metaText">-</div>
|
||||
<div class="ok-tip" id="userTip"></div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 52px;">序号</th>
|
||||
<th>workid</th>
|
||||
{% if project.get('query_sql_list') %}
|
||||
{% for b in project.get('query_sql_list') %}
|
||||
<th style="width: 100px;">{{ b.get('label') or b.get('key', '') }}</th>
|
||||
{% endfor %}
|
||||
<th style="width: 110px;">总量</th>
|
||||
{% else %}
|
||||
<th style="width: 120px;">完成量</th>
|
||||
{% endif %}
|
||||
<th style="width: 120px;">标记</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="tableBody"></tbody>
|
||||
</table>
|
||||
<div class="empty" id="emptyText" style="display:none;">当前日期暂无数据</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function $(id) { return document.getElementById(id); }
|
||||
|
||||
function getQueryParam(name) {
|
||||
try {
|
||||
var usp = new URLSearchParams(window.location.search || '');
|
||||
return String(usp.get(name) || '').trim();
|
||||
} catch (e) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
function renderRows(rows, breakdowns) {
|
||||
var tb = $('tableBody');
|
||||
var empty = $('emptyText');
|
||||
tb.innerHTML = '';
|
||||
if (!rows || !rows.length) {
|
||||
empty.style.display = 'block';
|
||||
return false;
|
||||
}
|
||||
empty.style.display = 'none';
|
||||
var hasCurrentUserRow = false;
|
||||
breakdowns = breakdowns || [];
|
||||
rows.forEach(function(row, idx) {
|
||||
var tr = document.createElement('tr');
|
||||
if (row.is_current_user) {
|
||||
tr.className = 'current-user';
|
||||
tr.id = 'currentUserRow';
|
||||
hasCurrentUserRow = true;
|
||||
}
|
||||
var mark = row.is_current_user ? '<span class="tag">当前用户</span>' : '<span class="muted">-</span>';
|
||||
var cells = '<td>' + (idx + 1) + '</td>' + '<td>' + (row.workid || '') + '</td>';
|
||||
if (breakdowns.length) {
|
||||
breakdowns.forEach(function(b) {
|
||||
cells += '<td>' + (row['count_' + b.key] || 0) + '</td>';
|
||||
});
|
||||
cells += '<td>' + (row.count || 0) + '</td>';
|
||||
} else {
|
||||
cells += '<td>' + (row.count || 0) + '</td>';
|
||||
}
|
||||
cells += '<td>' + mark + '</td>';
|
||||
tr.innerHTML = cells;
|
||||
tb.appendChild(tr);
|
||||
});
|
||||
return hasCurrentUserRow;
|
||||
}
|
||||
|
||||
async function queryData() {
|
||||
var dateVal = String(($('dateInput').value || '')).trim();
|
||||
var uuidVal = String(($('uuidInput').value || '')).trim();
|
||||
var meta = $('metaText');
|
||||
var tip = $('userTip');
|
||||
tip.textContent = '';
|
||||
meta.textContent = '查询中...';
|
||||
try {
|
||||
var qs = new URLSearchParams();
|
||||
if (dateVal) { qs.set('date', dateVal); }
|
||||
if (uuidVal) { qs.set('uuid', uuidVal); }
|
||||
var resp = await fetch('/api/project/{{ project_key }}/stats?' + qs.toString(), { method: 'GET' });
|
||||
var data = await resp.json();
|
||||
if (!data || !data.success) {
|
||||
meta.textContent = '查询失败:' + ((data && data.error) ? data.error : '未知错误');
|
||||
renderRows([]);
|
||||
return;
|
||||
}
|
||||
meta.textContent = '日期:' + data.date + ',总人数:' + data.total + ',总完成量:' + data.sum_count;
|
||||
var hasCurrentUserRow = renderRows(data.rows || [], data.breakdowns || []);
|
||||
if (uuidVal) {
|
||||
if (data.has_current_user) {
|
||||
tip.textContent = '已定位到你的数据,绿色高亮行即当前登录 UUID 的统计。';
|
||||
if (hasCurrentUserRow) {
|
||||
var targetRow = $('currentUserRow');
|
||||
if (targetRow && typeof targetRow.scrollIntoView === 'function') {
|
||||
targetRow.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||
}
|
||||
}
|
||||
} else {
|
||||
tip.textContent = '未匹配到当前 UUID 的数据。';
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
meta.textContent = '查询失败:网络或服务异常';
|
||||
renderRows([]);
|
||||
}
|
||||
}
|
||||
|
||||
(function init() {
|
||||
var fromUrlUuid = getQueryParam('uuid');
|
||||
if (fromUrlUuid && !$('uuidInput').value) {
|
||||
$('uuidInput').value = fromUrlUuid;
|
||||
}
|
||||
$('queryBtn').addEventListener('click', queryData);
|
||||
queryData();
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user