完善可自定义的管理界面

This commit is contained in:
raiots 2021-03-09 17:08:31 +08:00
parent 15f0165ae4
commit 7a73917e1c
5 changed files with 33 additions and 7 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@
/packagesdir/ /packagesdir/
/db.sqlite3 /db.sqlite3
/identifier.sqlite /identifier.sqlite
migrations/

View File

@ -156,8 +156,8 @@ SIMPLEUI_HOME_ICON = 'el el-icon-platform-eleme'
SIMPLEUI_DEFAULT_THEME = 'ant.design.css' SIMPLEUI_DEFAULT_THEME = 'ant.design.css'
SIMPLEUI_CONFIG = { SIMPLEUI_CONFIG = {
'system_keep': True, 'system_keep': False,
'menu_display': ['任务管理', '系统配置', '多级菜单测试', '动态菜单测试'], # 开启排序和过滤功能, 不填此字段为默认排序和全部显示, 空列表[] 为全部不显示. 'menu_display': ['任务管理', '系统配置', '关于'], # 开启排序和过滤功能, 不填此字段为默认排序和全部显示, 空列表[] 为全部不显示.
'dynamic': True, # 设置是否开启动态菜单, 默认为False. 如果开启, 则会在每次用户登陆时动态展示菜单内容 'dynamic': True, # 设置是否开启动态菜单, 默认为False. 如果开启, 则会在每次用户登陆时动态展示菜单内容
'menus': [{ 'menus': [{
'name': '任务管理', 'name': '任务管理',
@ -177,9 +177,22 @@ SIMPLEUI_CONFIG = {
'models': [{ 'models': [{
'name': '用户', 'name': '用户',
'icon': 'fa fa-user', 'icon': 'fa fa-user',
'url': 'users/user' 'url': 'users/user',
}, { }, {
'name': '部门' 'name': '部门',
'url': 'users/department'
}, {
'name': '任务属性',
'url': 'users/taskproperty',
}, {
'name': '权限组',
'url': 'users/mygroup',
}, {
'name': '评价等级定义',
'url': 'users/qualitymark',
}, {
'name': '评价等级考核系数',
'url': 'users/markvalue'
}] }]
}, { }, {
# 自2021.02.01+ 支持多级菜单models 为子菜单名 # 自2021.02.01+ 支持多级菜单models 为子菜单名
@ -214,5 +227,8 @@ SIMPLEUI_CONFIG = {
'url': 'http://baidu.com', 'url': 'http://baidu.com',
'icon': 'far fa-surprise' 'icon': 'far fa-surprise'
}] }]
}, {
'name': '关于',
'url': '/about'
}] }]
} }

View File

@ -1,6 +1,7 @@
from django.contrib import auth, messages from django.contrib import auth, messages
from django.contrib.auth import logout from django.contrib.auth import logout
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.db.models import Sum, F
from django.shortcuts import render, redirect from django.shortcuts import render, redirect
from django.utils.decorators import method_decorator from django.utils.decorators import method_decorator
import django.utils.timezone as timezone import django.utils.timezone as timezone
@ -12,9 +13,11 @@ from apps.users.models import User
class IndexView(View): class IndexView(View):
@method_decorator(login_required)
def get(self, request): def get(self, request):
users = User.objects.all() users = User.objects.all()
context = {'users': users} points = User.objects.annotate(a=Sum(F('main_executor__predict_work') * F('main_executor__evaluate_factor') + F('sub_executor__predict_work') * F('sub_executor__evaluate_factor')))
context = {'users': users, 'points': points}
return render(request, 'tasks/index.html', context) return render(request, 'tasks/index.html', context)

View File

@ -20,7 +20,9 @@ class User(AbstractUser):
@classmethod @classmethod
def get_total_point(cls): def get_total_point(cls):
return cls.objects.aggregate(total=Sum(F('main_executor__predict_work') * F('main_executor__evaluate_factor') + F('sub_executor__predict_work') * F('sub_executor__evaluate_factor')))['total'] return cls.objects.annotate(total=Sum('main_executor__predict_work'))
# def get_total_point(cls):
# return cls.objects.aggregate(total=Sum(F('main_executor__predict_work') * F('main_executor__evaluate_factor') + F('sub_executor__predict_work') * F('sub_executor__evaluate_factor')))['total']
@classmethod @classmethod
def get_predict_work_count(cls): def get_predict_work_count(cls):

View File

@ -125,6 +125,10 @@
<!-- /.content --> <!-- /.content -->
</div> </div>
<div class="content-wrapper"> <div class="content-wrapper">
{% for point in points %}
{{ point }}
{{ point.a }}
{% endfor %}
{# {% for user in users %}#} {# {% for user in users %}#}
{# {{ user }}#} {# {{ user }}#}
{# {{ user.get_predict_work_count.total_predict_work }}#} {# {{ user.get_predict_work_count.total_predict_work }}#}