|
@@ -216,60 +216,76 @@ class Suppler 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";
|
|
|
- $where =[['is_del',"=",0]];
|
|
|
+ $where =[['s.is_del',"=",0]];
|
|
|
$name = isset($this->post['name']) && $this->post['name'] !=="" ? trim($this->post['name']):"";
|
|
|
if($name !==""){
|
|
|
- $where[]=["name","like","%$name%"];
|
|
|
+ $where[]=["s.name","like","%$name%"];
|
|
|
}
|
|
|
$creater = isset($this->post['creater']) && $this->post['creater'] !=="" ? trim($this->post['creater']):"";
|
|
|
if($creater !==""){
|
|
|
- $where[] = ["creater","like","%$creater%"];
|
|
|
+ $where[] = ["s.creater","like","%$creater%"];
|
|
|
}
|
|
|
$person = isset($this->post['person']) && $this->post['person'] !=="" ? trim($this->post['person']):"";
|
|
|
if($person !==""){
|
|
|
- $where[] = ["person","like","%$person%"];
|
|
|
+ $where[] = ["s.person","like","%$person%"];
|
|
|
}
|
|
|
$status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status']):"";
|
|
|
if($status!==""){
|
|
|
- $where[]= ["status","=",$status];
|
|
|
+ $where[]= ["s.status","=",$status];
|
|
|
}
|
|
|
$ocr_status = isset($this->post['ocr_status']) && $this->post['ocr_status'] !=="" ? intval($this->post['ocr_status']):"";
|
|
|
if($ocr_status!==""){
|
|
|
- $where[]= ["ocr_status","=",$ocr_status];
|
|
|
+ $where[]= ["s.ocr_status","=",$ocr_status];
|
|
|
}
|
|
|
$start = isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start']:"";
|
|
|
if($start!==""){
|
|
|
- $where[]=['addtime',">=",$start];
|
|
|
+ $where[]=['s.addtime',">=",$start];
|
|
|
}
|
|
|
+ $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
|
|
|
+ if ($company_name !== "") $where[] = ["s.createrid", 'in', get_company_item_user_by_name($company_name)];
|
|
|
+
|
|
|
// $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] :"";
|
|
|
// if($end !=""){
|
|
|
-// $where[]=['a.addtime',"<=",$end];
|
|
|
+// $where[]=['s.addtime',"<=",$end];
|
|
|
// }
|
|
|
// $contactor = isset($this->post['contactor']) && $this->post['contactor'] !==""? trim($this->post['contactor']):"";
|
|
|
// if($contactor !=""){
|
|
|
-// $where[]=["contactor","like","%$contactor%"];
|
|
|
+// $where[]=["s.contactor","like","%$contactor%"];
|
|
|
// }
|
|
|
// $mobile = isset($this->post['mobile']) && $this->post['mobile'] !=="" ? intval($this->post['mobile']):"";
|
|
|
// if($mobile !=""){
|
|
|
-// $where[] = ['mobile',"like","%$mobile%"];
|
|
|
+// $where[] = ['s.mobile',"like","%$mobile%"];
|
|
|
// }
|
|
|
- $count = Db::name('supplier')->where($where)->count();
|
|
|
+ $count = Db::name('supplier')
|
|
|
+ ->alias('s')
|
|
|
+ ->where($where)
|
|
|
+ ->count();
|
|
|
$total = ceil($count / $size);
|
|
|
$page = $page >= $total ? $total : $page;
|
|
|
// $list = Db::name('supplier')->alias('a')
|
|
|
// ->join("supplier_contact b","b.code=a.code","left")
|
|
|
// ->where($where)->page($page,$size)->order("a.addtime desc")
|
|
|
// ->field("a.*,b.contactor,b.mobile")->select();
|
|
|
- $list = Db::name('supplier')->where($where)->page($page,$size)->order("addtime desc")->select();
|
|
|
- $var=[];
|
|
|
- foreach ($list as $value){
|
|
|
- $tem = Db::name('supplier_contact')->where(['code'=>$value['code']])->field("contactor,mobile")->find();
|
|
|
- $iten=[];
|
|
|
- $value['contactor']=$tem['contactor'];
|
|
|
- $value['mobile']=$tem['mobile'];
|
|
|
- $var[]=$value;
|
|
|
- }
|
|
|
- return app_show("0","获取成功",['list'=>$var,'count'=>$count]);
|
|
|
+ $list = Db::name('supplier')
|
|
|
+ ->alias('s')
|
|
|
+ ->field('s.*,u.itemid')
|
|
|
+ ->leftJoin("depart_user u", "u.uid=s.createrid AND u.is_del=0")
|
|
|
+ ->where($where)
|
|
|
+ ->page($page,$size)
|
|
|
+ ->order("addtime desc")
|
|
|
+ ->select()
|
|
|
+ ->toArray();
|
|
|
+
|
|
|
+ $all_codes = Db::name('supplier_contact')
|
|
|
+ ->whereIn('code', array_column($list, 'code'))
|
|
|
+ ->column("id,contactor,mobile",'code');
|
|
|
+
|
|
|
+ foreach ($list as &$value){
|
|
|
+ $value['contactor']=isset($all_codes[$value['code']]['contactor'])?$all_codes[$value['code']]['contactor']:'';
|
|
|
+ $value['mobile']=isset($all_codes[$value['code']]['mobile'])?$all_codes[$value['code']]['mobile']:'';
|
|
|
+ $value['company_name'] = implode('/', array_column(GetPart($value['itemid']), 'name'));
|
|
|
+ }
|
|
|
+ return app_show("0","获取成功",['list'=>$list,'count'=>$count]);
|
|
|
}
|
|
|
public function edit(){
|
|
|
$token = isset($this->post['token'])&&$this->post['token']!='' ? trim($this->post['token']):"";
|