瀏覽代碼

Merge branch 'master' of http://git.zzliaoyuan.com:4000/wushaodong/decorate

lijiangwei 4 年之前
父節點
當前提交
84b283007f
共有 5 個文件被更改,包括 13 次插入8 次删除
  1. 0 1
      apps/account/models.py
  2. 6 1
      apps/account/serializers.py
  3. 5 4
      apps/account/views.py
  4. 1 1
      apps/customer/views.py
  5. 1 1
      uis/views/report_check/index.html

+ 0 - 1
apps/account/models.py

@@ -80,7 +80,6 @@ class User(AbstractBaseUser, PermissionsMixin):
             ('delete_user', u'删除'),
             ('check_user', u'入职审核'),
             ('manager_store', u'管理门店'),
-            ('office_store', u'任职门店'),
         ]
 
     def __unicode__(self):

+ 6 - 1
apps/account/serializers.py

@@ -10,7 +10,7 @@ from apps.log.models import BizLog
 from utils import get_remote_addr
 from utils.booleancharfield import BooleanCharField
 from utils.exceptions import CustomError
-from apps.account.models import ManageStoreUser
+from apps.account.models import ManageStoreUser,OfficeStoreUser
 
 User = get_user_model()
 jwt_payload_handler = api_settings.JWT_PAYLOAD_HANDLER
@@ -63,6 +63,7 @@ class EmployeeSerializer(serializers.ModelSerializer):
     groups = serializers.SerializerMethodField()
     group_ids = serializers.PrimaryKeyRelatedField(source='groups', many=True, read_only=True)
     manager_barnchs = serializers.SerializerMethodField()
+    office_stores = serializers.SerializerMethodField()
 
     def get_manager_barnchs(self, obj):
         stores = ManageStoreUser.objects.filter(manage_user=obj)
@@ -71,6 +72,10 @@ class EmployeeSerializer(serializers.ModelSerializer):
     def get_groups(self, obj):
         return ','.join(obj.groups.values_list('name', flat=True))
 
+    def get_office_stores(self, obj):
+        stores = OfficeStoreUser.objects.filter(office_user=obj)
+        return ','.join(stores.values_list('store__name', flat=True))
+
     class Meta:
         model = User
         # fields = '__all__'

+ 5 - 4
apps/account/views.py

@@ -161,7 +161,7 @@ class EmployeeViewSet(CustomModelViewSet):
 
     @action(methods=['post'], detail=True)
     def office(self, request, pk):
-        check_permission(request, 'account.office_store')
+        check_permission(request, 'account.manager_store')
         data = json.loads(request.POST.get('stores'))
         try:
             with transaction.atomic():
@@ -326,7 +326,8 @@ class EmployeeTreeView(APIView):
                 'field': 'store',
                 'children': [],
             }
-            employees = User.objects.filter(store_id=store_id, is_active=True).values('id', 'name')
+            office_user_id = OfficeStoreUser.objects.filter(store_id=store_id).values('office_user_id')
+            employees = User.objects.filter(Q(store_id=store_id) | Q(id__in=office_user_id), is_active=True).values('id', 'name')
             for employee in employees:
                 user_item = {
                     'title': employee['name'],
@@ -433,7 +434,7 @@ class HomeStatisticsView(APIView):
 class OfficeStoreView(APIView):
     permission_classes = [isLogin, ]
 
-    @permission_required('account.office_store')
+    @permission_required('account.manager_store')
     def get(self, request):
         id = request.GET.get('id')
         store_data = []
@@ -475,4 +476,4 @@ class OfficeStoreView(APIView):
                     agent_item['children'].append(store_item)
             store_data.append(general_agent_item)
 
-        return response_ok(store_data)
+        return response_ok(store_data)

+ 1 - 1
apps/customer/views.py

@@ -482,4 +482,4 @@ class ListCountView(APIView):
             'review_count': review_count,  # 跟踪审核数量
             'order_count': order_count,  # 进度审核数量
         }
-        return response_ok(data)
+        return response_ok(data)

+ 1 - 1
uis/views/report_check/index.html

@@ -134,7 +134,7 @@
                 layer.open({
                     type: 2,
                     title: '分配客户',
-                    area: ['30%', '40%'],
+                    area: ['40%', '60%'],
                     btn: ['分配', '取消'],
                     yes: function (index, dom) {
                         layui.onSubmitChild = function (data) {