使用flask-restful实现数据校验与序列化3

This commit is contained in:
zhengxinonly
2021-06-27 19:27:08 +08:00
parent e9bd8a17a0
commit e3dd5458ad
23 changed files with 517 additions and 1202 deletions
+1 -1
View File
@@ -66,7 +66,7 @@
form.on('submit(role-save)', function (data) {
$.ajax({
url: '/admin/role/save',
url: '/admin/role/add',
data: JSON.stringify(data.field),
dataType: 'json',
contentType: 'application/json',
+4 -3
View File
@@ -32,9 +32,9 @@
<div class="layui-form-item">
<label class="layui-form-label">状态</label>
<div class="layui-input-block">
<input type="radio" name="enable" {% if role.enable == 0 %}checked {% endif %}value="0"
<input type="radio" name="enable" {% if role.enable == 1 %}checked {% endif %}value="0"
title="开启">
<input type="radio" name="enable" {% if role.enable == 1 %}checked {% endif %} value="1"
<input type="radio" name="enable" {% if role.enable == 0 %}checked {% endif %} value="1"
title="关闭">
</div>
</div>
@@ -78,7 +78,7 @@
form.on('submit(role-update)', function (data) {
$.ajax({
url: '/admin/role/update',
url: '/admin/role/edit/' + data.field.roleId,
data: JSON.stringify(data.field),
dataType: 'json',
contentType: 'application/json',
@@ -96,6 +96,7 @@
})
return false
})
})
})
</script>
<script>
+5 -5
View File
@@ -137,14 +137,14 @@
form.on('switch(role-enable)', function (obj) {
let operate
if (obj.elem.checked) {
operate = 'enable'
operate = 1
} else {
operate = 'disable'
operate = 0
}
let loading = layer.load()
$.ajax({
url: '/admin/role/' + operate,
data: JSON.stringify({ roleId: this.value }),
url: '/admin/role/enable',
data: JSON.stringify({ roleId: this.value, operate: operate }),
dataType: 'json',
contentType: 'application/json',
type: 'put',
@@ -194,7 +194,7 @@
layer.close(index)
let loading = layer.load()
$.ajax({
url: MODULE_PATH + 'remove/' + obj.data['id'],
url: MODULE_PATH + 'role_power/' + obj.data['id'],
dataType: 'json',
type: 'delete',
success: function (result) {
+2 -2
View File
@@ -35,7 +35,7 @@
dtree.render({
elem: '#role-power',
method: 'get',
url: '/admin/role/getRolePower/' + {{id}},
url: '/admin/role/role_power/' + {{id}},
dataFormat: 'list',
checkbar: true,
skin: 'layui',
@@ -56,7 +56,7 @@
data.field.powerIds = ids
$.ajax({
url: '/admin/role/saveRolePower',
url: '/admin/role/role_power/' + data.field.roleId,
data: data.field,
dataType: 'json',
type: 'put',