diff --git a/Application/Admin/Controller/AjaxController.class.php b/Application/Admin/Controller/AjaxController.class.php index 2d6092dec..5d9edbc81 100644 --- a/Application/Admin/Controller/AjaxController.class.php +++ b/Application/Admin/Controller/AjaxController.class.php @@ -176,6 +176,23 @@ class AjaxController extends ThinkController{ } $this->ajaxReturn(['code'=>1, 'msg'=>'获取成功', 'data'=>(new PromoteModel)->getPromotersByLevel($level)]); } + /** + * 根据公司id获取会长 + */ + public function getPromotersByCompanyid($company_id = -1) + { + $company_id = I('company_id'); + $data = M("Promote","tab_")->field("id,account,nickname,company_id"); + if($company_id == -1){ + $data = $data->where("level = '1'")->select(); + }else{ + $data = $data->where("company_id = '{$company_id}' and level = '1'")->select(); + } + foreach ($data as &$item) { + $item['nickname'] = $item['account'] . ($item['nickname'] ? "({$item['nickname']})" : ""); + } + $this->ajaxReturn(['code'=>1, 'msg'=>'获取成功', 'data'=>$data]); + } public function getPromotersByLevelOther() { diff --git a/Application/Admin/View/FinancePromote/index.html b/Application/Admin/View/FinancePromote/index.html index 9f60ea626..e78c19eaa 100644 --- a/Application/Admin/View/FinancePromote/index.html +++ b/Application/Admin/View/FinancePromote/index.html @@ -407,19 +407,24 @@ autoclose: true, pickerPosition: 'bottom-left' }) + var promote_id = "{:I('promote_id')}"; - function getPromotersByLevel() { + var company_id = "{:I('company_id')}"; + function getPromotersByCompanyid() { + var company_id = $("#company_id option:selected").val(); + if(!company_id){ + company_id = -1; + } $.ajax({ - url: "{:U('Ajax/getPromotersByLevel')}", + url: "{:U('Ajax/getPromotersByCompanyid')}", type: "get", - data: { level: 1 }, + data: { company_id:company_id}, dataType: 'json', success: function (response) { - str = ''; - // $.each(response.data, function(index, item){ - // console.log(item.id); - // str += ''; - // }); + str = ''; + if(company_id == 0 || company_id ==-1){ + str +=''; + } data = response.data; for (var i in data) { str += "" @@ -430,7 +435,11 @@ } }) } - getPromotersByLevel(); + getPromotersByCompanyid(); + + $("#company_id").change(function(){ + getPromotersByCompanyid(); + }) }) diff --git a/Application/Admin/View/FinancePromote/promoteUser.html b/Application/Admin/View/FinancePromote/promoteUser.html index 670441488..faee12887 100644 --- a/Application/Admin/View/FinancePromote/promoteUser.html +++ b/Application/Admin/View/FinancePromote/promoteUser.html @@ -382,18 +382,19 @@ pickerPosition: 'bottom-left' }) var promote_id = "{:I('promote_id')}"; - function getPromotersByLevel() { + var company_id = "{:I('company_id')}"; + function getPromotersByCompanyid() { + var company_id = $("#company_id option:selected").val(); + if(!company_id){ + company_id = -1; + } $.ajax({ - url: "{:U('Ajax/getPromotersByLevel')}", + url: "{:U('Ajax/getPromotersByCompanyid')}", type: "get", - data: { level: 1 }, + data: { company_id:company_id}, dataType: 'json', success: function (response) { - str = ''; - // $.each(response.data, function(index, item){ - // console.log(item.id); - // str += ''; - // }); + str = ''; data = response.data; for (var i in data) { str += "" @@ -404,7 +405,11 @@ } }) } - getPromotersByLevel(); + getPromotersByCompanyid(); + + $("#company_id").change(function(){ + getPromotersByCompanyid(); + }) })