This commit is contained in:
hl committed 2026-05-29 01:40:33 +08:00
1 parent ac815325d5
commit 164fad0a3e
3 files changed
+322 -147

No files matched your search

+320 -147
View File
@@ -1,14 +1,43 @@
import sqlite3
from contextlib import contextmanager
from datetime import datetime
from datetime import UTC, datetime, timedelta
from html import escape
from io import BytesIO
from typing import cast
from typing import Annotated, cast
import jwt
import pandas as pd
from fastapi import FastAPI, File, HTTPException, Query, UploadFile
from fastapi import Depends, FastAPI, File, HTTPException, Query, Request, UploadFile
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import HTMLResponse, StreamingResponse
from pydantic import BaseModel
from pydantic import BaseModel, BeforeValidator
SECRET_KEY = 'QET5hv3A@148fefo#5#W5x#aF%9Y#8!2'
ALGORITHM = 'HS256'
ACCESS_TOKEN_EXPIRE_MINUTES = 60 * 24
def create_access_token(data: dict):
to_encode = data.copy()
expire = datetime.now(UTC) + timedelta(minutes=ACCESS_TOKEN_EXPIRE_MINUTES)
to_encode.update({'exp': expire})
return jwt.encode(to_encode, SECRET_KEY, algorithm=ALGORITHM)
def verify_token(token: str):
try:
return jwt.decode(token, SECRET_KEY, algorithms=[ALGORITHM])
except jwt.PyJWTError as exc:
raise HTTPException(status_code=401, detail='Token 无效') from exc
async def require_admin(request: Request):
token = request.headers.get('Authorization', '').replace('Bearer ', '')
payload = verify_token(token)
if payload.get('role') != 'admin':
raise HTTPException(status_code=403, detail='需要管理员权限')
return payload
app = FastAPI(title='文艺汇演评分系统', description='乌鲁木齐群众文化艺术展评')
@@ -25,12 +54,20 @@ DB_PATH = 'score_system.db'
@contextmanager
def get_db():
def get_db(write=False):
conn = sqlite3.connect(DB_PATH)
conn.row_factory = sqlite3.Row
conn.execute('PRAGMA journal_mode=WAL')
conn.execute('PRAGMA busy_timeout=5000')
conn.execute('PRAGMA foreign_keys=ON')
if write:
conn.execute('BEGIN IMMEDIATE')
try:
yield conn
conn.commit()
except Exception:
conn.rollback()
raise
finally:
conn.close()
@@ -43,13 +80,13 @@ def init_db():
"""CREATE TABLE IF NOT EXISTS batches (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, created_at TIMESTAMP)"""
)
cursor.execute(
"""CREATE TABLE IF NOT EXISTS programs (sn TEXT PRIMARY KEY, name TEXT NOT NULL, unit TEXT, performer TEXT, category TEXT, batch_id INTEGER, order_num INTEGER, created_at TIMESTAMP)"""
"""CREATE TABLE IF NOT EXISTS programs (sn TEXT PRIMARY KEY, name TEXT NOT NULL, unit TEXT, performer TEXT, category TEXT, batch_id INTEGER NOT NULL, order_num INTEGER, created_at TIMESTAMP, UNIQUE(batch_id, order_num), FOREIGN KEY (batch_id) REFERENCES batches(id) ON DELETE CASCADE ON UPDATE CASCADE)"""
)
cursor.execute(
"""CREATE TABLE IF NOT EXISTS judges (id TEXT PRIMARY KEY, name TEXT NOT NULL, order_num INTEGER, created_at TIMESTAMP)"""
)
cursor.execute(
"""CREATE TABLE IF NOT EXISTS scores (id INTEGER PRIMARY KEY AUTOINCREMENT, judge_id TEXT NOT NULL, program_sn TEXT NOT NULL, content_score REAL, stage_score REAL, art_score REAL, overall_score REAL, comment TEXT, updated_at TIMESTAMP, UNIQUE(judge_id, program_sn))"""
"""CREATE TABLE IF NOT EXISTS scores (id INTEGER PRIMARY KEY AUTOINCREMENT, judge_id TEXT NOT NULL, program_sn TEXT NOT NULL, content_score REAL, stage_score REAL, art_score REAL, overall_score REAL, comment TEXT, updated_at TIMESTAMP, UNIQUE(judge_id, program_sn), FOREIGN KEY (program_sn) REFERENCES programs(sn) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (judge_id) REFERENCES judges(id) ON DELETE CASCADE ON UPDATE CASCADE)"""
)
cursor.execute(
"""CREATE TABLE IF NOT EXISTS admins (id TEXT PRIMARY KEY, username TEXT UNIQUE NOT NULL, password TEXT NOT NULL, created_at TIMESTAMP)"""
@@ -113,60 +150,69 @@ init_db()
# ==================== Pydantic模型 ====================
def escape_html(value: str) -> str:
if value is None:
return ''
return escape(str(value).strip())
EscapedStr = Annotated[str, BeforeValidator(escape_html)]
class AdminLogin(BaseModel):
username: str
password: str
username: EscapedStr
password: EscapedStr
class JudgeLogin(BaseModel):
judge_id: str
judge_name: str
judge_id: EscapedStr
judge_name: EscapedStr
class JudgeCreate(BaseModel):
id: str
name: str
id: EscapedStr
name: EscapedStr
class JudgeUpdate(BaseModel):
name: str
name: EscapedStr
class ProgramCreate(BaseModel):
sn: str
name: str
unit: str
performer: str
category: str
sn: EscapedStr
name: EscapedStr
unit: EscapedStr
performer: EscapedStr
category: EscapedStr
batch_id: int
class ProgramUpdate(BaseModel):
name: str
unit: str
performer: str
category: str
name: EscapedStr
unit: EscapedStr
performer: EscapedStr
category: EscapedStr
batch_id: int
class BatchCreate(BaseModel):
name: str
name: EscapedStr
class ScoreDetailUpdate(BaseModel):
program_sn: str
field: str
program_sn: EscapedStr
field: EscapedStr
value: float | None = None
class ScoreBatchUpdate(BaseModel):
program_sn: str
judge_scores: dict[str, float | None]
program_sn: EscapedStr
judge_scores: dict[EscapedStr, float | None]
class CommentUpdate(BaseModel):
program_sn: str
comment: str
program_sn: EscapedStr
comment: EscapedStr
class AwardSettings(BaseModel):
@@ -176,14 +222,14 @@ class AwardSettings(BaseModel):
class AwardNamesSettings(BaseModel):
first_name: str
second_name: str
third_name: str
first_name: EscapedStr
second_name: EscapedStr
third_name: EscapedStr
class TitleSettings(BaseModel):
main_title: str
sub_title: str
main_title: EscapedStr
sub_title: EscapedStr
# ==================== 根路径 ====================
@@ -204,7 +250,15 @@ async def admin_login(login_data: AdminLogin):
admin = cursor.fetchone()
if not admin:
raise HTTPException(status_code=401, detail='管理员用户名或密码错误')
return {'success': True, 'admin_id': admin['id'], 'username': admin['username']}
token = create_access_token(
{'id': admin['id'], 'username': admin['username'], 'role': 'admin'}
)
return {
'success': True,
'admin_id': admin['id'],
'username': admin['username'],
'token': token,
}
@app.get('/api/admin/check')
@@ -254,9 +308,9 @@ async def get_title_settings():
}
@app.post('/api/settings/titles')
@app.post('/api/settings/titles', dependencies=[Depends(require_admin)])
async def update_title_settings(titles: TitleSettings):
with get_db() as conn:
with get_db(write=True) as conn:
cursor = conn.cursor()
cursor.execute(
"UPDATE settings SET value = ? WHERE key = 'main_title'",
@@ -290,9 +344,9 @@ async def get_award_settings():
}
@app.post('/api/settings/awards')
@app.post('/api/settings/awards', dependencies=[Depends(require_admin)])
async def update_award_settings(settings: AwardSettings):
with get_db() as conn:
with get_db(write=True) as conn:
cursor = conn.cursor()
cursor.execute(
"UPDATE settings SET value = ? WHERE key = 'award_first'",
@@ -309,9 +363,9 @@ async def update_award_settings(settings: AwardSettings):
return {'success': True}
@app.post('/api/settings/award_names')
@app.post('/api/settings/award_names', dependencies=[Depends(require_admin)])
async def update_award_names(settings: AwardNamesSettings):
with get_db() as conn:
with get_db(write=True) as conn:
cursor = conn.cursor()
cursor.execute(
"UPDATE settings SET value = ? WHERE key = 'award_first_name'",
@@ -364,9 +418,9 @@ async def get_batches():
return batches
@app.post('/api/batches')
@app.post('/api/batches', dependencies=[Depends(require_admin)])
async def create_batch(batch: BatchCreate):
with get_db() as conn:
with get_db(write=True) as conn:
cursor = conn.cursor()
cursor.execute(
'INSERT INTO batches (name, created_at) VALUES (?, ?)',
@@ -376,35 +430,23 @@ async def create_batch(batch: BatchCreate):
return {'success': True, 'id': new_id, 'name': batch.name}
@app.delete('/api/batches/{batch_id}')
@app.delete('/api/batches/{batch_id}', dependencies=[Depends(require_admin)])
async def delete_batch(batch_id: int):
with get_db() as conn:
with get_db(write=True) as conn:
cursor = conn.cursor()
cursor.execute('SELECT id FROM batches WHERE id = ?', (batch_id,))
if not cursor.fetchone():
raise HTTPException(status_code=404, detail='批次不存在')
# 获取该批次所有节目序号
cursor.execute('SELECT sn FROM programs WHERE batch_id = ?', (batch_id,))
programs = cursor.fetchall()
for prog in programs:
cursor.execute('DELETE FROM scores WHERE program_sn = ?', (prog['sn'],))
cursor.execute('DELETE FROM programs WHERE batch_id = ?', (batch_id,))
cursor.execute('DELETE FROM batches WHERE id = ?', (batch_id,))
if cursor.rowcount == 0:
raise HTTPException(status_code=404, detail='批次不存在')
return {'success': True}
@app.delete('/api/batches/{batch_id}/programs')
@app.delete('/api/batches/{batch_id}/programs', dependencies=[Depends(require_admin)])
async def clear_batch_programs(batch_id: int):
with get_db() as conn:
with get_db(write=True) as conn:
cursor = conn.cursor()
cursor.execute('SELECT id FROM batches WHERE id = ?', (batch_id,))
if not cursor.fetchone():
raise HTTPException(status_code=404, detail='批次不存在')
cursor.execute('SELECT sn FROM programs WHERE batch_id = ?', (batch_id,))
programs = cursor.fetchall()
for prog in programs:
cursor.execute('DELETE FROM scores WHERE program_sn = ?', (prog['sn'],))
cursor.execute('DELETE FROM programs WHERE batch_id = ?', (batch_id,))
if cursor.rowcount == 0:
raise HTTPException(status_code=404, detail='批次不存在')
return {'success': True}
@@ -421,9 +463,9 @@ async def get_judges():
return judges
@app.post('/api/judges')
@app.post('/api/judges', dependencies=[Depends(require_admin)])
async def create_judge(judge: JudgeCreate):
with get_db() as conn:
with get_db(write=True) as conn:
cursor = conn.cursor()
cursor.execute('SELECT id FROM judges WHERE id = ?', (judge.id,))
if cursor.fetchone():
@@ -443,9 +485,9 @@ async def create_judge(judge: JudgeCreate):
return {'success': True}
@app.put('/api/judges/{judge_id}')
@app.put('/api/judges/{judge_id}', dependencies=[Depends(require_admin)])
async def update_judge(judge_id: str, judge: JudgeUpdate):
with get_db() as conn:
with get_db(write=True) as conn:
cursor = conn.cursor()
cursor.execute('SELECT id FROM judges WHERE id = ?', (judge_id,))
if not cursor.fetchone():
@@ -456,15 +498,13 @@ async def update_judge(judge_id: str, judge: JudgeUpdate):
return {'success': True}
@app.delete('/api/judges/{judge_id}')
@app.delete('/api/judges/{judge_id}', dependencies=[Depends(require_admin)])
async def delete_judge(judge_id: str):
with get_db() as conn:
with get_db(write=True) as conn:
cursor = conn.cursor()
cursor.execute('SELECT id FROM judges WHERE id = ?', (judge_id,))
if not cursor.fetchone():
raise HTTPException(status_code=404, detail='评委不存在')
cursor.execute('DELETE FROM scores WHERE judge_id = ?', (judge_id,))
cursor.execute('DELETE FROM judges WHERE id = ?', (judge_id,))
if cursor.rowcount == 0:
raise HTTPException(status_code=404, detail='评委不存在')
return {'success': True}
@@ -497,22 +537,16 @@ async def get_programs(batch_id: int | None = Query(None)):
return programs
@app.post('/api/programs')
@app.post('/api/programs', dependencies=[Depends(require_admin)])
async def create_program(program: ProgramCreate):
with get_db() as conn:
with get_db(write=True) as conn:
cursor = conn.cursor()
cursor.execute('SELECT sn FROM programs WHERE sn = ?', (program.sn,))
if cursor.fetchone():
raise HTTPException(status_code=400, detail='节目序号已存在')
cursor.execute(
'SELECT MAX(order_num) FROM programs WHERE batch_id = ?',
(program.batch_id,),
)
max_order = cursor.fetchone()[0]
if max_order is None:
max_order = 0
cursor.execute(
'INSERT INTO programs (sn, name, unit, performer, category, batch_id, order_num, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)',
"""
INSERT INTO programs (sn, name, unit, performer, category, batch_id, order_num, created_at)
SELECT ?, ?, ?, ?, ?, ?, COALESCE(MAX(order_num), 0) + 1, ?
FROM programs WHERE batch_id = ?
""",
(
program.sn,
program.name,
@@ -520,10 +554,12 @@ async def create_program(program: ProgramCreate):
program.performer,
program.category,
program.batch_id,
max_order + 1,
datetime.now(),
program.batch_id,
),
)
if cursor.rowcount == 0:
raise HTTPException(status_code=400, detail='节目序号已存在')
cursor.execute('SELECT id FROM judges')
for judge in cursor.fetchall():
cursor.execute(
@@ -533,43 +569,47 @@ async def create_program(program: ProgramCreate):
return {'success': True}
@app.post('/api/programs/import')
async def import_programs(batch_id: int = Query(...), file: UploadFile = File(...)):
@app.post('/api/programs/import', dependencies=[Depends(require_admin)])
async def import_programs(
request: Request, batch_id: int = Query(...), file: UploadFile = File(...)
):
MAX_MB = 10
content_length = request.headers.get('content-length')
if content_length and int(content_length) > MAX_MB * 1024 * 1024:
raise HTTPException(status_code=413, detail=f'文件大小超过 {MAX_MB}MB 限制')
try:
contents = await file.read()
df = pd.read_excel(BytesIO(contents))
required_columns = ['节目序号', '节目名称', '演出单位', '表演者', '节目类别']
required_columns = ['节目编号', '节目名称', '演出单位', '表演者', '节目类别']
for col in required_columns:
if col not in df.columns:
raise HTTPException(status_code=400, detail=f'Excel缺少必要列:{col}')
with get_db() as conn:
with get_db(write=True) as conn:
cursor = conn.cursor()
cursor.execute(
'SELECT MAX(order_num) FROM programs WHERE batch_id = ?', (batch_id,)
)
max_order_result = cursor.fetchone()[0]
start_order = max_order_result if max_order_result is not None else 0
for idx, row in df.iterrows():
sn = str(row['节目序号']).strip()
name = str(row['节目名称']).strip()
unit = str(row['演出单位']).strip() if pd.notna(row['演出单位']) else ''
order_counter = 0
for _, row in df.iterrows():
sn = escape_html(row['节目编号'])
name = escape_html(row['节目名称'])
unit = escape_html(row['演出单位']) if pd.notna(row['演出单位']) else ''
performer = (
str(row['表演者']).strip() if pd.notna(row['表演者']) else ''
escape_html(row['表演者']) if pd.notna(row['表演者']) else ''
)
category = (
str(row['节目类别']).strip()
if pd.notna(row['节目类别'])
else '舞蹈'
escape_html(row['节目类别']) if pd.notna(row['节目类别']) else ''
)
if not sn or not name:
continue
idx = cast(int, idx)
current_order = start_order + idx + 1
order_counter += 1
current_order = start_order + order_counter
cursor.execute('SELECT sn FROM programs WHERE sn = ?', (sn,))
if cursor.fetchone():
cursor.execute(
@@ -584,7 +624,7 @@ async def import_programs(batch_id: int = Query(...), file: UploadFile = File(..
)
else:
cursor.execute(
'INSERT INTO programs (sn, name, unit, performer, category, batch_id, order_num, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)',
'INSERT OR IGNORE INTO programs (sn, name, unit, performer, category, batch_id, order_num, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)',
(
sn,
name,
@@ -604,13 +644,13 @@ async def import_programs(batch_id: int = Query(...), file: UploadFile = File(..
)
return {'success': True, 'message': f'成功导入/更新 {df.shape[0]} 个节目'}
except Exception as e:
raise HTTPException(status_code=400, detail=f'导入失败:{str(e)}') from e
except Exception as exc:
raise HTTPException(status_code=400, detail=f'导入失败:{str(exc)}') from exc
@app.put('/api/programs/{program_sn}')
@app.put('/api/programs/{program_sn}', dependencies=[Depends(require_admin)])
async def update_program(program_sn: str, program: ProgramUpdate):
with get_db() as conn:
with get_db(write=True) as conn:
cursor = conn.cursor()
cursor.execute('SELECT sn FROM programs WHERE sn = ?', (program_sn,))
if not cursor.fetchone():
@@ -629,15 +669,13 @@ async def update_program(program_sn: str, program: ProgramUpdate):
return {'success': True}
@app.delete('/api/programs/{program_sn}')
@app.delete('/api/programs/{program_sn}', dependencies=[Depends(require_admin)])
async def delete_program(program_sn: str):
with get_db() as conn:
with get_db(write=True) as conn:
cursor = conn.cursor()
cursor.execute('SELECT sn FROM programs WHERE sn = ?', (program_sn,))
if not cursor.fetchone():
raise HTTPException(status_code=404, detail='节目不存在')
cursor.execute('DELETE FROM scores WHERE program_sn = ?', (program_sn,))
cursor.execute('DELETE FROM programs WHERE sn = ?', (program_sn,))
if cursor.rowcount == 0:
raise HTTPException(status_code=404, detail='节目不存在')
return {'success': True}
@@ -689,7 +727,7 @@ async def update_score(judge_id: str, score_data: ScoreDetailUpdate):
'art': 'art_score',
'overall': 'overall_score',
}
with get_db() as conn:
with get_db(write=True) as conn:
cursor = conn.cursor()
cursor.execute(
f"""
@@ -721,7 +759,7 @@ async def update_score(judge_id: str, score_data: ScoreDetailUpdate):
@app.post('/api/comment/{judge_id}')
async def update_comment(judge_id: str, comment_data: CommentUpdate):
with get_db() as conn:
with get_db(write=True) as conn:
cursor = conn.cursor()
cursor.execute(
'INSERT INTO scores (judge_id, program_sn, comment, updated_at) VALUES (?, ?, ?, ?) ON CONFLICT(judge_id, program_sn) DO UPDATE SET comment = excluded.comment, updated_at = excluded.updated_at',
@@ -730,7 +768,7 @@ async def update_comment(judge_id: str, comment_data: CommentUpdate):
return {'success': True}
@app.post('/api/scores/admin/batch')
@app.post('/api/scores/admin/batch', dependencies=[Depends(require_admin)])
async def batch_update_scores(batch_data: ScoreBatchUpdate):
"""管理员批量更新总分"""
with get_db() as conn:
@@ -738,7 +776,12 @@ async def batch_update_scores(batch_data: ScoreBatchUpdate):
for judge_id, total_score in batch_data.judge_scores.items():
if total_score is not None and (total_score < 0 or total_score > 100):
raise HTTPException(status_code=400, detail='总分必须在0-100之间')
cursor.execute('SELECT id FROM judges WHERE id = ?', (judge_id,))
if not cursor.fetchone():
raise HTTPException(status_code=404, detail=f'评委 {judge_id} 不存在')
with get_db(write=True) as conn:
cursor = conn.cursor()
for judge_id, total_score in batch_data.judge_scores.items():
if total_score is None:
cursor.execute(
"""
@@ -920,7 +963,7 @@ async def export_excel(batch_id: int | None = Query(None)):
data = [
{
'名次': item['rank'],
'节目序号': item['sn'],
'节目编号': item['sn'],
'节目名称': item['name'],
'演出单位': item['unit'],
'表演者': item['performer'],
@@ -1064,12 +1107,12 @@ def render_print_program_template(
html = f"""<!DOCTYPE html><html><head><meta charset="UTF-8"><title>{program['name']} - 评分详情</title>
<style>*{{margin:0;padding:0;box-sizing:border-box;}} body{{font-family: SimSun, 'Microsoft YaHei', serif; padding: 20px;}} .container{{max-width: 1000px; margin: 0 auto;}} h1{{text-align: center; margin-bottom: 5px; font-size: 22px;}} .subtitle{{text-align: center; color: #666; margin-bottom: 20px; font-size: 14px;}} .info{{margin-bottom: 20px; padding: 15px; background: #f5f5f5; border-radius: 8px;}} .info p{{margin: 5px 0;}} .stat-box{{display: flex; gap: 20px; justify-content: center; margin-bottom: 20px;}} .stat-item{{text-align: center; padding: 10px 20px; background: #e8f4e8; border-radius: 8px;}} .stat-item span{{font-size: 24px; font-weight: bold;}} table{{width: 100%; border-collapse: collapse; margin-top: 20px;}} th, td{{border: 1px solid #000; padding: 12px; text-align: center;}} th{{background: #f0f0f0;}} .comment-cell{{text-align: left;}} @media print{{.no-print{{display: none;}}}}</style></head>
<body><div class="container"><h1>{titles['main_title']}</h1><div class="subtitle">{titles['sub_title']} · 评分详情表</div>
<div class="info"><p><strong>节目序号:</strong> {program['sn']}</p><p><strong>节目名称:</strong> {program['name']}</p><p><strong>演出单位:</strong> {program['unit']}</p><p><strong>表演者:</strong> {program['performer']}</p><p><strong>节目类别:</strong> {program['category']}</p></div>
<div class="info"><p><strong>节目编号:</strong> {program['sn']}</p><p><strong>节目名称:</strong> {program['name']}</p><p><strong>演出单位:</strong> {program['unit']}</p><p><strong>表演者:</strong> {program['performer']}</p><p><strong>节目类别:</strong> {program['category']}</p></div>
<div class="stat-box"><div class="stat-item">📊 平均分<br><span>{avg_score}</span></div><div class="stat-item">🎯 最高分<br><span>{max_score}</span></div><div class="stat-item">⭐ 最低分<br><span>{min_score}</span></div></div>
<table><thead><tr><th>评委姓名</th><th>总分(100分)</th><th>评委点评</th></tr></thead><tbody>"""
for judge in judges:
s = scores_data.get(judge['name'], {})
html += f"""<tr><td style="font-weight:bold;">{judge['name']}</td><td class="total">{s.get('total') if s.get('total') > 0 else '-'}</td><td class="comment-cell">{s.get('comment', '')}</td></tr>"""
html += f"""<tr><td style="font-weight:bold;">{judge['name']}</td><td class="total">{s.get('total') if s.get('total', 0) > 0 else '-'}</td><td class="comment-cell">{s.get('comment', '')}</td></tr>"""
html += f"""</tbody></table><div style="margin-top: 30px;"><p>评委组签名:____________________</p><p style="text-align: right;">日期:{datetime.now().strftime('%Y年%m月%d日')}</p></div>
<div class="no-print" style="margin-top: 30px; text-align: center;"><button onclick="window.print()">🖨️ 打印本页</button> <button onclick="window.close()">关闭</button></div></div></body></html>"""
return html
@@ -1082,7 +1125,7 @@ def render_print_blank_template(program, judges, criteria, titles):
for _judge in judges:
html += f"""<div class="judge-sheet"><div class="sheet-top-space"></div>
<h1>{titles['main_title']}</h1><div class="subtitle">{titles['sub_title']} · 节目评分表</div>
<div class="program-info"><p><strong>节目序号:</strong> {program['sn']} | <strong>节目名称:</strong> {program['name']}</p>
<div class="program-info"><p><strong>节目编号:</strong> {program['sn']} | <strong>节目名称:</strong> {program['name']}</p>
<p><strong>演出单位:</strong> {program['unit']} | <strong>表演者:</strong> {program['performer']} | <strong>节目类别:</strong> {program['category']}</p></div>
<table><thead><tr><th style="width:20%">评分项目</th><th style="width:10%">满分</th><th style="width:15%">得分</th><th style="width:55%">评分要点</th></tr></thead><tbody>"""
for _key, cri in criteria.items():
@@ -1117,7 +1160,7 @@ def render_print_award_template(award_type, award_name, winners, titles, batch_n
<div class="award-title">{award_name}</div>
<table>
<thead>
<tr><th>名次</th><th>节目序号</th><th>节目名称</th><th>演出单位</th><th>表演者</th><th>节目类别</th><th>平均分</th></tr>
<tr><th>名次</th><th>节目编号</th><th>节目名称</th><th>演出单位</th><th>表演者</th><th>节目类别</th><th>平均分</th></tr>
</thead>
<tbody>"""
for idx, prog in enumerate(winners, 1):
@@ -1386,13 +1429,13 @@ HTML_TEMPLATE = """
<!-- 汇总表 -->
<div class="summary-panel">
<h3>📊 评分汇总表 <span id="summaryTitle"></span><button class="btn btn-success btn-sm" onclick="exportExcel()" style="float:right">📎 导出Excel</button></h3>
<div style="overflow-x: auto; clear: both;"><table class="summary-table" id="summaryTable"><thead><tr><th>名次</th><th>节目序号</th><th>节目名称</th><th>演出单位</th><th>表演者</th><th>类别</th><th>平均分</th><th>最高分</th><th>最低分</th><th>评委数</th><th class="col-operation">操作</th></tr></thead><tbody id="summaryBody"></tbody></table></div>
<div style="overflow-x: auto; clear: both;"><table class="summary-table" id="summaryTable"><thead><tr><th>名次</th><th>节目编号</th><th>节目名称</th><th>演出单位</th><th>表演者</th><th>类别</th><th>平均分</th><th>最高分</th><th>最低分</th><th>评委数</th><th class="col-operation">操作</th></tr></thead><tbody id="summaryBody"></tbody></table></div>
</div>
</div>
<!-- 模态框 -->
<div id="programModal" class="modal"><div class="modal-content"><h3 id="programModalTitle">添加节目</h3><input type="text" id="programSn" placeholder="节目序号"><input type="text" id="programName" placeholder="节目名称"><input type="text" id="programUnit" placeholder="演出单位"><input type="text" id="programPerformer" placeholder="表演者"><select id="programCategory"><option value="舞蹈">舞蹈</option><option value="音乐">音乐</option><option value="语言">语言</option><option value="器乐">器乐</option></select><select id="programBatchId"></select><div class="modal-buttons"><button class="btn btn-outline btn-sm" onclick="closeProgramModal()">取消</button><button class="btn btn-primary btn-sm" onclick="saveProgram()">保存</button></div></div></div>
<div id="importModal" class="modal"><div class="modal-content"><h3>从Excel导入节目</h3><p style="margin-bottom:10px; font-size:12px;">Excel需要包含列:节目序号、节目名称、演出单位、表演者、节目类别</p><input type="file" id="importFile" accept=".xlsx,.xls"><select id="importBatchId" style="margin-top:10px;"></select><div class="modal-buttons" style="margin-top:15px;"><button class="btn btn-outline btn-sm" onclick="closeImportModal()">取消</button><button class="btn btn-primary btn-sm" onclick="importPrograms()">导入</button></div></div></div>
<div id="programModal" class="modal"><div class="modal-content"><h3 id="programModalTitle">添加节目</h3><input type="text" id="programSn" placeholder="节目编号"><input type="text" id="programName" placeholder="节目名称"><input type="text" id="programUnit" placeholder="演出单位"><input type="text" id="programPerformer" placeholder="表演者"><select id="programCategory"><option value="舞蹈">舞蹈</option><option value="音乐">音乐</option><option value="语言">语言</option><option value="器乐">器乐</option></select><select id="programBatchId"></select><div class="modal-buttons"><button class="btn btn-outline btn-sm" onclick="closeProgramModal()">取消</button><button class="btn btn-primary btn-sm" onclick="saveProgram()">保存</button></div></div></div>
<div id="importModal" class="modal"><div class="modal-content"><h3>从Excel导入节目</h3><p style="margin-bottom:10px; font-size:12px;">Excel需要包含列:节目编号、节目名称、演出单位、表演者、节目类别</p><input type="file" id="importFile" accept=".xlsx,.xls"><select id="importBatchId" style="margin-top:10px;"></select><div class="modal-buttons" style="margin-top:15px;"><button class="btn btn-outline btn-sm" onclick="closeImportModal()">取消</button><button class="btn btn-primary btn-sm" onclick="importPrograms()">导入</button></div></div></div>
<div id="judgeModal" class="modal"><div class="modal-content"><h3 id="judgeModalTitle">添加评委</h3><input type="text" id="judgeId" placeholder="评委编号"><input type="text" id="judgeName" placeholder="评委姓名"><div class="modal-buttons"><button class="btn btn-outline btn-sm" onclick="closeJudgeModal()">取消</button><button class="btn btn-primary btn-sm" onclick="saveJudge()">保存</button></div></div></div>
<div id="batchModal" class="modal"><div class="modal-content"><h3>添加批次</h3><input type="text" id="batchName" placeholder="批次名称"><div class="modal-buttons"><button class="btn btn-outline btn-sm" onclick="closeBatchModal()">取消</button><button class="btn btn-primary btn-sm" onclick="saveBatch()">保存</button></div></div></div>
<div id="titleModal" class="modal"><div class="modal-content"><h3>修改标题</h3><input type="text" id="mainTitleInput" placeholder="主标题"><input type="text" id="subTitleInput" placeholder="副标题"><div class="modal-buttons"><button class="btn btn-outline btn-sm" onclick="closeTitleModal()">取消</button><button class="btn btn-primary btn-sm" onclick="saveTitleSettings()">保存</button></div></div></div>
@@ -1403,6 +1446,7 @@ HTML_TEMPLATE = """
let editingProgramSn = null, editingJudgeId = null;
let cachedAggregate = null, cachedAwardSettings = null;
let refreshTimer = null;
let userToken = null;
async function restoreLogin() {
const stored = localStorage.getItem('score_user');
@@ -1433,6 +1477,7 @@ HTML_TEMPLATE = """
if (!checkData.exists) throw new Error('用户不存在');
currentUser = { id: user.id, username: user.username };
userType = 'admin';
userToken = user.token;
document.getElementById('loginArea').style.display = 'none';
document.getElementById('userInfoArea').style.display = 'flex';
document.getElementById('userInfo').innerHTML = `👑 管理员:${user.username} <span class="mode-badge mode-admin">管理员模式</span>`;
@@ -1525,7 +1570,10 @@ HTML_TEMPLATE = """
async function clearBatchPrograms(batchId) {
if(confirm(`确定要清空该批次的所有节目吗?此操作不可恢复!`)){
const res = await fetch(`/api/batches/${batchId}/programs`, { method:'DELETE' });
const res = await fetch(`/api/batches/${batchId}/programs`, {
method:'DELETE',
headers:{'Authorization': 'Bearer ' + userToken},
});
if(res.ok){
showToast('该批次所有节目已清空');
await loadPrograms();
@@ -1586,8 +1634,10 @@ HTML_TEMPLATE = """
localStorage.setItem('score_user', JSON.stringify({
type: 'admin',
id: data.admin_id,
username: data.username
username: data.username,
token: data.token,
}));
userToken = data.token;
document.getElementById('loginArea').style.display = 'none';
document.getElementById('userInfoArea').style.display = 'flex';
document.getElementById('userInfo').innerHTML = `👑 管理员:${data.username} <span class="mode-badge mode-admin">管理员模式</span>`;
@@ -1635,7 +1685,7 @@ HTML_TEMPLATE = """
programsData.forEach(prog => {
const isActive = currentJudgeProgram && currentJudgeProgram.sn === prog.sn;
html += `<li class="program-item ${isActive ? 'active' : ''}" onclick="selectJudgeProgram('${prog.sn}')">
<strong>${escapeHtml(prog.name)}</strong><br><span style="font-size:12px; color:#666;">${prog.sn} | ${escapeHtml(prog.performer)}</span>
<strong>${prog.name}</strong><br><span style="font-size:12px; color:#666;">${prog.sn} | ${prog.performer}</span>
</li>`;
});
}
@@ -1657,7 +1707,7 @@ HTML_TEMPLATE = """
if(!prog) return;
const total = (scores.content||0)+(scores.stage||0)+(scores.art||0)+(scores.overall||0);
const html = `<div style="background:white; border-radius:16px; padding:20px;">
<h3>${escapeHtml(prog.name)}</h3><p style="color:#666; margin-bottom:20px;">序号:${prog.sn} | 单位:${escapeHtml(prog.unit)} | 表演者:${escapeHtml(prog.performer)} | 类别:${prog.category}</p>
<h3>${prog.name}</h3><p style="color:#666; margin-bottom:20px;">编号:${prog.sn} | 单位:${prog.unit} | 表演者:${prog.performer} | 类别:${prog.category}</p>
<div class="score-cards" style="display:grid; grid-template-columns:repeat(auto-fit,minmax(200px,1fr)); gap:15px;">
<div style="background:#f7fafc; padding:15px; border-radius:12px; text-align:center;">
<label>📖 内容取材</label><div style="font-size:12px; color:#999;">满分20分</div>
@@ -1681,7 +1731,7 @@ HTML_TEMPLATE = """
</div>
</div>
<div class="total-score">🏆 节目总分:<span id="totalScore">${total}</span> / 100</div>
<div style="margin:20px 0;"><textarea id="commentInput" rows="3" placeholder="评委点评(可选)" style="width:100%; padding:10px; border:1px solid #ddd; border-radius:8px;">${escapeHtml(scores.comment||'')}</textarea></div>
<div style="margin:20px 0;"><textarea id="commentInput" rows="3" placeholder="评委点评(可选)" style="width:100%; padding:10px; border:1px solid #ddd; border-radius:8px;">${scores.comment||''}</textarea></div>
<div style="display:flex; gap:10px; justify-content:flex-end;"><button class="btn btn-outline btn-sm" onclick="saveJudgeComment()">💾 保存点评</button></div>
</div>`;
document.getElementById('judgeScorePanel').innerHTML = html;
@@ -1730,11 +1780,11 @@ HTML_TEMPLATE = """
});
const scoresMap = await scoresMapRes.json(); // { program_sn: { judge_id: total } }
let html = '<table class="scoring-table"><thead><tr><th>节目序号</th><th>节目名称</th><th>表演者</th>';
let html = '<table class="scoring-table"><thead><tr><th>节目编号</th><th>节目名称</th><th>表演者</th>';
judgesData.forEach(j => { html += `<th>${j.name}<br><span style="font-size:11px;">(${j.id})</span></th>`; });
html += '<th>操作</th></tr></thead><tbody>';
for(let prog of programsData){
html += `<tr><td style="text-align:center;">${prog.sn}</td><td style="text-align:left;">${prog.name}</td><td style="text-align:left;">${escapeHtml(prog.performer)}`;
html += `<tr><td style="text-align:center;">${prog.sn}</td><td style="text-align:left;">${prog.name}</td><td style="text-align:left;">${prog.performer}`;
for(let judge of judgesData){
let score = '';
const progScores = scoresMap[prog.sn];
@@ -1761,7 +1811,7 @@ HTML_TEMPLATE = """
try {
const res = await fetch('/api/scores/admin/batch', {
method:'POST',
headers:{'Content-Type':'application/json'},
headers:{'Content-Type':'application/json', 'Authorization': 'Bearer ' + userToken},
body:JSON.stringify({program_sn:programSn, judge_scores:scores})
});
if(res.ok){
@@ -1868,7 +1918,7 @@ HTML_TEMPLATE = """
}
}
const firstCount = settings.first, secondCount = settings.second, thirdCount = settings.third;
let html = '<div class="award-table-container"><table class="award-table"><thead><tr><th>名次</th><th>节目序号</th><th>节目名称</th><th>演出单位</th><th>表演者</th><th>类别</th><th>平均分</th><th>奖项</th></tr></thead><tbody>';
let html = '<div class="award-table-container"><table class="award-table"><thead><tr><th>名次</th><th>节目编号</th><th>节目名称</th><th>演出单位</th><th>表演者</th><th>类别</th><th>平均分</th><th>奖项</th></tr></thead><tbody>';
programs.forEach((p, idx) => {
let award = '';
if (idx < firstCount) award = settings.first_name;
@@ -1896,7 +1946,7 @@ HTML_TEMPLATE = """
html += `<h4 style="margin:15px 0 5px 0;">📁 ${batchName}</h4>`;
grouped[batchName].forEach(p => {
html += `<div class="program-list-item">
<span>${p.sn} | ${escapeHtml(p.name)} | ${escapeHtml(p.unit)} | ${escapeHtml(p.performer)}</span>
<span>${p.sn} | ${p.name} | ${p.unit} | ${p.performer}</span>
<div class="program-buttons">
<button class="btn btn-outline btn-sm" onclick="editProgram('${p.sn}')">✏️ 编辑</button>
<button class="btn btn-outline btn-sm" onclick="deleteProgram('${p.sn}')">🗑️ 删除</button>
@@ -1938,7 +1988,7 @@ HTML_TEMPLATE = """
const third = parseInt(document.getElementById('awardThird').value) || 0;
await fetch('/api/settings/awards', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + userToken },
body: JSON.stringify({ first, second, third })
});
cachedAwardSettings = null;
@@ -1952,7 +2002,7 @@ HTML_TEMPLATE = """
const third_name = document.getElementById('awardThirdName').value;
await fetch('/api/settings/award_names', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + userToken },
body: JSON.stringify({ first_name, second_name, third_name })
});
cachedAwardSettings = null;
@@ -1961,10 +2011,23 @@ HTML_TEMPLATE = """
}
function showAddBatchModal() { document.getElementById('batchModal').style.display='flex'; }
async function saveBatch() { const name = document.getElementById('batchName').value.trim(); if(!name){ showToast('请输入批次名称'); return; } await fetch('/api/batches', { method:'POST', headers:{'Content-Type':'application/json'}, body:JSON.stringify({name}) }); closeBatchModal(); await loadBatches(); }
async function saveBatch() {
const name = document.getElementById('batchName').value.trim();
if(!name){ showToast('请输入批次名称'); return; }
await fetch('/api/batches', {
method:'POST',
headers:{'Content-Type':'application/json', 'Authorization': 'Bearer ' + userToken},
body:JSON.stringify({name})
});
closeBatchModal();
await loadBatches();
}
async function deleteBatch(id) {
if(confirm('确定删除该批次吗?')) {
const res = await fetch(`/api/batches/${id}`, { method:'DELETE' });
const res = await fetch(`/api/batches/${id}`, {
method:'DELETE',
headers:{'Authorization': 'Bearer ' + userToken},
});
if (res.ok) {
currentBatchId = null;
renderBatchBars();
@@ -1982,25 +2045,135 @@ HTML_TEMPLATE = """
function showAddProgramModal() { editingProgramSn=null; document.getElementById('programModalTitle').innerText='添加节目'; document.getElementById('programSn').disabled=false; document.getElementById('programSn').value=''; document.getElementById('programName').value=''; document.getElementById('programUnit').value=''; document.getElementById('programPerformer').value=''; document.getElementById('programCategory').value='舞蹈'; renderBatchSelect(); document.getElementById('programModal').style.display='flex'; }
function editProgram(sn) { const prog = programsData.find(p=>p.sn===sn); if(!prog) return; editingProgramSn=sn; document.getElementById('programModalTitle').innerText='编辑节目'; document.getElementById('programSn').value=prog.sn; document.getElementById('programSn').disabled=true; document.getElementById('programName').value=prog.name; document.getElementById('programUnit').value=prog.unit; document.getElementById('programPerformer').value=prog.performer; document.getElementById('programCategory').value=prog.category; renderBatchSelect(); document.getElementById('programBatchId').value=prog.batch_id; document.getElementById('programModal').style.display='flex'; }
async function saveProgram() { const sn = document.getElementById('programSn').value.trim(); const name = document.getElementById('programName').value.trim(); const unit = document.getElementById('programUnit').value.trim(); const performer = document.getElementById('programPerformer').value.trim(); const category = document.getElementById('programCategory').value; const batch_id = parseInt(document.getElementById('programBatchId').value); if(!sn||!name){ showToast('请填写节目序号和名称'); return; } let res; if(editingProgramSn){ res = await fetch(`/api/programs/${editingProgramSn}`, { method:'PUT', headers:{'Content-Type':'application/json'}, body:JSON.stringify({name,unit,performer,category,batch_id}) }); } else { res = await fetch('/api/programs', { method:'POST', headers:{'Content-Type':'application/json'}, body:JSON.stringify({sn,name,unit,performer,category,batch_id}) }); } if(res.ok){ closeProgramModal(); await loadPrograms(); if(userType==='judge') await loadJudgePrograms(); if(userType==='admin') await loadAdminScoring(); await loadAggregate(); } else { const err=await res.json(); showToast(err.detail); } }
async function deleteProgram(sn) { if(confirm(`确定删除节目 ${sn} 吗?`)){ await fetch(`/api/programs/${sn}`, { method:'DELETE' }); await loadPrograms(); if(userType==='judge') await loadJudgePrograms(); if(userType==='admin') await loadAdminScoring(); await loadAggregate(); } }
async function saveProgram() {
const sn = document.getElementById('programSn').value.trim();
const name = document.getElementById('programName').value.trim();
const unit = document.getElementById('programUnit').value.trim();
const performer = document.getElementById('programPerformer').value.trim();
const category = document.getElementById('programCategory').value;
const batch_id = parseInt(document.getElementById('programBatchId').value);
if(!sn||!name){ showToast('请填写节目编号和名称'); return; }
let res;
if(editingProgramSn){
res = await fetch(`/api/programs/${editingProgramSn}`, {
method:'PUT',
headers:{'Content-Type':'application/json', 'Authorization': 'Bearer ' + userToken},
body:JSON.stringify({name,unit,performer,category,batch_id})
});
} else {
res = await fetch('/api/programs', {
method:'POST',
headers:{'Content-Type':'application/json', 'Authorization': 'Bearer ' + userToken},
body:JSON.stringify({sn,name,unit,performer,category,batch_id})
});
}
if(res.ok){
closeProgramModal();
await loadPrograms();
if(userType==='judge') await loadJudgePrograms();
if(userType==='admin') await loadAdminScoring();
await loadAggregate();
} else {
const err=await res.json();
showToast(err.detail);
}
}
async function deleteProgram(sn) {
if(confirm(`确定删除节目 ${sn} 吗?`)){
await fetch(`/api/programs/${sn}`, {
method:'DELETE',
headers:{'Authorization': 'Bearer ' + userToken},
});
await loadPrograms();
if(userType==='judge') await loadJudgePrograms();
if(userType==='admin') await loadAdminScoring();
await loadAggregate();
}
}
function closeProgramModal() { document.getElementById('programModal').style.display='none'; document.getElementById('programSn').disabled=false; }
function showImportProgramModal() { renderBatchSelect(); document.getElementById('importBatchId').innerHTML = document.getElementById('programBatchId').innerHTML; document.getElementById('importModal').style.display='flex'; }
async function importPrograms() { const file = document.getElementById('importFile').files[0]; if(!file){ showToast('请选择Excel文件'); return; } const batch_id = document.getElementById('importBatchId').value; const formData = new FormData(); formData.append('file', file); const res = await fetch(`/api/programs/import?batch_id=${batch_id}`, { method:'POST', body:formData }); if(res.ok){ showToast('导入成功'); closeImportModal(); await loadPrograms(); if(userType==='judge') await loadJudgePrograms(); if(userType==='admin') await loadAdminScoring(); await loadAggregate(); } else { const err=await res.json(); showToast('导入失败:'+err.detail); } }
async function importPrograms() {
const file = document.getElementById('importFile').files[0];
if(!file){ showToast('请选择Excel文件'); return; }
const batch_id = document.getElementById('importBatchId').value;
const formData = new FormData();
formData.append('file', file);
const res = await fetch(`/api/programs/import?batch_id=${batch_id}`, {
method:'POST',
headers:{'Authorization': 'Bearer ' + userToken},
body:formData
});
if(res.ok){
showToast('导入成功');
closeImportModal();
await loadPrograms();
if(userType==='judge') await loadJudgePrograms();
if(userType==='admin') await loadAdminScoring();
await loadAggregate();
} else {
const err=await res.json();
showToast('导入失败:'+err.detail);
}
}
function closeImportModal() { document.getElementById('importModal').style.display='none'; document.getElementById('importFile').value=''; }
function showAddJudgeModal() { editingJudgeId=null; document.getElementById('judgeModalTitle').innerText='添加评委'; document.getElementById('judgeId').value=''; document.getElementById('judgeName').value=''; document.getElementById('judgeModal').style.display='flex'; }
function editJudge(id) { const judge = judgesData.find(j=>j.id===id); if(!judge) return; editingJudgeId=id; document.getElementById('judgeModalTitle').innerText='编辑评委'; document.getElementById('judgeId').value=judge.id; document.getElementById('judgeId').disabled=true; document.getElementById('judgeName').value=judge.name; document.getElementById('judgeModal').style.display='flex'; }
async function saveJudge() { const id = document.getElementById('judgeId').value.trim(); const name = document.getElementById('judgeName').value.trim(); if(!id||!name){ showToast('请填写评委编号和姓名'); return; } let res; if(editingJudgeId){ res = await fetch(`/api/judges/${editingJudgeId}`, { method:'PUT', headers:{'Content-Type':'application/json'}, body:JSON.stringify({name}) }); } else { res = await fetch('/api/judges', { method:'POST', headers:{'Content-Type':'application/json'}, body:JSON.stringify({id,name}) }); } if(res.ok){ closeJudgeModal(); await loadJudges(); if(userType==='admin') await renderAdminScoringTable(); } else { const err=await res.json(); showToast(err.detail); } }
async function deleteJudge(id) { if(confirm(`确定删除评委 ${id} 吗?`)){ await fetch(`/api/judges/${id}`, { method:'DELETE' }); await loadJudges(); if(userType==='admin') await renderAdminScoringTable(); await loadAggregate(); } }
async function saveJudge() {
const id = document.getElementById('judgeId').value.trim();
const name = document.getElementById('judgeName').value.trim();
if(!id||!name){ showToast('请填写评委编号和姓名'); return; }
let res;
if(editingJudgeId){
res = await fetch(`/api/judges/${editingJudgeId}`, {
method:'PUT',
headers:{'Content-Type':'application/json', 'Authorization': 'Bearer ' + userToken},
body:JSON.stringify({name})
});
} else {
res = await fetch('/api/judges', {
method:'POST',
headers:{'Content-Type':'application/json', 'Authorization': 'Bearer ' + userToken},
body:JSON.stringify({id,name})
});
}
if(res.ok){
closeJudgeModal();
await loadJudges();
if(userType==='admin') await renderAdminScoringTable();
} else {
const err=await res.json();
showToast(err.detail);
}
}
async function deleteJudge(id) {
if(confirm(`确定删除评委 ${id} 吗?`)){
await fetch(`/api/judges/${id}`, {
method:'DELETE',
headers:{'Authorization': 'Bearer ' + userToken},
});
await loadJudges();
if(userType==='admin') await renderAdminScoringTable();
await loadAggregate();
}
}
function closeJudgeModal() { document.getElementById('judgeModal').style.display='none'; document.getElementById('judgeId').disabled=false; }
function closeBatchModal() { document.getElementById('batchModal').style.display='none'; document.getElementById('batchName').value=''; }
function showTitleModal() { fetch('/api/settings/titles').then(r=>r.json()).then(data=>{ document.getElementById('mainTitleInput').value=data.main_title; document.getElementById('subTitleInput').value=data.sub_title; document.getElementById('titleModal').style.display='flex'; }); }
async function saveTitleSettings() { const main_title = document.getElementById('mainTitleInput').value; const sub_title = document.getElementById('subTitleInput').value; await fetch('/api/settings/titles', { method:'POST', headers:{'Content-Type':'application/json'}, body:JSON.stringify({main_title,sub_title}) }); closeTitleModal(); await loadTitles(); }
async function saveTitleSettings() {
const main_title = document.getElementById('mainTitleInput').value;
const sub_title = document.getElementById('subTitleInput').value;
await fetch('/api/settings/titles', {
method:'POST',
headers:{'Content-Type':'application/json', 'Authorization': 'Bearer ' + userToken},
body:JSON.stringify({main_title,sub_title})
});
closeTitleModal();
await loadTitles();
}
function closeTitleModal() { document.getElementById('titleModal').style.display='none'; }
function escapeHtml(str) { if(!str) return ''; return str.replace(/[&<>]/g, function(m){ if(m==='&') return '&amp;'; if(m==='<') return '&lt;'; if(m==='>') return '&gt;'; return m; }); }
function showToast(msg) { const toast = document.createElement('div'); toast.className='toast'; toast.innerText=msg; document.body.appendChild(toast); setTimeout(()=>toast.remove(),2000); }
init();
+2
View File
@@ -8,6 +8,8 @@ dependencies = [
'hypercorn',
'fastapi',
'python-multipart',
'cryptography',
'pyjwt',
'pandas',
'openpyxl',
]
BIN
View File
Binary file not shown.