Răsfoiți Sursa

报备客户权限

wushaodong 4 ani în urmă
părinte
comite
c154908d7b

+ 4 - 18
apps/customer/models.py

@@ -17,12 +17,12 @@ class ReportCustomer(models.Model):
         (REPEAT_REPORT, '重复报备')
     )
 
-    name = models.CharField(max_length=100, verbose_name=u"姓名")
-    tel = models.CharField(max_length=50, verbose_name=u'电话')
+    name = models.CharField(max_length=20, verbose_name=u"姓名")
+    tel = models.CharField(max_length=15, verbose_name=u'电话')
     gender = models.PositiveSmallIntegerField(choices=settings.GENDER_CHOICES, verbose_name=u'性别',
                                               default=settings.MALE)
-    village = models.CharField(max_length=100, verbose_name=u'小区')
-    address = models.CharField(max_length=100, verbose_name=u'地址')
+    village = models.CharField(max_length=200, verbose_name=u'小区')
+    address = models.CharField(max_length=200, verbose_name=u'地址')
     source = models.ForeignKey(Option, verbose_name=u'来源', related_name='customer_source', on_delete=models.PROTECT)
     project = models.ManyToManyField(Option, verbose_name=u'项目', related_name='customer_category', editable=False,
                                      null=True,blank=True)
@@ -44,20 +44,6 @@ class ReportCustomer(models.Model):
         permissions = [
             ('view_report_customer', u'查看'),
             ('add_report_customer', u'添加'),
-            ('update_report_customer', u'更新'),
             ('delete_report_customer', u'删除'),
             ('check_report_customer', u'审核'),
         ]
-
-    # def check_customer(self, user):
-    #     # 审核
-    #     if self.report_status == ReportCustomer.REPEAT_REPORT:
-    #
-    #
-    #     if self.report_status == ReportCustomer.NOT_CHECKED:
-    #         self.check_user = user
-    #         self.report_status = ReportCustomer.CHECKED
-    #         self.check_time = timezone.now()
-    #         self.save()
-    #     # if self.report_status == Customer.CHECKED:
-    #     #     # 撞单

+ 8 - 4
apps/customer/views.py

@@ -3,7 +3,7 @@ from rest_framework.views import APIView
 from django.db.models import Q
 from django.utils import timezone
 from rest_framework.decorators import action
-
+from utils.permission import isLogin, permission_required
 from utils.custom_modelviewset import CustomModelViewSet
 from utils import response_ok, response_error
 from utils.exceptions import CustomError
@@ -16,15 +16,17 @@ from .filters import ReportCustomerFilter
 
 
 class ReportCustomerViewSet(CustomModelViewSet):
-    permission_classes = []
+    permission_classes = [isLogin]
     queryset = ReportCustomer.objects.filter()
     serializer_class = ReportCustomerSerializer
 
+    @permission_required('customer.view_report_customer')
     def filter_queryset(self, queryset):
         queryset = queryset.filter()
         f = ReportCustomerFilter(self.request.GET, queryset=queryset)
         return f.qs
 
+    @permission_required('customer.add_report_customer')
     def perform_create(self, serializer):
         super(ReportCustomerViewSet, self).perform_create(serializer)
         instance = serializer.instance
@@ -32,6 +34,7 @@ class ReportCustomerViewSet(CustomModelViewSet):
         BizLog.objects.addnew(self.request.user, BizLog.INSERT,
                               u'添加客户报备[%s],id=%d' % (instance.name, instance.id), validated_data)
 
+    @permission_required('customer.add_report_customer')
     def perform_update(self, serializer):
         super(ReportCustomerViewSet, self).perform_update(serializer)
         instance = serializer.instance
@@ -39,12 +42,13 @@ class ReportCustomerViewSet(CustomModelViewSet):
         BizLog.objects.addnew(self.request.user, BizLog.UPDATE,
                               u'修改客户报备[%s],id=%d' % (instance.name, instance.id), validated_data)
 
+    @permission_required('customer.delete_report_customer')
     def perform_destroy(self, instance):
         BizLog.objects.addnew(self.request.user, BizLog.DELETE,
                               u'删除客户报备[%s],id=%d' % (instance.name, instance.id))
         super(ReportCustomerViewSet, self).perform_destroy(instance)
 
-
+    @permission_required('customer.check_report_customer')
     @action(methods=['post'], detail=False)
     def check(self, request, pk):
         # 审核
@@ -75,7 +79,7 @@ class ReportCustomerViewSet(CustomModelViewSet):
         return response_ok('审核完成!')
 
 class ReportCustomerDictView(APIView):
-    permission_classes = []
+    permission_classes = [isLogin]
 
     def get(self, request):
         scouce = Option.objects.filter(type=Option.CUSTOMER_SOURCE , enable=True)

+ 1 - 0
uis/views/customer/edit.html

@@ -131,6 +131,7 @@
                     var name = data_source[i].name;
                     source_node.append("<option value='" + pid + "'>" + name + "</option>");
                 }
