测试资源搜索功能添加

master
zhengyongxing 5 years ago
parent 878414aeb2
commit 132b601f74

@ -587,4 +587,15 @@ class AjaxController extends ThinkController{
$result = M('promote', 'tab_')->field("id,account,nickname")->where(['parent_id'=>$pid])->select();
$this->ajaxReturn(['code'=>1, 'data'=>$result]);
}
public function getPromotersByLevelResource()
{
$level = I('level');
if (!$level) {
// return $this->ajaxReturn(['code'=>1, 'msg'=>'获取成功', 'data'=>[]]);
$level = '';
}
$this->ajaxReturn(['code'=>1, 'msg'=>'获取成功', 'data'=>(new PromoteModel)->getPromotersByLevelResource($level)]);
}
}

@ -78,7 +78,7 @@ class TestResourceController extends ThinkController
if(!empty(I('user_account'))){
$map['tab_test_resource.user_account']=['like','%'.I('user_account').'%'];
}
if(!empty(I('promote_id'))){
if(!empty(I('promote_id')) || I('promote_id')=="0"){
$promote_id = I('promote_id');
@ -90,6 +90,11 @@ class TestResourceController extends ThinkController
$promnote_arr = implode(",",$promnote_arr);
$map['tab_test_resource.promote_id']=['in',$promnote_arr];
if (!I("promote_level")) {
$map['tab_test_resource.promote_id']=I('promote_id');
}
}
//为数据权限添加
setPowerPromoteIds($map, 'tab_test_resource.promote_id');

@ -450,5 +450,30 @@ class PromoteModel extends Model{
}
public function getPromotersByLevelResource($level)
{
if ($level) {
$where['level'] = $level;
}
$userAuth = session('user_auth');
setPowerPromoteIds($where,'id');
$offcialData = [0=>['id'=>0,'nickname'=>'官方渠道']];
$result = $this->field("*")->where($where)->select();
foreach ($result as &$item) {
$item['nickname'] = $item['account'] . ($item['nickname'] ? "({$item['nickname']})" : "");
}
if ((in_array('0',explode(',',$where['id'][1]))||$userAuth['data_empower_type']==1)) {
$result = array_merge($offcialData,$result);
// dump($result);die();
}
return $result;
}
}

@ -243,7 +243,7 @@
var promote_id = "{:I('promote_id')}";
$("#promote_level").change(function(){
$.ajax({
url:"{:U('Ajax/getPromotersByLevelOther')}",
url:"{:U('Ajax/getPromotersByLevelResource')}",
type:"get",
data:{level:$("#promote_level option:selected").val()},
dataType:'json',

Loading…
Cancel
Save