上传文件至 templates
This commit is contained in:
182
templates/results.html
Normal file
182
templates/results.html
Normal file
@@ -0,0 +1,182 @@
|
||||
|
||||
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}查询统计 - 紫金·稷下薪火·云枢智海师生成果共创系统{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<style>
|
||||
/* 基础样式重置 */
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
|
||||
/* 主体布局 */
|
||||
.container {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
/* 标题样式 */
|
||||
h2 {
|
||||
color: #2c3e50;
|
||||
border-bottom: 2px solid #3498db;
|
||||
padding-bottom: 10px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
/* 搜索区域样式 */
|
||||
.search-container {
|
||||
background: #f8f9fa;
|
||||
padding: 25px;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.search-form {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
flex: 1;
|
||||
padding: 12px 15px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 6px;
|
||||
font-size: 16px;
|
||||
transition: border-color 0.3s;
|
||||
}
|
||||
|
||||
.search-input:focus {
|
||||
border-color: #3498db;
|
||||
outline: none;
|
||||
box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
|
||||
}
|
||||
|
||||
.search-button {
|
||||
padding: 12px 25px;
|
||||
background: linear-gradient(135deg, #3498db, #1a5276);
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-weight: bold;
|
||||
transition: transform 0.2s, box-shadow 0.2s;
|
||||
}
|
||||
|
||||
.search-button:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 8px rgba(52, 152, 219, 0.4);
|
||||
}
|
||||
|
||||
/* 结果区域样式 */
|
||||
.results-container {
|
||||
min-height: 300px;
|
||||
}
|
||||
|
||||
.result-item {
|
||||
background: white;
|
||||
border-radius: 8px;
|
||||
padding: 20px;
|
||||
margin-bottom: 20px;
|
||||
box-shadow: 0 2px 10px rgba(0,0,0,0.05);
|
||||
border-left: 4px solid #3498db;
|
||||
transition: transform 0.3s;
|
||||
}
|
||||
|
||||
.result-item:hover {
|
||||
transform: translateY(-3px);
|
||||
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.result-item p {
|
||||
margin-bottom: 10px;
|
||||
line-height: 1.6;
|
||||
color: #34495e;
|
||||
}
|
||||
|
||||
.result-item strong {
|
||||
color: #2c3e50;
|
||||
}
|
||||
|
||||
/* 加载状态 */
|
||||
.loading {
|
||||
text-align: center;
|
||||
padding: 40px;
|
||||
color: #7f8c8d;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
/* 错误信息 */
|
||||
.error {
|
||||
color: #e74c3c;
|
||||
padding: 20px;
|
||||
text-align: center;
|
||||
background: rgba(231, 76, 60, 0.1);
|
||||
border-radius: 6px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="container">
|
||||
<h2>奖项成果查询</h2>
|
||||
<p>输入关键词(如姓名、奖项名等)搜索已录入的成果信息</p>
|
||||
|
||||
<div class="search-container">
|
||||
<form id="search-form" class="search-form">
|
||||
<input type="text" name="q" class="search-input" placeholder="输入关键词(如姓名、奖项名等)" required>
|
||||
<button type="submit" class="search-button">搜索</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div id="results" class="results-container">
|
||||
<!-- 结果将通过JS动态加载 -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.getElementById("search-form").addEventListener("submit", function (e) {
|
||||
e.preventDefault();
|
||||
const q = this.q.value;
|
||||
const resultsContainer = document.getElementById("results");
|
||||
|
||||
// 显示加载状态
|
||||
resultsContainer.innerHTML = '<div class="loading">正在搜索,请稍候...</div>';
|
||||
|
||||
fetch(`/search?q=${encodeURIComponent(q)}`)
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
const realData = data.hits?.hits || data;
|
||||
|
||||
if (!Array.isArray(realData) || realData.length === 0) {
|
||||
resultsContainer.innerHTML = '<div class="error">未找到相关结果</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
const html = realData.map(item => {
|
||||
const source = item._source || {};
|
||||
const students = Array.isArray(source.students)
|
||||
? source.students.join(', ')
|
||||
: (source.students || '无');
|
||||
|
||||
const teacher = Array.isArray(source.teacher)
|
||||
? source.teacher.join(', ')
|
||||
: (source.teacher || '无');
|
||||
|
||||
return `
|
||||
<div class="result-item">
|
||||
<p><strong>比赛/论文名称:</strong>${source.id || '无'}</p>
|
||||
<p><strong>项目名称:</strong>${source.name || '无'}</p>
|
||||
<p><strong>学生:</strong>${students}</p>
|
||||
<p><strong>指导老师:</strong>${teacher}</p>
|
||||
</div>
|
||||
`;
|
||||
}).join('');
|
||||
|
||||
resultsContainer.innerHTML = html;
|
||||
})
|
||||
.catch(err => {
|
||||
resultsContainer.innerHTML = '<div class="error">搜索过程中发生错误</div>';
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user