commit 1. 编辑/新增模态框 2. input新增date和month
This commit is contained in:
parent
d5a3a9d0a5
commit
691993373d
|
@ -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': {
|
||||
|
|
|
@ -195,7 +195,7 @@ def add_gbo_data(request):
|
|||
new_gbo_data.save()
|
||||
|
||||
# 返回添加成功的消息
|
||||
return Response({'message': '添加成功'})
|
||||
return JsonResponse({'message': '添加成功'})
|
||||
|
||||
|
||||
def modify_gbo_data(request):
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue