chenhao 4 years ago
parent
commit
f3d1bd3cfa

+ 31 - 1
application/admin/controller/Customer.php

@@ -103,6 +103,7 @@ class Customer extends Base
      */
     public function admin_user_index()
     {
+        Db::name('ranking')->where('status',0)->update(['status' => 1]);
         if (request()->isAjax()) {
             extract(input());
             $map = [];
@@ -168,6 +169,7 @@ class Customer extends Base
                     $a_website[] = '<a href='.$vv.' target="_blank" style="color:#3BA1FF">'.$vv.'</a>';
                 }
                 $lists[$k]['a_website'] = implode('&&',$a_website);
+                $lists[$k]['admin_group'] = session('groupid');
                 unset($a_website);
             }
             return json(['code' => 220, 'msg' => '', 'count' => $count, 'data' => $lists]);
@@ -191,7 +193,6 @@ class Customer extends Base
             ->select();
         $this->assign('type', $typrData);
         $this->assign('admin', UserModel::where('groupid', '4')->select());
-
         return $this->fetch('/customer/admin/admin_user_index');
     }
 
@@ -605,6 +606,7 @@ class Customer extends Base
                     $a_website[] = '<a href='.$vv.' target="_blank" style="color:#3BA1FF">'.$vv.'</a>';
                 }
                 $lists[$k]['a_website'] = implode('&&',$a_website);
+                $lists[$k]['admin_group'] = session('groupid');
                 unset($a_website);
             }
             return json(['code' => 220, 'msg' => '', 'count' => $count, 'data' => $lists]);
@@ -703,6 +705,7 @@ class Customer extends Base
                     $a_website[] = '<a href='.$vv.' target="_blank" style="color:#3BA1FF">'.$vv.'</a>';
                 }
                 $lists[$k]['a_website'] = implode('&&',$a_website);
+                $lists[$k]['admin_group'] = session('groupid');
                 unset($a_website);
             }
             return json(['code' => 220, 'msg' => '', 'count' => $count, 'data' => $lists]);
@@ -814,6 +817,7 @@ class Customer extends Base
                     $a_website[] = '<a href='.$vv.' target="_blank" style="color:#3BA1FF">'.$vv.'</a>';
                 }
                 $lists[$k]['a_website'] = implode('&&',$a_website);
+                $lists[$k]['admin_group'] = session('groupid');
                 unset($a_website);
             }
 
@@ -911,6 +915,7 @@ class Customer extends Base
                     $a_website[] = '<a href='.$vv.' target="_blank" style="color:#3BA1FF">'.$vv.'</a>';
                 }
                 $lists[$k]['a_website'] = implode('&&',$a_website);
+                $lists[$k]['admin_group'] = session('groupid');
                 unset($a_website);
             }
             return json(['code' => 220, 'msg' => '', 'count' => $count, 'data' => $lists]);
@@ -1967,4 +1972,29 @@ class Customer extends Base
         }
         return json(['code' => 200, 'msg' => '删除成功']);
     }
+    /**
+     * 修改业务员
+     */
+    public function customerEdit()
+    {
+        if ($this->request->isPost()) {
+            $param = input('post.');
+            try {
+                Db::startTrans();
+                Db::name('customer')->where('id',$param['id'])->update(['spread_id'=>$param['aid']]);
+                Db::name('ranking')->where('c_id',$param['id'])->update(['admin_id' =>$param['aid']]);
+                Db::commit();
+            } catch (Exception $e) {
+                Db::rollback();
+                $this->error($e);
+                return json(['code' =>100 ,'msg' => '修改失败']);
+            }
+            return json(['code' => 200, 'msg' => '修改成功']);
+        }
+        $id = $this->request->param('id');
+        $admin = Db::name('admin')->where('groupid',4)->select();
+        $this->assign('admin',$admin);
+        $this->assign('id',$id);
+        return $this->fetch();
+    }
 }

+ 1 - 1
application/admin/model/CustomerModel.php

@@ -16,7 +16,7 @@ class CustomerModel extends Model
         $res =  $this->alias ('a')
             ->join('admin ad', 'ad.id = a.spread_id','left')
             ->join('type t','t.id = a.type','left')
-            ->field('a.*, ad.username username,ad.nickname nickname,t.name type_name')
+            ->field('a.*, ad.username username,ad.nickname nickname,t.name type_name,ad.groupid')
             ->where($map)
             ->where(function ($query) use($whereOr) {
                 foreach ($whereOr as $k => $v) {

+ 6 - 3
application/admin/view/customer/admin/admin_user_index.html

@@ -162,10 +162,13 @@
             </script>
             <!--操作模板-->
             <script type="text/html" id="opeBar">
-
+				{{# if(d.admin_group==3){ }}
                 <a class="layui-btn layui-btn-danger layui-btn-xs layui-bg-gray" title="删除" onclick="wk.confirm('{{d.id}}','{:url('customerDel')}')">删除</i></a>
-
-                <a class="layui-btn layui-btn-xs layui-bg-gray" title="查看" onclick="wk.layer_show('','{:url('see')}?id={{d.id}}')">查看</i></a>
+				{{# } }}
+				{{# if(d.admin_group==5){ }}
+				<a class="layui-btn layui-btn-danger layui-btn-xs layui-bg-gray" title="" onclick="wk.layer_show('','{:url('customerEdit')}?id={{d.id}}')">修改</i></a>
+					{{# } }}
+				<a class="layui-btn layui-btn-xs layui-bg-gray" title="查看" onclick="wk.layer_show('','{:url('see')}?id={{d.id}}')">查看</i></a>
             </script>
             <!--查看全部业务员-->
             <script type="text/html" id="caozuo">

+ 9 - 6
application/admin/view/customer/admin/admin_user_index_1.html

@@ -133,9 +133,9 @@
 					<button class="layui-btn layui-btn-normal layuiBtn" data-type="guanLian">
                     标记为关联
                 </button>
-<!--				<button class="layui-btn layui-btn-normal layuiBtn"  data-type="huiFu">-->
-<!--					标记为已回复-->
-<!--				</button>-->
+				<button class="layui-btn layui-btn-normal layuiBtn"  data-type="huiFu">
+					 修改回复业务员
+				</button>
 					<!--                <button class="layui-btn layui-btn-normal layuiBtn"  data-type="hebing">-->
 					<!--                    合并-->
 					<!--                </button>-->
@@ -151,8 +151,12 @@
 				<!--操作模板-->
 				<script type="text/html" id="opeBar">
 
+					{{# if(d.admin_group==3){ }}
 					<a class="layui-btn layui-btn-danger layui-btn-xs layui-bg-gray" title="删除" onclick="wk.confirm('{{d.id}}','{:url('customerDel')}')">删除</i></a>
-
+					{{# } }}
+					{{# if(d.admin_group==5){ }}
+					<a class="layui-btn layui-btn-danger layui-btn-xs layui-bg-gray" title="" onclick="wk.layer_show('','{:url('customerEdit')}?id={{d.id}}')">修改</i></a>
+					{{# } }}
 					<a class="layui-btn layui-btn-xs layui-btn-normal" title="查看" onclick="wk.layer_show('','{:url('see')}?id={{d.id}}')">查看</i>
 					</a>
 				</script>
@@ -318,8 +322,7 @@
 						return false;
 					}
 					// alert(($(window).width())
-					wk.layer_show('', '{:url('
-						admin / customer / to_huifu ')}?id=' + ids);
+					wk.layer_show('','{:url('admin/customer/to_huifu')}?id='+ids);
 					//回复
 					// wk.huiFu(getIds(),"{:url('admin/customer/to_huifu')}");
 				},

+ 8 - 4
application/admin/view/customer/admin/admin_user_index_2.html

@@ -125,12 +125,12 @@
                 <button class="layui-btn layui-btn-normal layuiBtn"  data-type="excelAll">
                     导出Excel表
                 </button>
-<!--                <button class="layui-btn layui-btn-normal layuiBtn"  data-type="chengJiao">-->
-<!--                    标记为已成交-->
-<!--                </button>-->
                 <button class="layui-btn layui-btn-normal layuiBtn"  data-type="guanLian" >
                     标记为关联
                 </button>
+				<button class="layui-btn layui-btn-normal layuiBtn"  data-type="chengJiao">
+					修改成交业务员
+				</button>
                 <!--                <button class="layui-btn layui-btn-normal layuiBtn"  data-type="huiFu">-->
                 <!--                    标记为已回复-->
                 <!--                </button>-->
@@ -149,8 +149,12 @@
             <!--操作模板-->
             <script type="text/html" id="opeBar">
 
+				{{# if(d.admin_group==3){ }}
 				<a class="layui-btn layui-btn-danger layui-btn-xs layui-bg-gray" title="删除" onclick="wk.confirm('{{d.id}}','{:url('customerDel')}')">删除</i></a>
-
+				{{# } }}
+				{{# if(d.admin_group==5){ }}
+				<a class="layui-btn layui-btn-danger layui-btn-xs layui-bg-gray" title="" onclick="wk.layer_show('','{:url('customerEdit')}?id={{d.id}}')">修改</i></a>
+				{{# } }}
                 <a class="layui-btn layui-btn-xs layui-bg-gray" title="" onclick="wk.layer_show('','{:url('see')}?id={{d.id}}')">查看</i></a>
             </script>
             <!--查看全部业务员-->

+ 8 - 4
application/admin/view/customer/admin/admin_user_index_3.html

@@ -129,9 +129,9 @@
 <!--                <button class="layui-btn layui-btn-normal layuiBtn"  data-type="chengJiao">-->
 <!--                    标记为已成交-->
 <!--                </button>-->
-<!--                <button class="layui-btn layui-btn-normal layuiBtn"  data-type="guanLian" >-->
-<!--                    标记为关联-->
-<!--                </button>-->
+                <button class="layui-btn layui-btn-normal layuiBtn"  data-type="guanLian" >
+                    修改关联业务员
+                </button>
                 <!--                <button class="layui-btn layui-btn-normal layuiBtn"  data-type="huiFu">-->
                 <!--                    标记为已回复-->
                 <!--                </button>-->
@@ -150,8 +150,12 @@
             <!--操作模板-->
             <script type="text/html" id="opeBar">
 
+				{{# if(d.admin_group==3){ }}
 				<a class="layui-btn layui-btn-danger layui-btn-xs layui-bg-gray" title="删除" onclick="wk.confirm('{{d.id}}','{:url('customerDel')}')">删除</i></a>
-
+				{{# } }}
+				{{# if(d.admin_group==5){ }}
+				<a class="layui-btn layui-btn-danger layui-btn-xs layui-bg-gray" title="" onclick="wk.layer_show('','{:url('customerEdit')}?id={{d.id}}')">修改</i></a>
+				{{# } }}
                 <a class="layui-btn layui-btn-xs layui-bg-gray" title="" onclick="wk.layer_show('','{:url('see')}?id={{d.id}}')">查看</i></a>
             </script>
             <!--查看全部业务员-->

+ 5 - 1
application/admin/view/customer/admin/admin_user_index_4.html

@@ -161,8 +161,12 @@
             <!--操作模板-->
             <script type="text/html" id="opeBar">
 
+				{{# if(d.admin_group==3){ }}
 				<a class="layui-btn layui-btn-danger layui-btn-xs layui-bg-gray" title="删除" onclick="wk.confirm('{{d.id}}','{:url('customerDel')}')">删除</i></a>
-
+				{{# } }}
+				{{# if(d.admin_group==5){ }}
+				<a class="layui-btn layui-btn-danger layui-btn-xs layui-bg-gray" title="" onclick="wk.layer_show('','{:url('customerEdit')}?id={{d.id}}')">修改</i></a>
+				{{# } }}
                 <a class="layui-btn layui-btn-xs layui-bg-gray" title="查看" onclick="wk.layer_show('','{:url('see')}?id={{d.id}}')">查看</i></a>
             </script>
             <!--查看全部业务员-->

+ 100 - 0
application/admin/view/customer/customer_edit.html

@@ -0,0 +1,100 @@
+{include file="public/header" /}
+<body class="gray-bg">
+<div class="layui-fluid layui-col-md12">
+    <div class="layui-card">
+        <div class="layui-card-body layui-form">
+            <div class="layui-row layui-col-space10 layui-form-item ">
+                <input type="hidden" name = 'id' value="{$id}">
+                <div style="margin-left: 30%;font-size: 15px"><strong>客户将放在选择的业务员名下</strong></div>
+                <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
+                    <label class="layui-form-label" style="height: 20px;background-color:#C2C5D3;text-align: center ">业务员</label>
+                    <div class="layui-input-block">
+                        <select name="aid" lay-verify="required" lay-search="" style="width: 687px;height: 80px">
+                            {foreach name="admin" item="vo"}
+                            <option value="{$vo.id}">{$vo.username}</option>
+                            {/foreach}
+                        </select>
+                    </div>
+                </div>
+
+                <div class="layui-form-item layui-col-md-offset1 layui-col-md8" style="text-align: center">
+                    <div class="layui-input-block">
+                        <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="component-form-element">保存
+                        </button>
+                        <!--                        <button class="layui-btn layui-btn-primary" onclick="wk.layer_close('close')">关闭</button>-->
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+
+{include file="public/footer" /}
+<script type="text/javascript" src="__JS__/plugins/cropper/Crop.js"></script>
+<script>
+    //裁剪后的处理
+    $("#sureCut").on("click",function () {
+        if ($("#tailoringImg").attr("src") == null ){
+            layer.msg('请先选择头像',{anim:6})
+        }else{
+            var cas = $('#tailoringImg').cropper('getCroppedCanvas');//获取被裁剪后的canvas
+            var base64url = cas.toDataURL('image/png'); //转换为base64地址形式
+            $("#img_data").attr('src',base64url).show();
+            $('#data_photo').val(base64url);
+            //关闭裁剪框
+            layer.closeAll();
+        }
+    });
+</script>
+<script>
+    layui.use(['form'], function() {
+        var form = layui.form;
+        // form.verify({
+        //     username:function(value,item){
+        //         if(!/^[\S]{2,10}$/.test(value)){
+        //             return '名称必须2到10字符,且不能出现空格';
+        //         }
+        //         var checkResult = "";
+        //         $.ajax({
+        //             url:"{:url('User/checkName')}",
+        //             type:'post',
+        //             data:"username="+value,
+        //             async: false,//必须同步
+        //             success:function(res){
+        //                 if(res.code == 100){
+        //                     checkResult = "该名称已存在";
+        //                 }
+        //             }
+        //         })
+        //         return checkResult;
+        //     },
+        //     pass: [/^[\S]{6,16}$/,'密码必须6到16位,且不能出现空格'],
+        //     // headCrop:[/^[\S]$/,'头像不能为空'],
+        //     // headCrop:function(value,item){
+        //     //     if(value == ""){
+        //     //         return '头像不能为空';
+        //     //     }
+        //     // },
+        //     realname:[/^[\S]{2,10}$/,'真实姓名必须2到10字符,且不能出现空格']
+        //
+        // });
+        form.on('submit(component-form-element)', function (data) {
+            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
+            $.ajax({
+                url:"{:url('customerEdit')}",
+                type:'post',
+                dataType:'json',
+                data:data.field,
+                success:function(res){
+                    if (res.code == 200) {
+                        wk.success(res.msg,'wk.layer_close()');
+                    } else {
+                        wk.error(res.msg,'$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\')');
+                    }
+                }
+            })
+        });
+    });
+</script>
+</body>
+</html>