action form init 组装form
This commit is contained in:
parent
c5aafb79e0
commit
b966714f7b
|
@ -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)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue