Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
itimor committed Sep 16, 2020
1 parent 0a1ab1d commit d0a74b8
Show file tree
Hide file tree
Showing 16 changed files with 195 additions and 541 deletions.
4 changes: 2 additions & 2 deletions backend/core/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@
'DEFAULT_PAGINATION_CLASS': 'common.pagination.StandardResultsSetPagination',
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.AllowAny',
# 'rest_framework.permissions.IsAuthenticated',
# 'systems.permissions.IsOwnerRoles',
'rest_framework.permissions.IsAuthenticated',
'systems.permissions.IsOwnerRoles',
),
'DEFAULT_FILTER_BACKENDS': (
'django_filters.rest_framework.DjangoFilterBackend',
Expand Down
6 changes: 4 additions & 2 deletions backend/systems/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
'/api/sys/auth/jwt-token-auth/',
'/api/sys/auth/getuserinfo/',
'/api/sys/auth/getmenubutons/',
'/api/sys/user/',
]


Expand All @@ -42,8 +43,9 @@ def check_permission(request, perm):
class IsOwnerRoles(BasePermission):

def has_permission(self, request, view):
app = view.get_view_name().split()[0].lower()
perm = 'view_' + app
app = view.get_view_name().split()
object = ''.join(app[:-1]).lower()
perm = 'view_{}'.format(object)
return check_permission(request, perm)

def has_object_permission(self, request, view, obj):
Expand Down
5 changes: 1 addition & 4 deletions backend/tickets/management/commands/init_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def handle(self, *args, **options):
menumodel = Menu.objects.create(name='编辑工单', code='u_ticket', curl='/u_ticket/:id', icon='u_ticket', sequence=10, type=2,
hidden=True, active_menu='/new_ticket', parent_id=ticketmenu.id)
init_menu(menumodel)
menumodel = Menu.objects.create(name='审核工单', code='s_ticket', curl='/s_ticket/:id', icon='s_ticket', sequence=10, type=2,
menumodel = Menu.objects.create(name='审批工单', code='s_ticket', curl='/s_ticket/:id', icon='s_ticket', sequence=10, type=2,
hidden=True, active_menu='/todo_ticket', parent_id=ticketmenu.id)
init_menu(menumodel)
menumodel = Menu.objects.create(name='我的工单', code='my_ticket', curl='/my_ticket', icon='my_ticket', sequence=30, type=2,
Expand All @@ -32,7 +32,4 @@ def handle(self, *args, **options):
menumodel = Menu.objects.create(name='所有工单', code='all_ticket', curl='/all_ticket', icon='all_ticket', sequence=90, type=2,
no_cache=True, parent_id=ticketmenu.id)
init_menu(menumodel)
menumodel = Menu.objects.create(name='查看工单', code='c_ticket', curl='/c_ticket/:id', icon='list', sequence=100, type=2,
hidden=True, active_menu='/my_ticket', parent_id=ticketmenu.id)
init_menu(menumodel)
self.stdout.write(self.style.SUCCESS('初始化完成'))
18 changes: 18 additions & 0 deletions backend/tickets/migrations/0002_ticket_relation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.0.3 on 2020-09-16 13:23

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('tickets', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='ticket',
name='relation',
field=models.TextField(blank=True, default='', help_text='创建人、处理人,用于查询', verbose_name='工单关联人'),
),
]
2 changes: 2 additions & 0 deletions backend/tickets/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class Ticket(BaseModel):
state = models.ForeignKey(State, on_delete=models.CASCADE, verbose_name='当前状态')
transition = models.ForeignKey(Transition, on_delete=models.SET_NULL, blank=True, null=True, verbose_name='进行状态')
customfield = models.TextField('所有表单数据', default=[])
relation = models.TextField('工单关联人', default='', blank=True, help_text='创建人、处理人,用于查询')


def __str__(self):
return self.name
Expand Down
5 changes: 5 additions & 0 deletions backend/tickets/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ def update(self, instance, validated_data):
instance.transition = validated_data.get('transition', instance.transition)
instance.customfield = validated_data.get('customfield', instance.customfield)
instance.memo = validated_data.get('memo', instance.memo)

# update relation
relation = instance.relation.split(',')
relation.append(validated_data['relation'])
instance.relation = ','.join(set(relation))
instance.save()

# save ticketlog
Expand Down
11 changes: 7 additions & 4 deletions backend/tickets/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ def get_serializer_class(self):
return TicketSerializer

def get_queryset(self):
user = User.objects.get(username=self.request.user)
if user.is_admin:
try:
user = User.objects.get(username=self.request.user)
if user.is_admin:
return Ticket.objects.all()
else:
return Ticket.objects.all().filter(relation__icontains=self.request.user).distinct()
except:
return Ticket.objects.all()
else:
return Ticket.objects.all().filter(ticketuser__username=self.request.user).distinct()


class TicketFlowLogViewSet(BulkModelMixin):
Expand Down
2 changes: 1 addition & 1 deletion backend/workflows/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __str__(self):

class Meta:
ordering = ['order_id']
verbose_name = '类型'
verbose_name = '工作流类型'
verbose_name_plural = verbose_name


Expand Down
1 change: 0 additions & 1 deletion frontend/src/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export default {
new_ticket: 'new_ticket',
u_ticket: 'u_ticket',
s_ticket: 's_ticket',
c_ticket: 'c_ticket',
my_ticket: 'my_ticket',
todo_ticket: 'todo_ticket',
all_ticket: 'all_ticket',
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/lang/zh.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ export default {
ticket: '工单系统',
new_ticket: '新建工单',
u_ticket: '编辑工单',
s_ticket: '审核工单',
c_ticket: '查看工单',
s_ticket: '审批工单',
my_ticket: '我创建的',
todo_ticket: '我的待办',
all_ticket: '所有工单',
Expand Down
4 changes: 1 addition & 3 deletions frontend/src/store/modules/permission.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,8 @@ export const componentsMap = {

// tickets
new_ticket: () => import('@/views/ticket/new_ticket'), // 新建工单
c_ticket: () => import('@/views/ticket/c_ticket'), // 查看工单
u_ticket: () => import('@/views/ticket/u_ticket'), // 编辑工单
u_ticket: () => import('@/views/ticket/u_ticket'), // 编辑工单
s_ticket: () => import('@/views/ticket/s_ticket'), // 处理工单
s_ticket: () => import('@/views/ticket/s_ticket'), // 审批工单
my_ticket: () => import('@/views/ticket/my_ticket'), // 我创建的
todo_ticket: () => import('@/views/ticket/todo_ticket'), // 我的待办
all_ticket: () => import('@/views/ticket/all_ticket'), // 编辑工单
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/ticket/all_ticket.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<el-table-column label="名称" prop="name"></el-table-column>
<el-table-column label="工单流水号" prop="sn" width="240">
<template slot-scope="{ row }">
<router-link :to="'/c_ticket/' + row.id">
<router-link :to="'/s_ticket/' + row.id">
<el-link type="success">{{row.sn}}</el-link>
</router-link>
</template>
Expand Down
Loading

0 comments on commit d0a74b8

Please sign in to comment.