This commit is contained in:
jack
2026-04-27 17:09:24 +08:00
parent e75ed8b4ae
commit 0f0b0371d3
25 changed files with 3729 additions and 83 deletions
+52 -67
View File
@@ -179,63 +179,65 @@ function populateCategoryButtons(categories) {
});
}
function toggleCategory(btn) {
const allBtn = document.getElementById('cat-all');
const isAllBtn = (btn === allBtn);
if (isAllBtn) {
// 点击"不筛选"按钮:选中所有具体类别
allBtn.style.backgroundColor = '#000080';
allBtn.style.color = 'white';
const otherBtns = categoryButtons.querySelectorAll('button:not(#cat-all)');
// 全选/反选功能
function toggleAllCategories() {
const otherBtns = categoryButtons.querySelectorAll('button:not(#cat-all)');
// 检查是否全部选中
let allSelected = true;
otherBtns.forEach(b => {
if (!isCategoryButtonSelected(b)) {
allSelected = false;
}
});
if (allSelected) {
// 全部选中 -> 全不选
otherBtns.forEach(b => {
// 选中所有具体类别按钮
b.style.backgroundColor = '#000080';
b.style.color = 'white';
b.style.backgroundColor = 'white';
b.style.color = 'black';
});
} else {
// 点击具体类别按钮
if (btn.style.backgroundColor === 'rgb(0, 0, 128)') {
btn.style.backgroundColor = '#c0c0c0';
btn.style.color = 'black';
} else {
btn.style.backgroundColor = '#000080';
btn.style.color = 'white';
}
// 检查是否有选中的具体类别
const anySelected = categoryButtons.querySelectorAll('button:not(#cat-all)');
let hasSelected = false;
anySelected.forEach(b => {
if (b.style.backgroundColor === 'rgb(0, 0, 128)') {
hasSelected = true;
}
// 不是全部选中 -> 全选
otherBtns.forEach(b => {
b.style.backgroundColor = '#87CEEB'; // 浅蓝色
b.style.color = 'black';
});
// 如果没有选中任何具体类别,恢复"不筛选"按钮
if (!hasSelected) {
allBtn.style.backgroundColor = '#000080';
allBtn.style.color = 'white';
// 自动选中所有类别
anySelected.forEach(b => {
b.style.backgroundColor = '#000080';
b.style.color = 'white';
});
} else {
allBtn.style.backgroundColor = '#c0c0c0';
allBtn.style.color = 'black';
}
}
}
// 点击具体类别按钮
function toggleCategory(btn) {
if (isCategoryButtonSelected(btn)) {
btn.style.backgroundColor = 'white';
btn.style.color = 'black';
} else {
btn.style.backgroundColor = '#87CEEB'; // 浅蓝色
btn.style.color = 'black';
}
}
// 检查类别按钮是否被选中的辅助函数
function isCategoryButtonSelected(btn) {
const bg = btn.style.backgroundColor;
// 浅蓝色或 rgb(135, 206, 235) 都表示选中
return bg === '#87CEEB' || bg === 'rgb(135, 206, 235)' || bg === 'lightblue';
}
// 获取选中的类别列表
function getSelectedCategories() {
const allBtn = document.getElementById('cat-all');
const otherBtns = categoryButtons.querySelectorAll('button:not(#cat-all)');
// 如果"不筛选"按钮被选中,返回所有具体类别的值
if (allBtn.style.backgroundColor === 'rgb(0, 0, 128)') {
// 获取选中的具体类别(使用新的选中判断)
const selected = [];
otherBtns.forEach(b => {
if (isCategoryButtonSelected(b)) {
selected.push(b.dataset.value);
}
});
// 如果没有选中任何具体类别,返回所有类别(默认全选)
if (selected.length === 0) {
const allCategories = [];
otherBtns.forEach(b => {
allCategories.push(b.dataset.value);
@@ -243,13 +245,6 @@ function getSelectedCategories() {
return allCategories;
}
// 否则返回选中的具体类别
const selected = [];
otherBtns.forEach(b => {
if (b.style.backgroundColor === 'rgb(0, 0, 128)') {
selected.push(b.dataset.value);
}
});
return selected;
}
@@ -323,20 +318,10 @@ form.addEventListener('submit', async (e) => {
if (delay) formData.user_delay = parseInt(delay);
if (universe) formData.user_universe = universe;
const allBtn = document.getElementById('cat-all');
let selectedCategories = [];
if (allBtn.style.backgroundColor !== 'rgb(0, 0, 128)') {
const categoryBtns = categoryButtons.querySelectorAll('button:not(#cat-all)');
categoryBtns.forEach(btn => {
if (btn.style.backgroundColor === 'rgb(0, 0, 128)') {
selectedCategories.push(btn.dataset.value);
}
});
if (selectedCategories.length > 0) {
formData.user_category = selectedCategories;
}
// 使用 getSelectedCategories 获取选中的类别
const selectedCategories = getSelectedCategories();
if (selectedCategories.length > 0) {
formData.user_category = selectedCategories;
}
submitBtn.disabled = true;
+9 -9
View File
@@ -107,6 +107,13 @@
</select>
</div>
<div class="form-group">
<label for="universe">目标股票池 (可选 - 留空则使用种子Alpha的默认值)</label>
<select id="universe" name="universe" disabled>
<option value="">-- 先选择Delay --</option>
</select>
</div>
<div class="form-group">
<label for="delay">目标Delay</label>
<select id="delay" name="delay">
@@ -115,18 +122,11 @@
</select>
</div>
<div class="form-group">
<label for="universe">目标股票池 (可选 - 留空则使用种子Alpha的默认值)</label>
<select id="universe" name="universe" disabled>
<option value="">-- 先选择Delay --</option>
</select>
</div>
<div class="form-group">
<label>目标数据类别 (可多选)</label>
<div id="category-buttons">
<button type="button" class="btn" id="cat-all" data-value="" onclick="toggleCategory(this)">
不筛选 (默认)
<button type="button" class="btn" id="cat-all" data-value="" onclick="toggleAllCategories()">
全选/反选
</button>
</div>
</div>