+
                 var data_project = res.data.project;
                 let tempData = [];
                 if(data_project && data_project.length > 0){

+ 12 - 36
uis/views/customer/index.html

@@ -58,18 +58,9 @@
                 <div class="layui-col-md12">
                     <div class="LAY-btns" style="margin-bottom: 10px;">
                         <div style="float: left">
-                            <button class="layui-btn" id="customer_add"><i
+                            <button class="layui-btn" id="customer_add" data-permission="customer.add_report_customer"><i
                                     class="layui-icon layui-icon-add-circle"></i>添加
                             </button>
-                            <!--<button class="layui-nav">
-                                <div class="layui-nav-item">
-                                    <a href="javascript:;" style="color:#fff;">导入</a>
-                                    <dl class="layui-nav-child">
-                                        <dd><a href="#" id="btn_import">执行导入</a></dd>
-                                        <dd><a href="#" id="btn_download">下载模板</a></dd>
-                                    </dl>
-                                </div>
-                            </button>-->
                         </div>
                         <form class="layui-form" lay-filter="query-form-element1">
                             <div class="seach_items">
@@ -94,10 +85,12 @@
                     <script type="text/html" id="customer-operate-bar">
                         <div class="layui-btn-group">
                             <a class="layui-btn layui-btn-xs" lay-event="customer_edit"
+                               data-permission="customer.add_report_customer"
                             >修改</a>
                         </div>
                         <div class="layui-btn-group">
                             <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="customer_del"
+                               data-permission="customer.delete_report_customer"
                             >删除</a>
                         </div>
                     </script>
@@ -123,18 +116,18 @@
             elem: '#customer_datagrid'
             , url: '/customer/report_customer/'
             , cols: [[
-                {field: 'name', title: '姓名', width: 200}
+                {field: 'name', title: '姓名', width: 120}
                 , {field: 'gender_text', title: "性别", width: 70}
-                , {field: 'tel', title: '电话', width: 150}
-                , {field: 'village', title: '小区', width: 200}
+                , {field: 'tel', title: '电话', width: 120}
+                , {field: 'village', title: '小区', width: 150}
                 , {field: 'address', title: '地址', width: 200}
                 , {field: 'source_text', title: '来源', width: 100}
                 , {field: 'project_text', title: '项目', width: 200}
                 , {field: 'notes', title: '备注', width: 200}
-                , {field: 'report_status_text', title: '报备状态', width: 200}
+                , {field: 'report_status_text', title: '报备状态', width: 100}
                 , {field: 'check_user', title: '审核人', width: 100}
                 , {field: 'check_time', title: '审核时间', width: 150}
-                , {width: 150, align: 'center', fixed: 'right', toolbar: '#customer-operate-bar'}
+                , {width: 130, align: 'center', fixed: 'right', toolbar: '#customer-operate-bar'}
             ]]
             , page: true
             , height: 'full-108'
@@ -154,31 +147,14 @@
             }
         });
 
-        $('#btn_download').on('click', function () {
-            layui.view.download("/static/xls/设备信息导入模板.xlsx");
-        });
-        upload.render({
-            elem: '#btn_import'
-            , url: '/tenant/customer/import/'
-            , accept: 'file'
-            , acceptMime: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
-            , exts: 'xlsx'
-            , field: 'excel_file'
-            , done: function (res) {
-                if (res.code == 0) {
-                    table.reload('customer_datagrid', {});
-                } else {
-                    layer.msg(res.msg);
-                }
-            }
-            , error: function () {
-                layer.msg('导入失败');
-            }
-        });
         //监听工具条
         table.on('tool(customer-operate)', function (obj) {
             var data = obj.data;
             if (obj.event === 'customer_del') {
+                if(data.report_status !== 0){
+                    layer.msg("只有待审核才允许删除");
+                    return
+                }
                 layer.confirm('确定要删除吗?', function (index) {
                     layer.close(index);
                     admin.req({

+ 4 - 5
uis/views/employee/edit.html

@@ -60,14 +60,13 @@
                             </div>
 
                             <div class="layui-col-lg6">
-                                <label class="layui-form-label">性别:</label>
+                                <label class="layui-form-label"><font color='red' size="4">*</font>性别:</label>
                                 <div class="layui-input-block">
-                                    <select name="gender" lay-verify="required">
-                                        <option value="2">男</option>
-                                        <option value="1">女</option>
-                                    </select>
+                                    <input type="radio" name="gender" value="2" title="男" checked>
+                                    <input type="radio" name="gender" value="1" title="女">
                                 </div>
                             </div>
+
                             <div class="layui-col-lg6">
                                 <label class="layui-form-label">在职状态:</label>
                                 <div class="layui-input-block">

+ 2 - 2
uis/views/index.html

@@ -91,12 +91,12 @@
                             <cite>潜客作业</cite>
                         </a>
                         <dl class="layui-nav-child">
-                            <dd data-name="nav" data-permission="option.browse_option">
+                            <dd data-name="nav" data-permission="customer.view_report_customer">
                                 <a lay-href="customer/index.html">客户报备</a>
                             </dd>
                         </dl>
                         <dl class="layui-nav-child">
-                            <dd data-name="nav" data-permission="option.browse_option">
+                            <dd data-name="nav" data-permission="customer.check_report_customer">
                                 <a lay-href="report_check/index.html">报备审核</a>
                             </dd>
                         </dl>

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

@@ -103,7 +103,7 @@
 
         table.render({
             elem: '#report_check_datagrid'
-            , url: '/api/report_check.json'
+            , url: '/customer/report_customer/?report_status=0'
             , cols: [[
                 {type:'checkbox'}
                 , {field: 'name', title: '姓名', width: 200}