commit 1. 编辑/新增模态框 2. input新增date和month
This commit is contained in:
parent
d5a3a9d0a5
commit
691993373d
|
@ -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': {
|
||||||
|
|
|
@ -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):
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
Loading…
Reference in New Issue