php 参数存在 keyValue 只返回已选中数据
/*** @description: 学校下部门* @return {*}*/public function school_dept(){$params=$this->request->param();$where['type']=2;$where['status']=1;$list=collection($this->model->where($where)->select())->toArray();$total = count($list);$rows=[];foreach($list as $k => $v){$item=[];$item['id']=$v['id'];$item['name']=$v['deptname'];if(isset($params['keyValue'])){if(in_array($v['id'],explode(',',$params['keyValue']))){$rows[]=$item;}}else{$rows[]=$item;}}$result = array("total" => $total, "rows" => $rows);return json($result);}
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号