commit 1. 编辑/新增模态框 2. input新增date和month

This commit is contained in:
彭森 2024-06-02 14:07:08 +08:00
parent d5a3a9d0a5
commit 691993373d
3 changed files with 14 additions and 5 deletions

View File

@ -135,8 +135,8 @@ DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.mysql', 'ENGINE': 'django.db.backends.mysql',
'NAME': 'xh_digital_manage', # 数据库名 'NAME': 'xh_digital_manage', # 数据库名
'USER': 'wsc', # 用户名 'USER': 'ps', # 用户名
'PASSWORD': 'jsxh9512..', # 密码 'PASSWORD': 'ps240523..', # 密码
'HOST': 'bj-cdb-7qxczedm.sql.tencentcdb.com', # 地址 'HOST': 'bj-cdb-7qxczedm.sql.tencentcdb.com', # 地址
'PORT': '59450', # 端口号 'PORT': '59450', # 端口号
'OPTIONS': { 'OPTIONS': {

View File

@ -195,7 +195,7 @@ def add_gbo_data(request):
new_gbo_data.save() new_gbo_data.save()
# 返回添加成功的消息 # 返回添加成功的消息
return Response({'message': '添加成功'}) return JsonResponse({'message': '添加成功'})
def modify_gbo_data(request): def modify_gbo_data(request):

View File

@ -64,7 +64,9 @@
$(document).ready(function () { $(document).ready(function () {
$('.edit-btn').on('click', function () { $('.edit-btn').on('click', function () {
var record = {}; var record = {
target_id: $(this).data('target_id')
};
{% for field in form_fields_config.fields.keys %} {% for field in form_fields_config.fields.keys %}
record['{{ field }}'] = $(this).data('{{ field }}'); record['{{ field }}'] = $(this).data('{{ field }}');
{% endfor %} {% endfor %}
@ -72,8 +74,10 @@
}); });
$('#submitForm').on('click', function () { $('#submitForm').on('click', function () {
var operationType = $('#operationType').val();
var formData = $('#formModalForm').serialize(); 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({ $.ajax({
type: 'POST', type: 'POST',
@ -81,6 +85,11 @@
data: formData, data: formData,
success: function (response) { success: function (response) {
$('#addModifyModal').modal('hide'); $('#addModifyModal').modal('hide');
if (operationType === 'modify') {
alert('修改成功');
} else {
alert('添加成功');
}
location.reload(); // 刷新页面 location.reload(); // 刷新页面
}, },
error: function (response) { error: function (response) {