From b966714f7bb7d0a831025f75a57e3458bad0b737 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Mon, 8 Nov 2021 09:27:10 +0800 Subject: [PATCH] =?UTF-8?q?action=20form=20init=20=E7=BB=84=E8=A3=85form?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/wpm/views.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/hb_server/apps/wpm/views.py b/hb_server/apps/wpm/views.py index bf4fe1b..c5ff876 100644 --- a/hb_server/apps/wpm/views.py +++ b/hb_server/apps/wpm/views.py @@ -62,20 +62,21 @@ class DoFormInit(CreateAPIView, GenericAPIView): serializer.is_valid(raise_exception=True) vdata = serializer.validated_data ret = {} - ret['step'] = data['step'] - ret['subproduction_plan'] = data['subproduction_plan'] + ret_0 = {} + ret_0['step'] = data['step'] + ret_0['subproduction_plan'] = data['subproduction_plan'] if 'wproducts' in data and data['wproducts']: - ret['wproducts'] = data['wproducts'] + ret_0['wproducts'] = data['wproducts'] else: - ret['wproducts'] = [] + ret_0['wproducts'] = [] # 调出该子计划现有物料 - ret['input'] = list(WMaterial.objects.filter(subproduction_plan=vdata['subproduction_plan'])\ + ret_0['input'] = list(WMaterial.objects.filter(subproduction_plan=vdata['subproduction_plan'])\ .values('id', 'material', 'material__name', 'count', 'material__number', 'batch')) - for i in ret['input']: + for i in ret_0['input']: i['count_input'] = 0 # 需要输出的物料 # 如果传入半成品列表就不需要 - if ret['wproducts']: + if ret_0['wproducts']: # 排除wproduct列表 # mids = WProduct.objects.filter(pk__in=data['wproducts']).values_list('m_state', flat=True) o_objs = SubProductionProgress.objects.filter( @@ -83,13 +84,16 @@ class DoFormInit(CreateAPIView, GenericAPIView): else: o_objs = SubProductionProgress.objects.filter( subproduction_plan=vdata['subproduction_plan'], type=2) - ret['output'] = list(o_objs.values('material', 'material__name', 'material__number')) - for i in ret['output']: + ret_0['output'] = list(o_objs.values('material', 'material__name', 'material__number')) + for i in ret_0['output']: i['count_output']=0 ret['forms'] = [] + ret_0['id'] = 0 + ret_0['name'] = '基本信息' + ret['forms'].append(ret_0) forms = RecordForm.objects.filter(step=vdata['step'], type=1) if forms.exists(): - ret['forms'] = RecordFormDetailSerializer(instance=forms, many=True).data + ret['forms'].extend(RecordFormDetailSerializer(instance=forms, many=True).data) return Response(ret)