修改数据采集
This commit is contained in:
@@ -424,7 +424,37 @@ async function saveSumData() {
|
||||
try {
|
||||
// 分组编辑模式
|
||||
if (editingGroupIds && editingGroupIds.length > 0) {
|
||||
// 读取动态字段值
|
||||
// 先获取分组信息,确定需要删除的自动采集记录
|
||||
if (editingGroupData && editingGroupData.length > 0) {
|
||||
const chargeItem = editingGroupData.find(i => i.sum_field_key === 'charge_degree') || editingGroupData[0];
|
||||
|
||||
// 查询该分组下所有字段的ID(用于删除重复的自动采集记录)
|
||||
const deleteResponse = await fetch('/api/sum-data/batch-query', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
conditions: {
|
||||
report_date: chargeItem.report_date,
|
||||
config_id: chargeItem.config_id,
|
||||
split_type: chargeItem.split_type,
|
||||
split_value: chargeItem.split_value,
|
||||
data_source: 'auto'
|
||||
}
|
||||
})
|
||||
});
|
||||
const deleteResult = await deleteResponse.json();
|
||||
|
||||
// 删除所有自动采集的记录(避免重复)
|
||||
if (deleteResult.success && deleteResult.data && deleteResult.data.length > 0) {
|
||||
const autoIds = deleteResult.data.map(d => d.id);
|
||||
for (const autoId of autoIds) {
|
||||
await fetch(`/api/sum-data/${autoId}`, { method: 'DELETE' });
|
||||
}
|
||||
console.log(`已删除 ${autoIds.length} 条自动采集记录`);
|
||||
}
|
||||
}
|
||||
|
||||
// 读取动态字段值(这些是手动编辑后的记录)
|
||||
const fieldInputs = document.querySelectorAll('#sum-data-dynamic-fields input[data-field-key]');
|
||||
let successCount = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user