公会统计新增公司联动

master
chenzhi 5 years ago
parent 6625eaa4f7
commit f594e3bb14

@ -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()
{

@ -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 = '<option value="">请选择会长</option><option value="0"' + (promote_id && 0 == promote_id ? 'selected' : '') + '>官方渠道</option>';
// $.each(response.data, function(index, item){
// console.log(item.id);
// str += '<option value="'+item.id+' '+(promote_id && item.id == promote_id?'selected':'')+'">'+item.nickname+'</option>';
// });
str = '<option value="">请选择会长</option>';
if(company_id == 0 || company_id ==-1){
str +='<option value="0"' + (promote_id && 0 == promote_id ? 'selected' : '') + '>官方渠道</option>';
}
data = response.data;
for (var i in data) {
str += "<option value='" + data[i].id + "' " + (promote_id && data[i].id == promote_id ? 'selected' : '') + ">" + data[i].nickname + "</option>"
@ -430,7 +435,11 @@
}
})
}
getPromotersByLevel();
getPromotersByCompanyid();
$("#company_id").change(function(){
getPromotersByCompanyid();
})
})

Loading…
Cancel
Save