709 lines
24 KiB
HTML
709 lines
24 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>查询进度步骤条 - 精确对齐版本</title>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
|
|
}
|
|
|
|
body {
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
min-height: 100vh;
|
|
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
|
|
padding: 40px 20px;
|
|
}
|
|
|
|
.container {
|
|
width: 100%;
|
|
max-width: 800px;
|
|
min-height: 600px;
|
|
background: white;
|
|
border-radius: 12px;
|
|
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
|
|
overflow: hidden;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
.header {
|
|
background: linear-gradient(to right, #4b6cb7, #182848);
|
|
color: white;
|
|
padding: 25px 30px;
|
|
text-align: center;
|
|
}
|
|
|
|
.header h1 {
|
|
font-size: 24px;
|
|
font-weight: 600;
|
|
margin-bottom: 5px;
|
|
}
|
|
|
|
.header p {
|
|
opacity: 0.9;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.progress-container {
|
|
padding: 40px 30px;
|
|
flex: 1;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
.progress-steps {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
position: relative;
|
|
margin-bottom: 30px;
|
|
counter-reset: step;
|
|
}
|
|
|
|
.step {
|
|
position: relative;
|
|
z-index: 3;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
flex: 1;
|
|
}
|
|
|
|
.step-connector {
|
|
position: absolute;
|
|
top: 25px;
|
|
height: 4px;
|
|
background-color: #e0e0e0;
|
|
z-index: 1;
|
|
}
|
|
|
|
.step-progress {
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
height: 100%;
|
|
width: 0;
|
|
background: #4b6cb7;
|
|
transition: width 0.8s ease, background-color 0.8s ease;
|
|
z-index: 2;
|
|
}
|
|
|
|
.step-progress.success {
|
|
background: linear-gradient(to right, #4CAF50, #2E7D32);
|
|
}
|
|
|
|
.step-progress.failed {
|
|
background: linear-gradient(to right, #f44336, #c62828);
|
|
}
|
|
|
|
.step-icon {
|
|
width: 50px;
|
|
height: 50px;
|
|
border-radius: 50%;
|
|
background: #e0e0e0;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
color: #999;
|
|
font-weight: bold;
|
|
border: 4px solid white;
|
|
box-shadow: 0 0 0 3px #e0e0e0;
|
|
transition: all 0.5s ease;
|
|
position: relative;
|
|
z-index: 4;
|
|
}
|
|
|
|
.step.active .step-icon {
|
|
background: #4b6cb7;
|
|
color: white;
|
|
box-shadow: 0 0 0 3px #b8c6f0;
|
|
animation: pulse 1.5s infinite;
|
|
}
|
|
|
|
.step.completed .step-icon {
|
|
background: #4CAF50;
|
|
color: white;
|
|
box-shadow: 0 0 0 3px #a5d6a7;
|
|
}
|
|
|
|
.step.failed .step-icon {
|
|
background: #f44336;
|
|
color: white;
|
|
box-shadow: 0 0 0 3px #ffcdd2;
|
|
}
|
|
|
|
.step.completed .step-icon::after {
|
|
content: '✓';
|
|
font-size: 24px;
|
|
}
|
|
|
|
.step.failed .step-icon::after {
|
|
content: '✕';
|
|
font-size: 24px;
|
|
}
|
|
|
|
.step-label {
|
|
margin-top: 10px;
|
|
text-align: center;
|
|
font-size: 14px;
|
|
color: #666;
|
|
font-weight: 500;
|
|
max-width: 100px;
|
|
}
|
|
|
|
.step.active .step-label {
|
|
color: #4b6cb7;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.step.completed .step-label {
|
|
color: #4CAF50;
|
|
}
|
|
|
|
.step.failed .step-label {
|
|
color: #f44336;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.progress-info {
|
|
background: #f8f9fa;
|
|
border-radius: 8px;
|
|
padding: 20px;
|
|
margin-top: 20px;
|
|
text-align: center;
|
|
border-left: 4px solid #4b6cb7;
|
|
min-height: 120px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: center;
|
|
}
|
|
|
|
.progress-info.failed {
|
|
border-left-color: #f44336;
|
|
}
|
|
|
|
.progress-info.success {
|
|
border-left-color: #4CAF50;
|
|
}
|
|
|
|
.progress-status {
|
|
font-size: 16px;
|
|
color: #333;
|
|
margin-bottom: 10px;
|
|
}
|
|
|
|
.progress-details {
|
|
font-size: 14px;
|
|
color: #666;
|
|
line-height: 1.5;
|
|
}
|
|
|
|
.progress-time {
|
|
display: inline-block;
|
|
background: #e3f2fd;
|
|
padding: 3px 8px;
|
|
border-radius: 4px;
|
|
font-size: 12px;
|
|
color: #1565c0;
|
|
margin-top: 5px;
|
|
}
|
|
|
|
.error-message {
|
|
color: #f44336;
|
|
background: #ffebee;
|
|
padding: 10px;
|
|
border-radius: 4px;
|
|
margin-top: 10px;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.buttons {
|
|
display: flex;
|
|
justify-content: center;
|
|
gap: 15px;
|
|
margin-top: 30px;
|
|
}
|
|
|
|
button {
|
|
padding: 12px 25px;
|
|
border: none;
|
|
border-radius: 6px;
|
|
font-size: 15px;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
#startBtn {
|
|
background: linear-gradient(to right, #4b6cb7, #182848);
|
|
color: white;
|
|
}
|
|
|
|
#retryBtn {
|
|
background: linear-gradient(to right, #ff9800, #f57c00);
|
|
color: white;
|
|
display: none;
|
|
}
|
|
|
|
#resetBtn {
|
|
background: #f5f5f5;
|
|
color: #666;
|
|
}
|
|
|
|
button:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
button:disabled {
|
|
opacity: 0.6;
|
|
cursor: not-allowed;
|
|
transform: none;
|
|
box-shadow: none;
|
|
}
|
|
|
|
@keyframes pulse {
|
|
0% {
|
|
box-shadow: 0 0 0 0 rgba(75, 108, 183, 0.7);
|
|
}
|
|
70% {
|
|
box-shadow: 0 0 0 10px rgba(75, 108, 183, 0);
|
|
}
|
|
100% {
|
|
box-shadow: 0 0 0 0 rgba(75, 108, 183, 0);
|
|
}
|
|
}
|
|
|
|
.spinner {
|
|
display: inline-block;
|
|
width: 20px;
|
|
height: 20px;
|
|
border: 3px solid rgba(255, 255, 255, 0.3);
|
|
border-radius: 50%;
|
|
border-top-color: white;
|
|
animation: spin 1s linear infinite;
|
|
margin-right: 8px;
|
|
vertical-align: middle;
|
|
}
|
|
|
|
@keyframes spin {
|
|
to {
|
|
transform: rotate(360deg);
|
|
}
|
|
}
|
|
|
|
@media (max-width: 600px) {
|
|
.step-icon {
|
|
width: 40px;
|
|
height: 40px;
|
|
}
|
|
|
|
.step-label {
|
|
font-size: 12px;
|
|
max-width: 80px;
|
|
}
|
|
|
|
.progress-info {
|
|
padding: 15px;
|
|
}
|
|
|
|
button {
|
|
padding: 10px 20px;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.container {
|
|
min-height: 500px;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<div class="header">
|
|
<h1>远程数据查询进度</h1>
|
|
<p>正在从服务器获取数据,每一步都可能失败,请耐心等待...</p>
|
|
</div>
|
|
|
|
<div class="progress-container">
|
|
<div class="progress-steps">
|
|
<!-- 步骤1 -->
|
|
<div class="step active" id="step1">
|
|
<div class="step-icon">1</div>
|
|
<div class="step-label">验证查询条件</div>
|
|
</div>
|
|
|
|
<!-- 步骤2 -->
|
|
<div class="step" id="step2">
|
|
<div class="step-icon">2</div>
|
|
<div class="step-label">发出请求</div>
|
|
</div>
|
|
|
|
<!-- 步骤3 -->
|
|
<div class="step" id="step3">
|
|
<div class="step-icon">3</div>
|
|
<div class="step-label">等待响应</div>
|
|
</div>
|
|
|
|
<!-- 步骤4 -->
|
|
<div class="step" id="step4">
|
|
<div class="step-icon">4</div>
|
|
<div class="step-label">查询成功</div>
|
|
</div>
|
|
|
|
<!-- 连接线1-2 -->
|
|
<div class="step-connector" id="connector1" style="left: 12.5%; width: 25%;">
|
|
<div class="step-progress" id="progress1"></div>
|
|
</div>
|
|
|
|
<!-- 连接线2-3 -->
|
|
<div class="step-connector" id="connector2" style="left: 37.5%; width: 25%;">
|
|
<div class="step-progress" id="progress2"></div>
|
|
</div>
|
|
|
|
<!-- 连接线3-4 -->
|
|
<div class="step-connector" id="connector3" style="left: 62.5%; width: 25%;">
|
|
<div class="step-progress" id="progress3"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="progress-info" id="progressInfo">
|
|
<div class="progress-status" id="progressStatus">正在验证查询条件...</div>
|
|
<div class="progress-details" id="progressDetails">
|
|
检查查询参数的有效性,确保数据请求符合系统要求。
|
|
<div class="progress-time">已用时间: <span id="timeElapsed">0分00秒</span></div>
|
|
</div>
|
|
<div class="error-message" id="errorMessage" style="display: none;"></div>
|
|
</div>
|
|
|
|
<div class="buttons">
|
|
<button id="startBtn">开始查询</button>
|
|
<button id="retryBtn">重试当前步骤</button>
|
|
<button id="resetBtn" disabled>重置进度</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const steps = document.querySelectorAll('.step');
|
|
const stepProgresses = document.querySelectorAll('.step-progress');
|
|
const connectors = document.querySelectorAll('.step-connector');
|
|
const progressInfoElement = document.getElementById('progressInfo');
|
|
const progressStatus = document.getElementById('progressStatus');
|
|
const progressDetails = document.getElementById('progressDetails');
|
|
const errorMessage = document.getElementById('errorMessage');
|
|
const timeElapsed = document.getElementById('timeElapsed');
|
|
const startBtn = document.getElementById('startBtn');
|
|
const retryBtn = document.getElementById('retryBtn');
|
|
const resetBtn = document.getElementById('resetBtn');
|
|
|
|
let currentStep = 1;
|
|
let isRunning = false;
|
|
let hasFailed = false;
|
|
let timerInterval;
|
|
let seconds = 0;
|
|
let stepStatus = [null, 'active', null, null, null];
|
|
|
|
// 计算连接线位置
|
|
function calculateConnectorPositions() {
|
|
const stepWidth = 100 / steps.length; // 每个步骤占据的宽度百分比
|
|
|
|
connectors.forEach((connector, index) => {
|
|
// 计算连接线的起始位置和宽度
|
|
const left = (index + 0.5) * stepWidth; // 从第一个步骤的中心开始
|
|
const width = stepWidth; // 连接线宽度等于步骤宽度
|
|
|
|
connector.style.left = `${left}%`;
|
|
connector.style.width = `${width}%`;
|
|
});
|
|
}
|
|
|
|
// 更新步骤状态
|
|
function updateSteps() {
|
|
steps.forEach((step, index) => {
|
|
step.classList.remove('active', 'completed', 'failed');
|
|
|
|
if (index + 1 < currentStep) {
|
|
step.classList.add('completed');
|
|
} else if (index + 1 === currentStep) {
|
|
if (currentStep > steps.length) {
|
|
// 如果所有步骤已完成,最后一个步骤显示为完成状态
|
|
step.classList.add('completed');
|
|
} else {
|
|
step.classList.add('active');
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
// 更新进度条
|
|
function updateProgressBars() {
|
|
// 重置所有进度条
|
|
stepProgresses.forEach((progress, index) => {
|
|
progress.style.width = '0';
|
|
progress.classList.remove('success', 'failed');
|
|
});
|
|
|
|
// 设置已完成的进度条
|
|
for (let i = 1; i < currentStep; i++) {
|
|
if (i <= stepProgresses.length) {
|
|
const progress = document.getElementById(`progress${i}`);
|
|
if (progress) {
|
|
progress.style.width = '100%';
|
|
// 根据步骤状态设置颜色
|
|
if (stepStatus[i] === 'completed') {
|
|
progress.classList.add('success');
|
|
} else if (stepStatus[i] === 'failed') {
|
|
progress.classList.add('failed');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 标记步骤失败
|
|
function markStepFailed(stepIndex, error) {
|
|
stepStatus[stepIndex] = 'failed';
|
|
hasFailed = true;
|
|
|
|
steps[stepIndex - 1].classList.remove('active', 'completed');
|
|
steps[stepIndex - 1].classList.add('failed');
|
|
|
|
// 标记前一个连接线为失败
|
|
if (stepIndex > 1) {
|
|
const prevProgress = document.getElementById(`progress${stepIndex - 1}`);
|
|
if (prevProgress) {
|
|
prevProgress.classList.add('failed');
|
|
}
|
|
}
|
|
|
|
progressInfoElement.classList.add('failed');
|
|
errorMessage.textContent = error;
|
|
errorMessage.style.display = 'block';
|
|
|
|
isRunning = false;
|
|
stopTimer();
|
|
|
|
startBtn.disabled = true;
|
|
retryBtn.style.display = 'inline-block';
|
|
resetBtn.disabled = false;
|
|
|
|
updateProgressBars();
|
|
}
|
|
|
|
// 标记步骤成功
|
|
function markStepCompleted(stepIndex) {
|
|
stepStatus[stepIndex] = 'completed';
|
|
updateSteps();
|
|
|
|
// 标记前一个连接线为成功
|
|
if (stepIndex > 1) {
|
|
const prevProgress = document.getElementById(`progress${stepIndex - 1}`);
|
|
if (prevProgress) {
|
|
prevProgress.classList.add('success');
|
|
}
|
|
}
|
|
|
|
updateProgressBars();
|
|
}
|
|
|
|
// 标记所有步骤完成
|
|
function markAllStepsCompleted() {
|
|
for (let i = 1; i <= steps.length; i++) {
|
|
stepStatus[i] = 'completed';
|
|
}
|
|
updateSteps();
|
|
updateProgressBars();
|
|
}
|
|
|
|
// 更新状态信息
|
|
function updateStatus() {
|
|
const statusTexts = [
|
|
'',
|
|
'正在验证查询条件...',
|
|
'正在向服务器发出请求...',
|
|
'正在等待服务器响应...',
|
|
'查询成功,正在处理结果...'
|
|
];
|
|
|
|
const detailTexts = [
|
|
'',
|
|
'检查查询参数的有效性,确保数据请求符合系统要求。',
|
|
'将查询请求发送到远程服务器,建立数据连接。',
|
|
'等待服务器处理查询请求并返回结果。',
|
|
'处理查询结果并准备返回,即将完成整个过程。'
|
|
];
|
|
|
|
progressStatus.textContent = statusTexts[currentStep];
|
|
progressDetails.innerHTML = detailTexts[currentStep] +
|
|
`<div class="progress-time">已用时间: <span id="timeElapsed">${formatTime(seconds)}</span></div>`;
|
|
|
|
// 隐藏错误信息
|
|
errorMessage.style.display = 'none';
|
|
progressInfoElement.classList.remove('failed');
|
|
}
|
|
|
|
// 格式化时间显示
|
|
function formatTime(totalSeconds) {
|
|
const minutes = Math.floor(totalSeconds / 60);
|
|
const seconds = totalSeconds % 60;
|
|
return `${minutes}分${seconds.toString().padStart(2, '0')}秒`;
|
|
}
|
|
|
|
// 开始计时器
|
|
function startTimer() {
|
|
seconds = 0;
|
|
timerInterval = setInterval(() => {
|
|
seconds++;
|
|
timeElapsed.textContent = formatTime(seconds);
|
|
}, 1000);
|
|
}
|
|
|
|
// 停止计时器
|
|
function stopTimer() {
|
|
clearInterval(timerInterval);
|
|
}
|
|
|
|
// 模拟查询过程
|
|
function simulateQuery() {
|
|
if (currentStep > steps.length) {
|
|
// 查询完成
|
|
isRunning = false;
|
|
hasFailed = false;
|
|
startBtn.disabled = true;
|
|
retryBtn.style.display = 'none';
|
|
resetBtn.disabled = false;
|
|
stopTimer();
|
|
|
|
// 标记所有步骤为完成状态
|
|
markAllStepsCompleted();
|
|
|
|
progressStatus.innerHTML = '<span style="color:#4CAF50;">查询完成!</span>';
|
|
progressDetails.innerHTML = '数据查询已成功完成,结果已准备就绪。' +
|
|
`<div class="progress-time">总用时: <span id="timeElapsed">${formatTime(seconds)}</span></div>`;
|
|
return;
|
|
}
|
|
|
|
// 模拟每个步骤的耗时
|
|
const stepDurations = [0, 1000, 1000, 1000, 1000];
|
|
|
|
// 模拟每一步有20%的失败概率
|
|
const willFail = Math.random() < 0.2;
|
|
|
|
setTimeout(() => {
|
|
if (willFail && !hasFailed) {
|
|
// 模拟失败
|
|
const errorMessages = [
|
|
'',
|
|
'验证查询条件失败:查询参数格式不正确。',
|
|
'发出请求失败:无法连接到远程服务器。',
|
|
'等待响应失败:服务器响应超时。',
|
|
'查询成功失败:数据处理错误。'
|
|
];
|
|
|
|
markStepFailed(currentStep, errorMessages[currentStep]);
|
|
return;
|
|
}
|
|
|
|
if (currentStep === steps.length) {
|
|
// 最后一步成功,标记为完成
|
|
markStepCompleted(currentStep);
|
|
currentStep++;
|
|
|
|
// 完成所有步骤
|
|
updateProgressBars();
|
|
updateStatus();
|
|
simulateQuery();
|
|
} else {
|
|
// 步骤成功,继续下一步
|
|
markStepCompleted(currentStep);
|
|
currentStep++;
|
|
updateStatus();
|
|
|
|
if (currentStep <= steps.length) {
|
|
// 继续下一步
|
|
updateSteps();
|
|
updateProgressBars();
|
|
simulateQuery();
|
|
}
|
|
}
|
|
}, stepDurations[currentStep]);
|
|
}
|
|
|
|
// 开始查询
|
|
startBtn.addEventListener('click', function() {
|
|
if (!isRunning) {
|
|
isRunning = true;
|
|
hasFailed = false;
|
|
// 重置步骤状态
|
|
stepStatus = [null, 'active', null, null, null];
|
|
startBtn.disabled = true;
|
|
retryBtn.style.display = 'none';
|
|
resetBtn.disabled = true;
|
|
startTimer();
|
|
updateSteps();
|
|
updateProgressBars();
|
|
simulateQuery();
|
|
}
|
|
});
|
|
|
|
// 重试当前步骤
|
|
retryBtn.addEventListener('click', function() {
|
|
if (!isRunning) {
|
|
isRunning = true;
|
|
hasFailed = false;
|
|
startBtn.disabled = true;
|
|
retryBtn.style.display = 'none';
|
|
resetBtn.disabled = true;
|
|
startTimer();
|
|
|
|
// 重新开始当前步骤
|
|
updateSteps();
|
|
updateStatus();
|
|
simulateQuery();
|
|
}
|
|
});
|
|
|
|
// 重置进度
|
|
resetBtn.addEventListener('click', function() {
|
|
isRunning = false;
|
|
hasFailed = false;
|
|
currentStep = 1;
|
|
stepStatus = [null, 'active', null, null, null];
|
|
updateSteps();
|
|
updateProgressBars();
|
|
updateStatus();
|
|
stopTimer();
|
|
seconds = 0;
|
|
timeElapsed.textContent = formatTime(seconds);
|
|
startBtn.disabled = false;
|
|
retryBtn.style.display = 'none';
|
|
resetBtn.disabled = true;
|
|
|
|
progressStatus.textContent = '准备开始新的查询...';
|
|
progressDetails.innerHTML = '点击"开始查询"按钮启动数据检索过程。' +
|
|
`<div class="progress-time">已用时间: <span id="timeElapsed">${formatTime(seconds)}</span></div>`;
|
|
});
|
|
|
|
// 初始化
|
|
calculateConnectorPositions();
|
|
updateSteps();
|
|
updateProgressBars();
|
|
updateStatus();
|
|
|
|
// 窗口大小改变时重新计算连接线位置
|
|
window.addEventListener('resize', function() {
|
|
calculateConnectorPositions();
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|