fix(issues):修改bug

This commit is contained in:
zhengxinonly
2021-07-28 00:08:47 +08:00
parent 460984f209
commit 0640255519
3 changed files with 47 additions and 72 deletions
+3 -5
View File
@@ -110,6 +110,7 @@ def make_menu_tree():
if _dict['id'] in menu_dict: if _dict['id'] in menu_dict:
# 当前节点添加子节点 # 当前节点添加子节点
_dict['children'] = copy.deepcopy(menu_dict[_dict['id']]) _dict['children'] = copy.deepcopy(menu_dict[_dict['id']])
_dict['children'].sort(key=lambda item: item['sort'])
# 删除子节点 # 删除子节点
del menu_dict[_dict['id']] del menu_dict[_dict['id']]
@@ -160,9 +161,6 @@ class RightRights(Resource):
def get(self): def get(self):
"""获取选择父节点""" """获取选择父节点"""
# power = Power.query.all()
# res = marshal(power, power_fields)
power = Power.query.all() power = Power.query.all()
power_data = marshal(power, power_fields) power_data = marshal(power, power_fields)
power_data.append({"powerId": 0, "powerName": "顶级权限", "parentId": -1}) power_data.append({"powerId": 0, "powerName": "顶级权限", "parentId": -1})
@@ -247,12 +245,12 @@ class RightsPower(Resource):
return success_api(msg="更新权限成功") return success_api(msg="更新权限成功")
@rights_api.resource('power/<int:right_id>/status') @rights_api.resource('/power/<int:right_id>/status')
class PowerStatus(Resource): class PowerStatus(Resource):
@authorize("admin:power:edit", log=True) @authorize("admin:power:edit", log=True)
def put(self, right_id): def put(self, right_id):
power = Power.query.get(id=right_id) power = Power.query.get(right_id)
if power: if power:
power.enable = not power.enable power.enable = not power.enable
db.session.commit() db.session.commit()
+16 -23
View File
@@ -34,26 +34,6 @@
</div> </div>
</div> </div>
<script type="text/html" id="toolbar">
<button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="add">
<i class="layui-icon layui-icon-add-1"></i>
新增
</button>
<button class="pear-btn pear-btn-sm" lay-event="batchRemove">
<i class="layui-icon layui-icon-delete"></i>
删除
</button>
</script>
<script type="text/html" id="user-bar">
<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="file-uploadTime">
{{ ' {{layui.util.toDateString(d.create_time, "yyyy-MM-dd HH:mm:ss")}' |safe }}}
</script>
{% include 'common/footer.html' %} {% include 'common/footer.html' %}
<script type="module"> <script type="module">
import { FILE_API } from '/static/api/http.js' import { FILE_API } from '/static/api/http.js'
@@ -108,13 +88,17 @@
{ {
field: 'create_time', field: 'create_time',
title: '创建时间', title: '创建时间',
templet: '#file-uploadTime', templet: (d) => `${layui.util.toDateString(d.create_time, 'yyyy-MM-dd HH:mm:ss')}`,
unresize: true, unresize: true,
align: 'center' align: 'center'
}, },
{ {
title: '操作', title: '操作',
toolbar: '#user-bar', toolbar: (d) => {
return `<button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="remove">
<i class="layui-icon layui-icon-delete"></i>
</button>`
},
align: 'center', align: 'center',
unresize: true, unresize: true,
width: 200 width: 200
@@ -128,7 +112,16 @@
page: true, page: true,
cols: cols, cols: cols,
skin: 'line', skin: 'line',
toolbar: '#toolbar', toolbar: (d) => {
return `<button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="add">
<i class="layui-icon layui-icon-add-1"></i>
新增
</button>
<button class="pear-btn pear-btn-sm" lay-event="batchRemove">
<i class="layui-icon layui-icon-delete"></i>
删除
</button>`
},
defaultToolbar: [{ defaultToolbar: [{
layEvent: 'refresh', layEvent: 'refresh',
icon: 'layui-icon-refresh', icon: 'layui-icon-refresh',
+28 -44
View File
@@ -35,49 +35,23 @@
<script type="text/html" id="power-toolbar"> <script type="text/html" id="power-toolbar">
{% if authorize("admin:power:add") %} <button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add"> <i class="layui-icon layui-icon-add-1"></i>
<i class="layui-icon layui-icon-add-1"></i> 新增
新增 </button>
</button> <button class="pear-btn pear-btn-md" lay-event="batchRemove">
{% endif %} <i class="layui-icon layui-icon-delete"></i>
{% if authorize("admin:role:remove") %} 删除
<button class="pear-btn pear-btn-md" lay-event="batchRemove"> </button>
<i class="layui-icon layui-icon-delete"></i>
删除
</button>
{% endif %}
</script> </script>
<script type="text/html" id="power-bar"> <script type="text/html" id="power-bar">
{% if authorize("admin:role:edit") %} <button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit"><i
<button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>
class="layui-icon layui-icon-edit"></i> </button>
</button> <button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="remove"><i
{% endif %} class="layui-icon layui-icon-delete"></i>
{% if authorize("admin:role:remove") %} </button>
<button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="remove"><i
class="layui-icon layui-icon-delete"></i>
</button>
{% endif %}
</script>
<script type="text/html" id="power-type">
{{ "
{{#if (d.powerType == '0') { }}
<span>目录</span>
{{# }else if(d.powerType == '1'){ }}
<span>菜单</span>
{{# }else if(d.powerType == '2'){ }}
<span>按钮</span>
{{# } }}
" |safe }}
</script>
<script type="text/html" id="icon">
<i class="layui-icon {{ "{{d.icon}}" }}"></i>
</script> </script>
@@ -190,12 +164,22 @@
[ [
{ type: 'checkbox' }, { type: 'checkbox' },
{ field: 'powerName', minWidth: 200, title: '权限名称' }, { field: 'powerName', minWidth: 200, title: '权限名称' },
{ field: 'icon', title: '图标', templet: '#icon' }, { field: 'icon', title: '图标', templet: (d) => `<i class="layui-icon ${d.icon}"></i>` },
{ field: 'powerType', title: '权限类型', templet: '#power-type' }, {
field: 'powerType', title: '权限类型', templet: (d) => {
if (d.powerType == '0') {
return `<span>目录</span>`
} else if (d.powerType == '1') {
return `<span>菜单</span>`
} else if (d.powerType == '2') {
return `<span>按钮</span>`
}
}
},
{ {
field: 'enable', title: '是否可用', templet: (d) => { field: 'enable', title: '是否可用', templet: (d) => {
// TODO 修改禁用启动逻辑 // TODO 修改禁用启动逻辑
return `<input type="checkbox" name="enable" value="${d.powerId}" lay-skin="switch" lay-text="启用|禁用" lay-filter="power_enable" ${d.enable == 1 ? 'checked=checked' : ''}` return `<input type="checkbox" name="enable" value="${d.powerId}" lay-skin="switch" lay-text="启用|禁用" lay-filter="power_enable" ${d.enable === 1 ? 'checked=checked' : ''}>`
} }
}, },
{ field: 'sort', title: '排序' }, { field: 'sort', title: '排序' },
@@ -253,7 +237,7 @@
} }
}) })
form.on('switch(power-enable)', function (obj) { form.on('switch(power_enable)', function (obj) {
let operate let operate
if (obj.elem.checked) { if (obj.elem.checked) {
operate = 1 /*启用*/ operate = 1 /*启用*/