fix: 修复 JS 文件拆分导致的函数重复和缺失问题
Coze-Commit-Type: user Coze-User-ID: 3722323274763196 Coze-Conversation-ID: 9894087
This commit is contained in:
BIN
assets/image_20260713155902656.png
Normal file
BIN
assets/image_20260713155902656.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 41 KiB |
@@ -1,31 +1,68 @@
|
|||||||
// 全局错误处理,防止JavaScript错误中断执行
|
async function loadConfigs() {
|
||||||
window.onerror = function(msg, url, line, col, error) {
|
try {
|
||||||
console.error('JavaScript错误:', msg, 'at', url, 'line:', line);
|
const response = await fetch('/api/config');
|
||||||
return true; // 阻止错误传播
|
const result = await response.json();
|
||||||
};
|
|
||||||
|
if (result.success) {
|
||||||
let editingConfigId = null;
|
renderConfigList(result.data);
|
||||||
let allFields = [];
|
} else {
|
||||||
let currentPage = 1;
|
alert('加载配置失败: ' + result.message);
|
||||||
const pageSize = 20;
|
}
|
||||||
|
} catch (error) {
|
||||||
// 切换标签页
|
alert('加载配置失败: ' + error.message);
|
||||||
function switchTab(tabName, event) {
|
|
||||||
document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
|
|
||||||
document.querySelectorAll('.tab-content').forEach(t => t.classList.remove('active'));
|
|
||||||
|
|
||||||
if (event && event.target) {
|
|
||||||
event.target.classList.add('active');
|
|
||||||
}
|
|
||||||
document.getElementById(`${tabName}-tab`).classList.add('active');
|
|
||||||
|
|
||||||
if (tabName === 'config') {
|
|
||||||
loadConfigs();
|
|
||||||
} else if (tabName === 'generate') {
|
|
||||||
loadGenerateConfigs();
|
|
||||||
} else if (tabName === 'history') {
|
|
||||||
loadHistory();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加载配置列表
|
// 渲染配置列表
|
||||||
|
function renderConfigList(configs) {
|
||||||
|
const tbody = document.getElementById('config-list');
|
||||||
|
|
||||||
|
if (configs.length === 0) {
|
||||||
|
tbody.innerHTML = '<tr><td colspan="6" class="empty">暂无配置,请点击"创建配置"按钮</td></tr>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
tbody.innerHTML = configs.map(config => `
|
||||||
|
<tr>
|
||||||
|
<td>${config.config_name}</td>
|
||||||
|
<td>${config.split_type === 'company_id' ? '按企业ID' : '按用户ID'}</td>
|
||||||
|
<td>${config.split_name || config.split_value}</td>
|
||||||
|
<td>${config.selected_fields.length}</td>
|
||||||
|
<td>
|
||||||
|
<span class="status-badge ${config.is_active ? 'status-active' : 'status-inactive'}">
|
||||||
|
${config.is_active ? '已启用' : '已禁用'}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div class="action-buttons">
|
||||||
|
<button class="btn btn-sm btn-warning" onclick="toggleConfig(${config.id})">
|
||||||
|
${config.is_active ? '禁用' : '启用'}
|
||||||
|
</button>
|
||||||
|
<button class="btn btn-sm btn-primary" onclick="editConfig(${config.id})">编辑</button>
|
||||||
|
<button class="btn btn-sm btn-success" onclick="copyConfig(${config.id})">复制</button>
|
||||||
|
<button class="btn btn-sm btn-danger" onclick="deleteConfig(${config.id})">删除</button>
|
||||||
|
<button class="btn btn-sm" onclick="moveConfig(${config.id}, 'up')">↑</button>
|
||||||
|
<button class="btn btn-sm" onclick="moveConfig(${config.id}, 'down')">↓</button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
`).join('');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 显示创建模态框
|
||||||
|
function showCreateModal() {
|
||||||
|
editingConfigId = null;
|
||||||
|
document.getElementById('modal-title').textContent = '创建配置';
|
||||||
|
document.getElementById('config-name').value = '';
|
||||||
|
document.getElementById('split-type').value = '';
|
||||||
|
document.getElementById('split-value').innerHTML = '<option value="">请先选择拆分方式</option>';
|
||||||
|
|
||||||
|
// 重置字段自定义名头
|
||||||
|
fieldCustomNames = {};
|
||||||
|
|
||||||
|
// 重置合并特来电配置
|
||||||
|
const mergeTelecomCheckbox = document.getElementById('merge-telecom');
|
||||||
|
const telecomVehicleNoInput = document.getElementById('telecom-vehicle-no');
|
||||||
|
const mergeTelecomGroup = document.getElementById('merge-telecom-group');
|
||||||
|
if (mergeTelecomCheckbox) mergeTelecomCheckbox.checked = false;
|
||||||
|
if (telecomVehicleNoInput) telecomVehicleNoInput.value = '';
|
||||||
|
|||||||
@@ -1,55 +1,3 @@
|
|||||||
async function loadConfigs() {
|
|
||||||
try {
|
|
||||||
const response = await fetch('/api/config');
|
|
||||||
const result = await response.json();
|
|
||||||
|
|
||||||
if (result.success) {
|
|
||||||
renderConfigList(result.data);
|
|
||||||
} else {
|
|
||||||
alert('加载配置失败: ' + result.message);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
alert('加载配置失败: ' + error.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 渲染配置列表
|
|
||||||
function renderConfigList(configs) {
|
|
||||||
const tbody = document.getElementById('config-list');
|
|
||||||
|
|
||||||
if (configs.length === 0) {
|
|
||||||
tbody.innerHTML = '<tr><td colspan="6" class="empty">暂无配置,请点击"创建配置"按钮</td></tr>';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
tbody.innerHTML = configs.map(config => `
|
|
||||||
<tr>
|
|
||||||
<td>${config.config_name}</td>
|
|
||||||
<td>${config.split_type === 'company_id' ? '按企业ID' : '按用户ID'}</td>
|
|
||||||
<td>${config.split_name || config.split_value}</td>
|
|
||||||
<td>${config.selected_fields.length}</td>
|
|
||||||
<td>
|
|
||||||
<span class="status-badge ${config.is_active ? 'status-active' : 'status-inactive'}">
|
|
||||||
${config.is_active ? '已启用' : '已禁用'}
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div class="action-buttons">
|
|
||||||
<button class="btn btn-sm btn-warning" onclick="toggleConfig(${config.id})">
|
|
||||||
${config.is_active ? '禁用' : '启用'}
|
|
||||||
</button>
|
|
||||||
<button class="btn btn-sm btn-primary" onclick="editConfig(${config.id})">编辑</button>
|
|
||||||
<button class="btn btn-sm btn-success" onclick="copyConfig(${config.id})">复制</button>
|
|
||||||
<button class="btn btn-sm btn-danger" onclick="deleteConfig(${config.id})">删除</button>
|
|
||||||
<button class="btn btn-sm" onclick="moveConfig(${config.id}, 'up')">↑</button>
|
|
||||||
<button class="btn btn-sm" onclick="moveConfig(${config.id}, 'down')">↓</button>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
`).join('');
|
|
||||||
}
|
|
||||||
|
|
||||||
// 显示创建模态框
|
|
||||||
function showCreateModal() {
|
function showCreateModal() {
|
||||||
editingConfigId = null;
|
editingConfigId = null;
|
||||||
document.getElementById('modal-title').textContent = '创建配置';
|
document.getElementById('modal-title').textContent = '创建配置';
|
||||||
|
|||||||
Reference in New Issue
Block a user