|
@@ -4,6 +4,7 @@ namespace app\admin\controller;
|
|
|
|
|
|
use app\BaseController;
|
|
|
use think\App;
|
|
|
+use think\db\Where;
|
|
|
use think\facade\Db;
|
|
|
|
|
|
class Newfill extends BaseController
|
|
@@ -19,38 +20,35 @@ class Newfill extends BaseController
|
|
|
}
|
|
|
public function list()
|
|
|
{
|
|
|
- $page = isset($this->post['page']) && $this->post['page'] != "" ? intval($this->post['page']) : 1;
|
|
|
- $size = isset($this->post['size']) && $this->post['size'] != "" ? intval($this->post['size']) : 10;
|
|
|
+// $page = isset($this->post['page']) && $this->post['page'] != "" ? intval($this->post['page']) : 1;
|
|
|
+// $size = isset($this->post['size']) && $this->post['size'] != "" ? intval($this->post['size']) : 10;
|
|
|
$condition=[];
|
|
|
$condition[] = ['is_del',"=",0];
|
|
|
- isset($this->post['pid']) &&$this->post['pid']!=="" ? $condition[]=["pid","=",$this->post['pid']]: $condition[]=['pid',"=",0];
|
|
|
- isset($this->post['name'])&&$this->post['name']!=="" ? $condition[]=["name","like","%{$this->post['name']}%"]:"";
|
|
|
+ $pid = isset($this->post['pid']) &&$this->post['pid']!=="" ?intval($this->post['pid']): "";
|
|
|
+ if($pid!==""){
|
|
|
+ $condition[]=["pid","=",$pid];
|
|
|
+ }
|
|
|
+ $name= isset($this->post['name'])&&$this->post['name']!=="" ? trim($this->post['name']):"";
|
|
|
+ if($name!=""){
|
|
|
+ $condition[]=["name","like","%{$this->post['name']}%"];
|
|
|
+ }
|
|
|
$nickname = isset($this->post['nickname']) && $this->post['nickname'] !==""? trim($this->post['nickname']) :"";
|
|
|
if($nickname!=""){
|
|
|
$is= Db::name("depart_user")->where([['nickname','like',"%{$nickname}%"]])->column('itemid');
|
|
|
- // var_dump($this->post[$nickname]);
|
|
|
+
|
|
|
if(empty($is)){
|
|
|
return error_show(1004,"未找到数据");
|
|
|
}
|
|
|
+ $condition[]=["id","in",$is];
|
|
|
}
|
|
|
- $count = Db::name("company_item")->where($condition)->count();
|
|
|
- $page >= ceil($count / $size) ? $page = ceil($count / $size) : "";
|
|
|
- $list = Db::name("company_item")->where($condition)->page($page, $size)->select();
|
|
|
- // var_dump(Db::name("company_item")->getLastSql());
|
|
|
-// $this->carray($this->treelist);
|
|
|
-// var_dump($this->carray($this->treelist));
|
|
|
- $data=[];
|
|
|
- $act=[];
|
|
|
- foreach ($list as $value){
|
|
|
- // crea($value);
|
|
|
- //var_dump($value);
|
|
|
- $data[]= crea($value);;
|
|
|
-
|
|
|
+ if($pid==="" &&$name=="" &&$nickname==""){
|
|
|
+ $condition[]=["pid","=",0];
|
|
|
}
|
|
|
- // array_walk($data,function (&$value){
|
|
|
- //$value['child']= array_values($value['child']);
|
|
|
- // });
|
|
|
- return app_show(0,"获取成功",["list"=>$data,"count"=>$count]);
|
|
|
+ $pidlist = Db::name("company_item")->where($condition)->column("pid");
|
|
|
+ $list = Db::name("company_item")->where($condition)->select();
|
|
|
+ $item = Db::name("depart_user")->where([["itemid","in",$pidlist],["is_del","=",0]])->select();
|
|
|
+
|
|
|
+ return app_show(0,"获取成功",["depart"=>$list,"item"=>$item]);
|
|
|
}
|
|
|
/*状态*/
|
|
|
public function stat(){
|
|
@@ -72,25 +70,26 @@ class Newfill extends BaseController
|
|
|
public function userp(){
|
|
|
$id = isset($this->post['id'])?intval($this->post['id']):"";
|
|
|
if($id==""){
|
|
|
- return error_show(1004,"参数id 不能为空");
|
|
|
+ return error_show(1004,"参数id不能为空");
|
|
|
}
|
|
|
$t = Db::name('depart_user')->where(["id"=>$id,"is_del"=>0])->find();
|
|
|
if(empty($t)){
|
|
|
return error_show(1005,"未找到用户");
|
|
|
}
|
|
|
$position = isset($this->post['position'])?intval($this->post['position']):"";
|
|
|
- if($position!=""){
|
|
|
- return error_show(1004,"职位 不能为空");
|
|
|
+ if($position==""){
|
|
|
+ return error_show(1004,"职位不能为空");
|
|
|
}
|
|
|
if($position==2){
|
|
|
$f = Db::name('depart_user')->where(['itemid'=>$t['itemid'],"is_del"=>0,"position"=>2])->find();
|
|
|
if(!empty($f)&& $f['id']!=$id){
|
|
|
- return error_show(1004,"部门负责任已存在");
|
|
|
+ return error_show(1004,"部门负责人已存在");
|
|
|
}
|
|
|
}
|
|
|
$t['position']=$position;
|
|
|
$t['updatetime'] = date("Y-m-d H:i:s");
|
|
|
- $ti = Db::name('company_item')->save($t);
|
|
|
+ //var_dump($t);
|
|
|
+ $ti = Db::name('depart_user')->save($t);
|
|
|
return app_show(0,"修改成功");
|
|
|
}
|
|
|
public function add(){
|