diff --git a/app.py b/app.py index a5ec92c..1cabc4c 100644 --- a/app.py +++ b/app.py @@ -163,15 +163,21 @@ def copy_config(config_id): original = configs[0] - # 生成新配置名称 + # 生成新ID和新名称 + new_id = int(datetime.now().timestamp() * 1000) new_name = f"{original['config_name']}_副本" + # 获取最大排序值 + max_sort = execute_query('SELECT MAX(sort_order) as max_sort FROM t_daily_report_config') + sort_order = (max_sort[0]['max_sort'] or 0) + 1 + # 插入新配置 - new_id = execute_insert( + execute_insert( '''INSERT INTO t_daily_report_config - (config_name, split_type, split_value, split_name, selected_fields, sum_fields, is_active, sort_order) - VALUES (%s, %s, %s, %s, %s, %s, %s, %s)''', + (id, config_name, split_type, split_value, split_name, selected_fields, sum_fields, is_active, sort_order, create_time, update_time) + VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, NOW(), NOW())''', ( + new_id, new_name, original['split_type'], original['split_value'], @@ -179,7 +185,7 @@ def copy_config(config_id): original['selected_fields'], original.get('sum_fields', ''), original['is_active'], - original.get('sort_order', 0) + sort_order ) ) diff --git a/assets/image_20260710130841559.png b/assets/image_20260710130841559.png new file mode 100644 index 0000000..dc02cb0 Binary files /dev/null and b/assets/image_20260710130841559.png differ diff --git a/templates/index.html b/templates/index.html index 37bb0c1..e8286f1 100644 --- a/templates/index.html +++ b/templates/index.html @@ -902,7 +902,7 @@ alert('配置复制成功!'); loadConfigs(); } else { - alert('复制失败: ' + result.error); + alert('复制失败: ' + (result.message || result.error || '未知错误')); } } catch (error) { console.error('复制配置失败:', error);