diff --git a/safesite/views.py b/safesite/views.py index 41c3f8e8..37416281 100644 --- a/safesite/views.py +++ b/safesite/views.py @@ -7527,14 +7527,23 @@ def getresbilitydata(req): obj = Resbility() data = json.loads(req.body.decode('utf-8')) obj.title = data['title'] - obj.jobs =Group.objects.get(groupid= data['group']) - obj.homeworktype= Dickey.objects.get(dickeyid=data['type']) - obj.department=Partment.objects.get(partid=data['jobpart']) - obj.resbilitypath=data['filepath'] + if data['group']: + + obj.jobs =Group.objects.get(groupid= data['group']) + if data['type']: + obj.homeworktype= Dickey.objects.get(dickeyid=data['type']) + if data['filepath']: + obj.resbilitypath=data['filepath'] + obj.createuser=User.objects.get(userid=userid) - obj.createdate=data['publisdate'] + if data['publisdate']: + obj.createdate=data['publisdate'] obj.usecomp=Partment.objects.get(partid=companyid) - obj.filepath=data['filepath'] + if data['filepath']: + obj.filepath=data['filepath'] + if 'jobpart' in data and data['jobpart']: + obj.department=Partment.objects.get(partid=data['jobpart']) + obj.save() return JsonResponse({"code":1}) elif a=='listall':#责任列表 @@ -7614,14 +7623,20 @@ def getprodata(req): obj = Operproce() data = json.loads(req.body.decode('utf-8')) obj.title = data['title'] - obj.jobs =Group.objects.get(groupid= data['group']) - obj.homeworktype= Dickey.objects.get(dickeyid=data['type']) - obj.department=Partment.objects.get(partid=data['jobpart']) - obj.operprocepath=data['filepath'] + if data['group']: + obj.jobs =Group.objects.get(groupid= data['group']) + if data['type']: + obj.homeworktype= Dickey.objects.get(dickeyid=data['type']) + if 'jobpart' in data and data['jobpart']: + obj.department=Partment.objects.get(partid=data['jobpart']) + if data['filepath']: + obj.operprocepath=data['filepath'] obj.createuser=User.objects.get(userid=userid) - obj.createdate=data['publisdate'] + if data['publisdate']: + obj.createdate=data['publisdate'] obj.usecomp=Partment.objects.get(partid=companyid) - obj.filepath=data['filepath'] + if data['filepath']: + obj.filepath=data['filepath'] obj.save() return JsonResponse({"code":1}) elif a=='listall':#责任列表