使用flask-restful实现数据校验与序列化2
This commit is contained in:
@@ -32,23 +32,6 @@ def create_dept_data():
|
||||
add_data(_fields, _data_list, Dept)
|
||||
|
||||
|
||||
def create_admin_dict_data():
|
||||
from applications.models import DictData, DictType
|
||||
|
||||
_fields = ['id', 'data_label', 'data_value', 'type_code', 'is_default', 'enable', 'remark', 'create_time',
|
||||
'update_time', ]
|
||||
_data_list = [
|
||||
(8, '男', 'boy', 'user_sex', None, 1, '男 : body', '2021-04-16 13:36:34', '2021-04-16 14:05:06'),
|
||||
(9, '女', 'girl', 'user_sex', None, 1, '女 : girl', '2021-04-16 13:36:55', '2021-04-16 13:36:55'),
|
||||
]
|
||||
|
||||
add_data(_fields, _data_list, DictData)
|
||||
_fields = ['id', 'type_name', 'type_code', 'description', 'enable', 'create_time', 'update_time', ]
|
||||
_data_list = [
|
||||
(1, '用户性别', 'user_sex', '用户性别', 1, None, '2021-04-16 13:37:11')
|
||||
]
|
||||
add_data(_fields, _data_list, DictType)
|
||||
|
||||
|
||||
def create_admin_photo():
|
||||
from applications.models import Photo
|
||||
@@ -125,14 +108,6 @@ def create_admin_power():
|
||||
(32, '图片删除', '2', 'admin:file:delete', '', '', '18', 'layui-icon layui-icon-delete', 2,
|
||||
'2021-03-22 19:58:45',
|
||||
'2021-03-25 19:15:29', 1),
|
||||
(44, '数据字典', '1', 'admin:dict:main', '/admin/dict', '_iframe', '1', 'layui-icon layui-icon-console', 6,
|
||||
'2021-04-16 13:59:49', '2021-04-16 13:59:49', 1),
|
||||
(45, '字典增加', '2', 'admin:dict:add', '', '', '44', 'layui-icon ', 1,
|
||||
'2021-04-16 14:00:59', '2021-04-16 14:00:59', 1),
|
||||
(46, '字典修改', '2', 'admin:dict:edit', '', '', '44', 'layui-icon ', 2, '2021-04-16 14:01:33',
|
||||
'2021-04-16 14:01:33', 1),
|
||||
(47, '字典删除', '2', 'admin:dict:remove', '', '', '44', 'layui-icon ', 3, '2021-04-16 14:02:06',
|
||||
'2021-04-16 14:02:06', 1),
|
||||
(48, '部门管理', '1', 'admin:dept:main', '/dept', '_iframe', '1', 'layui-icon layui-icon-group', 3,
|
||||
'2021-06-01 16:22:11', '2021-06-01 16:22:11', 1),
|
||||
(49, '部门增加', '2', 'admin:dept:add', '', '', '48', 'layui-icon None', 1, '2021-06-01 17:35:52',
|
||||
@@ -291,7 +266,6 @@ def register_script(app: Flask):
|
||||
def init_db():
|
||||
"""数据库初始化"""
|
||||
create_dept_data()
|
||||
create_admin_dict_data()
|
||||
create_admin_photo()
|
||||
create_admin_power()
|
||||
create_admin_role()
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>字典增加</title>
|
||||
{% include 'admin/common/header.html' %}
|
||||
</head>
|
||||
<body>
|
||||
<form class="layui-form" action="">
|
||||
<div class="mainBox">
|
||||
<div class="main-container">
|
||||
<div class="main-container">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="typeName" lay-verify="title" autocomplete="off" placeholder="请输入名称"
|
||||
class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">标识</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="typeCode" lay-verify="title" autocomplete="off" placeholder="请输入标识"
|
||||
class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">状态</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="enable" value="1" title="开启">
|
||||
<input type="radio" name="enable" value="0" title="关闭" checked>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">描述</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea placeholder="请输入描述" name="description" class="layui-textarea"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bottom">
|
||||
<div class="button-container">
|
||||
<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
|
||||
lay-filter="dict-type-save">
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
提交
|
||||
</button>
|
||||
<button type="reset" class="pear-btn pear-btn-sm">
|
||||
<i class="layui-icon layui-icon-refresh"></i>
|
||||
重置
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{% include 'admin/common/footer.html' %}
|
||||
<script>
|
||||
layui.use(['form', 'jquery'], function () {
|
||||
let form = layui.form
|
||||
let $ = layui.jquery
|
||||
|
||||
form.on('submit(dict-type-save)', function (data) {
|
||||
$.ajax({
|
||||
url: '/admin/dict/dictType/save',
|
||||
data: JSON.stringify(data.field),
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'post',
|
||||
success: function (result) {
|
||||
if (result.success) {
|
||||
layer.msg(result.msg, { icon: 1, time: 1000 }, function () {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name)) //关闭当前页
|
||||
parent.layui.table.reload('dict-type-table')
|
||||
})
|
||||
} else {
|
||||
layer.msg(result.msg, { icon: 2, time: 1000 })
|
||||
}
|
||||
}
|
||||
})
|
||||
return false
|
||||
})
|
||||
})
|
||||
</script>
|
||||
<script>
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,95 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>字典增加</title>
|
||||
{% include 'admin/common/header.html' %}
|
||||
</head>
|
||||
<body>
|
||||
<form class="layui-form" action="">
|
||||
<div class="mainBox">
|
||||
<div class="main-container">
|
||||
<div class="main-container">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">标签</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="dataLabel" lay-verify="title" autocomplete="off" placeholder="请输入标签"
|
||||
class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">值</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="dataValue" lay-verify="title" autocomplete="off" placeholder="请输入值"
|
||||
class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">标识</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" value="{{ type_code }}" readonly="readonly" name="typeCode"
|
||||
lay-verify="title"
|
||||
autocomplete="off" placeholder="请输入标题" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">状态</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="enable" value="1" title="开启">
|
||||
<input type="radio" name="enable" value="0" title="关闭" checked>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">描述</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea placeholder="请输入描述" name="remark" class="layui-textarea"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bottom">
|
||||
<div class="button-container">
|
||||
<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
|
||||
lay-filter="dict-data-save">
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
提交
|
||||
</button>
|
||||
<button type="reset" class="pear-btn pear-btn-sm">
|
||||
<i class="layui-icon layui-icon-refresh"></i>
|
||||
重置
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{% include 'admin/common/footer.html' %}
|
||||
<script>
|
||||
layui.use(['form', 'jquery'], function () {
|
||||
let form = layui.form
|
||||
let $ = layui.jquery
|
||||
|
||||
form.on('submit(dict-data-save)', function (data) {
|
||||
$.ajax({
|
||||
url: '/admin/dict/dictData/save',
|
||||
data: JSON.stringify(data.field),
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'post',
|
||||
success: function (result) {
|
||||
if (result.success) {
|
||||
layer.msg(result.msg, { icon: 1, time: 1000 }, function () {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name))//关闭当前页
|
||||
parent.layui.table.reload('dict-data-table')
|
||||
})
|
||||
} else {
|
||||
layer.msg(result.msg, { icon: 2, time: 1000 })
|
||||
}
|
||||
}
|
||||
})
|
||||
return false
|
||||
})
|
||||
})
|
||||
</script>
|
||||
<script>
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,103 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>字典增加</title>
|
||||
{% include 'admin/common/header.html' %}
|
||||
</head>
|
||||
<body>
|
||||
<form class="layui-form" action="">
|
||||
<div class="mainBox">
|
||||
<div class="main-container">
|
||||
<div class="main-container">
|
||||
<div class="layui-form-item layui-hide">
|
||||
<label class="layui-form-label">编号</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" value="{{ dict_data.id }}" name="dataId" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">标签</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" value="{{ dict_data.data_label }}" name="dataLabel" lay-verify="title"
|
||||
autocomplete="off" placeholder="请输入标题" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">值</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" value="{{ dict_data.data_value }}" name="dataValue" lay-verify="title"
|
||||
autocomplete="off" placeholder="请输入标题" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">标识</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" value="{{ dict_data.type_code }}" readonly="readonly" name="typeCode"
|
||||
lay-verify="title" autocomplete="off" placeholder="请输入标题" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">状态</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" {% if dict_data.enable == 1 %} } checked{% endif %} name="enable" value="1"
|
||||
title="开启">
|
||||
<input type="radio" {% if dict_data.enable == 0 %} } checked{% endif %} name="enable" value="0"
|
||||
title="关闭">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">描述</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea placeholder="请输入描述" name="remark"
|
||||
class="layui-textarea">{{ dict_data.remark }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bottom">
|
||||
<div class="button-container">
|
||||
<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
|
||||
lay-filter="dict-data-save">
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
提交
|
||||
</button>
|
||||
<button type="reset" class="pear-btn pear-btn-sm">
|
||||
<i class="layui-icon layui-icon-refresh"></i>
|
||||
重置
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{% include 'admin/common/footer.html' %}
|
||||
<script>
|
||||
layui.use(['form', 'jquery'], function () {
|
||||
let form = layui.form
|
||||
let $ = layui.jquery
|
||||
|
||||
form.on('submit(dict-data-save)', function (data) {
|
||||
$.ajax({
|
||||
url: '/admin/dict/dictData/update',
|
||||
data: JSON.stringify(data.field),
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'put',
|
||||
success: function (result) {
|
||||
if (result.success) {
|
||||
layer.msg(result.msg, { icon: 1, time: 1000 }, function () {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name))//关闭当前页
|
||||
parent.layui.table.reload('dict-data-table')
|
||||
})
|
||||
} else {
|
||||
layer.msg(result.msg, { icon: 2, time: 1000 })
|
||||
}
|
||||
}
|
||||
})
|
||||
return false
|
||||
})
|
||||
})
|
||||
</script>
|
||||
<script>
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,97 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>字典增加</title>
|
||||
{% include 'admin/common/header.html' %}
|
||||
</head>
|
||||
<body>
|
||||
<form class="layui-form" action="">
|
||||
<div class="mainBox">
|
||||
<div class="main-container">
|
||||
<div class="main-container">
|
||||
<div class="layui-form-item layui-hide">
|
||||
<label class="layui-form-label">编号</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" value="{{ dict_type.id }}" name="id" lay-verify="title" autocomplete="off"
|
||||
placeholder="请输入标题" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" value="{{ dict_type.type_name }}" name="typeName" lay-verify="title"
|
||||
autocomplete="off" placeholder="请输入标题" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">标识</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" value="{{ dict_type.type_code }}" readonly name="typeCode"
|
||||
lay-verify="title" autocomplete="off" placeholder="请输入标题" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">状态</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" {% if dict_type.enable == 1 %} } checked{% endif %} name="enable" value="1"
|
||||
title="开启">
|
||||
<input type="radio" {% if dict_type.enable == 0 %} } checked{% endif %} name="enable" value="0"
|
||||
title="关闭">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">描述</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea placeholder="请输入描述" name="description"
|
||||
class="layui-textarea">{{ dict_type.description }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bottom">
|
||||
<div class="button-container">
|
||||
<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
|
||||
lay-filter="dict-type-update">
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
提交
|
||||
</button>
|
||||
<button type="reset" class="pear-btn pear-btn-sm">
|
||||
<i class="layui-icon layui-icon-refresh"></i>
|
||||
重置
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{% include 'admin/common/footer.html' %}
|
||||
<script>
|
||||
layui.use(['form', 'jquery'], function () {
|
||||
let form = layui.form
|
||||
let $ = layui.jquery
|
||||
|
||||
form.on('submit(dict-type-update)', function (data) {
|
||||
$.ajax({
|
||||
url: '/admin/dict/dictType/update',
|
||||
data: JSON.stringify(data.field),
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'put',
|
||||
success: function (result) {
|
||||
if (result.success) {
|
||||
layer.msg(result.msg, { icon: 1, time: 1000 }, function () {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name))//关闭当前页
|
||||
parent.layui.table.reload('dict-type-table')
|
||||
})
|
||||
} else {
|
||||
layer.msg(result.msg, { icon: 2, time: 1000 })
|
||||
}
|
||||
}
|
||||
})
|
||||
return false
|
||||
})
|
||||
})
|
||||
</script>
|
||||
<script>
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,378 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>字典管理</title>
|
||||
{% include 'admin/common/header.html' %}
|
||||
</head>
|
||||
<body class="pear-container">
|
||||
<div class="layui-row layui-col-space10">
|
||||
<div class="layui-col-md12">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<form class="layui-form" action="">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">字典名称</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="typeName" placeholder="" class="layui-input">
|
||||
</div>
|
||||
<button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="dict-type-query">
|
||||
<i class="layui-icon layui-icon-search"></i>
|
||||
查询
|
||||
</button>
|
||||
<button type="reset" class="pear-btn pear-btn-md">
|
||||
<i class="layui-icon layui-icon-refresh"></i>
|
||||
重置
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-md6">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<table id="dict-type-table" lay-filter="dict-type-table"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-md6">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<svg class="empty" style="margin-top: 50px;margin-left: 220px;margin-bottom: 80px;" width="184"
|
||||
height="152" viewBox="0 0 184 152" xmlns="http://www.w3.org/2000/svg">
|
||||
<g fill="none" fillRule="evenodd">
|
||||
<g transform="translate(24 31.67)">
|
||||
<ellipse fillOpacity=".8" fill="#F5F5F7" cx="67.797" cy="106.89" rx="67.797"
|
||||
ry="12.668"></ellipse>
|
||||
<path d="M122.034 69.674L98.109 40.229c-1.148-1.386-2.826-2.225-4.593-2.225h-51.44c-1.766 0-3.444.839-4.592 2.225L13.56 69.674v15.383h108.475V69.674z"
|
||||
fill="#AEB8C2"></path>
|
||||
<path d="M101.537 86.214L80.63 61.102c-1.001-1.207-2.507-1.867-4.048-1.867H31.724c-1.54 0-3.047.66-4.048 1.867L6.769 86.214v13.792h94.768V86.214z"
|
||||
fill="url(#linearGradient-1)" transform="translate(13.56)"></path>
|
||||
<path d="M33.83 0h67.933a4 4 0 0 1 4 4v93.344a4 4 0 0 1-4 4H33.83a4 4 0 0 1-4-4V4a4 4 0 0 1 4-4z"
|
||||
fill="#F5F5F7"></path>
|
||||
<path d="M42.678 9.953h50.237a2 2 0 0 1 2 2V36.91a2 2 0 0 1-2 2H42.678a2 2 0 0 1-2-2V11.953a2 2 0 0 1 2-2zM42.94 49.767h49.713a2.262 2.262 0 1 1 0 4.524H42.94a2.262 2.262 0 0 1 0-4.524zM42.94 61.53h49.713a2.262 2.262 0 1 1 0 4.525H42.94a2.262 2.262 0 0 1 0-4.525zM121.813 105.032c-.775 3.071-3.497 5.36-6.735 5.36H20.515c-3.238 0-5.96-2.29-6.734-5.36a7.309 7.309 0 0 1-.222-1.79V69.675h26.318c2.907 0 5.25 2.448 5.25 5.42v.04c0 2.971 2.37 5.37 5.277 5.37h34.785c2.907 0 5.277-2.421 5.277-5.393V75.1c0-2.972 2.343-5.426 5.25-5.426h26.318v33.569c0 .617-.077 1.216-.221 1.789z"
|
||||
fill="#DCE0E6"></path>
|
||||
</g>
|
||||
<path d="M149.121 33.292l-6.83 2.65a1 1 0 0 1-1.317-1.23l1.937-6.207c-2.589-2.944-4.109-6.534-4.109-10.408C138.802 8.102 148.92 0 161.402 0 173.881 0 184 8.102 184 18.097c0 9.995-10.118 18.097-22.599 18.097-4.528 0-8.744-1.066-12.28-2.902z"
|
||||
fill="#DCE0E6"></path>
|
||||
<g transform="translate(149.65 15.383)" fill="#FFF">
|
||||
<ellipse cx="20.654" cy="3.167" rx="2.849" ry="2.815"></ellipse>
|
||||
<path d="M5.698 5.63H0L2.898.704zM9.259.704h4.985V5.63H9.259z"></path>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
<table id="dict-data-table" lay-filter="dict-data-table"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
<script type="text/html" id="dict-type-toolbar">
|
||||
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">
|
||||
<i class="layui-icon layui-icon-add-1"></i>
|
||||
新增
|
||||
</button>
|
||||
<button class="pear-btn pear-btn-md" lay-event="batchRemove">
|
||||
<i class="layui-icon layui-icon-delete"></i>
|
||||
删除
|
||||
</button>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="dict-type-bar">
|
||||
<button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit">
|
||||
<i class="layui-icon layui-icon-edit"></i>
|
||||
</button>
|
||||
<button class="pear-btn pear-btn-warming pear-btn-sm" lay-event="details">
|
||||
<i class="layui-icon layui-icon-transfer"></i>
|
||||
</button>
|
||||
<button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="remove">
|
||||
<i class="layui-icon layui-icon-delete"></i>
|
||||
</button>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="dict-type-enable">
|
||||
<input type="checkbox" value="{{ "{{ d.id }}" }}"
|
||||
lay-skin="switch" lay-text="启用|禁用"
|
||||
lay-filter="dict-type-enable"
|
||||
{{ "{{# if(d.enable==1){ }} checked {{# } }}" }}>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="dict-data-toolbar">
|
||||
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">
|
||||
<i class="layui-icon layui-icon-add-1"></i>
|
||||
新增
|
||||
</button>
|
||||
<button class="pear-btn pear-btn-md" lay-event="batchRemove">
|
||||
<i class="layui-icon layui-icon-delete"></i>
|
||||
删除
|
||||
</button>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="dict-data-bar">
|
||||
<button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit">
|
||||
<i class="layui-icon layui-icon-edit"></i>
|
||||
</button>
|
||||
<button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="remove">
|
||||
<i class="layui-icon layui-icon-delete"></i>
|
||||
</button>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="dict-data-enable">
|
||||
<input type="checkbox" value="{{ "{{ d.dataId }}" }}" lay-skin="switch" lay-text="启用|禁用"
|
||||
lay-filter="dict-data-enable"
|
||||
{{ "{{# if(d.enable==1){ }} checked {{# } }}" }}>
|
||||
</script>
|
||||
{% include 'admin/common/footer.html' %}
|
||||
<script>
|
||||
layui.use(['table', 'form', 'jquery', 'popup'], function () {
|
||||
let table = layui.table
|
||||
let form = layui.form
|
||||
let $ = layui.jquery
|
||||
let popup = layui.popup
|
||||
|
||||
let typeCode
|
||||
|
||||
let cols = [
|
||||
[
|
||||
{ type: 'checkbox' },
|
||||
{ title: '字典名称', field: 'typeName', align: 'center', width: 120 },
|
||||
{ title: '描述', field: 'description', align: 'center' },
|
||||
{ title: '字典状态', field: 'enable', align: 'center', templet: '#dict-type-enable' },
|
||||
{ title: '操作', toolbar: '#dict-type-bar', align: 'center', width: 180 }
|
||||
]
|
||||
]
|
||||
|
||||
let dataCols = [
|
||||
[
|
||||
{ type: 'checkbox' },
|
||||
{ title: '标签', field: 'dataLabel', align: 'center', width: 120 },
|
||||
{ title: '对应值', field: 'dataValue', align: 'center' },
|
||||
{ title: '状态', field: 'enable', align: 'center', templet: '#dict-data-enable' },
|
||||
{ title: '操作', toolbar: '#dict-data-bar', align: 'center', width: 180 }
|
||||
]
|
||||
]
|
||||
|
||||
table.render({
|
||||
elem: '#dict-type-table',
|
||||
url: '/admin/dict/dictType/data',
|
||||
page: true,
|
||||
cols: cols,
|
||||
skin: 'line',
|
||||
height: 'full-148',
|
||||
toolbar: '#dict-type-toolbar',
|
||||
defaultToolbar: [{
|
||||
layEvent: 'refresh',
|
||||
icon: 'layui-icon-refresh',
|
||||
}, 'filter', 'print', 'exports']
|
||||
})
|
||||
|
||||
window.renderData = function (code) {
|
||||
typeCode = code
|
||||
$('.empty').hide()
|
||||
table.render({
|
||||
elem: '#dict-data-table',
|
||||
url: '/admin/dict/dictData/data?typeCode=' + typeCode,
|
||||
page: true,
|
||||
height: 'full-148',
|
||||
cols: dataCols,
|
||||
skin: 'line',
|
||||
toolbar: '#dict-data-toolbar'
|
||||
})
|
||||
}
|
||||
|
||||
table.on('tool(dict-type-table)', function (obj) {
|
||||
if (obj.event === 'remove') {
|
||||
window.removeType(obj)
|
||||
} else if (obj.event === 'edit') {
|
||||
window.editType(obj)
|
||||
} else if (obj.event === 'details') {
|
||||
window.renderData(obj.data['typeCode'])
|
||||
}
|
||||
})
|
||||
|
||||
table.on('toolbar(dict-type-table)', function (obj) {
|
||||
if (obj.event === 'add') {
|
||||
window.addType()
|
||||
} else if (obj.event === 'refresh') {
|
||||
window.refreshType()
|
||||
}
|
||||
})
|
||||
|
||||
form.on('submit(dict-type-query)', function (data) {
|
||||
table.reload('dict-type-table', { where: data.field })
|
||||
return false
|
||||
})
|
||||
|
||||
form.on('switch(dict-type-enable)', function (obj) {
|
||||
let operate
|
||||
if (obj.elem.checked) {
|
||||
operate = 'enable'
|
||||
} else {
|
||||
operate = 'disable'
|
||||
}
|
||||
let loading = layer.load()
|
||||
$.ajax({
|
||||
url: '/admin/dict/dictType/' + operate,
|
||||
data: JSON.stringify({ id: this.value }),
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'put',
|
||||
success: function (result) {
|
||||
layer.close(loading)
|
||||
if (result.success) {
|
||||
popup.success(result.msg)
|
||||
} else {
|
||||
popup.failure(result.msg)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
window.addType = function () {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '新增',
|
||||
shade: 0.1,
|
||||
area: ['500px', '400px'],
|
||||
content: '/admin/dict/dictType/add'
|
||||
})
|
||||
}
|
||||
|
||||
window.editType = function (obj) {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '修改',
|
||||
shade: 0.1,
|
||||
area: ['500px', '400px'],
|
||||
content: '/admin/dict/dictType/edit?dictTypeId=' + obj.data['id']
|
||||
})
|
||||
}
|
||||
|
||||
window.removeType = function (obj) {
|
||||
layer.confirm('确定要删除该字典分类', { icon: 3, title: '提示' }, function (index) {
|
||||
layer.close(index)
|
||||
let loading = layer.load()
|
||||
$.ajax({
|
||||
url: '/admin/dict/dictType/remove/' + obj.data['id'],
|
||||
dataType: 'json',
|
||||
type: 'delete',
|
||||
success: function (result) {
|
||||
layer.close(loading)
|
||||
if (result.success) {
|
||||
popup.success(result.msg, function () {
|
||||
if (typeCode === obj.data['typeCode']) {
|
||||
$('[lay-id=\'dict-data-table\']').remove()
|
||||
$('.empty').show()
|
||||
}
|
||||
obj.del()
|
||||
})
|
||||
} else {
|
||||
popup.failure(result.msg)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
window.refreshType = function () {
|
||||
table.reload('dict-type-table')
|
||||
}
|
||||
|
||||
window.addData = function () {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '新增',
|
||||
shade: 0.1,
|
||||
area: ['500px', '450px'],
|
||||
content: '/admin/dict/dictData/add?typeCode=' + typeCode
|
||||
})
|
||||
}
|
||||
|
||||
window.editData = function (obj) {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '修改',
|
||||
shade: 0.1,
|
||||
area: ['500px', '450px'],
|
||||
content: '/admin/dict/dictData/edit?dataId=' + obj.data['dataId']
|
||||
})
|
||||
}
|
||||
|
||||
window.removeData = function (obj) {
|
||||
layer.confirm('确定要删除该字典值', { icon: 3, title: '提示' }, function (index) {
|
||||
layer.close(index)
|
||||
let loading = layer.load()
|
||||
$.ajax({
|
||||
url: '/admin/dict/dictData/remove/' + obj.data['dataId'],
|
||||
dataType: 'json',
|
||||
type: 'delete',
|
||||
success: function (result) {
|
||||
layer.close(loading)
|
||||
if (result.success) {
|
||||
popup.success(result.msg, function () {
|
||||
obj.del()
|
||||
})
|
||||
} else {
|
||||
popup.failure(result.msg)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
table.on('tool(dict-data-table)', function (obj) {
|
||||
if (obj.event === 'remove') {
|
||||
window.removeData(obj)
|
||||
} else if (obj.event === 'edit') {
|
||||
window.editData(obj)
|
||||
} else if (obj.event === 'details') {
|
||||
window.details(obj)
|
||||
}
|
||||
})
|
||||
|
||||
table.on('toolbar(dict-data-table)', function (obj) {
|
||||
if (obj.event === 'add') {
|
||||
window.addData()
|
||||
} else if (obj.event === 'refresh') {
|
||||
window.refreshData()
|
||||
}
|
||||
})
|
||||
|
||||
form.on('submit(dict-data-query)', function (data) {
|
||||
data.field.typeCode = typeCode
|
||||
table.reload('dict-data-table', { where: data.field })
|
||||
return false
|
||||
})
|
||||
|
||||
form.on('switch(dict-data-enable)', function (obj) {
|
||||
let operate
|
||||
if (obj.elem.checked) {
|
||||
operate = 'enable'
|
||||
} else {
|
||||
operate = 'disable'
|
||||
}
|
||||
let loading = layer.load()
|
||||
$.ajax({
|
||||
url: '/admin/dict/dictData/' + operate,
|
||||
data: JSON.stringify({ dataId: this.value }),
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'put',
|
||||
success: function (result) {
|
||||
layer.close(loading)
|
||||
if (result.success) {
|
||||
popup.success(result.msg)
|
||||
} else {
|
||||
popup.failure(result.msg)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
window.refreshData = function () {
|
||||
table.reload('dict-data-table')
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</html>
|
||||
+1
-1
@@ -126,7 +126,7 @@
|
||||
form.on('submit(power-save)', function (data) {
|
||||
data.field.icon = 'layui-icon ' + data.field.icon
|
||||
$.ajax({
|
||||
url: '{{ url_for('rights.save') }}',
|
||||
url: '/rights/power',
|
||||
data: JSON.stringify(data.field),
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
+6
-6
@@ -106,7 +106,7 @@
|
||||
toolbar: '#power-toolbar',
|
||||
elem: '#power-table',
|
||||
url: '{{ url_for('rights.data') }}',
|
||||
page: false,
|
||||
page: false,
|
||||
cols: [
|
||||
[
|
||||
{% if authorize("admin:role:remove") %}
|
||||
@@ -174,14 +174,14 @@
|
||||
form.on('switch(power-enable)', function (obj) {
|
||||
let operate
|
||||
if (obj.elem.checked) {
|
||||
operate = 'enable'
|
||||
operate = 1 /*启用*/
|
||||
} else {
|
||||
operate = 'disable'
|
||||
operate = 0 /*禁用*/
|
||||
}
|
||||
let loading = layer.load()
|
||||
$.ajax({
|
||||
url: MODULE_PATH + operate,
|
||||
data: JSON.stringify({ powerId: this.value }),
|
||||
url: MODULE_PATH + 'enable',
|
||||
data: JSON.stringify({ powerId: this.value, operate: operate }),
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'put',
|
||||
@@ -202,7 +202,7 @@
|
||||
title: '新增',
|
||||
shade: 0.1,
|
||||
area: ['450px', '500px'],
|
||||
content: MODULE_PATH + 'add'
|
||||
content: MODULE_PATH + 'power'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>用户编辑</title>
|
||||
{% include 'admin/common/header.html' %}
|
||||
</head>
|
||||
<body>
|
||||
<form class="layui-form" action="">
|
||||
<div class="mainBox">
|
||||
<div class="main-container">
|
||||
<div class="main-container">
|
||||
<div class="layui-form-item layui-hide">
|
||||
<label class="layui-form-label">编号</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" value="{{ user.id }}" name="userId" lay-verify="title"
|
||||
autocomplete="off" placeholder="请输入标题" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">账号</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" value="{{ user.username }}" name="username" lay-verify="title"
|
||||
autocomplete="off" placeholder="请输入标题" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">姓名</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" value="{{ user.realname }}" name="realName" lay-verify="title"
|
||||
autocomplete="off" placeholder="请输入标题"
|
||||
class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">部门</label>
|
||||
<div class="layui-input-block">
|
||||
<ul id="selectParent" name="deptId" class="dtree" data-id="0"></ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">角色</label>
|
||||
<div class="layui-input-block">
|
||||
{% for role in roles %}
|
||||
<input {% if role.id in checked_roles %}
|
||||
checked
|
||||
{% endif %}
|
||||
value="{{ role.id }}" title="{{ role.name }}" type="checkbox"
|
||||
name="roleIds" lay-skin="primary">
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bottom">
|
||||
<div class="button-container">
|
||||
<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="user-update">
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
提交
|
||||
</button>
|
||||
<button type="reset" class="pear-btn pear-btn-sm">
|
||||
<i class="layui-icon layui-icon-refresh"></i>
|
||||
重置
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{% include 'admin/common/footer.html' %}
|
||||
<script>
|
||||
layui.use(['form', 'jquery', 'dtree'], function () {
|
||||
let form = layui.form
|
||||
let $ = layui.jquery
|
||||
let dtree = layui.dtree
|
||||
|
||||
dtree.renderSelect({
|
||||
elem: '#selectParent',
|
||||
url: '/dept/tree',
|
||||
method: 'get',
|
||||
selectInputName: { nodeId: 'deptId', context: 'deptName' },
|
||||
skin: 'layui',
|
||||
dataFormat: 'list',
|
||||
response: { treeId: 'deptId', parentId: 'parentId', title: 'deptName' },
|
||||
selectInitVal: "{{ user.dept_id }}"
|
||||
})
|
||||
form.on('submit(user-update)', function (data) {
|
||||
let roleIds = ''
|
||||
$('input[type=checkbox]:checked').each(function () {
|
||||
roleIds += $(this).val() + ','
|
||||
})
|
||||
roleIds = roleIds.substr(0, roleIds.length - 1)
|
||||
data.field.roleIds = roleIds
|
||||
$.ajax({
|
||||
url: '/users/' + data.field.userId,
|
||||
data: JSON.stringify(data.field),
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'put',
|
||||
success: function (result) {
|
||||
if (result.success) {
|
||||
layer.msg(result.msg, { icon: 1, time: 1000 }, function () {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name))//关闭当前页
|
||||
parent.layui.table.reload('user-table')
|
||||
})
|
||||
} else {
|
||||
layer.msg(result.msg, { icon: 2, time: 1000 })
|
||||
}
|
||||
}
|
||||
})
|
||||
return false
|
||||
})
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,285 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>付费学员管理</title>
|
||||
{% include 'admin/common/header.html' %}
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='/admin/admin/css/other/user.css') }}"/>
|
||||
</head>
|
||||
|
||||
<body class="pear-container">
|
||||
{# 查询表单 #}
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<form class="layui-form" action="" lay-filter="user-query-form">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">用户</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="username" placeholder="" class="layui-input">
|
||||
</div>
|
||||
<label class="layui-form-label">微信</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="wx" placeholder="" class="layui-input">
|
||||
</div>
|
||||
<button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="user-query">
|
||||
<i class="layui-icon layui-icon-search"></i>
|
||||
查询
|
||||
</button>
|
||||
<button type="reset" class="pear-btn pear-btn-md">
|
||||
<i class="layui-icon layui-icon-refresh"></i>
|
||||
重置
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{#影藏侧边栏#}
|
||||
<div class="user-left user-collasped">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<div class="button button-primary user-group" user-group="1"> 进阶课</div>
|
||||
<div class="button button-default user-group" user-group="2"> 爬虫课</div>
|
||||
<div class="button button-default user-group" user-group="3"> 数据分析课</div>
|
||||
<div style="overflow: auto">
|
||||
{# <ul id="dept-tree" class="dept-tree" data-id="0"></ul>#}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{# 用户表格 #}
|
||||
<div class="user-main user-collasped">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<table id="user-table" lay-filter="user-table"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
{% include 'admin/common/footer.html' %}
|
||||
{# 用户更新时间 #}
|
||||
<script type="text/html" id="user-updateTime">
|
||||
{{ ' {{layui.util.toDateString(d.update_at, "yyyy-MM-dd HH:mm:ss")}' |safe }}}
|
||||
</script>
|
||||
{# 表格操作 #}
|
||||
<script type="text/html" id="user-toolbar">
|
||||
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">
|
||||
<i class="pear-icon pear-icon-add"></i>
|
||||
新增
|
||||
</button>
|
||||
|
||||
<button class="pear-btn pear-btn-md" lay-event="batchRemove">
|
||||
<i class="pear-icon pear-icon-ashbin"></i>
|
||||
删除
|
||||
</button>
|
||||
|
||||
<button class="pear-btn pear-btn-md" lay-event="collasped">
|
||||
<i class="pear-icon pear-icon-modular"></i>
|
||||
高级
|
||||
</button>
|
||||
</script>
|
||||
{# 用户修改操作 #}
|
||||
<script type="text/html" id="user-bar">
|
||||
<button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit">
|
||||
<i class="pear-icon pear-icon-edit"></i>
|
||||
</button>
|
||||
<button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="remove">
|
||||
<i class="pear-icon pear-icon-ashbin"></i>
|
||||
</button>
|
||||
</script>
|
||||
<script>
|
||||
layui.use(['table', 'dtree', 'form', 'jquery', 'popup', 'common'], function () {
|
||||
let table = layui.table
|
||||
let form = layui.form
|
||||
let $ = layui.jquery
|
||||
let dtree = layui.dtree
|
||||
let popup = layui.popup
|
||||
let common = layui.common
|
||||
let MODULE_PATH = '/vip/'
|
||||
|
||||
// 表格数据
|
||||
let cols = [
|
||||
[
|
||||
{#{ type: 'checkbox' },#}
|
||||
{ title: 'ID', field: 'id', align: 'center', width: 110 },
|
||||
{ title: '期数', field: 'phase', align: 'center', width: 110 },
|
||||
{ title: '用户名', field: 'username', align: 'center', width: 110 },
|
||||
{ title: '电话号码', field: 'mobile', align: 'center', hide: true },
|
||||
{ title: '身份证号', field: 'id_card', align: 'center', hide: true },
|
||||
{ title: '微信号', field: 'wx', align: 'center' },
|
||||
{ title: 'QQ号', field: 'qq', align: 'center' },
|
||||
{ title: '报名账号', field: 'account', align: 'center' },
|
||||
{ title: '学号', field: 'number', align: 'center' },
|
||||
{ title: '创建时间', field: 'create_at', templet: '#user-updateTime', align: 'center' },
|
||||
{ title: '操作', toolbar: '#user-bar', align: 'center', width: 130 }
|
||||
]
|
||||
]
|
||||
|
||||
// 渲染表格数据
|
||||
table.render({
|
||||
elem: '#user-table',
|
||||
url: MODULE_PATH + 'data',
|
||||
page: true,
|
||||
cols: cols,
|
||||
skin: 'line',
|
||||
height: 'full-148',
|
||||
toolbar: '#user-toolbar', /*工具栏*/
|
||||
text: { none: '暂无人员信息' },
|
||||
defaultToolbar: [{ layEvent: 'refresh', icon: 'layui-icon-refresh' }, 'filter', 'print', 'exports'] /*默认工具栏*/
|
||||
})
|
||||
|
||||
//
|
||||
$('.user-group').click(function () {
|
||||
let group = $(this).attr('user-group')
|
||||
let field = form.val('user-query-form')
|
||||
field.class_level = group
|
||||
$(this).removeClass('button-default')
|
||||
$(this).siblings().removeClass('button-primary')
|
||||
$(this).siblings().addClass('button-default')
|
||||
$(this).addClass('button-primary')
|
||||
|
||||
window.refresh(field)
|
||||
})
|
||||
|
||||
table.on('tool(user-table)', function (obj) {
|
||||
if (obj.event === 'remove') {
|
||||
window.remove(obj)
|
||||
} else if (obj.event === 'edit') {
|
||||
window.edit(obj)
|
||||
}
|
||||
})
|
||||
|
||||
table.on('toolbar(user-table)', function (obj) {
|
||||
if (obj.event === 'add') {
|
||||
window.add()
|
||||
} else if (obj.event === 'refresh') {
|
||||
window.refresh()
|
||||
} else if (obj.event === 'batchRemove') {
|
||||
window.batchRemove(obj)
|
||||
} else if (obj.event === 'collasped') {
|
||||
$('.user-left').toggleClass('user-collasped')
|
||||
$('.user-main').toggleClass('user-collasped')
|
||||
table.resize()
|
||||
}
|
||||
})
|
||||
|
||||
form.on('submit(user-query)', function (data) {
|
||||
window.refresh(data.field)
|
||||
return false
|
||||
})
|
||||
|
||||
form.on('switch(user-enable)', function (obj) {
|
||||
let operate
|
||||
if (obj.elem.checked) {
|
||||
operate = 1
|
||||
} else {
|
||||
operate = 0
|
||||
}
|
||||
let loading = layer.load()
|
||||
$.ajax({
|
||||
url: MODULE_PATH + 'enable',
|
||||
data: JSON.stringify({ operate: operate, userId: this.value }),
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'put',
|
||||
success: function (result) {
|
||||
layer.close(loading)
|
||||
if (result.success) {
|
||||
popup.success(result.msg)
|
||||
} else {
|
||||
popup.failure(result.msg)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
window.add = function () {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '新增',
|
||||
shade: 0.1,
|
||||
area: ['550px', '550px'],
|
||||
content: MODULE_PATH + 'add'
|
||||
})
|
||||
}
|
||||
|
||||
window.edit = function (obj) {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '修改',
|
||||
shade: 0.1,
|
||||
area: ['550px', '500px'],
|
||||
content: MODULE_PATH + obj.data['id']
|
||||
})
|
||||
}
|
||||
|
||||
window.remove = function (obj) {
|
||||
layer.confirm('确定要删除该用户', { icon: 3, title: '提示' }, function (index) {
|
||||
layer.close(index)
|
||||
let loading = layer.load()
|
||||
$.ajax({
|
||||
url: MODULE_PATH + 'remove/' + obj.data['id'],
|
||||
dataType: 'json',
|
||||
type: 'delete',
|
||||
success: function (result) {
|
||||
layer.close(loading)
|
||||
if (result.success) {
|
||||
popup.success(result.msg, function () {
|
||||
obj.del()
|
||||
})
|
||||
} else {
|
||||
popup.failure(result.msg)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
window.batchRemove = function (obj) {
|
||||
let data = table.checkStatus(obj.config.id).data
|
||||
if (data.length === 0) {
|
||||
layer.msg('未选中数据', {
|
||||
icon: 3,
|
||||
time: 1000
|
||||
})
|
||||
return false
|
||||
}
|
||||
var ids = []
|
||||
var hasCheck = table.checkStatus('user-table')
|
||||
var hasCheckData = hasCheck.data
|
||||
if (hasCheckData.length > 0) {
|
||||
$.each(hasCheckData, function (index, element) {
|
||||
ids.push(element.id)
|
||||
})
|
||||
}
|
||||
{#console.log(ids);#}
|
||||
layer.confirm('确定要删除选中角色', {
|
||||
icon: 3,
|
||||
title: '提示'
|
||||
}, function (index) {
|
||||
layer.close(index)
|
||||
let loading = layer.load()
|
||||
$.ajax({
|
||||
|
||||
url: MODULE_PATH + 'batchRemove',
|
||||
data: { ids: ids },
|
||||
dataType: 'json',
|
||||
type: 'delete',
|
||||
success: function (result) {
|
||||
layer.close(loading)
|
||||
if (result.success) {
|
||||
popup.success(result.msg, function () {
|
||||
table.reload('role-table')
|
||||
})
|
||||
} else {
|
||||
popup.failure(result.msg)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
window.refresh = function (param) {
|
||||
table.reload('user-table', { where: param })
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</html>
|
||||
@@ -1,7 +1,6 @@
|
||||
from flask import Flask
|
||||
|
||||
from applications.view.admin.logs import admin_log
|
||||
from applications.view.admin.dict import admin_dict
|
||||
from applications.view.admin.index import admin_bp
|
||||
from applications.view.admin.file import file_bp
|
||||
from applications.view.rights.role import role_bp
|
||||
@@ -16,4 +15,3 @@ def register_admin_views(app: Flask):
|
||||
app.register_blueprint(admin_monitor_bp)
|
||||
app.register_blueprint(admin_log)
|
||||
app.register_blueprint(role_bp)
|
||||
app.register_blueprint(admin_dict)
|
||||
|
||||
@@ -1,178 +0,0 @@
|
||||
from flask import Blueprint, render_template, request, jsonify
|
||||
|
||||
from applications.common.utils.http import table_api, success_api, fail_api
|
||||
from applications.common.utils.rights import authorize
|
||||
from applications.models import DictType, DictData
|
||||
from applications.view.admin import dict_curd
|
||||
|
||||
admin_dict = Blueprint('adminDict', __name__, url_prefix='/admin/dict')
|
||||
|
||||
|
||||
# 数据字典
|
||||
@admin_dict.get('/')
|
||||
@authorize("admin:dict:main", log=True)
|
||||
def main():
|
||||
return render_template('admin/dict/main.html')
|
||||
|
||||
|
||||
@admin_dict.get('/dictType/data')
|
||||
@authorize("admin:dict:main", log=True)
|
||||
def dict_type_data():
|
||||
page = request.args.get('page', type=int)
|
||||
limit = request.args.get('limit', type=int)
|
||||
type_name = request.args.get('typeName', type=str)
|
||||
data, count = dict_curd.get_dict_type(page=page, limit=limit, type_name=type_name)
|
||||
return table_api(data=data, count=count)
|
||||
|
||||
|
||||
@admin_dict.get('/dictType/add')
|
||||
@authorize("admin:dict:add", log=True)
|
||||
def dict_type_add():
|
||||
return render_template('admin/dict/add.html')
|
||||
|
||||
|
||||
@admin_dict.post('/dictType/save')
|
||||
@authorize("admin:dict:add", log=True)
|
||||
def dict_type_save():
|
||||
req_json = request.json
|
||||
res = dict_curd.save_dict_type(req_json=req_json)
|
||||
if res is None:
|
||||
return fail_api(msg="增加失败")
|
||||
return success_api(msg="增加成功")
|
||||
|
||||
|
||||
# 编辑字典类型
|
||||
@admin_dict.get('/dictType/edit')
|
||||
@authorize("admin:dict:edit", log=True)
|
||||
def dict_type_edit():
|
||||
_id = request.args.get('dictTypeId', type=int)
|
||||
dict_type = DictType.query.filter_by(id=_id).first()
|
||||
return render_template('admin/dict/edit.html', dict_type=dict_type)
|
||||
|
||||
|
||||
# 编辑字典类型
|
||||
@admin_dict.put('/dictType/update')
|
||||
@authorize("admin:dict:edit", log=True)
|
||||
def dict_type_update():
|
||||
req_json = request.json
|
||||
dict_curd.update_dict_type(req_json)
|
||||
return success_api(msg="更新成功")
|
||||
|
||||
|
||||
# 启用字典
|
||||
@admin_dict.put('/dictType/enable')
|
||||
@authorize("admin:dict:edit", log=True)
|
||||
def dict_type_enable():
|
||||
_id = request.json.get('id')
|
||||
if id:
|
||||
res = dict_curd.enable_dict_type_status(_id)
|
||||
if not res:
|
||||
return fail_api(msg="出错啦")
|
||||
return success_api("启动成功")
|
||||
return fail_api(msg="数据错误")
|
||||
|
||||
|
||||
# 禁用字典
|
||||
@admin_dict.put('/dictType/disable')
|
||||
@authorize("admin:dict:edit", log=True)
|
||||
def dict_type_dis_enable():
|
||||
_id = request.json.get('id')
|
||||
if id:
|
||||
res = dict_curd.disable_dict_type_status(_id)
|
||||
if not res:
|
||||
return fail_api(msg="出错啦")
|
||||
return success_api("禁用成功")
|
||||
return fail_api(msg="数据错误")
|
||||
|
||||
|
||||
# 删除字典类型
|
||||
@admin_dict.delete('/dictType/remove/<int:_id>')
|
||||
@authorize("admin:dict:remove", log=True)
|
||||
def dict_type_delete(_id):
|
||||
res = dict_curd.delete_type_by_id(_id)
|
||||
if not res:
|
||||
return fail_api(msg="删除失败")
|
||||
return success_api(msg="删除成功")
|
||||
|
||||
|
||||
@admin_dict.get('/dictData/data')
|
||||
@authorize("admin:dict:main", log=True)
|
||||
def dict_code_data():
|
||||
page = request.args.get('page', type=int)
|
||||
limit = request.args.get('limit', type=int)
|
||||
type_code = request.args.get('typeCode', type=str)
|
||||
data, count = dict_curd.get_dict_data(page=page, limit=limit, type_code=type_code)
|
||||
return table_api(data=data,count=count)
|
||||
|
||||
|
||||
# 增加字典数据
|
||||
@admin_dict.get('/dictData/add')
|
||||
@authorize("admin:dict:add", log=True)
|
||||
def dict_data_add():
|
||||
type_code = request.args.get('typeCode', type=str)
|
||||
return render_template('admin/dict/data/add.html', type_code=type_code)
|
||||
|
||||
|
||||
# 增加字典数据
|
||||
@admin_dict.get('/dictData/save')
|
||||
@authorize("admin:dict:add", log=True)
|
||||
def dict_data_save():
|
||||
req_json = request.json
|
||||
res = dict_curd.save_dict_data(req_json=req_json)
|
||||
if not res:
|
||||
return jsonify(success=False, msg="增加失败")
|
||||
return jsonify(success=True, msg="增加成功")
|
||||
|
||||
|
||||
# 编辑字典数据
|
||||
@admin_dict.get('/dictData/edit')
|
||||
@authorize("admin:dict:edit", log=True)
|
||||
def dict_data_edit():
|
||||
_id = request.args.get('dataId', type=str)
|
||||
dict_data = DictData.query.filter_by(id=_id).first()
|
||||
return render_template('admin/dict/data/edit.html', dict_data=dict_data)
|
||||
|
||||
|
||||
# 编辑字典数据
|
||||
@admin_dict.put('/dictData/update')
|
||||
@authorize("admin:dict:edit", log=True)
|
||||
def dict_data_update():
|
||||
req_json = request.json
|
||||
dict_curd.update_dict_data(req_json)
|
||||
return success_api(msg="更新成功")
|
||||
|
||||
|
||||
# 启用字典数据
|
||||
@admin_dict.put('/dictData/enable')
|
||||
@authorize("admin:dict:edit", log=True)
|
||||
def dict_data_enable():
|
||||
_id = request.json.get('dataId')
|
||||
if _id:
|
||||
res = dict_curd.enable_dict_data_status(_id)
|
||||
if not res:
|
||||
return fail_api(msg="出错啦")
|
||||
return success_api(msg="启动成功")
|
||||
return fail_api(msg="数据错误")
|
||||
|
||||
|
||||
# 禁用字典数据
|
||||
@admin_dict.put('/dictData/disable')
|
||||
@authorize("admin:dict:edit", log=True)
|
||||
def dict_data_disenable():
|
||||
_id = request.json.get('dataId')
|
||||
if _id:
|
||||
res = dict_curd.disable_dict_data_status(_id)
|
||||
if not res:
|
||||
return fail_api(msg="出错啦")
|
||||
return success_api(msg="禁用成功")
|
||||
return fail_api(msg="数据错误")
|
||||
|
||||
|
||||
# 删除字典类型
|
||||
@admin_dict.delete('dictData/remove/<int:id>')
|
||||
@authorize("admin:dict:remove", log=True)
|
||||
def dict_data_delete(id):
|
||||
res = dict_curd.delete_data_by_id(id)
|
||||
if not res:
|
||||
return fail_api(msg="删除失败")
|
||||
return success_api(msg="删除成功")
|
||||
@@ -1,145 +0,0 @@
|
||||
from flask import escape
|
||||
from applications.extensions import db
|
||||
from applications.models import DictType, DictData, DictTypeSchema, DictDataSchema
|
||||
from applications.common.curd import model_to_dicts
|
||||
|
||||
|
||||
def get_dict(typecode: str):
|
||||
dict_list = []
|
||||
if DictType.query.filter_by(type_code=typecode, enable=1).first():
|
||||
dicts = DictData.query.filter_by(type_code=typecode, enable=1).all()
|
||||
for d in dicts:
|
||||
dict_dict = {"key": d.data_label, "value": d.data_value}
|
||||
dict_list.append(dict_dict)
|
||||
else:
|
||||
return None
|
||||
return dict_list
|
||||
|
||||
|
||||
def get_dict_type(page, limit, type_name):
|
||||
dict_all = DictType.query
|
||||
if type_name:
|
||||
dict_all = dict_all.filter(DictType.type_name.like('%' + type_name + '%'))
|
||||
dict_all = dict_all.paginate(page=page,
|
||||
per_page=limit,
|
||||
error_out=False)
|
||||
count = DictType.query.count()
|
||||
data = model_to_dicts(Schema=DictTypeSchema, model=dict_all.items)
|
||||
return data, count
|
||||
|
||||
|
||||
def get_dict_data(page, limit, type_code):
|
||||
dict_all = DictData.query.filter_by(type_code=type_code).paginate(page=page,
|
||||
per_page=limit,
|
||||
error_out=False)
|
||||
count = DictType.query.count()
|
||||
dict_dict = model_to_dicts(Schema=DictDataSchema, model=dict_all.items)
|
||||
return dict_dict, count
|
||||
|
||||
|
||||
# 增加 dict type
|
||||
def save_dict_type(req_json):
|
||||
description = escape(req_json.get("description"))
|
||||
enable = escape(req_json.get("enable"))
|
||||
type_code = escape(req_json.get("typeCode"))
|
||||
type_name = escape(req_json.get("typeName"))
|
||||
d = DictType(type_name=type_name, type_code=type_code, enable=enable, description=description)
|
||||
db.session.add(d)
|
||||
db.session.commit()
|
||||
return d.id
|
||||
|
||||
|
||||
# 编辑字典类型
|
||||
def update_dict_type(req_json):
|
||||
id = escape(req_json.get("id"))
|
||||
description = escape(req_json.get("description"))
|
||||
enable = escape(req_json.get("enable"))
|
||||
type_code = escape(req_json.get("typeCode"))
|
||||
type_name = escape(req_json.get("typeName"))
|
||||
DictType.query.filter_by(id=id).update({
|
||||
"description": description,
|
||||
"enable": enable,
|
||||
"type_code": type_code,
|
||||
"type_name": type_name
|
||||
})
|
||||
db.session.commit()
|
||||
return
|
||||
|
||||
|
||||
def enable_dict_type_status(id):
|
||||
enable = 1
|
||||
res = DictType.query.filter_by(id=id).update({"enable": enable})
|
||||
if res:
|
||||
db.session.commit()
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def disable_dict_type_status(id):
|
||||
enable = 0
|
||||
res = DictType.query.filter_by(id=id).update({"enable": enable})
|
||||
if res:
|
||||
db.session.commit()
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
# 删除字典类型
|
||||
def delete_type_by_id(id):
|
||||
type_code = DictType.query.filter_by(id=id).first().type_code
|
||||
DictData.query.filter_by(type_code=type_code).delete()
|
||||
res = DictType.query.filter_by(id=id).delete()
|
||||
db.session.commit()
|
||||
return res
|
||||
|
||||
|
||||
# 增加dictdata
|
||||
def save_dict_data(req_json):
|
||||
data_label = escape(req_json.get("dataLabel"))
|
||||
data_value = escape(req_json.get("dataValue"))
|
||||
enable = escape(req_json.get("enable"))
|
||||
remark = escape(req_json.get("remark"))
|
||||
type_code = escape(req_json.get("typeCode"))
|
||||
d = DictData(data_label=data_label, data_value=data_value, enable=enable, remark=remark, type_code=type_code)
|
||||
db.session.add(d)
|
||||
db.session.commit()
|
||||
return d.id
|
||||
|
||||
|
||||
# 编辑字典数据
|
||||
def update_dict_data(req_json):
|
||||
id = req_json.get("dataId")
|
||||
DictData.query.filter_by(id=id).update({
|
||||
"data_label": escape(req_json.get("dataLabel")),
|
||||
"data_value": escape(req_json.get("dataValue")),
|
||||
"enable": escape(req_json.get("enable")),
|
||||
"remark": escape(req_json.get("remark")),
|
||||
"type_code": escape(req_json.get("typeCode"))
|
||||
})
|
||||
db.session.commit()
|
||||
return
|
||||
|
||||
|
||||
def enable_dict_data_status(id):
|
||||
enable = 1
|
||||
res = DictData.query.filter_by(id=id).update({"enable": enable})
|
||||
if res:
|
||||
db.session.commit()
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def disable_dict_data_status(id):
|
||||
enable = 0
|
||||
res = DictData.query.filter_by(id=id).update({"enable": enable})
|
||||
if res:
|
||||
db.session.commit()
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
# 删除dictdata
|
||||
def delete_data_by_id(id):
|
||||
res = DictData.query.filter_by(id=id).delete()
|
||||
db.session.commit()
|
||||
return res
|
||||
@@ -5,7 +5,7 @@ rights_bp = Blueprint('rights', __name__, url_prefix='/rights')
|
||||
rights_api = Api(rights_bp)
|
||||
|
||||
from . import routes
|
||||
from . import view
|
||||
from . import right
|
||||
|
||||
|
||||
def register_rights_view(app: Flask):
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
from flask import render_template, request, jsonify, make_response
|
||||
from flask_restful import Resource, reqparse
|
||||
|
||||
from . import rights_bp, rights_api, right_curd
|
||||
from ...common.utils.http import success_api, fail_api
|
||||
from ...common.utils.rights import authorize
|
||||
from ...extensions import db
|
||||
from ...models import Power
|
||||
|
||||
|
||||
@rights_bp.get('/')
|
||||
@authorize("admin:power:main", log=True)
|
||||
def index():
|
||||
return render_template('admin/rights/main.html')
|
||||
|
||||
|
||||
@rights_bp.get('/data')
|
||||
@authorize("admin:power:main", log=True)
|
||||
def data():
|
||||
power_data = right_curd.get_power_dict()
|
||||
res = {
|
||||
"data": power_data
|
||||
}
|
||||
return jsonify(res)
|
||||
|
||||
|
||||
@rights_api.resource('/power')
|
||||
class AddRight(Resource):
|
||||
@authorize("admin:power:add", log=True)
|
||||
def get(self):
|
||||
"""获取增加视图"""
|
||||
return make_response(render_template('admin/rights/add.html'))
|
||||
|
||||
@authorize("admin:power:add", log=True)
|
||||
def post(self):
|
||||
req = request.json
|
||||
right_curd.save_power(req)
|
||||
return success_api(msg="成功")
|
||||
|
||||
|
||||
@rights_bp.get('/selectParent')
|
||||
@authorize("admin:power:main", log=True)
|
||||
def select_parent():
|
||||
"""获取选择父节点"""
|
||||
power_data = right_curd.select_parent()
|
||||
res = {
|
||||
"status": {"code": 200, "message": "默认"},
|
||||
"data": power_data
|
||||
|
||||
}
|
||||
return jsonify(res)
|
||||
|
||||
|
||||
@rights_api.resource('/power/<int:power_id>')
|
||||
class RightsURD(Resource):
|
||||
@authorize("admin:power:edit", log=True)
|
||||
def get(self, power_id):
|
||||
power = right_curd.get_power_by_id(power_id)
|
||||
icon = str(power.icon).split()
|
||||
if len(icon) == 2:
|
||||
icon = icon[1]
|
||||
else:
|
||||
icon = None
|
||||
return make_response(render_template('admin/rights/edit.html', power=power, icon=icon))
|
||||
|
||||
@authorize("admin:power:remove", log=True)
|
||||
def delete(self, power_id):
|
||||
r = right_curd.remove_power(power_id)
|
||||
if r:
|
||||
return success_api(msg="删除成功")
|
||||
else:
|
||||
return fail_api(msg="删除失败")
|
||||
|
||||
@authorize("admin:power:edit", log=True)
|
||||
def put(self, power_id):
|
||||
parser = reqparse.RequestParser(bundle_errors=True)
|
||||
parser.add_argument('icon', type=str)
|
||||
parser.add_argument('openType', type=str, dest='open_type')
|
||||
parser.add_argument('parentId', type=str, dest='parent_id')
|
||||
parser.add_argument('powerCode', type=str, dest='power_code')
|
||||
parser.add_argument('powerName', type=str, dest='power_name')
|
||||
parser.add_argument('powerType', type=str, dest='power_type')
|
||||
parser.add_argument('powerUrl', type=str, dest='power_url')
|
||||
parser.add_argument('sort', type=int, dest='sort')
|
||||
|
||||
res = parser.parse_args()
|
||||
data = {
|
||||
"icon": res.icon,
|
||||
"open_type": res.open_type,
|
||||
"parent_id": res.parent_id,
|
||||
"code": res.power_code,
|
||||
"name": res.power_name,
|
||||
"type": res.power_type,
|
||||
"url": res.power_url,
|
||||
"sort": res.sort
|
||||
}
|
||||
power = Power.query.filter_by(id=power_id).update(data)
|
||||
db.session.commit()
|
||||
|
||||
if not power:
|
||||
return fail_api(msg="更新权限失败")
|
||||
return success_api(msg="更新权限成功")
|
||||
|
||||
|
||||
# 启用权限
|
||||
@rights_bp.put('/enable')
|
||||
@authorize("admin:power:edit", log=True)
|
||||
def enable():
|
||||
parser = reqparse.RequestParser(bundle_errors=True)
|
||||
parser.add_argument('powerId', dest='power_id', type=int, required=True)
|
||||
parser.add_argument('operate', type=int, required=True, choices=[0, 1])
|
||||
|
||||
res = parser.parse_args()
|
||||
|
||||
power = Power.query.filter_by(id=res.power_id).update({"enable": res.operate})
|
||||
if power:
|
||||
db.session.commit()
|
||||
message = "启用成功" if res.operate else '禁用成功'
|
||||
return success_api(msg=message)
|
||||
else:
|
||||
return fail_api(msg="出错啦")
|
||||
|
||||
|
||||
# 批量删除
|
||||
@rights_bp.delete('/batchRemove')
|
||||
@authorize("admin:power:remove", log=True)
|
||||
def batch_remove():
|
||||
ids = request.form.getlist('ids[]')
|
||||
right_curd.batch_remove(ids)
|
||||
return success_api(msg="批量删除成功")
|
||||
@@ -1,114 +0,0 @@
|
||||
from flask import render_template, request, jsonify, make_response
|
||||
from flask_restful import Resource
|
||||
|
||||
from . import rights_bp, rights_api, rights_curd
|
||||
from ...common.utils.http import success_api, fail_api
|
||||
from ...common.utils.rights import authorize
|
||||
|
||||
|
||||
@rights_bp.get('/')
|
||||
@authorize("admin:power:main", log=True)
|
||||
def index():
|
||||
return render_template('admin/power/main.html')
|
||||
|
||||
|
||||
@rights_bp.get('/data')
|
||||
@authorize("admin:power:main", log=True)
|
||||
def data():
|
||||
power_data = rights_curd.get_power_dict()
|
||||
res = {
|
||||
"data": power_data
|
||||
}
|
||||
return jsonify(res)
|
||||
|
||||
|
||||
@rights_bp.get('/add')
|
||||
@authorize("admin:power:add", log=True)
|
||||
def add():
|
||||
"""获取增加视图"""
|
||||
return render_template('admin/power/add.html')
|
||||
|
||||
|
||||
@rights_bp.get('/selectParent')
|
||||
@authorize("admin:power:main", log=True)
|
||||
def select_parent():
|
||||
"""获取选择父节点"""
|
||||
power_data = rights_curd.select_parent()
|
||||
res = {
|
||||
"status": {"code": 200, "message": "默认"},
|
||||
"data": power_data
|
||||
|
||||
}
|
||||
return jsonify(res)
|
||||
|
||||
|
||||
# 增加
|
||||
@rights_bp.post('/save')
|
||||
@authorize("admin:power:add", log=True)
|
||||
def save():
|
||||
req = request.json
|
||||
rights_curd.save_power(req)
|
||||
return success_api(msg="成功")
|
||||
|
||||
|
||||
@rights_api.resource('/power/<int:power_id>')
|
||||
class RightsURD(Resource):
|
||||
@authorize("admin:power:edit", log=True)
|
||||
def get(self, power_id):
|
||||
power = rights_curd.get_power_by_id(power_id)
|
||||
icon = str(power.icon).split()
|
||||
if len(icon) == 2:
|
||||
icon = icon[1]
|
||||
else:
|
||||
icon = None
|
||||
return make_response(render_template('admin/power/edit.html', power=power, icon=icon))
|
||||
|
||||
@authorize("admin:power:remove", log=True)
|
||||
def delete(self, power_id):
|
||||
r = rights_curd.remove_power(power_id)
|
||||
if r:
|
||||
return success_api(msg="删除成功")
|
||||
else:
|
||||
return fail_api(msg="删除失败")
|
||||
|
||||
@authorize("admin:power:edit", log=True)
|
||||
def put(self, power_id):
|
||||
res = rights_curd.update_power(request.json)
|
||||
if not res:
|
||||
return fail_api(msg="更新权限失败")
|
||||
return success_api(msg="更新权限成功")
|
||||
|
||||
|
||||
# 启用权限
|
||||
@rights_bp.put('/enable')
|
||||
@authorize("admin:power:edit", log=True)
|
||||
def enable():
|
||||
power_id = request.json.get('powerId')
|
||||
if id:
|
||||
res = rights_curd.enable_status(power_id)
|
||||
if not res:
|
||||
return fail_api(msg="出错啦")
|
||||
return success_api(msg="启用成功")
|
||||
return fail_api(msg="数据错误")
|
||||
|
||||
|
||||
# 禁用权限
|
||||
@rights_bp.put('/disable')
|
||||
@authorize("admin:power:edit", log=True)
|
||||
def dis_enable():
|
||||
_id = request.json.get('powerId')
|
||||
if _id:
|
||||
res = rights_curd.disable_status(_id)
|
||||
if not res:
|
||||
return fail_api(msg="出错啦")
|
||||
return success_api(msg="禁用成功")
|
||||
return fail_api(msg="数据错误")
|
||||
|
||||
|
||||
# 批量删除
|
||||
@rights_bp.delete('/batchRemove')
|
||||
@authorize("admin:power:remove", log=True)
|
||||
def batch_remove():
|
||||
ids = request.form.getlist('ids[]')
|
||||
rights_curd.batch_remove(ids)
|
||||
return success_api(msg="批量删除成功")
|
||||
Reference in New Issue
Block a user