From a7efe58a789820ce711b5da54feeac6434cf69e7 Mon Sep 17 00:00:00 2001
From: shilixia <2309368887@qq.com>
Date: Fri, 3 Sep 2021 14:18:25 +0800
Subject: [PATCH 1/4] TIJIAO
---
hb_client/src/api/inm.js | 30 ++++
hb_client/src/router/index.js | 36 +++-
hb_client/src/views/inm/warehouse.vue | 248 ++++++++++++++++++++++++++
3 files changed, 312 insertions(+), 2 deletions(-)
create mode 100644 hb_client/src/api/inm.js
create mode 100644 hb_client/src/views/inm/warehouse.vue
diff --git a/hb_client/src/api/inm.js b/hb_client/src/api/inm.js
new file mode 100644
index 0000000..3258078
--- /dev/null
+++ b/hb_client/src/api/inm.js
@@ -0,0 +1,30 @@
+import request from '@/utils/request'
+
+export function getWarehouseList(query) {
+ return request({
+ url: '/inm/warehouse/',
+ method: 'get',
+ params: query
+ })
+}
+export function createWarehouse(data) {
+ return request({
+ url: '/inm/warehouse/',
+ method: 'post',
+ data
+ })
+}
+export function updateWarehouse(id, data) {
+ return request({
+ url: `/inm/warehouse/${id}/`,
+ method: 'put',
+ data
+ })
+}
+export function deleteWarehouse(id, data) {
+ return request({
+ url: `/inm/warehouse/${id}/`,
+ method: 'delete',
+ data
+ })
+}
diff --git a/hb_client/src/router/index.js b/hb_client/src/router/index.js
index 924dfbc..309d736 100644
--- a/hb_client/src/router/index.js
+++ b/hb_client/src/router/index.js
@@ -87,6 +87,12 @@ export const asyncRoutes = [
name: 'equipment',
meta: { title: '设备管理', icon: 'example', perms: ['equipment_set'] },
children: [
+ {
+ path: 'index',
+ name: 'index',
+ component: () => import('@/views/equipment/index'),
+ meta: { title: '设备台账', icon: 'example', perms: ['index_manage'] }
+ },
{
path: 'index',
name: 'index',
@@ -95,14 +101,34 @@ export const asyncRoutes = [
}
]
},
-
+ {
+ path: '/inm',
+ component: Layout,
+ redirect: '/inm/warehouse',
+ name: 'inm',
+ meta: { title: '库存管理', icon: 'example', perms: ['equipment_set'] },
+ children: [
+ {
+ path: 'warehouse',
+ name: 'warehouse',
+ component: () => import('@/views/inm/warehouse'),
+ meta: { title: '仓库', icon: 'example', perms: ['index_manage'] }
+ },
+ {
+ path: 'warehouse',
+ name: 'warehouse',
+ component: () => import('@/views/inm/warehouse'),
+ meta: { title: '仓库', icon: 'example', perms: ['index_manage'] }
+ }
+ ]
+ },
{
path: '/mtm',
component: Layout,
redirect: '/mtm/material/',
name: 'mtm',
- meta: { title: '制造技术管理', icon: 'example', perms: ['procurement_set'] },
+ meta: { title: '制造管理', icon: 'example', perms: ['procurement_set'] },
children: [
{
path: 'material',
@@ -147,6 +173,12 @@ export const asyncRoutes = [
name: 'procurement',
meta: { title: '采购管理', icon: 'example', perms: ['procurement_set'] },
children: [
+ {
+ path: 'vendor',
+ name: 'vendor',
+ component: () => import('@/views/procurement/vendor'),
+ meta: { title: '供应商', icon: 'example', perms: ['vendor_manage'] }
+ },
{
path: 'vendor',
name: 'vendor',
diff --git a/hb_client/src/views/inm/warehouse.vue b/hb_client/src/views/inm/warehouse.vue
new file mode 100644
index 0000000..a7c9e23
--- /dev/null
+++ b/hb_client/src/views/inm/warehouse.vue
@@ -0,0 +1,248 @@
+
+
+
+
+
+ 搜索
+ 重置
+
+
+ 新增设备
+
+
+
+
+
+
+ {{ scope.row.name }}
+
+
+
+ {{ scope.row.number }}
+
+
+ {{ scope.row.place }}
+
+
+
+
+
+
+ 编辑
+ 删除
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 取消
+ 确认
+
+
+
+
+
From 6805669f47783e6132e9c5a0411fd29448d0ab5c Mon Sep 17 00:00:00 2001
From: caoqianming
Date: Mon, 6 Sep 2021 08:53:26 +0800
Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B7=A5=E5=BA=8F?=
=?UTF-8?q?=E6=8E=92=E5=88=97=E6=96=B9=E5=BC=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
hb_server/apps/mtm/serializers.py | 2 +-
hb_server/apps/mtm/views.py | 9 ++++++++
hb_server/apps/wf/models.py | 3 +++
hb_server/apps/wf/serializers.py | 16 ++++++++++++++-
hb_server/apps/wf/services.py | 3 ++-
hb_server/apps/wf/views.py | 34 +++++++++++++++++++++----------
6 files changed, 53 insertions(+), 14 deletions(-)
diff --git a/hb_server/apps/mtm/serializers.py b/hb_server/apps/mtm/serializers.py
index 1440aaa..428af15 100644
--- a/hb_server/apps/mtm/serializers.py
+++ b/hb_server/apps/mtm/serializers.py
@@ -18,7 +18,7 @@ class MaterialDetailSerializer(serializers.ModelSerializer):
fields = '__all__'
def get_processes_(self, obj):
- objs = Process.objects.filter(id__in=obj.processes)
+ objs = Process.objects.filter(id__in=obj.processes).order_by('number')
return ProcessSimpleSerializer(instance=objs, many=True).data
diff --git a/hb_server/apps/mtm/views.py b/hb_server/apps/mtm/views.py
index 11c3927..c21c08f 100644
--- a/hb_server/apps/mtm/views.py
+++ b/hb_server/apps/mtm/views.py
@@ -156,6 +156,15 @@ class RecordFormViewSet(OptimizationMixin, CreateUpdateModelAMixin, ModelViewSet
elif self.action == 'update':
return RecordFormUpdateSerializer
return RecordFormSerializer
+
+ @action(methods=['get'], detail=True, perms_map={'get':'*'}, pagination_class=None, serializer_class=RecordFormFieldSerializer)
+ def fields(self, request, pk=None):
+ """
+ 表格下的字段
+ """
+ instance = self.get_object()
+ serializer = self.serializer_class(instance=RecordFormField.objects.filter(form=instance, is_deleted=False), many=True)
+ return Response(serializer.data)
class RecordFormFieldViewSet(OptimizationMixin, CreateUpdateModelAMixin, ModelViewSet):
diff --git a/hb_server/apps/wf/models.py b/hb_server/apps/wf/models.py
index 2591a75..740928c 100644
--- a/hb_server/apps/wf/models.py
+++ b/hb_server/apps/wf/models.py
@@ -79,6 +79,9 @@ class Transition(CommonAModel):
"""
工作流流转,定时器,条件(允许跳过), 条件流转与定时器不可同时存在
"""
+ TRANSITION_ATTRIBUTE_TYPE_ACCEPT = 1 # 同意
+ TRANSITION_ATTRIBUTE_TYPE_REFUSE = 2 # 拒绝
+ TRANSITION_ATTRIBUTE_TYPE_OTHER = 3 # 其他
attribute_type_choices = (
(1, '同意'),
(2, '拒绝'),
diff --git a/hb_server/apps/wf/serializers.py b/hb_server/apps/wf/serializers.py
index d4ca696..eedf40c 100644
--- a/hb_server/apps/wf/serializers.py
+++ b/hb_server/apps/wf/serializers.py
@@ -1,7 +1,8 @@
+from apps.system.serializers import UserSimpleSerializer
import rest_framework
from rest_framework import serializers
-from .models import State, Ticket, Workflow, Transition, CustomField
+from .models import State, Ticket, TicketFlow, Workflow, Transition, CustomField
class WorkflowSerializer(serializers.ModelSerializer):
@@ -42,6 +43,10 @@ class CustomFieldSerializer(serializers.ModelSerializer):
model = CustomField
fields = '__all__'
+class TicketSimpleSerializer(serializers.ModelSerializer):
+ class Meta:
+ model = Ticket
+ fields = '__all__'
class TicketCreateSerializer(serializers.ModelSerializer):
transition = serializers.IntegerField(label='流转ID')
@@ -65,3 +70,12 @@ class TicketSerializer(serializers.ModelSerializer):
def setup_eager_loading(queryset):
queryset = queryset.select_related('workflow','state')
return queryset
+
+class TicketFlowSerializer(serializers.ModelSerializer):
+ participant_ = UserSimpleSerializer(source='participant', read_only=True)
+ state_ = StateSimpleSerializer(source='state', read_only=True)
+ class Meta:
+ model = TicketFlow
+ fields = '__all__'
+
+
\ No newline at end of file
diff --git a/hb_server/apps/wf/services.py b/hb_server/apps/wf/services.py
index d17de32..06ce023 100644
--- a/hb_server/apps/wf/services.py
+++ b/hb_server/apps/wf/services.py
@@ -1,3 +1,4 @@
+from apps.wf.serializers import TicketSerializer, TicketSimpleSerializer
from typing import Tuple
from apps.system.models import User
from apps.wf.models import CustomField, State, Ticket, Transition, Workflow
@@ -198,7 +199,7 @@ class WfService(object):
:return:
"""
# 获取工单基础表中的字段中的字段信息
- field_info_dict = ticket.get_dict()
+ field_info_dict = TicketSimpleSerializer(instance=ticket).data
# 获取自定义字段的值
custom_fields_queryset = cls.get_workflow_custom_fields(ticket.workflow)
for i in custom_fields_queryset:
diff --git a/hb_server/apps/wf/views.py b/hb_server/apps/wf/views.py
index 0823dca..40732c8 100644
--- a/hb_server/apps/wf/views.py
+++ b/hb_server/apps/wf/views.py
@@ -2,7 +2,7 @@ from django.core.exceptions import AppRegistryNotReady
from rest_framework.response import Response
from rest_framework import serializers
from rest_framework.mixins import CreateModelMixin, DestroyModelMixin, ListModelMixin, RetrieveModelMixin, UpdateModelMixin
-from apps.wf.serializers import CustomFieldSerializer, StateSerializer, TicketCreateSerializer, TicketSerializer, TransitionSerializer, WorkflowSerializer
+from apps.wf.serializers import CustomFieldSerializer, StateSerializer, TicketCreateSerializer, TicketFlowSerializer, TicketSerializer, TransitionSerializer, WorkflowSerializer
from django.shortcuts import get_object_or_404, render
from rest_framework.viewsets import GenericViewSet, ModelViewSet
from rest_framework.decorators import action, api_view
@@ -116,7 +116,7 @@ class TicketViewSet(OptimizationMixin, CreateUpdateCustomMixin, CreateModelMixin
if value == State.STATE_FIELD_REQUIRED:
if key not in ticket_data or not ticket_data[key]:
raise APIException('字段{}必填'.format(key))
- ticket = serializer.save(state=start_state) # 先创建出来
+ ticket = serializer.save(state=start_state, create_by=request.user) # 先创建出来
next_state = WfService.get_next_state_by_transition_and_ticket_info(ticket=ticket, transition=transition)
participant_info = WfService.get_ticket_state_participant_info(state=next_state, ticket=ticket, ticket_data=ticket.ticket_data)
destination_participant_type = participant_info.get('destination_participant_type', 0)
@@ -134,7 +134,7 @@ class TicketViewSet(OptimizationMixin, CreateUpdateCustomMixin, CreateModelMixin
if title_template:
all_ticket_data = {**rdata, **rdata['ticket_data']}
title = title_template.format(**all_ticket_data)
- # 更新工单
+ # 更新一下信息
ticket.sn=sn
ticket.title=title
ticket.state=next_state
@@ -146,7 +146,7 @@ class TicketViewSet(OptimizationMixin, CreateUpdateCustomMixin, CreateModelMixin
# 新增流转记录
TicketFlow.objects.create(ticket=ticket, state=start_state, ticket_data=WfService.get_ticket_all_field_value(ticket),
suggestion=rdata.get('suggestion',''), participant_type=State.PARTICIPANT_TYPE_PERSONAL,
- participant=ticket.create_by, transition=transition, create_by=request.user)
+ participant=ticket.create_by, transition=transition)
return Response(TicketSerializer(instance=ticket).data)
@@ -204,14 +204,14 @@ class TicketViewSet(OptimizationMixin, CreateUpdateCustomMixin, CreateModelMixin
ticket.participant = destination_participant
ticket.multi_all_person = multi_all_person
if destination_state.type == State.STATE_TYPE_END:
- ticket.act_state = State.TICKET_ACT_STATE_FINISH
+ ticket.act_state = Ticket.TICKET_ACT_STATE_FINISH
elif destination_state.type == State.STATE_TYPE_START:
- ticket.act_state = State.TICKET_ACT_STATE_DRAFT
+ ticket.act_state = Ticket.TICKET_ACT_STATE_DRAFT
else:
- ticket.act_state = State.TICKET_ACT_STATE_ONGOING
+ ticket.act_state = Ticket.TICKET_ACT_STATE_ONGOING
- if transition.attribute_type == State.TRANSITION_ATTRIBUTE_TYPE_REFUSE:
- transition.act_state = State.TICKET_ACT_STATE_BACK
+ if transition.attribute_type == Transition.TRANSITION_ATTRIBUTE_TYPE_REFUSE:
+ transition.act_state = Ticket.TICKET_ACT_STATE_BACK
# 只更新必填和可选的字段
for key, value in ticket.state.state_fields.items():
@@ -223,7 +223,7 @@ class TicketViewSet(OptimizationMixin, CreateUpdateCustomMixin, CreateModelMixin
# 更新工单流转记录
TicketFlow.objects.create(ticket=ticket, state=source_state, ticket_data=WfService.get_ticket_all_field_value(ticket),
suggestion=data.get('suggestion',''), participant_type=State.PARTICIPANT_TYPE_PERSONAL,
- participant=request.user, transition=transition, create_by=request.user)
+ participant=request.user, transition=transition)
return Response(TicketSerializer(instance=ticket).data)
@@ -243,4 +243,16 @@ class TicketViewSet(OptimizationMixin, CreateUpdateCustomMixin, CreateModelMixin
"""
ticket = self.get_object()
transitions = WfService.get_ticket_transitions(ticket)
- return Response(TransitionSerializer(instance=transitions, many=True).data)
\ No newline at end of file
+ return Response(TransitionSerializer(instance=transitions, many=True).data)
+
+
+class TicketFlowViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet):
+ """
+ 工单日志
+ """
+ perms_map = {'*':'*'}
+ queryset = TicketFlow.objects.all()
+ serializer_class = TicketFlowSerializer
+ search_fields = ['suggestion']
+ filterset_fields = ['paticipant', 'state', 'ticket']
+ ordering = ['-create_time']
\ No newline at end of file
From 55a266808f4751e293bcf98955a175bbe3ff386d Mon Sep 17 00:00:00 2001
From: caoqianming
Date: Mon, 6 Sep 2021 09:07:55 +0800
Subject: [PATCH 3/4] =?UTF-8?q?=E5=AD=90=E5=B7=A5=E5=BA=8F=E5=88=97?=
=?UTF-8?q?=E8=A1=A8=E5=A2=9E=E5=8A=A0=E8=AE=BE=E5=A4=87=E4=BF=A1=E6=81=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
hb_server/apps/mtm/views.py | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/hb_server/apps/mtm/views.py b/hb_server/apps/mtm/views.py
index c21c08f..d218d7b 100644
--- a/hb_server/apps/mtm/views.py
+++ b/hb_server/apps/mtm/views.py
@@ -62,7 +62,7 @@ class ProcessViewSet(PageOrNot, CreateUpdateModelAMixin, ModelViewSet):
serializer = self.serializer_class(instance=Step.objects.filter(process=process, is_deleted=False), many=True)
return Response(serializer.data)
-class StepViewSet(CreateUpdateModelAMixin, CreateModelMixin, UpdateModelMixin, RetrieveModelMixin, DestroyModelMixin, GenericViewSet):
+class StepViewSet(OptimizationMixin, CreateUpdateModelAMixin, CreateModelMixin, UpdateModelMixin, RetrieveModelMixin, DestroyModelMixin, GenericViewSet):
"""
子工序-增删改查
"""
@@ -74,9 +74,7 @@ class StepViewSet(CreateUpdateModelAMixin, CreateModelMixin, UpdateModelMixin, R
ordering = ['sort']
def get_serializer_class(self):
- if self.action == 'retrieve':
- return StepDetailSerializer
- return StepSerializer
+ return StepDetailSerializer
# class ProductProcessViewSet(PageOrNot, CreateModelMixin, UpdateModelMixin, ListModelMixin, DestroyModelMixin, GenericViewSet):
# """
From 13dbd18efc1b53c1eaf9fbf011187739f7b2e4a5 Mon Sep 17 00:00:00 2001
From: caoqianming
Date: Mon, 6 Sep 2021 09:12:43 +0800
Subject: [PATCH 4/4] =?UTF-8?q?=E5=AD=90=E5=B7=A5=E5=BA=8F=E5=88=97?=
=?UTF-8?q?=E8=A1=A8=E8=BF=94=E5=9B=9E=E8=AE=BE=E5=A4=87=E4=BF=A1=E6=81=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
hb_server/apps/mtm/views.py | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/hb_server/apps/mtm/views.py b/hb_server/apps/mtm/views.py
index d218d7b..d9c9eaf 100644
--- a/hb_server/apps/mtm/views.py
+++ b/hb_server/apps/mtm/views.py
@@ -53,13 +53,13 @@ class ProcessViewSet(PageOrNot, CreateUpdateModelAMixin, ModelViewSet):
ordering_fields = ['number']
ordering = ['number']
- @action(methods=['get'], detail=True, perms_map={'get':'process_update'}, pagination_class=None, serializer_class=StepSerializer)
+ @action(methods=['get'], detail=True, perms_map={'get':'process_update'}, pagination_class=None, serializer_class=StepDetailSerializer)
def steps(self, request, pk=None):
"""
工序下的子工序
"""
process = self.get_object()
- serializer = self.serializer_class(instance=Step.objects.filter(process=process, is_deleted=False), many=True)
+ serializer = self.serializer_class(instance=Step.objects.prefetch_related('equipments').filter(process=process, is_deleted=False), many=True)
return Response(serializer.data)
class StepViewSet(OptimizationMixin, CreateUpdateModelAMixin, CreateModelMixin, UpdateModelMixin, RetrieveModelMixin, DestroyModelMixin, GenericViewSet):
@@ -74,7 +74,9 @@ class StepViewSet(OptimizationMixin, CreateUpdateModelAMixin, CreateModelMixin,
ordering = ['sort']
def get_serializer_class(self):
- return StepDetailSerializer
+ if self.action == 'retrieve':
+ return StepDetailSerializer
+ return StepSerializer
# class ProductProcessViewSet(PageOrNot, CreateModelMixin, UpdateModelMixin, ListModelMixin, DestroyModelMixin, GenericViewSet):
# """