|
@@ -6,6 +6,7 @@
|
|
<title>群组管理 - 后台管理系统</title>
|
|
<title>群组管理 - 后台管理系统</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css" rel="stylesheet">
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css" rel="stylesheet">
|
|
|
|
+ <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
|
<style>
|
|
<style>
|
|
.sidebar {
|
|
.sidebar {
|
|
position: fixed;
|
|
position: fixed;
|
|
@@ -115,6 +116,7 @@
|
|
<th>群组ID</th>
|
|
<th>群组ID</th>
|
|
<th>群组名称</th>
|
|
<th>群组名称</th>
|
|
<th>状态</th>
|
|
<th>状态</th>
|
|
|
|
+ <th>费率(%)</th>
|
|
<th>创建时间</th>
|
|
<th>创建时间</th>
|
|
<th>操作</th>
|
|
<th>操作</th>
|
|
</tr>
|
|
</tr>
|
|
@@ -180,6 +182,10 @@
|
|
</label>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
+ <div class="mb-3">
|
|
|
|
+ <label for="editFeeRate" class="form-label">费率 (%)</label>
|
|
|
|
+ <input type="number" class="form-control" id="editFeeRate" step="0.1" min="0" max="100" required>
|
|
|
|
+ </div>
|
|
</form>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<div class="modal-footer">
|
|
@@ -262,6 +268,7 @@
|
|
${group.is_active ? '启用' : '禁用'}
|
|
${group.is_active ? '启用' : '禁用'}
|
|
</span>
|
|
</span>
|
|
</td>
|
|
</td>
|
|
|
|
+ <td>${parseFloat(group.fee_rate || 0).toFixed(1)}%</td>
|
|
<td>${new Date(group.created_at).toLocaleString()}</td>
|
|
<td>${new Date(group.created_at).toLocaleString()}</td>
|
|
<td>
|
|
<td>
|
|
<button class="btn btn-sm btn-primary btn-action" onclick="editGroup('${group.id}')">
|
|
<button class="btn btn-sm btn-primary btn-action" onclick="editGroup('${group.id}')">
|
|
@@ -325,13 +332,25 @@
|
|
document.getElementById('editGroupId').value = group.id;
|
|
document.getElementById('editGroupId').value = group.id;
|
|
document.getElementById('editGroupName').value = group.group_name;
|
|
document.getElementById('editGroupName').value = group.group_name;
|
|
document.getElementById('editGroupStatus').checked = group.is_active;
|
|
document.getElementById('editGroupStatus').checked = group.is_active;
|
|
|
|
+ document.getElementById('editFeeRate').value = group.fee_rate || 0;
|
|
|
|
|
|
const modal = new bootstrap.Modal(document.getElementById('editGroupModal'));
|
|
const modal = new bootstrap.Modal(document.getElementById('editGroupModal'));
|
|
modal.show();
|
|
modal.show();
|
|
|
|
+ } else {
|
|
|
|
+ const data = await response.json();
|
|
|
|
+ Swal.fire({
|
|
|
|
+ icon: 'error',
|
|
|
|
+ title: '加载失败',
|
|
|
|
+ text: data.message || '加载群组信息失败'
|
|
|
|
+ });
|
|
}
|
|
}
|
|
} catch (error) {
|
|
} catch (error) {
|
|
console.error('加载群组信息失败:', error);
|
|
console.error('加载群组信息失败:', error);
|
|
- alert('加载群组信息失败,请稍后重试');
|
|
|
|
|
|
+ Swal.fire({
|
|
|
|
+ icon: 'error',
|
|
|
|
+ title: '加载失败',
|
|
|
|
+ text: '加载群组信息失败,请稍后重试'
|
|
|
|
+ });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -340,6 +359,16 @@
|
|
const groupId = document.getElementById('editGroupId').value;
|
|
const groupId = document.getElementById('editGroupId').value;
|
|
const groupName = document.getElementById('editGroupName').value;
|
|
const groupName = document.getElementById('editGroupName').value;
|
|
const isActive = document.getElementById('editGroupStatus').checked;
|
|
const isActive = document.getElementById('editGroupStatus').checked;
|
|
|
|
+ const feeRate = parseFloat(document.getElementById('editFeeRate').value) || 0;
|
|
|
|
+
|
|
|
|
+ if (isNaN(feeRate) || feeRate < 0 || feeRate > 100) {
|
|
|
|
+ Swal.fire({
|
|
|
|
+ icon: 'error',
|
|
|
|
+ title: '输入错误',
|
|
|
|
+ text: '费率必须在0-100之间'
|
|
|
|
+ });
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
|
|
try {
|
|
try {
|
|
const token = localStorage.getItem('token');
|
|
const token = localStorage.getItem('token');
|
|
@@ -349,20 +378,35 @@
|
|
'Authorization': `Bearer ${token}`,
|
|
'Authorization': `Bearer ${token}`,
|
|
'Content-Type': 'application/json'
|
|
'Content-Type': 'application/json'
|
|
},
|
|
},
|
|
- body: JSON.stringify({ groupName, isActive })
|
|
|
|
|
|
+ body: JSON.stringify({ groupName, isActive, feeRate })
|
|
});
|
|
});
|
|
|
|
|
|
if (response.ok) {
|
|
if (response.ok) {
|
|
const modal = bootstrap.Modal.getInstance(document.getElementById('editGroupModal'));
|
|
const modal = bootstrap.Modal.getInstance(document.getElementById('editGroupModal'));
|
|
modal.hide();
|
|
modal.hide();
|
|
- loadGroups();
|
|
|
|
|
|
+ await loadGroups();
|
|
|
|
+ Swal.fire({
|
|
|
|
+ icon: 'success',
|
|
|
|
+ title: '更新成功',
|
|
|
|
+ text: '群组信息已更新!',
|
|
|
|
+ timer: 1500,
|
|
|
|
+ showConfirmButton: false
|
|
|
|
+ });
|
|
} else {
|
|
} else {
|
|
const data = await response.json();
|
|
const data = await response.json();
|
|
- alert(data.message || '更新群组失败');
|
|
|
|
|
|
+ Swal.fire({
|
|
|
|
+ icon: 'error',
|
|
|
|
+ title: '更新失败',
|
|
|
|
+ text: data.message || '更新群组失败'
|
|
|
|
+ });
|
|
}
|
|
}
|
|
} catch (error) {
|
|
} catch (error) {
|
|
console.error('更新群组失败:', error);
|
|
console.error('更新群组失败:', error);
|
|
- alert('更新群组失败,请稍后重试');
|
|
|
|
|
|
+ Swal.fire({
|
|
|
|
+ icon: 'error',
|
|
|
|
+ title: '更新失败',
|
|
|
|
+ text: '更新群组失败,请稍后重试'
|
|
|
|
+ });
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|