<!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 {
|
background-color: #f5f7fa;
|
color: #333;
|
line-height: 1.6;
|
padding: 20px;
|
min-height: 100vh;
|
}
|
.container {
|
max-width: 1000px;
|
margin: 0 auto;
|
padding: 30px;
|
background-color: white;
|
border-radius: 12px;
|
box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
|
}
|
header {
|
text-align: center;
|
margin-bottom: 40px;
|
}
|
|
h1 {
|
color: #2c3e50;
|
margin-bottom: 10px;
|
font-size: 28px;
|
}
|
|
.description {
|
color: #7f8c8d;
|
max-width: 600px;
|
margin: 0 auto;
|
}
|
|
.process-container {
|
position: relative;
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
margin-bottom: 60px;
|
}
|
|
/* 连接线 */
|
.process-line {
|
position: absolute;
|
top: 40px;
|
left: 80px;
|
right: 80px;
|
height: 4px;
|
background-color: #e0e0e0;
|
z-index: 1;
|
}
|
|
.process-line.active {
|
background-color: #3498db;
|
}
|
|
.node {
|
position: relative;
|
display: flex;
|
flex-direction: column;
|
align-items: center;
|
width: 120px;
|
z-index: 2;
|
}
|
|
.node-indicator {
|
width: 80px;
|
height: 80px;
|
border-radius: 50%;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
font-size: 20px;
|
font-weight: bold;
|
color: white;
|
margin-bottom: 15px;
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
transition: all 0.3s ease;
|
cursor: pointer;
|
}
|
|
.node-indicator.start {
|
background: linear-gradient(135deg, #1abc9c, #16a085);
|
}
|
|
.node-indicator.manager {
|
background: linear-gradient(135deg, #3498db, #2980b9);
|
}
|
|
.node-indicator.leader {
|
background: linear-gradient(135deg, #9b59b6, #8e44ad);
|
}
|
|
.node-indicator.group {
|
background: linear-gradient(135deg, #e67e22, #d35400);
|
}
|
|
.node-indicator.end {
|
background: linear-gradient(135deg, #e74c3c, #c0392b);
|
}
|
|
.node-indicator.disabled {
|
background: #bdc3c7;
|
transform: scale(0.9);
|
opacity: 0.7;
|
}
|
|
.node-label {
|
font-weight: 600;
|
margin-bottom: 8px;
|
color: #2c3e50;
|
text-align: center;
|
}
|
|
.toggle-container {
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
}
|
|
/* 切换开关样式 */
|
.toggle-switch {
|
position: relative;
|
display: inline-block;
|
width: 50px;
|
height: 24px;
|
}
|
|
.toggle-switch input {
|
opacity: 0;
|
width: 0;
|
height: 0;
|
}
|
|
.toggle-slider {
|
position: absolute;
|
cursor: pointer;
|
top: 0;
|
left: 0;
|
right: 0;
|
bottom: 0;
|
background-color: #ccc;
|
transition: .4s;
|
border-radius: 24px;
|
}
|
|
.toggle-slider:before {
|
position: absolute;
|
content: "";
|
height: 18px;
|
width: 18px;
|
left: 3px;
|
bottom: 3px;
|
background-color: white;
|
transition: .4s;
|
border-radius: 50%;
|
}
|
|
input:checked + .toggle-slider {
|
background-color: #2ecc71;
|
}
|
|
input:checked + .toggle-slider:before {
|
transform: translateX(26px);
|
}
|
|
.toggle-label {
|
margin-left: 8px;
|
font-size: 14px;
|
color: #7f8c8d;
|
}
|
|
.toggle-label.active {
|
color: #2ecc71;
|
font-weight: 600;
|
}
|
|
.toggle-label.inactive {
|
color: #e74c3c;
|
}
|
|
.controls {
|
display: flex;
|
justify-content: center;
|
gap: 20px;
|
margin-top: 40px;
|
padding-top: 30px;
|
border-top: 1px solid #eee;
|
}
|
|
.btn {
|
padding: 12px 30px;
|
border: none;
|
border-radius: 6px;
|
font-size: 16px;
|
font-weight: 600;
|
cursor: pointer;
|
transition: all 0.3s ease;
|
}
|
|
.btn-save {
|
background-color: #3498db;
|
color: white;
|
}
|
|
.btn-save:hover {
|
background-color: #2980b9;
|
transform: translateY(-2px);
|
}
|
|
.btn-reset {
|
background-color: #ecf0f1;
|
color: #34495e;
|
}
|
|
.btn-reset:hover {
|
background-color: #d5dbdb;
|
}
|
|
.status-bar {
|
background-color: #f8f9fa;
|
padding: 15px 20px;
|
border-radius: 8px;
|
margin-top: 30px;
|
border-left: 4px solid #3498db;
|
}
|
|
.status-text {
|
font-size: 15px;
|
color: #2c3e50;
|
}
|
|
.status-text .enabled-count {
|
font-weight: bold;
|
color: #27ae60;
|
}
|
|
.status-text .disabled-count {
|
font-weight: bold;
|
color: #e74c3c;
|
}
|
|
@media (max-width: 768px) {
|
.process-container {
|
flex-direction: column;
|
align-items: center;
|
}
|
|
.node {
|
margin-bottom: 30px;
|
width: 100%;
|
}
|
|
.process-line {
|
display: none;
|
}
|
|
.controls {
|
flex-direction: column;
|
}
|
}
|
</style>
|
</head>
|
<body>
|
<div class="container">
|
|
<div class="process-container">
|
<!-- 连接线 -->
|
<div class="process-line" id="processLine"></div>
|
|
<!-- 开始节点 -->
|
<div class="node">
|
<div class="node-indicator start" id="node-start">开始</div>
|
<div class="node-label">开始节点</div>
|
<div class="toggle-container">
|
<label class="toggle-switch">
|
<input type="checkbox" class="node-toggle" data-node="start" checked>
|
<span class="toggle-slider"></span>
|
</label>
|
<span class="toggle-label active" id="label-start">启用</span>
|
</div>
|
</div>
|
|
<!-- 经理审批节点 -->
|
<div class="node">
|
<div class="node-indicator manager" id="node-manager">经理</div>
|
<div class="node-label">经理审批</div>
|
<div class="toggle-container">
|
<label class="toggle-switch">
|
<input type="checkbox" class="node-toggle" data-node="manager" checked>
|
<span class="toggle-slider"></span>
|
</label>
|
<span class="toggle-label active" id="label-manager">启用</span>
|
</div>
|
</div>
|
|
<!-- 领导审批节点 -->
|
<div class="node">
|
<div class="node-indicator leader" id="node-leader">领导</div>
|
<div class="node-label">领导审批</div>
|
<div class="toggle-container">
|
<label class="toggle-switch">
|
<input type="checkbox" class="node-toggle" data-node="leader" checked>
|
<span class="toggle-slider"></span>
|
</label>
|
<span class="toggle-label active" id="label-leader">启用</span>
|
</div>
|
</div>
|
|
<!-- 集团审批节点 -->
|
<div class="node">
|
<div class="node-indicator group" id="node-group">集团</div>
|
<div class="node-label">集团审批</div>
|
<div class="toggle-container">
|
<label class="toggle-switch">
|
<input type="checkbox" class="node-toggle" data-node="group" checked>
|
<span class="toggle-slider"></span>
|
</label>
|
<span class="toggle-label active" id="label-group">启用</span>
|
</div>
|
</div>
|
|
<!-- 结束节点 -->
|
<div class="node">
|
<div class="node-indicator end" id="node-end">结束</div>
|
<div class="node-label">结束节点</div>
|
<div class="toggle-container">
|
<label class="toggle-switch">
|
<input type="checkbox" class="node-toggle" data-node="end" checked disabled>
|
<span class="toggle-slider"></span>
|
</label>
|
<span class="toggle-label active" id="label-end">启用</span>
|
</div>
|
</div>
|
</div>
|
|
<div class="status-bar">
|
<p class="status-text">当前状态:<span id="enabledCount" class="enabled-count">5</span>个节点已启用,<span id="disabledCount" class="disabled-count">0</span>个节点已禁用。<span id="statusDetail">所有节点均已启用,流程可正常执行。</span></p>
|
</div>
|
|
<div class="controls">
|
<button class="btn btn-save" id="saveBtn">保存配置</button>
|
<button class="btn btn-reset" id="resetBtn">重置为默认</button>
|
</div>
|
</div>
|
|
<script>
|
document.addEventListener('DOMContentLoaded', function() {
|
// 获取所有节点切换开关
|
const nodeToggles = document.querySelectorAll('.node-toggle');
|
const processLine = document.getElementById('processLine');
|
|
// 更新连接线状态
|
function updateProcessLine() {
|
const enabledNodes = [];
|
|
nodeToggles.forEach(toggle => {
|
if (toggle.checked) {
|
enabledNodes.push(toggle.dataset.node);
|
}
|
});
|
|
// 如果所有节点都启用,将连接线设置为激活状态
|
if (enabledNodes.length === nodeToggles.length) {
|
processLine.classList.add('active');
|
} else {
|
processLine.classList.remove('active');
|
}
|
|
// 更新节点指示器状态
|
nodeToggles.forEach(toggle => {
|
const node = toggle.dataset.node;
|
const nodeIndicator = document.getElementById(`node-${node}`);
|
const label = document.getElementById(`label-${node}`);
|
|
if (toggle.checked) {
|
nodeIndicator.classList.remove('disabled');
|
label.textContent = '启用';
|
label.className = 'toggle-label active';
|
} else {
|
nodeIndicator.classList.add('disabled');
|
label.textContent = '禁用';
|
label.className = 'toggle-label inactive';
|
}
|
});
|
|
// 更新状态栏
|
updateStatusBar();
|
}
|
|
// 更新状态栏信息
|
function updateStatusBar() {
|
const enabledCount = document.querySelectorAll('.node-toggle:checked').length;
|
const disabledCount = nodeToggles.length - enabledCount;
|
|
document.getElementById('enabledCount').textContent = enabledCount;
|
document.getElementById('disabledCount').textContent = disabledCount;
|
|
const statusDetail = document.getElementById('statusDetail');
|
|
if (enabledCount === nodeToggles.length) {
|
statusDetail.textContent = '所有节点均已启用,流程可正常执行。';
|
} else if (disabledCount === nodeToggles.length) {
|
statusDetail.textContent = '所有节点均已禁用,流程无法执行。';
|
} else if (disabledCount === 1) {
|
statusDetail.textContent = '有1个节点被禁用,流程将跳过该节点执行。';
|
} else {
|
statusDetail.textContent = `有${disabledCount}个节点被禁用,流程将跳过这些节点执行。`;
|
}
|
}
|
|
// 为每个切换开关添加事件监听
|
nodeToggles.forEach(toggle => {
|
toggle.addEventListener('change', updateProcessLine);
|
});
|
|
// 保存配置按钮
|
document.getElementById('saveBtn').addEventListener('click', function() {
|
const config = {};
|
nodeToggles.forEach(toggle => {
|
config[toggle.dataset.node] = toggle.checked;
|
});
|
|
// 在实际应用中,这里会发送配置到服务器
|
// 现在只显示一个提示
|
alert('配置已保存!\n\n当前配置:\n' +
|
JSON.stringify(config, null, 2));
|
|
// 添加视觉反馈
|
this.textContent = '保存成功!';
|
this.style.backgroundColor = '#2ecc71';
|
|
setTimeout(() => {
|
this.textContent = '保存配置';
|
this.style.backgroundColor = '#3498db';
|
}, 1500);
|
});
|
|
// 重置按钮
|
document.getElementById('resetBtn').addEventListener('click', function() {
|
if (confirm('确定要重置所有节点配置为默认状态吗?')) {
|
nodeToggles.forEach(toggle => {
|
// 结束节点始终启用且不可更改
|
if (toggle.dataset.node === 'end') {
|
toggle.checked = true;
|
toggle.disabled = true;
|
} else {
|
toggle.checked = true;
|
}
|
});
|
|
updateProcessLine();
|
|
// 添加视觉反馈
|
this.textContent = '已重置!';
|
this.style.backgroundColor = '#9b59b6';
|
|
setTimeout(() => {
|
this.textContent = '重置为默认';
|
this.style.backgroundColor = '#ecf0f1';
|
}, 1500);
|
}
|
});
|
|
// 为节点指示器添加点击切换功能
|
document.querySelectorAll('.node-indicator').forEach(indicator => {
|
// 跳过结束节点,因为它不可禁用
|
if (indicator.id === 'node-end') return;
|
|
indicator.addEventListener('click', function() {
|
const nodeId = this.id.replace('node-', '');
|
const toggle = document.querySelector(`.node-toggle[data-node="${nodeId}"]`);
|
|
if (toggle && !toggle.disabled) {
|
toggle.checked = !toggle.checked;
|
toggle.dispatchEvent(new Event('change'));
|
}
|
});
|
});
|
|
// 初始化状态
|
updateProcessLine();
|
});
|
</script>
|
</body>
|
</html>
|