From 52838222dba91f7ab1c2c60266688f1f513a473f Mon Sep 17 00:00:00 2001 From: wojiaoyishang Date: Thu, 23 Jan 2025 21:16:16 +0800 Subject: [PATCH] =?UTF-8?q?Update:=20=EF=BC=88=E6=AD=A5=E9=AA=A4=E5=A4=87?= =?UTF-8?q?=E4=BB=BD=EF=BC=89=E5=AE=8C=E5=96=84=E5=AD=97=E5=85=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- applications/common/utils/rights.py | 7 + applications/view/system/dict.py | 115 +++- applications/view/system/log.py | 8 +- static/system/admin/css/other/monitor.css | 26 +- .../system/component/pear/module/tabPage.js | 3 +- templates/system/dept/edit.html | 59 +- templates/system/dict/add.html | 8 +- templates/system/dict/data/add.html | 6 +- templates/system/dict/data/edit.html | 57 +- templates/system/dict/edit.html | 63 +- templates/system/dict/main.html | 643 ++++++++++-------- templates/system/monitor.html | 8 +- 12 files changed, 599 insertions(+), 404 deletions(-) diff --git a/applications/common/utils/rights.py b/applications/common/utils/rights.py index edd857f..640a129 100644 --- a/applications/common/utils/rights.py +++ b/applications/common/utils/rights.py @@ -18,7 +18,12 @@ def authorize(power: str, log: bool = False): def wrapper(*args, **kwargs): # 定义管理员的id为1 if current_user.username == current_app.config.get("SUPERADMIN"): + + if log: + admin_log(request=request, is_access=True) + return func(*args, **kwargs) + if not power in session.get('permissions'): if log: admin_log(request=request, is_access=False) @@ -26,8 +31,10 @@ def authorize(power: str, log: bool = False): abort(403) else: return jsonify(success=False, msg="权限不足!") + if log: admin_log(request=request, is_access=True) + return func(*args, **kwargs) return wrapper diff --git a/applications/view/system/dict.py b/applications/view/system/dict.py index ac76c59..d07cfa3 100644 --- a/applications/view/system/dict.py +++ b/applications/view/system/dict.py @@ -33,6 +33,7 @@ def dict_type_data(): dict_all = DictType.query.filter(mf.get_filter(DictType)).layui_paginate() count = dict_all.total data = curd.model_to_dicts(schema=DictTypeOutSchema, data=dict_all.items) + return table_api(data=data, count=count) @@ -46,13 +47,24 @@ def dict_type_add(): @authorize("system:dict:add", log=True) def dict_type_save(): req_json = request.get_json(force=True) - description = str_escape(req_json.get("description")) - enable = str_escape(req_json.get("enable")) - type_code = str_escape(req_json.get("typeCode")) - if type_code is None: - return fail_api(msg="标识必须填写") - type_name = str_escape(req_json.get("typeName")) - d = DictType(type_name=type_name, type_code=type_code, enable=enable, description=description) + + data = { + 'type_name': str_escape(req_json.get("typeName")), + 'type_code': str_escape(req_json.get("typeCode")), + 'enable': str_escape(req_json.get("enable")), + 'description': str_escape(req_json.get("description")) + } + + description = data['description'] + del data['description'] + + if not all(data.values()): + return fail_api(msg="参数提供不足") + + if description is not None: + data['description'] = description + + d = DictType(**data) db.session.add(d) db.session.commit() if d.id is None: @@ -75,16 +87,26 @@ def dict_type_edit(): def dict_type_update(): req_json = request.get_json(force=True) id = str_escape(req_json.get("id")) - description = str_escape(req_json.get("description")) - enable = str_escape(req_json.get("enable")) - type_code = str_escape(req_json.get("typeCode")) - type_name = str_escape(req_json.get("typeName")) - DictType.query.filter_by(id=id).update({ - "description": description, - "enable": enable, - "type_code": type_code, - "type_name": type_name - }) + + data = { + "description": str_escape(req_json.get("description")), + "enable": str_escape(req_json.get("enable")), + "type_code": str_escape(req_json.get("typeCode")), + "type_name": str_escape(req_json.get("typeName")) + } + + if id is None: + return fail_api(msg="字典类型不存在") + + description = data['description'] + del data['description'] + + if not all(data.values()): + return fail_api(msg="参数提供不足") + + data['description'] = description + + DictType.query.filter_by(id=id).update(data) db.session.commit() return success_api(msg="更新成功") @@ -94,11 +116,11 @@ def dict_type_update(): @authorize("system:dict:edit", log=True) def dict_type_enable(): _id = request.get_json(force=True).get('id') - if id: - res = curd.enable_status(DictType,_id) + if _id: + res = curd.enable_status(DictType, _id) if not res: return fail_api(msg="出错啦") - return success_api("启动成功") + return success_api("启用成功") return fail_api(msg="数据错误") @@ -107,8 +129,8 @@ def dict_type_enable(): @authorize("system:dict:edit", log=True) def dict_type_dis_enable(): _id = request.get_json(force=True).get('id') - if id: - res = curd.disable_status(DictType,_id) + if _id: + res = curd.disable_status(DictType, _id) if not res: return fail_api(msg="出错啦") return success_api("禁用成功") @@ -119,9 +141,15 @@ def dict_type_dis_enable(): @bp.delete('/dictType/remove/') @authorize("system:dict:remove", log=True) def dict_type_delete(_id): - res = curd.delete_one_by_id(DictType,_id) + DictData.query.filter_by( + type_code=DictType.query.filter_by(id=_id).first().type_code + ).all() + res = DictType.query.filter_by(id=_id).delete() + if not res: return fail_api(msg="删除失败") + + db.session.commit() return success_api(msg="删除成功") @@ -148,11 +176,13 @@ def dict_data_add(): @authorize("system:dict:add", log=True) def dict_data_save(): req_json = request.get_json(force=True) + data_label = str_escape(req_json.get("dataLabel")) data_value = str_escape(req_json.get("dataValue")) enable = str_escape(req_json.get("enable")) remark = str_escape(req_json.get("remark")) type_code = str_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() @@ -213,7 +243,7 @@ def dict_data_disenable(): return fail_api(msg="数据错误") -# 删除字典类型 +# 删除字典数据 @bp.delete('dictData/remove/') @authorize("system:dict:remove", log=True) def dict_data_delete(id): @@ -221,3 +251,40 @@ def dict_data_delete(id): if not res: return fail_api(msg="删除失败") return success_api(msg="删除成功") + + +# 批量删除字典 +@bp.delete('dictData/batchRemoveDictType') +@authorize("system:dict:remove", log=True) +def dict_type_batch_remove(): + ids = request.form.getlist('ids[]') + + for _id in ids: + DictData.query.filter_by( + type_code=DictType.query.filter_by(id=_id).first().type_code + ).all() + + res = DictType.query.filter_by(id=_id).delete() + + if res == 0: + db.session.rollback() + return fail_api(msg="删除失败,请重试") + + db.session.commit() + return success_api(msg="删除成功") + + +# 批量删除字典数据 +@bp.delete('dictData/batchRemoveDictData') +@authorize("system:dict:remove", log=True) +def dict_data_batch_remove(): + ids = request.form.getlist('ids[]') + print(ids) + for _id in ids: + res = curd.delete_one_by_id(model=DictData, id=_id) + if not res: + db.session.rollback() + return fail_api(msg="删除失败,请重试") + + db.session.commit() + return success_api(msg="删除成功") diff --git a/applications/view/system/log.py b/applications/view/system/log.py index bad5444..bc33397 100644 --- a/applications/view/system/log.py +++ b/applications/view/system/log.py @@ -22,8 +22,8 @@ def index(): def login_log(): # orm查询 # 使用分页获取data需要.items - log = AdminLog.query.filter( - AdminLog.url != '/passport/login' + log = AdminLog.query.filter_by( + url='/system/passport/login' ).order_by(desc(AdminLog.create_time)).layui_paginate() count = log.total return table_api(data=model_to_dicts(schema=LogOutSchema, data=log.items), count=count) @@ -35,8 +35,8 @@ def login_log(): def operate_log(): # orm查询 # 使用分页获取data需要.items - log = AdminLog.query.filter_by( - url='/passport/login' + log = AdminLog.query.filter( + AdminLog.url != '/system/passport/login' ).order_by( desc(AdminLog.create_time)).layui_paginate() count = log.total diff --git a/static/system/admin/css/other/monitor.css b/static/system/admin/css/other/monitor.css index 687b22c..e7a9198 100644 --- a/static/system/admin/css/other/monitor.css +++ b/static/system/admin/css/other/monitor.css @@ -1,7 +1,4 @@ -.pear-container { - background-color: whitesmoke; - margin: 10px; -} + .pear-card { width: 100%; @@ -28,6 +25,16 @@ margin-bottom: 3px; } +.pear-admin-dark .pear-card2 { + width: 100%; + height: 90px; + background-color: #353537; + display: inline-block; + border-radius: 5px; + text-align: center; + margin-bottom: 3px; +} + .pear-card2 i { font-size: 30px; height: 90px; @@ -185,3 +192,14 @@ color: #333; } +.pear-admin-dark .progress-ring .progress-text { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + font-size: 18px; + font-weight: bold; + color: #cfcfcf; +} + + diff --git a/static/system/component/pear/module/tabPage.js b/static/system/component/pear/module/tabPage.js index 9598d53..f39ddae 100644 --- a/static/system/component/pear/module/tabPage.js +++ b/static/system/component/pear/module/tabPage.js @@ -383,7 +383,8 @@ layui.define(['jquery', 'element', 'dropdown'], function (exports) { */ tabPage.prototype.refresh = function (time) { - var $iframe = $(".layui-tab[lay-filter='" + this.option.elem + "'] .layui-tab-content .layui-show > div[data-frameid], iframe[data-frameid]"); + var $iframe = $(".layui-tab[lay-filter='" + this.option.elem + "'] .layui-tab-content .layui-show > div[data-frameid], " + + ".layui-tab[lay-filter='" + this.option.elem + "'] .layui-tab-content .layui-show > iframe[data-frameid]"); var $iframeLoad; if (time != false && time != 0) { diff --git a/templates/system/dept/edit.html b/templates/system/dept/edit.html index 4bfd682..1d9a3c3 100644 --- a/templates/system/dept/edit.html +++ b/templates/system/dept/edit.html @@ -26,7 +26,8 @@
-
@@ -34,7 +35,8 @@
-
@@ -42,7 +44,8 @@
-
@@ -70,11 +73,7 @@
+ class="layui-textarea">{% if dept.address %}{{ dept.address }}{% endif %}
@@ -96,31 +95,31 @@ {% include 'system/common/footer.html' %} diff --git a/templates/system/dict/add.html b/templates/system/dict/add.html index 8e579d8..276cc02 100644 --- a/templates/system/dict/add.html +++ b/templates/system/dict/add.html @@ -12,14 +12,14 @@
-
-
@@ -41,12 +41,12 @@
- - diff --git a/templates/system/dict/data/add.html b/templates/system/dict/data/add.html index 2579d6b..3feb617 100644 --- a/templates/system/dict/data/add.html +++ b/templates/system/dict/data/add.html @@ -28,7 +28,7 @@
+ autocomplete="off" placeholder="请输入标识" class="layui-input">
@@ -49,12 +49,12 @@
- - diff --git a/templates/system/dict/data/edit.html b/templates/system/dict/data/edit.html index 4f33615..ce09040 100644 --- a/templates/system/dict/data/edit.html +++ b/templates/system/dict/data/edit.html @@ -19,21 +19,21 @@
+ autocomplete="off" placeholder="请输入标签" class="layui-input">
+ autocomplete="off" placeholder="请输入值" class="layui-input">
+ lay-verify="title" autocomplete="off" placeholder="请输入标识" class="layui-input">
@@ -49,7 +49,8 @@
+ class="layui-textarea" + >{% if dict_data.remark %}{{ dict_data.remark }}{% endif %}
@@ -57,12 +58,12 @@
- - @@ -71,31 +72,31 @@ {% include 'system/common/footer.html' %} diff --git a/templates/system/dict/edit.html b/templates/system/dict/edit.html index 2271c36..858151d 100644 --- a/templates/system/dict/edit.html +++ b/templates/system/dict/edit.html @@ -12,22 +12,22 @@
-
- +
+ lay-verify="required" autocomplete="off" placeholder="请输入标识" class="layui-input">
@@ -42,8 +42,11 @@
- +
@@ -51,12 +54,12 @@
- - @@ -65,31 +68,31 @@ {% include 'system/common/footer.html' %} diff --git a/templates/system/dict/main.html b/templates/system/dict/main.html index b84534a..807b2f3 100644 --- a/templates/system/dict/main.html +++ b/templates/system/dict/main.html @@ -10,16 +10,17 @@
-
+
- - @@ -38,29 +39,32 @@
- - - - - - - - + + + + + + + + + + + + + + - - - - - - - + +
+
@@ -69,48 +73,51 @@ @@ -121,254 +128,346 @@ {% include 'system/common/footer.html' %} \ No newline at end of file diff --git a/templates/system/monitor.html b/templates/system/monitor.html index 22ac9f8..c12e379 100644 --- a/templates/system/monitor.html +++ b/templates/system/monitor.html @@ -12,7 +12,7 @@
- 主机信息 + 主机监控
@@ -95,7 +95,7 @@
主机信息
- +
@@ -244,7 +244,6 @@ }) - let bgColor = "#fff"; let color = [ "#0090FF", "#36CE9E", @@ -269,7 +268,7 @@ let echartData = []; var option = { - backgroundColor: bgColor, + backgroundColor: 'transparent', color: color, legend: { right: 10, @@ -286,6 +285,7 @@ } }, grid: { + backgroundColor: 'transparent', top: 100, containLabel: true },
属性