diff --git a/XH_Digital_Management/settings.py b/XH_Digital_Management/settings.py index 3fbfd81..7977721 100644 --- a/XH_Digital_Management/settings.py +++ b/XH_Digital_Management/settings.py @@ -135,8 +135,8 @@ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'xh_digital_manage', # 数据库名 - 'USER': 'wsc', # 用户名 - 'PASSWORD': 'jsxh9512..', # 密码 + 'USER': 'ps', # 用户名 + 'PASSWORD': 'ps240523..', # 密码 'HOST': 'bj-cdb-7qxczedm.sql.tencentcdb.com', # 地址 'PORT': '59450', # 端口号 'OPTIONS': { diff --git a/application/perf_mgnt/views.py b/application/perf_mgnt/views.py index 60cedec..3a0f107 100644 --- a/application/perf_mgnt/views.py +++ b/application/perf_mgnt/views.py @@ -195,7 +195,7 @@ def add_gbo_data(request): new_gbo_data.save() # 返回添加成功的消息 - return Response({'message': '添加成功'}) + return JsonResponse({'message': '添加成功'}) def modify_gbo_data(request): diff --git a/templates/add_modify_modal.html b/templates/add_modify_modal.html index 969d15e..8bc26e1 100644 --- a/templates/add_modify_modal.html +++ b/templates/add_modify_modal.html @@ -64,7 +64,9 @@ $(document).ready(function () { $('.edit-btn').on('click', function () { - var record = {}; + var record = { + target_id: $(this).data('target_id') + }; {% for field in form_fields_config.fields.keys %} record['{{ field }}'] = $(this).data('{{ field }}'); {% endfor %} @@ -72,8 +74,10 @@ }); $('#submitForm').on('click', function () { + var operationType = $('#operationType').val(); var formData = $('#formModalForm').serialize(); - var url = $('#operationType').val() === 'modify' ? '{% url "modify_gbo_data" %}' : '{% url "add_gbo_data" %}'; + var url = operationType === 'modify' ? '{% url "modify_gbo_data" %}' : '{% url "add_gbo_data" %}'; + $.ajax({ type: 'POST', @@ -81,6 +85,11 @@ data: formData, success: function (response) { $('#addModifyModal').modal('hide'); + if (operationType === 'modify') { + alert('修改成功'); + } else { + alert('添加成功'); + } location.reload(); // 刷新页面 }, error: function (response) {