新增和完成了录入修改,查询
This commit is contained in:
		@@ -82,6 +82,7 @@
 | 
			
		||||
        box-shadow: 0 2px 10px rgba(0,0,0,0.05);
 | 
			
		||||
        border-left: 4px solid #3498db;
 | 
			
		||||
        transition: transform 0.3s;
 | 
			
		||||
        cursor: pointer;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    .result-item:hover {
 | 
			
		||||
@@ -89,14 +90,119 @@
 | 
			
		||||
        box-shadow: 0 5px 15px rgba(0,0,0,0.1);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    .result-item p {
 | 
			
		||||
        margin-bottom: 10px;
 | 
			
		||||
        line-height: 1.6;
 | 
			
		||||
    .result-preview {
 | 
			
		||||
        margin-bottom: 15px;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    .result-preview .field-item {
 | 
			
		||||
        display: inline-block;
 | 
			
		||||
        margin-right: 20px;
 | 
			
		||||
        margin-bottom: 8px;
 | 
			
		||||
        padding: 5px 10px;
 | 
			
		||||
        background: #f8f9fa;
 | 
			
		||||
        border-radius: 4px;
 | 
			
		||||
        border: 1px solid #e9ecef;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    .result-preview .field-label {
 | 
			
		||||
        font-weight: bold;
 | 
			
		||||
        color: #2c3e50;
 | 
			
		||||
        margin-right: 5px;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    .result-preview .field-value {
 | 
			
		||||
        color: #34495e;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    .result-item strong {
 | 
			
		||||
    .result-details {
 | 
			
		||||
        display: none;
 | 
			
		||||
        border-top: 1px solid #e9ecef;
 | 
			
		||||
        padding-top: 15px;
 | 
			
		||||
        margin-top: 15px;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    .result-details.expanded {
 | 
			
		||||
        display: block;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    .result-details .field-item {
 | 
			
		||||
        margin-bottom: 10px;
 | 
			
		||||
        padding: 8px 12px;
 | 
			
		||||
        background: #f8f9fa;
 | 
			
		||||
        border-radius: 4px;
 | 
			
		||||
        border-left: 3px solid #3498db;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    .result-details .field-label {
 | 
			
		||||
        font-weight: bold;
 | 
			
		||||
        color: #2c3e50;
 | 
			
		||||
        display: inline-block;
 | 
			
		||||
        min-width: 120px;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    .result-details .field-value {
 | 
			
		||||
        color: #34495e;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    .expand-indicator {
 | 
			
		||||
        float: right;
 | 
			
		||||
        color: #3498db;
 | 
			
		||||
        font-size: 14px;
 | 
			
		||||
        transition: all 0.3s;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    .result-item.expanded .expand-indicator {
 | 
			
		||||
        color: #2c3e50;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    .image-container {
 | 
			
		||||
        margin-top: 15px;
 | 
			
		||||
        text-align: center;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    .result-image {
 | 
			
		||||
        max-width: 100%;
 | 
			
		||||
        max-height: 300px;
 | 
			
		||||
        border-radius: 8px;
 | 
			
		||||
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
 | 
			
		||||
        cursor: pointer;
 | 
			
		||||
        transition: transform 0.3s;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    .result-image:hover {
 | 
			
		||||
        transform: scale(1.05);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    .image-modal {
 | 
			
		||||
        display: none;
 | 
			
		||||
        position: fixed;
 | 
			
		||||
        z-index: 1000;
 | 
			
		||||
        left: 0;
 | 
			
		||||
        top: 0;
 | 
			
		||||
        width: 100%;
 | 
			
		||||
        height: 100%;
 | 
			
		||||
        background-color: rgba(0,0,0,0.8);
 | 
			
		||||
        cursor: pointer;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    .image-modal img {
 | 
			
		||||
        position: absolute;
 | 
			
		||||
        top: 50%;
 | 
			
		||||
        left: 50%;
 | 
			
		||||
        transform: translate(-50%, -50%);
 | 
			
		||||
        max-width: 90%;
 | 
			
		||||
        max-height: 90%;
 | 
			
		||||
        border-radius: 8px;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    .close-modal {
 | 
			
		||||
        position: absolute;
 | 
			
		||||
        top: 20px;
 | 
			
		||||
        right: 30px;
 | 
			
		||||
        color: white;
 | 
			
		||||
        font-size: 30px;
 | 
			
		||||
        font-weight: bold;
 | 
			
		||||
        cursor: pointer;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /* 加载状态 */
 | 
			
		||||
@@ -152,22 +258,47 @@
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
                
 | 
			
		||||
                const html = realData.map(item => {
 | 
			
		||||
                const html = realData.map((item, index) => {
 | 
			
		||||
                    const source = item._source || {};
 | 
			
		||||
                    const students = Array.isArray(source.students)
 | 
			
		||||
                        ? source.students.join(', ')
 | 
			
		||||
                        : (source.students || '无');
 | 
			
		||||
                    const allFields = Object.entries(source).filter(([key, value]) => key !== 'image' && value);
 | 
			
		||||
                    
 | 
			
		||||
                    const teacher = Array.isArray(source.teacher)
 | 
			
		||||
                        ? source.teacher.join(', ')
 | 
			
		||||
                        : (source.teacher || '无');
 | 
			
		||||
                    // 获取前3个字段作为预览
 | 
			
		||||
                    const previewFields = allFields.slice(0, 3);
 | 
			
		||||
                    const hasMoreFields = allFields.length > 3;
 | 
			
		||||
                    
 | 
			
		||||
                    // 生成预览字段HTML
 | 
			
		||||
                    const previewHtml = previewFields.map(([key, value]) => `
 | 
			
		||||
                        <div class="field-item">
 | 
			
		||||
                            <span class="field-label">${key}:</span>
 | 
			
		||||
                            <span class="field-value">${Array.isArray(value) ? value.join(', ') : value}</span>
 | 
			
		||||
                        </div>
 | 
			
		||||
                    `).join('');
 | 
			
		||||
                    
 | 
			
		||||
                    // 生成详细字段HTML
 | 
			
		||||
                    const detailsHtml = allFields.map(([key, value]) => `
 | 
			
		||||
                        <div class="field-item">
 | 
			
		||||
                            <span class="field-label">${key}:</span>
 | 
			
		||||
                            <span class="field-value">${Array.isArray(value) ? value.join(', ') : value}</span>
 | 
			
		||||
                        </div>
 | 
			
		||||
                    `).join('');
 | 
			
		||||
                    
 | 
			
		||||
                    // 图片HTML
 | 
			
		||||
                    const imageHtml = source.image ? `
 | 
			
		||||
                        <div class="image-container">
 | 
			
		||||
                            <img src="/image/${source.image}" alt="相关图片" class="result-image" onclick="openImageModal('/image/${source.image}')">
 | 
			
		||||
                        </div>
 | 
			
		||||
                    ` : '';
 | 
			
		||||
                    
 | 
			
		||||
                    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 class="result-item" onclick="toggleDetails(${index})" data-index="${index}">
 | 
			
		||||
                            <div class="result-preview">
 | 
			
		||||
                                ${previewHtml}
 | 
			
		||||
                                ${hasMoreFields ? '<span class="expand-indicator">▼ 点击查看更多</span>' : ''}
 | 
			
		||||
                            </div>
 | 
			
		||||
                            <div class="result-details" id="details-${index}">
 | 
			
		||||
                                ${detailsHtml}
 | 
			
		||||
                                ${imageHtml}
 | 
			
		||||
                            </div>
 | 
			
		||||
                        </div>
 | 
			
		||||
                    `;
 | 
			
		||||
                }).join('');
 | 
			
		||||
@@ -178,5 +309,54 @@
 | 
			
		||||
                resultsContainer.innerHTML = '<div class="error">搜索过程中发生错误</div>';
 | 
			
		||||
            });
 | 
			
		||||
    });
 | 
			
		||||
    
 | 
			
		||||
    function toggleDetails(index) {
 | 
			
		||||
        const resultItem = document.querySelector(`[data-index="${index}"]`);
 | 
			
		||||
        const detailsDiv = document.getElementById(`details-${index}`);
 | 
			
		||||
        
 | 
			
		||||
        if (detailsDiv.classList.contains('expanded')) {
 | 
			
		||||
            detailsDiv.classList.remove('expanded');
 | 
			
		||||
            resultItem.classList.remove('expanded');
 | 
			
		||||
        } else {
 | 
			
		||||
            detailsDiv.classList.add('expanded');
 | 
			
		||||
            resultItem.classList.add('expanded');
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    function openImageModal(imageSrc) {
 | 
			
		||||
        event.stopPropagation(); // 阻止事件冒泡
 | 
			
		||||
        
 | 
			
		||||
        // 创建模态框
 | 
			
		||||
        const modal = document.createElement('div');
 | 
			
		||||
        modal.className = 'image-modal';
 | 
			
		||||
        modal.innerHTML = `
 | 
			
		||||
            <span class="close-modal" onclick="closeImageModal()">×</span>
 | 
			
		||||
            <img src="${imageSrc}" alt="图片预览">
 | 
			
		||||
        `;
 | 
			
		||||
        
 | 
			
		||||
        document.body.appendChild(modal);
 | 
			
		||||
        modal.style.display = 'block';
 | 
			
		||||
        
 | 
			
		||||
        // 点击模态框背景关闭
 | 
			
		||||
        modal.addEventListener('click', function(e) {
 | 
			
		||||
            if (e.target === modal) {
 | 
			
		||||
                closeImageModal();
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    function closeImageModal() {
 | 
			
		||||
        const modal = document.querySelector('.image-modal');
 | 
			
		||||
        if (modal) {
 | 
			
		||||
            modal.remove();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    // ESC键关闭模态框
 | 
			
		||||
    document.addEventListener('keydown', function(e) {
 | 
			
		||||
        if (e.key === 'Escape') {
 | 
			
		||||
            closeImageModal();
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
</script>
 | 
			
		||||
{% endblock %}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user