Forráskód Böngészése

客户添加项目

wushaodong 4 éve
szülő
commit
c606887e2c
2 módosított fájl, 8 hozzáadás és 7 törlés
  1. 6 5
      apps/customer/views.py
  2. 2 2
      uis/views/customer/add_project.html

+ 6 - 5
apps/customer/views.py

@@ -1,6 +1,7 @@
 # coding=utf-8
 from rest_framework.views import APIView
 from django.db.models import Q
+import json
 import traceback
 import datetime
 from django.db import transaction
@@ -315,6 +316,7 @@ class NewCustomerViewSet(CustomModelViewSet):
     @action(methods=['post'], detail=True)
     def inner_review(self, request , pk):
         #内部跟踪
+        check_permission(request, 'customer.inner_review')
         description = request.POST.get('description')
         next_time = request.POST.get('next_time')
         is_copy = request.POST.get('is_copy') == '1'
@@ -377,9 +379,9 @@ class NewCustomerViewSet(CustomModelViewSet):
 
     @action(methods=['post'], detail=True)
     def add_projects(self, request, pk):
-
-        projects = request.POST.get('projects')
-        projects = projects.split(',')
+        # 添加项目
+        check_permission(request, 'customer.add_review')
+        projects = json.loads(request.POST.get('projects'))
         try:
             with transaction.atomic():
                 instance = NewCustomer.objects.filter(id=pk).first()
@@ -389,7 +391,6 @@ class NewCustomerViewSet(CustomModelViewSet):
                 if not stage_progress.track_day:
                     raise CustomError('当前阶段,没有设置跟踪天数!')
                 next_time = (timezone.now() + datetime.timedelta(days=stage_progress.track_day)).strftime('%Y-%m-%d')
-                projects = Option.objects.filter(id__in=projects)
                 for project in projects:
                     customer = NewCustomer.objects.create(report_customer=instance.report_customer, gender=instance.gender,
                                                           track_user=instance.track_user, stage_progress=stage_progress,
@@ -398,7 +399,7 @@ class NewCustomerViewSet(CustomModelViewSet):
                                                           address=instance.address, source=instance.source,
                                                           notes=instance.notes,next_time=next_time,
                                                           )
-                    customer.project.add(project.id)
+                    customer.project.add(project)
 
                     NewCustomerRemind.objects.create(customer=customer, store=customer.store, next_time=next_time,
                                                      remind_user_id=instance.track_user_id,)

+ 2 - 2
uis/views/customer/add_project.html

@@ -97,13 +97,13 @@
         //form.render(null, 'component-form-element');
 
         form.on('submit(component-form-element)', function (data) {
-            var url = '/customer/report_customer/' + customer_id + '/add_project/';
+            var url = '/customer/new_customer/' + customer_id + '/add_projects/';
             var type = 'post';
 
             var project = formSelects.value('selectProject', 'val');
             admin.req({
                 url: url
-                , data: {project: JSON.stringify(project)}
+                , data: {projects: JSON.stringify(project)}
                 , type: type
                 , done: function (res) {
                     parent.layui.onSubmitChild(res);