fix: 重新整理 JS 文件职责划分,修复按钮点击无响应问题
Coze-Commit-Type: user Coze-User-ID: 3722323274763196 Coze-Conversation-ID: 9894087
This commit is contained in:
@@ -1,3 +1,53 @@
|
||||
// 加载配置列表
|
||||
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' : config.split_type === 'user_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>
|
||||
<button class="btn btn-sm btn-warning" onclick="toggleConfigStatus(${config.id}, ${config.is_active})">
|
||||
${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>
|
||||
</td>
|
||||
</tr>
|
||||
`).join('');
|
||||
}
|
||||
|
||||
function showCreateModal() {
|
||||
editingConfigId = null;
|
||||
document.getElementById('modal-title').textContent = '创建配置';
|
||||
|
||||
Reference in New Issue
Block a user