首次提交
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
# README
|
||||
|
||||
|
||||
回顾一下从头开始配置 Django 项目以展示你的 `zjptjg` 前端组件的主要步骤:
|
||||
|
||||
1. **项目结构确认**: 我们确认了你的项目结构,包含独立的 `backend` (Django) 和 `frontend` (HTML/CSS/JS) 目录。
|
||||
2. **创建 Django 应用**: 你创建了名为 `zjptjg` 的 Django 应用 (`python manage.py startapp zjptjg`) 并将其添加到了 `settings.py` 的 `INSTALLED_APPS` 中。
|
||||
3. **配置主 URL 路由**:
|
||||
|
||||
* 编辑了项目的主 `urls.py` 文件 (`backend/MDP/MDP/urls.py`)。
|
||||
* 导入了 `include` 函数。
|
||||
* 添加了 `path('zjptjg/', include('zjptjg.urls'))`,将所有访问 `/zjptjg/` 开头的请求转发给 `zjptjg` 应用处理。
|
||||
4. **配置应用 URL 路由**:
|
||||
|
||||
* 在 `zjptjg` 应用目录下创建了 `urls.py` 文件。
|
||||
* 在 `zjptjg/urls.py` 中定义了 `path('', views.index, name='zjptjg_index')`,将 `/zjptjg/` (即空路径,相对于应用根路径) 指向名为 `index` 的视图函数。
|
||||
5. **创建视图函数**:
|
||||
|
||||
* 编辑了 `zjptjg/views.py` 文件。
|
||||
* 创建了名为 `index` 的函数。
|
||||
* 这个函数最终的作用是使用 `render(request, 'MDP/zjptjg/index.html')` 来渲染你的 HTML 文件。*(我们中间尝试过让它从数据库获取数据,但后来还原了)*
|
||||
6. **配置模板目录**:
|
||||
|
||||
* 编辑了 `settings.py` 文件 (`backend/MDP/MDP/settings.py`)。
|
||||
* 修改了 `TEMPLATES` 设置中的 `DIRS` 列表,加入了前端目录的路径 `[os.path.join(BASE_DIR.parent.parent, 'frontend')]`。这使得 Django 能够找到位于 `frontend` 目录下的 HTML 模板。
|
||||
7. **配置静态文件目录**:
|
||||
|
||||
* 同样在 `settings.py` 文件中。
|
||||
* 确认 `STATIC_URL = 'static/'`。
|
||||
* 添加了 `STATICFILES_DIRS = [os.path.join(BASE_DIR.parent.parent, 'frontend')]`。这使得 Django 的开发服务器 (`runserver`) 能够找到位于 `frontend` 目录下的 CSS 和 JS 文件。
|
||||
8. **修改 HTML 以使用静态文件标签**:
|
||||
|
||||
* 编辑了你的 `index.html` 文件 (`frontend/MDP/zjptjg/index.html`)。
|
||||
* 在文件顶部添加了 `{% load static %}`。
|
||||
* 将链接 CSS 的 `<link>` 标签的 `href` 修改为 `{% static 'MDP/zjptjg/style.css' %}`。
|
||||
* 将引用 JS 的 `<script>` 标签的 `src` 修改为 `{% static 'MDP/zjptjg/script.js' %}`。
|
||||
* 这利用了 Django 的静态文件处理机制来确保 CSS 和 JS 文件能被正确加载。
|
||||
9. **(已还原) 模型和 Admin**:
|
||||
|
||||
* 我们曾尝试创建 `GeneralMachineSetting` 和 `StepSetting` 模型来匹配前端数据,并在 Admin 后台注册了它们。
|
||||
* 之后根据你的要求,我们**撤销了**这些模型的创建、Admin 注册以及相关的数据库迁移操作。
|
||||
10. **创建 Admin 超级用户**:
|
||||
|
||||
* 运行了 `python manage.py createsuperuser` 命令,设置了访问 `/admin` 后台所需的管理员账号和密码。
|
||||
11. **运行和测试**:
|
||||
|
||||
* 使用 `python manage.py runserver` 启动了 Django 开发服务器。
|
||||
* 通过访问 `http://127.0.0.1:8000/zjptjg/` 来查看页面效果。
|
||||
* 通过访问 `http://127.0.0.1:8000/admin/` 来登录管理后台。
|
||||
|
||||
**总结:** 核心目标是让 Django 正确地找到并提供你的 HTML、CSS 和 JS 文件。关键配置在于 `settings.py` 中的 `TEMPLATES['DIRS']` 和 `STATICFILES_DIRS`,以及在 HTML 中使用 `{% static %}` 标签来引用静态资源。
|
||||
@@ -0,0 +1,16 @@
|
||||
"""
|
||||
ASGI config for MDP project.
|
||||
|
||||
It exposes the ASGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/5.1/howto/deployment/asgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.asgi import get_asgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'MDP.settings')
|
||||
|
||||
application = get_asgi_application()
|
||||
@@ -0,0 +1,130 @@
|
||||
"""
|
||||
Django settings for MDP project.
|
||||
|
||||
Generated by 'django-admin startproject' using Django 5.1.7.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/5.1/topics/settings/
|
||||
|
||||
For the full list of settings and their values, see
|
||||
https://docs.djangoproject.com/en/5.1/ref/settings/
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
import os # 导入 os 模块
|
||||
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = 'django-insecure-zu^ow%m3i!!&zcxnt&ixfpt*5z^wfh_9=urka+gju2r_xd(u*-'
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = []
|
||||
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'zjptjg.apps.ZjptjgConfig'
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'MDP.urls'
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [os.path.join(BASE_DIR.parent.parent, 'frontend')],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
'django.template.context_processors.debug',
|
||||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
WSGI_APPLICATION = 'MDP.wsgi.application'
|
||||
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': BASE_DIR / 'db.sqlite3',
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators
|
||||
|
||||
AUTH_PASSWORD_VALIDATORS = [
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/5.1/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
|
||||
TIME_ZONE = 'UTC'
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/5.1/howto/static-files/
|
||||
|
||||
STATIC_URL = 'static/'
|
||||
|
||||
# 添加额外的静态文件查找目录
|
||||
STATICFILES_DIRS = [
|
||||
os.path.join(BASE_DIR.parent.parent, 'frontend'),
|
||||
]
|
||||
|
||||
# Default primary key field type
|
||||
# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||
@@ -0,0 +1,23 @@
|
||||
"""
|
||||
URL configuration for MDP project.
|
||||
|
||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||
https://docs.djangoproject.com/en/5.1/topics/http/urls/
|
||||
Examples:
|
||||
Function views
|
||||
1. Add an import: from my_app import views
|
||||
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
||||
Class-based views
|
||||
1. Add an import: from other_app.views import Home
|
||||
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
||||
Including another URLconf
|
||||
1. Import the include() function: from django.urls import include, path
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.contrib import admin
|
||||
from django.urls import path, include
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path('zjptjg/', include('zjptjg.urls')),
|
||||
]
|
||||
@@ -0,0 +1,16 @@
|
||||
"""
|
||||
WSGI config for MDP project.
|
||||
|
||||
It exposes the WSGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/5.1/howto/deployment/wsgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'MDP.settings')
|
||||
|
||||
application = get_wsgi_application()
|
||||
Binary file not shown.
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python
|
||||
"""Django's command-line utility for administrative tasks."""
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
"""Run administrative tasks."""
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'MDP.settings')
|
||||
try:
|
||||
from django.core.management import execute_from_command_line
|
||||
except ImportError as exc:
|
||||
raise ImportError(
|
||||
"Couldn't import Django. Are you sure it's installed and "
|
||||
"available on your PYTHONPATH environment variable? Did you "
|
||||
"forget to activate a virtual environment?"
|
||||
) from exc
|
||||
execute_from_command_line(sys.argv)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
@@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class ZjptjgConfig(AppConfig):
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "zjptjg"
|
||||
@@ -0,0 +1,3 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
@@ -0,0 +1,7 @@
|
||||
from django.urls import path
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
path('', views.index, name='zjptjg_index'), # 访问 /zjptjg/ 时调用的视图
|
||||
# 其他路由
|
||||
]
|
||||
@@ -0,0 +1,7 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
def index(request):
|
||||
"""处理 /zjptjg/ 的请求,渲染前端页面"""
|
||||
# 直接渲染静态模板,不传递额外上下文
|
||||
return render(request, 'MDP/zjptjg/index.html')
|
||||
@@ -0,0 +1,80 @@
|
||||
{% load static %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>一般机构组件</title>
|
||||
<link rel="stylesheet" href="{% static 'MDP/zjptjg/style.css' %}">
|
||||
</head>
|
||||
<body>
|
||||
<!-- Main Component Display -->
|
||||
<div id="machine-component" class="machine-component">
|
||||
<div class="header">
|
||||
<span id="machine-name-display">一般机构</span>
|
||||
<div class="status-indicator"></div>
|
||||
</div>
|
||||
<div class="info-grid">
|
||||
<div class="info-label">当前步骤</div>
|
||||
<div id="current-step" class="info-value">第一步</div>
|
||||
<div class="info-label">理论产能</div>
|
||||
<div id="theoretical-ppm" class="info-value">60.00PPM</div>
|
||||
<div class="info-label">当前产能</div>
|
||||
<div id="current-ppm" class="info-value">59.05PPM</div>
|
||||
</div>
|
||||
<div id="machine-status" class="status-text">等待下料</div>
|
||||
</div>
|
||||
|
||||
<!-- Settings Modal -->
|
||||
<div id="settings-modal" class="modal-overlay" style="display: none;">
|
||||
<div class="modal-content">
|
||||
<!-- Fixed Header -->
|
||||
<div class="modal-fixed-header">
|
||||
<div class="modal-header">
|
||||
<span id="modal-title">编辑-一般机构</span>
|
||||
<button id="close-modal-btn" class="close-btn">×</button>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="machine-name-input">机构名称:</label>
|
||||
<input type="text" id="machine-name-input" value="一般机构" required>
|
||||
<span class="error-message" id="machine-name-error"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="batch-quantity-input">批量处理数量:</label>
|
||||
<input type="number" id="batch-quantity-input" value="1" min="0" step="1" placeholder="0代表禁用">
|
||||
<span class="error-message" id="batch-quantity-error"></span>
|
||||
</div>
|
||||
<legend class="steps-legend">步骤设置:</legend>
|
||||
</div>
|
||||
|
||||
<!-- Scrollable Steps Area -->
|
||||
<div class="modal-scrollable-steps">
|
||||
<div id="steps-container">
|
||||
<!-- Steps will be added here by JS -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Fixed Footer -->
|
||||
<div class="modal-fixed-footer">
|
||||
<button id="add-step-btn" class="add-btn">添加步骤</button>
|
||||
<div class="form-group cache-group">
|
||||
<input type="checkbox" id="has-cache-checkbox">
|
||||
<label for="has-cache-checkbox">是否有缓存</label>
|
||||
<input type="number" id="cache-quantity-input" min="1" step="1" placeholder="必须>0的整数" disabled>
|
||||
<span class="error-message" id="cache-quantity-error"></span>
|
||||
</div>
|
||||
<div class="summary-section">
|
||||
<span>总耗时: <span id="total-time-display">0.00</span>秒</span>
|
||||
<span>理论产能: <span id="calculated-ppm-display">0.00</span>PPM</span>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button id="save-settings-btn" class="save-btn">保存</button>
|
||||
<button id="cancel-settings-btn" class="cancel-btn">取消</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="{% static 'MDP/zjptjg/script.js' %}"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,436 @@
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
// --- DOM Elements ---
|
||||
const machineComponent = document.getElementById('machine-component');
|
||||
const settingsModal = document.getElementById('settings-modal');
|
||||
const closeModalBtn = document.getElementById('close-modal-btn');
|
||||
const cancelSettingsBtn = document.getElementById('cancel-settings-btn');
|
||||
const saveSettingsBtn = document.getElementById('save-settings-btn');
|
||||
const addStepBtn = document.getElementById('add-step-btn');
|
||||
const stepsContainer = document.getElementById('steps-container');
|
||||
const machineNameInput = document.getElementById('machine-name-input');
|
||||
const batchQuantityInput = document.getElementById('batch-quantity-input');
|
||||
const hasCacheCheckbox = document.getElementById('has-cache-checkbox');
|
||||
const cacheQuantityInput = document.getElementById('cache-quantity-input');
|
||||
const totalTimeDisplay = document.getElementById('total-time-display');
|
||||
const calculatedPpmDisplay = document.getElementById('calculated-ppm-display');
|
||||
const machineNameDisplay = document.getElementById('machine-name-display');
|
||||
const theoreticalPpmDisplay = document.getElementById('theoretical-ppm');
|
||||
const modalTitle = document.getElementById('modal-title');
|
||||
const statusIndicator = machineComponent.querySelector('.status-indicator');
|
||||
const machineStatus = document.getElementById('machine-status');
|
||||
|
||||
// --- State ---
|
||||
let steps = []; // Array to hold step data
|
||||
let initialSettings = {}; // 恢复为空对象
|
||||
let isActive = false; // 恢复状态变量
|
||||
let isDisabled = false;
|
||||
|
||||
// --- Functions ---
|
||||
const updateMachineStatus = (newStatusText) => {
|
||||
machineStatus.textContent = newStatusText;
|
||||
statusIndicator.classList.remove('active', 'disabled'); // 清除状态
|
||||
isDisabled = false;
|
||||
isActive = false;
|
||||
if (newStatusText === '运行中') {
|
||||
statusIndicator.classList.add('active');
|
||||
isActive = true;
|
||||
} else if (newStatusText === '禁用中') {
|
||||
statusIndicator.classList.add('disabled');
|
||||
isDisabled = true;
|
||||
} else {
|
||||
// 默认黄色脉冲,不需要特定类
|
||||
}
|
||||
// 恢复存储状态逻辑
|
||||
if (initialSettings) {
|
||||
initialSettings.statusText = newStatusText;
|
||||
initialSettings.isActive = isActive;
|
||||
initialSettings.isDisabled = isDisabled;
|
||||
}
|
||||
};
|
||||
|
||||
// --- Validation Helpers ---
|
||||
const clearValidationErrors = () => {
|
||||
const errorMessages = settingsModal.querySelectorAll('.error-message');
|
||||
errorMessages.forEach(msg => {
|
||||
msg.textContent = '';
|
||||
msg.style.display = 'none';
|
||||
});
|
||||
const invalidInputs = settingsModal.querySelectorAll('.invalid');
|
||||
invalidInputs.forEach(input => input.classList.remove('invalid'));
|
||||
};
|
||||
|
||||
const showValidationError = (inputElement, message) => {
|
||||
inputElement.classList.add('invalid');
|
||||
const errorSpanId = inputElement.id + '-error'; // Assumes error span ID convention
|
||||
const errorSpan = document.getElementById(errorSpanId);
|
||||
if (errorSpan) {
|
||||
errorSpan.textContent = message;
|
||||
errorSpan.style.display = 'block';
|
||||
}
|
||||
// Focus the first invalid element found
|
||||
if (!settingsModal.querySelector('.invalid:focus')) {
|
||||
inputElement.focus();
|
||||
}
|
||||
};
|
||||
|
||||
// Function to remove error state when user types
|
||||
const clearErrorOnInput = (event) => {
|
||||
const inputElement = event.target;
|
||||
inputElement.classList.remove('invalid');
|
||||
const errorSpanId = inputElement.id + '-error';
|
||||
const errorSpan = document.getElementById(errorSpanId);
|
||||
if (errorSpan) {
|
||||
errorSpan.textContent = '';
|
||||
errorSpan.style.display = 'none';
|
||||
}
|
||||
};
|
||||
|
||||
// --- Main Validation Logic ---
|
||||
const validateSettings = () => {
|
||||
clearValidationErrors();
|
||||
let isValid = true;
|
||||
const errors = [];
|
||||
|
||||
// 1. Check Machine Name
|
||||
if (!machineNameInput.value.trim()) {
|
||||
showValidationError(machineNameInput, '机构名称不能为空');
|
||||
isValid = false;
|
||||
errors.push('机构名称不能为空');
|
||||
}
|
||||
|
||||
// 2. Check Batch Quantity
|
||||
const batchQuantityValue = batchQuantityInput.value;
|
||||
if (batchQuantityValue === '' || !Number.isInteger(Number(batchQuantityValue)) || Number(batchQuantityValue) < 0) {
|
||||
showValidationError(batchQuantityInput, '批量处理数量必须是非负整数');
|
||||
isValid = false;
|
||||
errors.push('批量处理数量必须是非负整数');
|
||||
}
|
||||
|
||||
// 3. Check Steps
|
||||
steps.forEach((step, index) => {
|
||||
const stepIndexDisplay = index + 1;
|
||||
// Check Step Name
|
||||
if (!step.nameInput.value.trim()) {
|
||||
showValidationError(step.nameInput, `步骤 ${stepIndexDisplay} 名称不能为空`);
|
||||
isValid = false;
|
||||
errors.push(`步骤 ${stepIndexDisplay} 名称不能为空`);
|
||||
}
|
||||
// Add listeners to step inputs dynamically if not already added
|
||||
if (!step.nameInput.dataset.listenerAdded) {
|
||||
step.nameInput.addEventListener('input', clearErrorOnInput);
|
||||
step.nameInput.dataset.listenerAdded = 'true';
|
||||
}
|
||||
// Note: We are not validating start/work time based on requirements, only name
|
||||
});
|
||||
|
||||
// 4. Check Cache Quantity (if applicable)
|
||||
if (hasCacheCheckbox.checked) {
|
||||
const cacheQuantityValue = cacheQuantityInput.value;
|
||||
if (cacheQuantityValue === '' || !Number.isInteger(Number(cacheQuantityValue)) || Number(cacheQuantityValue) <= 0) {
|
||||
showValidationError(cacheQuantityInput, '缓存数量必须是大于0的整数');
|
||||
isValid = false;
|
||||
errors.push('缓存数量必须是大于0的整数');
|
||||
}
|
||||
}
|
||||
|
||||
if (!isValid) {
|
||||
// Optionally display a summary alert, though inline errors are better UX
|
||||
// alert('请修正以下错误:\n- ' + errors.join('\n- '));
|
||||
}
|
||||
|
||||
return isValid;
|
||||
};
|
||||
|
||||
// Calculate Total Time and Theoretical PPM
|
||||
const calculateMetrics = () => {
|
||||
let totalDuration = 0;
|
||||
let maxEndTime = 0;
|
||||
|
||||
steps.forEach(step => {
|
||||
const startTime = parseFloat(step.startTimeInput.value) || 0;
|
||||
const workTime = parseFloat(step.workTimeInput.value) || 0;
|
||||
const endTime = startTime + workTime;
|
||||
if (endTime > maxEndTime) {
|
||||
maxEndTime = endTime;
|
||||
}
|
||||
});
|
||||
|
||||
totalDuration = maxEndTime;
|
||||
totalTimeDisplay.textContent = totalDuration.toFixed(2);
|
||||
|
||||
const batchQuantityRaw = batchQuantityInput.value;
|
||||
let batchQuantity = 1; // Default if invalid for calculation display
|
||||
|
||||
// Use valid integer for calculation, default to 1 if invalid or 0
|
||||
if (batchQuantityRaw !== '' && Number.isInteger(Number(batchQuantityRaw)) && Number(batchQuantityRaw) > 0) {
|
||||
batchQuantity = parseInt(batchQuantityRaw);
|
||||
}
|
||||
|
||||
let calculatedPpm = 0;
|
||||
if (totalDuration > 0) {
|
||||
calculatedPpm = (60 / totalDuration) * batchQuantity;
|
||||
}
|
||||
calculatedPpmDisplay.textContent = calculatedPpm.toFixed(2);
|
||||
};
|
||||
|
||||
// Update Step Titles (e.g., "步骤 1", "步骤 2")
|
||||
const updateStepTitles = () => {
|
||||
steps.forEach((step, index) => {
|
||||
step.element.querySelector('.step-title').textContent = `步骤 ${index + 1}`;
|
||||
step.element.dataset.index = index; // Update data-index for reordering
|
||||
});
|
||||
calculateMetrics(); // Recalculate when steps change order/number
|
||||
};
|
||||
|
||||
// Create HTML for a single step
|
||||
const createStepElement = (stepData = {}, index) => {
|
||||
const stepId = `step-${Date.now()}-${Math.random()}`;
|
||||
const stepDiv = document.createElement('div');
|
||||
stepDiv.classList.add('step-item');
|
||||
stepDiv.id = stepId;
|
||||
stepDiv.dataset.index = index;
|
||||
|
||||
stepDiv.innerHTML = `
|
||||
<div class="step-header">
|
||||
<span class="step-title">步骤 ${index + 1}</span>
|
||||
<div class="step-controls">
|
||||
<button class="step-btn move-up-btn" title="上移">↑</button>
|
||||
<button class="step-btn move-down-btn" title="下移">↓</button>
|
||||
<button class="step-btn delete-step-btn" title="删除">✖</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="step-inputs">
|
||||
<div class="form-group">
|
||||
<label for="step-name-${stepId}">名称:</label>
|
||||
<input type="text" id="step-name-${stepId}" class="step-name-input" value="${stepData.name || `步骤${index + 1}`}" maxlength="12" required>
|
||||
<span class="error-message step-error" id="step-name-error-${stepId}"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="step-start-${stepId}">开始时间(秒):</label>
|
||||
<input type="number" id="step-start-${stepId}" class="step-start-input" value="${stepData.startTime || 0}" min="0" step="0.1">
|
||||
<span class="error-message step-error" id="step-start-error-${stepId}"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="step-work-${stepId}">工作时间(秒):</label>
|
||||
<input type="number" id="step-work-${stepId}" class="step-work-input" value="${stepData.workTime || 0}" min="0" step="0.1">
|
||||
<span class="error-message step-error" id="step-work-error-${stepId}"></span>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
// Add event listeners for controls within this step
|
||||
stepDiv.querySelector('.delete-step-btn').addEventListener('click', () => deleteStep(stepId));
|
||||
stepDiv.querySelector('.move-up-btn').addEventListener('click', () => moveStep(stepId, -1));
|
||||
stepDiv.querySelector('.move-down-btn').addEventListener('click', () => moveStep(stepId, 1));
|
||||
|
||||
// Add listeners to inputs for real-time calculation and error clearing
|
||||
const nameInput = stepDiv.querySelector('.step-name-input');
|
||||
const startTimeInput = stepDiv.querySelector('.step-start-input');
|
||||
const workTimeInput = stepDiv.querySelector('.step-work-input');
|
||||
|
||||
[startTimeInput, workTimeInput, batchQuantityInput].forEach(input => {
|
||||
input.addEventListener('input', calculateMetrics);
|
||||
});
|
||||
// Add input listener for validation clearing (only needed once per element)
|
||||
if (!nameInput.dataset.listenerAdded) {
|
||||
nameInput.addEventListener('input', clearErrorOnInput);
|
||||
nameInput.dataset.listenerAdded = 'true';
|
||||
}
|
||||
|
||||
return { element: stepDiv, id: stepId, nameInput, startTimeInput, workTimeInput };
|
||||
};
|
||||
|
||||
// Add a new step
|
||||
const addStep = (stepData = {}) => {
|
||||
const newIndex = steps.length;
|
||||
const newStep = createStepElement(stepData, newIndex);
|
||||
stepsContainer.appendChild(newStep.element);
|
||||
steps.push(newStep);
|
||||
updateStepTitles();
|
||||
};
|
||||
|
||||
// Delete a step
|
||||
const deleteStep = (stepId) => {
|
||||
const stepIndex = steps.findIndex(s => s.id === stepId);
|
||||
if (stepIndex > -1) {
|
||||
steps[stepIndex].element.remove();
|
||||
steps.splice(stepIndex, 1);
|
||||
updateStepTitles();
|
||||
}
|
||||
};
|
||||
|
||||
// Move a step up or down
|
||||
const moveStep = (stepId, direction) => {
|
||||
const index = steps.findIndex(s => s.id === stepId);
|
||||
const newIndex = index + direction;
|
||||
|
||||
if (newIndex >= 0 && newIndex < steps.length) {
|
||||
// Visual feedback
|
||||
const currentElement = steps[index].element;
|
||||
currentElement.classList.add('moving');
|
||||
setTimeout(() => {
|
||||
currentElement.classList.remove('moving');
|
||||
// Also remove from the swapped element if it had the class briefly
|
||||
if (steps[newIndex] && steps[newIndex].element) {
|
||||
steps[newIndex].element.classList.remove('moving');
|
||||
}
|
||||
}, 300); // Match CSS transition duration
|
||||
|
||||
// Swap in the steps array
|
||||
[steps[index], steps[newIndex]] = [steps[newIndex], steps[index]];
|
||||
|
||||
// Re-insert elements in the DOM based on the new order
|
||||
stepsContainer.innerHTML = ''; // Clear container
|
||||
steps.forEach(step => stepsContainer.appendChild(step.element)); // Re-append in new order
|
||||
|
||||
updateStepTitles();
|
||||
}
|
||||
};
|
||||
|
||||
// Toggle Cache Quantity Input
|
||||
const toggleCacheInput = () => {
|
||||
const isChecked = hasCacheCheckbox.checked;
|
||||
cacheQuantityInput.disabled = !isChecked;
|
||||
if (isChecked) {
|
||||
cacheQuantityInput.required = true; // Make required when checked
|
||||
} else {
|
||||
cacheQuantityInput.required = false; // Not required when unchecked
|
||||
cacheQuantityInput.value = ''; // Clear value when disabled
|
||||
// Clear potential validation error when disabling
|
||||
cacheQuantityInput.classList.remove('invalid');
|
||||
const errorSpan = document.getElementById('cache-quantity-input-error');
|
||||
if (errorSpan) {
|
||||
errorSpan.textContent = '';
|
||||
errorSpan.style.display = 'none';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Open Settings Modal
|
||||
const openModal = () => {
|
||||
clearValidationErrors();
|
||||
// 恢复为从当前状态存储设置
|
||||
initialSettings = {
|
||||
name: machineNameInput.value,
|
||||
batchQuantity: batchQuantityInput.value,
|
||||
hasCache: hasCacheCheckbox.checked,
|
||||
cacheQuantity: cacheQuantityInput.value,
|
||||
stepsData: steps.map(s => ({
|
||||
name: s.nameInput.value,
|
||||
startTime: s.startTimeInput.value,
|
||||
workTime: s.workTimeInput.value
|
||||
})),
|
||||
isActive: statusIndicator.classList.contains('active'),
|
||||
isDisabled: statusIndicator.classList.contains('disabled'),
|
||||
statusText: machineStatus.textContent,
|
||||
theoreticalPPM: theoreticalPpmDisplay.textContent,
|
||||
currentStep: document.getElementById('current-step').textContent,
|
||||
currentPPM: document.getElementById('current-ppm').textContent
|
||||
};
|
||||
// 恢复从JS状态重建模态框步骤
|
||||
stepsContainer.innerHTML = '';
|
||||
steps = [];
|
||||
initialSettings.stepsData.forEach(stepData => addStep(stepData));
|
||||
|
||||
modalTitle.textContent = `编辑-${initialSettings.name || '一般机构'}`;
|
||||
toggleCacheInput();
|
||||
calculateMetrics();
|
||||
settingsModal.style.display = 'flex';
|
||||
};
|
||||
|
||||
// Close Settings Modal
|
||||
const closeModal = () => {
|
||||
settingsModal.style.display = 'none';
|
||||
};
|
||||
|
||||
// Revert settings to initial state (on cancel or 'X' click)
|
||||
const revertSettings = () => {
|
||||
clearValidationErrors();
|
||||
machineNameInput.value = initialSettings.name;
|
||||
batchQuantityInput.value = initialSettings.batchQuantity;
|
||||
hasCacheCheckbox.checked = initialSettings.hasCache;
|
||||
cacheQuantityInput.value = initialSettings.cacheQuantity;
|
||||
toggleCacheInput();
|
||||
|
||||
stepsContainer.innerHTML = '';
|
||||
steps = [];
|
||||
initialSettings.stepsData.forEach(stepData => addStep(stepData));
|
||||
|
||||
// 恢复主显示状态
|
||||
machineNameDisplay.textContent = initialSettings.name;
|
||||
theoreticalPpmDisplay.textContent = initialSettings.theoreticalPPM;
|
||||
updateMachineStatus(initialSettings.statusText);
|
||||
document.getElementById('current-step').textContent = initialSettings.currentStep;
|
||||
document.getElementById('current-ppm').textContent = initialSettings.currentPPM;
|
||||
|
||||
closeModal();
|
||||
};
|
||||
|
||||
// Save Settings
|
||||
const saveSettings = () => {
|
||||
if (!validateSettings()) {
|
||||
console.log("Validation failed.");
|
||||
return;
|
||||
}
|
||||
console.log("Validation passed.");
|
||||
|
||||
const newName = machineNameInput.value.trim();
|
||||
const batchQty = parseInt(batchQuantityInput.value);
|
||||
|
||||
machineNameDisplay.textContent = newName;
|
||||
calculateMetrics();
|
||||
theoreticalPpmDisplay.textContent = calculatedPpmDisplay.textContent + 'PPM';
|
||||
|
||||
if (batchQty === 0) {
|
||||
updateMachineStatus('禁用中');
|
||||
} else {
|
||||
updateMachineStatus('运行中');
|
||||
}
|
||||
|
||||
document.getElementById('current-step').textContent = steps.length > 0 ? steps[0].nameInput.value : '无步骤';
|
||||
document.getElementById('current-ppm').textContent = '0.00PPM';
|
||||
|
||||
closeModal();
|
||||
};
|
||||
|
||||
// --- Event Listeners ---
|
||||
machineComponent.addEventListener('dblclick', openModal);
|
||||
closeModalBtn.addEventListener('click', revertSettings);
|
||||
cancelSettingsBtn.addEventListener('click', revertSettings);
|
||||
saveSettingsBtn.addEventListener('click', saveSettings);
|
||||
addStepBtn.addEventListener('click', () => addStep());
|
||||
hasCacheCheckbox.addEventListener('change', toggleCacheInput);
|
||||
machineNameInput.addEventListener('input', clearErrorOnInput);
|
||||
batchQuantityInput.addEventListener('input', clearErrorOnInput);
|
||||
cacheQuantityInput.addEventListener('input', clearErrorOnInput);
|
||||
|
||||
// --- Initialization ---
|
||||
const initialize = () => {
|
||||
// 恢复添加默认步骤
|
||||
addStep({ name: '步骤1', startTime: 0, workTime: 3 });
|
||||
addStep({ name: '步骤2', startTime: 2, workTime: 3 });
|
||||
|
||||
// 恢复设置默认值
|
||||
machineNameInput.value = '一般机构';
|
||||
batchQuantityInput.value = 1;
|
||||
hasCacheCheckbox.checked = true;
|
||||
cacheQuantityInput.value = 3;
|
||||
toggleCacheInput();
|
||||
|
||||
machineNameDisplay.textContent = machineNameInput.value;
|
||||
calculateMetrics();
|
||||
theoreticalPpmDisplay.textContent = calculatedPpmDisplay.textContent + 'PPM';
|
||||
|
||||
document.getElementById('current-step').textContent = '步骤1';
|
||||
document.getElementById('current-ppm').textContent = '0.00PPM';
|
||||
updateMachineStatus('等待中');
|
||||
|
||||
// 恢复存储初始理论PPM
|
||||
if (!initialSettings.theoreticalPPM) {
|
||||
initialSettings.theoreticalPPM = theoreticalPpmDisplay.textContent;
|
||||
}
|
||||
clearValidationErrors();
|
||||
};
|
||||
|
||||
initialize();
|
||||
});
|
||||
@@ -0,0 +1,679 @@
|
||||
/* 全局和页面基础样式 */
|
||||
body {
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
background-color: #f4f7f6; /* 页面背景色 */
|
||||
display: flex;
|
||||
justify-content: center; /* 水平居中 */
|
||||
align-items: center; /* 垂直居中 */
|
||||
min-height: 100vh;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* --- 主组件显示区域样式 --- */
|
||||
.machine-component {
|
||||
background-color: #ffffff; /* 组件背景色 */
|
||||
border-radius: 12px; /* 圆角 */
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); /* 阴影 */
|
||||
padding: 15px; /* Adjusted padding */
|
||||
max-width: 350px; /* Max width on larger screens */
|
||||
width: 90%; /* Relative width on smaller screens */
|
||||
margin: 10px; /* Add some margin */
|
||||
cursor: pointer; /* 鼠标样式 */
|
||||
transition: box-shadow 0.3s ease; /* 阴影过渡效果 */
|
||||
border: 1px solid #e0e0e0; /* 边框 */
|
||||
}
|
||||
|
||||
.machine-component:hover {
|
||||
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12); /* 鼠标悬浮时阴影加强 */
|
||||
}
|
||||
|
||||
/* 主组件头部 */
|
||||
.header {
|
||||
display: flex;
|
||||
justify-content: space-between; /* 两端对齐 */
|
||||
align-items: center; /* 垂直居中 */
|
||||
margin-bottom: 15px;
|
||||
padding-bottom: 10px;
|
||||
border-bottom: 1px solid #eee; /* 底部边框分割线 */
|
||||
}
|
||||
|
||||
/* 主组件 - 机构名称 */
|
||||
#machine-name-display {
|
||||
font-size: 1.2em;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
/* 主组件 - 状态指示灯 */
|
||||
.status-indicator {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
border-radius: 50%; /* 圆形 */
|
||||
background-color: #ffc107; /* Default Yellow for waiting */
|
||||
transition: background-color 0.3s ease; /* Keep transition for color change */
|
||||
/* Apply default yellow pulse animation */
|
||||
animation: pulse-yellow 1.5s infinite;
|
||||
}
|
||||
|
||||
/* Active state overrides */
|
||||
.status-indicator.active {
|
||||
background-color: #4CAF50; /* Green when active */
|
||||
animation-name: pulse-green; /* Change animation name */
|
||||
}
|
||||
|
||||
/* Disabled state overrides */
|
||||
.status-indicator.disabled {
|
||||
background-color: #dc3545; /* Red when disabled */
|
||||
animation-name: pulse-red; /* Use red pulse */
|
||||
}
|
||||
|
||||
/* Define the GREEN pulse animation */
|
||||
@keyframes pulse-green {
|
||||
0% {
|
||||
box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.5); /* Green shadow */
|
||||
}
|
||||
70% {
|
||||
box-shadow: 0 0 0 8px rgba(76, 175, 80, 0);
|
||||
}
|
||||
100% {
|
||||
box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Define the YELLOW pulse animation */
|
||||
@keyframes pulse-yellow {
|
||||
0% {
|
||||
box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.5); /* Yellow shadow */
|
||||
}
|
||||
70% {
|
||||
box-shadow: 0 0 0 8px rgba(255, 193, 7, 0);
|
||||
}
|
||||
100% {
|
||||
box-shadow: 0 0 0 0 rgba(255, 193, 7, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Define the RED pulse animation */
|
||||
@keyframes pulse-red {
|
||||
0% {
|
||||
box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.5); /* Red shadow */
|
||||
}
|
||||
70% {
|
||||
box-shadow: 0 0 0 8px rgba(220, 53, 69, 0);
|
||||
}
|
||||
100% {
|
||||
box-shadow: 0 0 0 0 rgba(220, 53, 69, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* 主组件 - 信息网格布局 */
|
||||
.info-grid {
|
||||
display: grid;
|
||||
grid-template-columns: auto 1fr; /* 标签自适应,值占满剩余空间 */
|
||||
gap: 8px 15px; /* 行间距 列间距 */
|
||||
margin-bottom: 15px;
|
||||
font-size: 0.95em;
|
||||
}
|
||||
|
||||
/* 主组件 - 信息标签 */
|
||||
.info-label {
|
||||
color: #555;
|
||||
font-weight: 500;
|
||||
text-align: right; /* 文本右对齐 */
|
||||
}
|
||||
|
||||
/* 主组件 - 信息值 */
|
||||
.info-value {
|
||||
color: #333;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* 主组件 - 底部状态文本 */
|
||||
.status-text {
|
||||
text-align: center;
|
||||
font-weight: 500;
|
||||
color: #666;
|
||||
padding-top: 10px;
|
||||
border-top: 1px solid #eee; /* 顶部边框分割线 */
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
/* --- 设置弹窗 (Modal) 样式 --- */
|
||||
|
||||
/* 弹窗遮罩层 */
|
||||
.modal-overlay {
|
||||
position: fixed; /* 固定定位,覆盖全屏 */
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.5); /* 半透明黑色背景 */
|
||||
display: flex;
|
||||
justify-content: center; /* 水平居中弹窗内容 */
|
||||
align-items: center; /* 垂直居中弹窗内容 */
|
||||
z-index: 1000; /* 置于顶层 */
|
||||
}
|
||||
|
||||
/* 弹窗内容区域 */
|
||||
.modal-content {
|
||||
background-color: #fff;
|
||||
border-radius: 10px; /* 圆角 */
|
||||
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
|
||||
max-width: 600px; /* Max width on larger screens */
|
||||
width: 90vw; /* Relative width */
|
||||
max-height: 90vh; /* 最大高度为视窗的90% */
|
||||
display: flex; /* Use flexbox for layout */
|
||||
flex-direction: column; /* Stack header, scroll, footer vertically */
|
||||
overflow: hidden; /* Re-add overflow hidden to clip children and enforce height */
|
||||
}
|
||||
|
||||
/* Remove scrollbar styles from .modal-content */
|
||||
/*
|
||||
.modal-content::-webkit-scrollbar { ... }
|
||||
.modal-content::-webkit-scrollbar-track { ... }
|
||||
.modal-content::-webkit-scrollbar-thumb { ... }
|
||||
.modal-content::-webkit-scrollbar-thumb:hover { ... }
|
||||
*/
|
||||
|
||||
/* Fixed Header Section */
|
||||
.modal-fixed-header {
|
||||
padding: 20px 25px 0 25px; /* Padding T, R/L, B */
|
||||
border-bottom: 1px solid #eee; /* Separator */
|
||||
}
|
||||
|
||||
.steps-legend {
|
||||
/* Styles for the moved legend */
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
padding: 10px 0 5px 0; /* Adjust padding */
|
||||
margin: 0; /* Remove default legend margin */
|
||||
font-size: 1.1em; /* Match step-title size */
|
||||
}
|
||||
|
||||
|
||||
/* Scrollable Steps Area */
|
||||
.modal-scrollable-steps {
|
||||
flex-grow: 1; /* Allow this section to take available vertical space */
|
||||
overflow-y: auto; /* Enable vertical scrolling ONLY for this section */
|
||||
padding: 15px 25px; /* Padding inside the scrollable area */
|
||||
/* Apply custom scrollbar styles HERE */
|
||||
scrollbar-width: thin; /* Firefox */
|
||||
scrollbar-color: #ccc #f4f4f4; /* Firefox */
|
||||
}
|
||||
|
||||
.modal-scrollable-steps::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
}
|
||||
|
||||
.modal-scrollable-steps::-webkit-scrollbar-track {
|
||||
background: #f4f4f4;
|
||||
border-radius: 10px;
|
||||
margin: 5px 0; /* Add slight margin */
|
||||
}
|
||||
|
||||
.modal-scrollable-steps::-webkit-scrollbar-thumb {
|
||||
background-color: #ccc;
|
||||
border-radius: 10px;
|
||||
border: 2px solid #f4f4f4;
|
||||
}
|
||||
|
||||
.modal-scrollable-steps::-webkit-scrollbar-thumb:hover {
|
||||
background-color: #aaa;
|
||||
}
|
||||
|
||||
/* Fixed Footer Section */
|
||||
.modal-fixed-footer {
|
||||
padding: 10px 25px 20px 25px; /* Padding T, R/L, B */
|
||||
border-top: 1px solid #eee; /* Separator */
|
||||
background-color: #fff; /* Ensure solid background */
|
||||
}
|
||||
|
||||
/* Adjustments for items moved to footer */
|
||||
.modal-fixed-footer .add-btn {
|
||||
margin-top: 10px; /* Adjust top margin */
|
||||
margin-bottom: 15px; /* Add bottom margin */
|
||||
}
|
||||
|
||||
.modal-fixed-footer .cache-group {
|
||||
margin-bottom: 15px; /* Add consistent margin */
|
||||
}
|
||||
|
||||
.modal-fixed-footer .summary-section {
|
||||
margin-top: 15px; /* Adjust top margin */
|
||||
padding-top: 0; /* Remove padding as border is above */
|
||||
border-top: none; /* Remove border as it's on footer now */
|
||||
}
|
||||
|
||||
.modal-fixed-footer .modal-footer {
|
||||
margin-top: 15px; /* Adjust top margin */
|
||||
padding-top: 0; /* Remove padding as border is above */
|
||||
border-top: none; /* Remove border as it's on footer now */
|
||||
}
|
||||
|
||||
|
||||
/* Remove original steps-config styling */
|
||||
/*
|
||||
.steps-config { ... }
|
||||
.steps-config legend { ... }
|
||||
*/
|
||||
|
||||
/* 弹窗头部 */
|
||||
.modal-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
border-bottom: 1px solid #eee;
|
||||
padding-bottom: 15px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
/* 弹窗标题 */
|
||||
#modal-title {
|
||||
font-size: 1.4em;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
/* 弹窗关闭按钮 */
|
||||
.close-btn {
|
||||
background: none;
|
||||
border: none;
|
||||
font-size: 1.8em;
|
||||
cursor: pointer;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.close-btn:hover {
|
||||
color: #333;
|
||||
}
|
||||
|
||||
/* 弹窗主体内容区域 */
|
||||
.modal-body {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
/* 通用表单组样式 */
|
||||
.form-group {
|
||||
margin-bottom: 15px;
|
||||
display: grid;
|
||||
grid-template-columns: 120px 1fr; /* 标签固定宽度,输入框占满剩余 - Default */
|
||||
align-items: center;
|
||||
gap: 5px 10px; /* Reduced gap slightly */
|
||||
}
|
||||
|
||||
/* 表单标签 */
|
||||
.form-group label {
|
||||
font-weight: 500;
|
||||
color: #555;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
/* 表单输入框 (文本和数字) */
|
||||
.form-group input[type="text"],
|
||||
.form-group input[type="number"] {
|
||||
padding: 8px 12px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 6px;
|
||||
font-size: 0.95em;
|
||||
transition: border-color 0.3s ease;
|
||||
}
|
||||
|
||||
/* 输入框获取焦点时样式 */
|
||||
.form-group input[type="text"]:focus,
|
||||
.form-group input[type="number"]:focus {
|
||||
border-color: #007bff; /* 边框变蓝 */
|
||||
outline: none; /* 移除默认轮廓 */
|
||||
}
|
||||
|
||||
/* 禁用的数字输入框 */
|
||||
.form-group input[type="number"][disabled] {
|
||||
background-color: #e9ecef;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
/* --- 步骤设置区域 --- */
|
||||
.steps-config {
|
||||
border: 1px solid #ddd; /* 边框 */
|
||||
border-radius: 8px; /* 圆角 */
|
||||
padding: 15px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
/* 步骤设置区域标题 */
|
||||
.steps-config legend {
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
/* 单个步骤项 */
|
||||
.step-item {
|
||||
border: 1px dashed #ccc; /* 虚线边框 */
|
||||
border-radius: 6px;
|
||||
padding: 15px;
|
||||
margin-bottom: 15px;
|
||||
position: relative;
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
|
||||
/* 步骤项头部 */
|
||||
.step-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
/* 步骤标题 (如: 步骤 1) */
|
||||
.step-title {
|
||||
font-weight: bold;
|
||||
font-size: 1.1em;
|
||||
}
|
||||
|
||||
/* 步骤控制按钮组 (上移/下移/删除) */
|
||||
.step-controls {
|
||||
display: flex;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
/* 步骤控制按钮通用样式 */
|
||||
.step-btn {
|
||||
background: none;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
font-size: 1.2em;
|
||||
color: #888;
|
||||
}
|
||||
.step-btn:hover { color: #333; }
|
||||
/* 删除按钮特定颜色 */
|
||||
.delete-step-btn { color: #dc3545; }
|
||||
.delete-step-btn:hover { color: #a71d2a; }
|
||||
|
||||
/* 步骤内部输入框布局 */
|
||||
.step-inputs {
|
||||
display: grid;
|
||||
grid-template-columns: auto 1fr 1fr; /* 名称自适应,时间占剩余空间 - Default */
|
||||
gap: 10px;
|
||||
align-items: start; /* 顶部对齐 */
|
||||
}
|
||||
|
||||
/* 步骤内表单组 */
|
||||
.step-inputs .form-group {
|
||||
grid-template-columns: 1fr; /* 内部标签和输入框垂直排列 */
|
||||
margin-bottom: 0;
|
||||
gap: 3px;
|
||||
}
|
||||
/* 步骤内标签样式 */
|
||||
.step-inputs label {
|
||||
text-align: left;
|
||||
font-size: 0.85em;
|
||||
margin-bottom: 2px;
|
||||
color: #666;
|
||||
display: block; /* 确保独占一行 */
|
||||
white-space: nowrap; /* 防止标签换行 */
|
||||
overflow: hidden; /* 隐藏超出部分 */
|
||||
text-overflow: ellipsis; /* 超出部分显示省略号 */
|
||||
max-width: 100%; /* 防止标签撑开布局 */
|
||||
}
|
||||
|
||||
/* 限制步骤内时间输入框的最大宽度 */
|
||||
.step-inputs .form-group:nth-child(2) input[type="number"],
|
||||
.step-inputs .form-group:nth-child(3) input[type="number"] {
|
||||
max-width: 85px; /* 最大宽度限制 */
|
||||
width: 100%; /* 允许在容器缩小时也缩小 */
|
||||
}
|
||||
|
||||
/* 确保步骤内名称输入框填满其列 */
|
||||
.step-inputs .form-group:nth-child(1) input[type="text"] {
|
||||
width: 85%;
|
||||
}
|
||||
|
||||
/* --- 其他设置和按钮 --- */
|
||||
|
||||
/* 添加步骤按钮 */
|
||||
.add-btn {
|
||||
padding: 8px 15px;
|
||||
background-color: #28a745;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
font-size: 0.95em;
|
||||
transition: background-color 0.3s ease;
|
||||
margin-top: 15px;
|
||||
/* 居中显示 */
|
||||
display: block;
|
||||
width: fit-content; /* 宽度自适应内容 */
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.add-btn:hover {
|
||||
background-color: #218838;
|
||||
}
|
||||
|
||||
/* 缓存设置组 */
|
||||
.cache-group {
|
||||
display: grid; /* Use grid for better control with errors */
|
||||
grid-template-columns: auto auto 1fr; /* checkbox, label, input - Default */
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
/* 缓存复选框 */
|
||||
.cache-group input[type="checkbox"] { grid-row: 1; }
|
||||
.cache-group label[for="has-cache-checkbox"] { grid-row: 1; text-align: left; }
|
||||
.cache-group input[type="number"] { grid-row: 1; }
|
||||
.cache-group .error-message {
|
||||
grid-column: 3; /* Error below the number input */
|
||||
grid-row: 2;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
/* 汇总信息区域 */
|
||||
.summary-section {
|
||||
margin-top: 20px;
|
||||
padding-top: 15px;
|
||||
border-top: 1px solid #eee;
|
||||
display: flex;
|
||||
justify-content: space-around; /* 两端分散对齐 */
|
||||
font-size: 0.95em;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
/* 汇总信息中的数值 */
|
||||
.summary-section span span {
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
/* 弹窗底部按钮区域 */
|
||||
.modal-footer {
|
||||
display: flex;
|
||||
justify-content: flex-end; /* 按钮靠右对齐 */
|
||||
gap: 10px;
|
||||
padding-top: 15px;
|
||||
border-top: 1px solid #eee;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
/* 保存和取消按钮通用样式 */
|
||||
.save-btn,
|
||||
.cancel-btn {
|
||||
padding: 10px 20px;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-size: 1em;
|
||||
transition: background-color 0.3s ease, color 0.3s ease;
|
||||
}
|
||||
|
||||
/* 保存按钮 */
|
||||
.save-btn {
|
||||
background-color: #007bff;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.save-btn:hover {
|
||||
background-color: #0056b3;
|
||||
}
|
||||
|
||||
/* 取消按钮 */
|
||||
.cancel-btn {
|
||||
background-color: #f8f9fa;
|
||||
color: #333;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
|
||||
.cancel-btn:hover {
|
||||
background-color: #e2e6ea;
|
||||
}
|
||||
|
||||
/* --- 工具类样式 --- */
|
||||
|
||||
/* 错误消息 (未使用,可备用) */
|
||||
.error-message {
|
||||
color: #dc3545;
|
||||
font-size: 0.85em; /* Slightly larger */
|
||||
padding-left: 0; /* Remove padding */
|
||||
display: none; /* Hidden by default */
|
||||
margin-top: 2px; /* Add small top margin */
|
||||
}
|
||||
|
||||
/* Ensure error message appears below input in standard form groups */
|
||||
.form-group .error-message {
|
||||
grid-column: 2; /* Align with input */
|
||||
grid-row: 2; /* Place on the row below the input */
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
/* Error messages within steps */
|
||||
.step-inputs .error-message {
|
||||
/* display: block; */ /* Already block by default */
|
||||
width: 100%; /* Take full width */
|
||||
margin-top: 2px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
/* Adjust cache group alignment when error shows */
|
||||
.cache-group {
|
||||
display: grid; /* Use grid for better control with errors */
|
||||
grid-template-columns: auto auto 1fr; /* checkbox, label, input */
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
.cache-group input[type="checkbox"] { grid-row: 1; }
|
||||
.cache-group label[for="has-cache-checkbox"] { grid-row: 1; text-align: left; }
|
||||
.cache-group input[type="number"] { grid-row: 1; }
|
||||
.cache-group .error-message {
|
||||
grid-column: 3; /* Error below the number input */
|
||||
grid-row: 2;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
/* 步骤项移动时的视觉反馈 */
|
||||
.step-item.moving {
|
||||
transition: background-color 0.3s ease-out;
|
||||
background-color: #e6f7ff; /* 淡蓝色高亮 */
|
||||
}
|
||||
|
||||
/* Input Validation Styles */
|
||||
input:invalid,
|
||||
textarea:invalid {
|
||||
border-color: #dc3545; /* Red border for invalid fields */
|
||||
}
|
||||
|
||||
.form-group input.invalid,
|
||||
.step-item input.invalid {
|
||||
border-color: #dc3545 !important; /* Force red border */
|
||||
background-color: #fff3f3; /* Light red background */
|
||||
}
|
||||
|
||||
.error-tooltip {
|
||||
color: #dc3545;
|
||||
font-size: 0.8em;
|
||||
padding-left: 5px;
|
||||
display: none; /* Hidden by default */
|
||||
}
|
||||
|
||||
.form-group .error-tooltip {
|
||||
grid-column: 2; /* Align with input in main form groups */
|
||||
}
|
||||
|
||||
/* --- Responsive Adjustments --- */
|
||||
|
||||
@media (max-width: 600px) {
|
||||
|
||||
/* Reduce padding/font size slightly globally in modal? Optional */
|
||||
.modal-content {
|
||||
width: 95vw; /* Use more width on mobile */
|
||||
max-height: 95vh; /* Allow slightly more height */
|
||||
}
|
||||
|
||||
.modal-fixed-header,
|
||||
.modal-scrollable-steps,
|
||||
.modal-fixed-footer {
|
||||
padding: 15px; /* Consistent padding */
|
||||
}
|
||||
|
||||
/* Stack form groups vertically */
|
||||
.form-group {
|
||||
grid-template-columns: 1fr; /* Single column */
|
||||
gap: 5px; /* Reduce gap */
|
||||
}
|
||||
|
||||
.form-group label {
|
||||
text-align: left; /* Align labels left */
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
/* Ensure error messages span full width below input */
|
||||
.form-group .error-message {
|
||||
grid-column: 1; /* Span full column */
|
||||
grid-row: 3; /* Ensure it's below label and input */
|
||||
}
|
||||
|
||||
/* Stack step inputs vertically */
|
||||
.step-inputs {
|
||||
grid-template-columns: 1fr; /* Single column */
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
/* Allow time inputs to take more width when stacked */
|
||||
.step-inputs .form-group:nth-child(2) input[type="number"],
|
||||
.step-inputs .form-group:nth-child(3) input[type="number"] {
|
||||
max-width: none; /* Remove max-width limit */
|
||||
}
|
||||
|
||||
/* Stack cache group elements */
|
||||
.cache-group {
|
||||
grid-template-columns: auto 1fr; /* Checkbox | Label & Input */
|
||||
gap: 5px 10px;
|
||||
}
|
||||
.cache-group input[type="checkbox"] { grid-row: 1; grid-column: 1; }
|
||||
.cache-group label[for="has-cache-checkbox"] { grid-row: 1; grid-column: 2; }
|
||||
.cache-group input[type="number"] { grid-row: 2; grid-column: 1 / span 2; width: 100%;} /* Input below */
|
||||
.cache-group .error-message {
|
||||
grid-row: 3; /* Error below input */
|
||||
grid-column: 1 / span 2;
|
||||
}
|
||||
|
||||
/* Stack summary section */
|
||||
.summary-section {
|
||||
flex-direction: column; /* Stack items */
|
||||
align-items: center; /* Center align */
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
/* Adjust footer buttons */
|
||||
.modal-footer {
|
||||
justify-content: space-around; /* Space out buttons more */
|
||||
}
|
||||
|
||||
.save-btn,
|
||||
.cancel-btn {
|
||||
padding: 8px 15px; /* Slightly smaller buttons */
|
||||
font-size: 0.95em;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user