Procházet zdrojové kódy

商品模块大部分列表增加创建人所在部门筛选条件

wufeng před 2 roky
rodič
revize
d6d0058293

+ 33 - 20
app/admin/controller/Activity.php

@@ -20,60 +20,73 @@ class Activity extends Base
     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 = [["ga.is_del","=",0]];
         $activity_name = isset($this->post['activity_name']) && $this->post['activity_name'] !=="" ? trim($this->post['activity_name']):"";
         if($activity_name!=""){
-            $where[]=['activity_name',"like","%$activity_name%"];
+            $where[]=['ga.activity_name',"like","%$activity_name%"];
         }
         $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status']):"";
         if($status!==""){
-            $where[]=['status',"=",$status];
+            $where[]=['ga.status',"=",$status];
         }
         $activity_code = isset($this->post['activity_code']) && $this->post['activity_code'] !=="" ? intval($this->post['activity_code']):"";
         if($activity_code!==""){
-            $where[]=['activity_code',"like","%$activity_code%"];
+            $where[]=['ga.activity_code',"like","%$activity_code%"];
         }
         $starttime = isset($this->post['starttime']) && $this->post['starttime']!=="" ? $this->post['starttime']:"";
         if($starttime!==""){
-            $where[]=['start',">=",date('Y-m-d H:i:s',strtotime($starttime))];
+            $where[]=['ga.start',">=",date('Y-m-d H:i:s',strtotime($starttime))];
         }
         $endtime = isset($this->post['endtime']) && $this->post['endtime']!=="" ? $this->post['endtime']:"";
         if($endtime!==""){
-            $where[]=['end',"<",date('Y-m-d H:i:s',strtotime($endtime)+24*3600)];
+            $where[]=['ga.end',"<",date('Y-m-d H:i:s',strtotime($endtime)+24*3600)];
         }
         $platform_code = isset($this->post['platform_code']) && $this->post['platform_code'] !=="" ? trim($this->post['platform_code']):"";
         if($platform_code!==""){
-            $where[]=['platform_code',"=",$platform_code];
+            $where[]=['ga.platform_code',"=",$platform_code];
         }
         $company_id = isset($this->post['company_id']) && $this->post['company_id'] !=="" ? trim($this->post['company_id']):"";
         if($company_id!==""){
-            $where[]=['company_id',"=",$company_id];
+            $where[]=['ga.company_id',"=",$company_id];
         }
         $creater = isset($this->post['creater']) && $this->post['creater'] !=="" ? trim($this->post['creater'])
             :"";
         if($creater!=""){
-            $where[]=['creater',"like","%$creater%"];
+            $where[]=['ga.creater',"like","%$creater%"];
         }
         $createrid = isset($this->post['createrid']) && $this->post['createrid'] !=="" ? trim($this->post['createrid'])
             :"";
         if($createrid!==""){
-            $where[]=['createrid',"=",$createrid];
+            $where[]=['ga.createrid',"=",$createrid];
         }
         $role=$this->checkRole();
         if(!empty($role['write'])){
-            $where[]=["createrid","in",$role['write']];
+            $where[]=["ga.createrid","in",$role['write']];
         }
-        $count = Db::name('good_activity')->where($where)->count();
+        $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
+        if ($company_name !== "") $where[] = ["ga.createrid", 'in', get_company_item_user_by_name($company_name)];
+
+        $count = Db::name('good_activity')
+            ->alias('ga')
+            ->where($where)
+            ->count();
         $total = ceil($count / $size);
         $page = $page >= $total ? $total : $page;
-        $list = Db::name('good_activity')->where($where)->page($page,$size)->order("addtime desc")->select();
-        $data=[];
-        foreach ($list as $value){
-            $info = Db::name("platform")->where(['id'=>$value['platform_code']])->find();
-            $value['platform_name']=$info['platform_name'];
-            $data[]=$value;
-        }
-        return app_show(0,"获取成功",['list'=>$data,'count'=>$count]);
+        $list = Db::name('good_activity')
+            ->alias('ga')
+            ->field('ga.*,p.platform_name,u.itemid')
+            ->leftJoin("depart_user u", "u.uid=ga.createrid AND u.is_del=0")
+            ->leftJoin("platform p", "p.id=ga.platform_code")
+            ->append(['company_name'])
+            ->withAttr('company_name',function($val,$data){
+                return implode('/', array_column(GetPart($data['itemid']), 'name'));
+            })
+            ->where($where)
+            ->page($page,$size)
+            ->order("ga.addtime desc")
+            ->select()
+            ->toArray();
+        return app_show(0,"获取成功",['list'=>$list,'count'=>$count]);
     }
     public function linst()
     {

+ 26 - 9
app/admin/controller/Brand.php

@@ -57,27 +57,27 @@ class Brand extends Base
     {
         $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 = [["b.is_del", "=", 0]];
         $brand_name = isset($this->post['brand_name']) && $this->post['brand_name'] !== "" ? trim($this->post['brand_name']) : "";
         if ($brand_name !== "") {
-            $where[] = ['brand_name', "like", "%$brand_name%"];
+            $where[] = ['b.brand_name', "like", "%$brand_name%"];
         }
         $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status'])
             : "";
         if ($status !== "") {
-            $where[] = ['status', "=", $status];
+            $where[] = ['b.status', "=", $status];
         }
         $creater = isset($this->post['creater']) && $this->post['creater'] !== "" ? trim($this->post['creater']) : "";
         if ($creater !== "") {
-            $where[] = ['creater', "like", "%$creater%"];
+            $where[] = ['b.creater', "like", "%$creater%"];
         }
         $start = isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start'] : "";
         if ($start !== "") {
-            $where[] = ['addtime', ">=", date('Y-m-d H:i:s', strtotime($start))];
+            $where[] = ['b.addtime', ">=", date('Y-m-d H:i:s', strtotime($start))];
         }
         $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] : "";
         if ($end !== "") {
-            $where[] = ['addtime', "<", date('Y-m-d H:i:s', strtotime($end) + 24 * 3600)];
+            $where[] = ['b.addtime', "<", date('Y-m-d H:i:s', strtotime($end) + 24 * 3600)];
         }
         $supplierNo = isset($this->post['supplierNo']) && $this->post['supplierNo'] != "" ? trim($this->post['supplierNo']) : "";
         if($supplierNo!=""){
@@ -86,12 +86,29 @@ class Brand extends Base
                 return error_show(1004,"未找到供应商信息");
             }
         $wsmcode = Db::name("brand_book")->where(["gyscode" => $supplierNo, "is_del" => 0])->column("brand_id");
-        $where[] = ['id', "in", $wsmcode];
+        $where[] = ['b.id', "in", $wsmcode];
     }
-        $count = Db::name('brand') ->where($where)->count();
+        $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
+        if ($company_name !== "") $where[] = ["b.createrid", 'in', get_company_item_user_by_name($company_name)];
+
+        $count = Db::name('brand')
+            ->alias('b')
+            ->where($where)
+            ->count();
         $total = ceil($count / $size);
         $page = $page >= $total ? $total : $page;
-        $list = Db::name('brand')->where($where)->page($page,$size)->order("addtime desc,id desc")->select();
+        $list = Db::name('brand')
+            ->alias('b')
+            ->field('b.*,u.itemid')
+            ->leftJoin("depart_user u", "u.uid=b.createrid AND u.is_del=0")
+            ->where($where)
+            ->append(['company_name'])
+            ->withAttr('company_name',function($val,$data){
+                return implode('/', array_column(GetPart($data['itemid']), 'name'));
+            })
+            ->page($page,$size)
+            ->order("addtime desc,id desc")
+            ->select();
         return app_show(0,"获取成功",['list'=>$list,'count'=>$count]);
     }
     public function edit(){

+ 28 - 8
app/admin/controller/Cat.php

@@ -36,23 +36,32 @@ public function list(){
 public function plist(){
     $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 =[["c.is_del","=",0]];
     $cat_name=isset($this->post['cat_name']) && $this->post['cat_name'] !==""? trim($this->post['cat_name']) :"";
     if($cat_name!==""){
-        $where[]=['cat_name',"like","%$cat_name%"];
+        $where[]=['c.cat_name',"like","%$cat_name%"];
     }
     $pid=isset($this->post['pid']) && $this->post['pid'] !==""? intval($this->post['pid']) :"";
     if($pid!==""){
-        $where[]=['pid',"=",$pid];
+        $where[]=['c.pid',"=",$pid];
     }
     $status=isset($this->post['status']) && $this->post['status'] !==""? intval($this->post['status']) :"";
     if($status!==""){
-        $where[]=['status',"=",$status];
+        $where[]=['c.status',"=",$status];
     }
-    $count = Db::name("cat")->where($where)->count();
+    $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
+    if ($company_name !== "") $where[] = ["c.createrid", 'in', get_company_item_user_by_name($company_name)];
+
+    $count = Db::name("cat")->alias('c')->where($where)->count();
     $total = ceil($count / $size);
     $page = $page >= $total ? $total : $page;
-    $list = Db::name('cat')->where($where)->page($page, $size)->select();
+    $list = Db::name('cat')
+        ->alias('c')
+        ->field('c.*,u.itemid')
+        ->leftJoin("depart_user u", "u.uid=c.createrid AND u.is_del=0")
+        ->where($where)
+        ->page($page, $size)
+        ->cursor();
     $var =[];
     foreach ($list as $value){
         $info = Db::name('cat_specs')->where(['cat_id'=>$value['id'],'is_del'=>0])->column('specs_id');
@@ -61,6 +70,7 @@ public function plist(){
             $temp=[];
         }
         $value['im']=$temp;
+        $value['company_name'] = implode('/', array_column(GetPart($value['itemid']), 'name'));
         $var[]=$value;
     }
     return app_show(0, "获取成功", ['list' =>$var, 'count' => $count]);
@@ -141,10 +151,19 @@ public function title(){
         if($end !==""){
             $where[]=['addtime',"<=",$end];
         }
-        $count = Db::name('cat')->where($where)->count();
+        $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
+        if ($company_name !== "") $where[] = ["c.createrid", 'in', get_company_item_user_by_name($company_name)];
+
+        $count = Db::name('cat')->alias('c')->where($where)->count();
         $total = ceil($count / $size);
         $page = $page >= $total ? $total : $page;
-        $list = Db::name('cat')->where($where)->page($page, $size)->select();
+        $list = Db::name('cat')
+            ->alias('c')
+            ->field('c.*,u.itemid')
+            ->leftJoin("depart_user u", "u.uid=c.createrid AND u.is_del=0")
+            ->where($where)
+            ->page($page, $size)
+            ->cursor();
         $var =[];
         foreach ($list as $value){
             $info = Db::name('cat_specs')->where(['cat_id'=>$value['id'],'is_del'=>0])->column('specs_id');
@@ -153,6 +172,7 @@ public function title(){
                  $temp=[];
             }
             $value['im']=$temp;
+            $value['company_name'] = implode('/', array_column(GetPart($value['itemid']), 'name'));
             $var[]=$value;
         }
         return app_show(0, "获取成功", ['list' => $var, 'count' => $count]);

+ 25 - 13
app/admin/controller/Goldprice.php

@@ -185,20 +185,32 @@ class Goldprice extends BaseController
     }
 
     public function lastlist(){
-        $where=['is_del'=>0];
-        $type=isset($this->post['type'])&&$this->post['type']!=""?intval($this->post['type']):"";
-        if($type!==""){
-            $where['type']=$type;
-        }
-        $ids =Db::name("gold_price1")->where(['is_del'=>0])->group("type")->column("max(id) as id");
-        $where['id']=$ids;
-        $list =Db::name("gold_price1")->where($where)->select();
-        $data=[];
-        foreach ($list as $value){
-            $value['type_cn']=$this->gold[$value['type']];
-            $data[]=$value;
+        $where = [['g.is_del', '=', 0]];
+        $type = isset($this->post['type']) && $this->post['type'] != "" ? intval($this->post['type']) : "";
+        if ($type !== "") {
+            $where[] = ['g.type', '=', $type];
         }
-        return app_show(0,"获取成功",$data);
+        $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
+        if ($company_name !== "") $where[] = ["g.action_id", 'in', get_company_item_user_by_name($company_name)];
+
+        $ids = Db::name("gold_price1")
+            ->where(['is_del' => 0])
+            ->group("type")
+            ->column("max(id) as id");
+        $where[] = ['g.id', 'in', $ids];
+        $list = Db::name("gold_price1")
+            ->alias('g')
+            ->field('g.*,u.itemid')
+            ->leftJoin("depart_user u", "u.uid=g.action_id AND u.is_del=0")
+            ->where($where)
+            ->cursor();
+        $data = [];
+        foreach ($list as $value) {
+            $value['type_cn'] = $this->gold[$value['type']];
+            $value['company_name'] = implode('/', array_column(GetPart($value['itemid']), 'name'));
+            $data[] = $value;
+        }
+        return app_show(0, "获取成功", $data);
     }
 
     public function ratelist(){

+ 7 - 3
app/admin/controller/Good.php

@@ -109,6 +109,9 @@ class Good extends Base
         if(!empty($role['write']) ){
             $where[]=["a.createrid","in",$role['write']];
         }
+        $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
+        if ($company_name !== "") $where[] = ["a.createrid", 'in', get_company_item_user_by_name($company_name)];
+
 //        if(!empty($role['platform']) ){
 //            $where[]=["b.platform_code","in",$role['platform']];
 //        }
@@ -120,14 +123,14 @@ class Good extends Base
             ->alias("a")
             ->field("b.skuCode,b.platform_code,b.plat_code,b.id as good_id,a.cat_id,a.good_name,a.good_img,a.good_info_img
             ,b.createrid,a.is_exclusive,a.brand_id,a.supplierNo,a.good_unit,a.noble_metal,a.companyNo,a.spuCode,a.good_type,
-            b.creater,b.addtime,b.updatetime,b.exam_status,a.createrid purchase_id,a.creater purchase")//成本表里的创建人,也是线上商品的采购人,为了防止混淆,给creater取个别名
+            b.creater,b.addtime,b.updatetime,b.exam_status,a.createrid purchase_id,a.creater purchase,u.itemid")//成本表里的创建人,也是线上商品的采购人,为了防止混淆,给creater取个别名
             ->leftJoin("good_platform b","a.spuCode=b.spuCode")
 //            ->leftJoin("good_basic gb","gb.spuCode=a.spuCode")
+            ->leftJoin("depart_user u", "u.uid=a.createrid AND u.is_del=0")
             ->where($where)
             ->page($page,$size)
             ->order("b.addtime desc")
-            ->select()
-            ->toArray();
+            ->cursor();
         $data=[];
         foreach ($list as $value){
             $value['cat_info']= made($value['cat_id'],[]);
@@ -163,6 +166,7 @@ class Good extends Base
             }
             $value['specinfo']=$speclist;
             $value['noble_name']=isset($value['noble_metal'])&&$value['noble_metal']!=0?$this->noble[$value['noble_metal']] :"";
+            $value['company_name'] = implode('/', array_column(GetPart($value['itemid']), 'name'));
             $data[]=$value;
         }
         return app_show(0,"获取成功",['list'=>$data,'count'=>$count]);

+ 35 - 21
app/admin/controller/Goodup.php

@@ -23,82 +23,82 @@ class Goodup extends Base
     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 =[["gb.is_del","=",0]];
         $condit =[["a.is_del","=",0]];
         $cat_id = isset($this->post['cat_id']) && $this->post['cat_id'] !=="" ? intval($this->post['cat_id']):"";
         if($cat_id!==""){
             $cat_ids=catChild($cat_id);
-            $where[]=['cat_id',"in",$cat_ids];
+            $where[]=['gb.cat_id',"in",$cat_ids];
             $condit[]=['a.cat_id',"in",$cat_ids];
         }
         $good_name = isset($this->post['good_name']) && $this->post['good_name'] !=="" ? trim($this->post['good_name']):"";
         if($good_name!==""){
-            $where[]=['good_name',"like","%$good_name%"];
+            $where[]=['gb.good_name',"like","%$good_name%"];
             $condit[]=['a.good_name',"like","%$good_name%"];
         }
         $spucode = isset($this->post['spucode']) && $this->post['spucode'] !=="" ? trim($this->post['spucode'])
             :"";
         if($spucode!==""){
-            $where[]=['spuCode',"like","%$spucode%"];
+            $where[]=['gb.spuCode',"like","%$spucode%"];
             $condit[]=['a.spuCode',"like","%$spucode%"];
         }
         $good_type = isset($this->post['good_type']) && $this->post['good_type'] !=="" ? trim($this->post['good_type'])
             :"";
         if($good_type!==""){
-            $where[]=['good_type',"=",$good_type];
+            $where[]=['gb.good_type',"=",$good_type];
             $condit[]=['a.good_type',"=",$good_type];
         }
         $companyNo = isset($this->post['companyNo']) && $this->post['companyNo'] !=="" ? trim($this->post['companyNo'])
             :"";
         if($companyNo!==""){
-            $where[]=['companyNo',"like","%$companyNo%"];
+            $where[]=['gb.companyNo',"like","%$companyNo%"];
             $condit[]=['a.companyNo',"like","%$companyNo%"];
         }
         $supplierNo = isset($this->post['supplierNo']) && $this->post['supplierNo'] !=="" ? trim($this->post['supplierNo'])
             :"";
         if($supplierNo!==""){
-            $where[]=['supplierNo',"like","%$supplierNo%"];
+            $where[]=['gb.supplierNo',"like","%$supplierNo%"];
             $condit[]=['a.supplierNo',"like","%$supplierNo%"];
         }
         $supplier = isset($this->post['supplier']) && $this->post['supplier'] !=="" ? trim($this->post['supplier'])
             :"";
         if($supplier!==""){
             $suppliernos = Db::name("supplier")->where([["name","like","%$supplier%"]])->column("code");
-            $where[]=['supplierNo',"in",$suppliernos];
+            $where[]=['gb.supplierNo',"in",$suppliernos];
             $condit[]=['a.supplierNo',"in",$suppliernos];
         }
         $company = isset($this->post['company']) && $this->post['company'] !=="" ? trim($this->post['company'])
             :"";
         if($company!==""){
             $companyNos = Db::name("business")->where([["company","like","%$company%"]])->column("companyNo");
-            $where[]=['companyNo',"in",$companyNos];
+            $where[]=['gb.companyNo',"in",$companyNos];
             $condit[]=['a.companyNo',"in",$companyNos];
         }
 
         $brandid = isset($this->post['brandid']) && $this->post['brandid'] !=="" ? intval($this->post['brandid'])
             :"";
         if($brandid!==""){
-            $where[]=['brand_id',"=",$brandid];
+            $where[]=['gb.brand_id',"=",$brandid];
             $condit[]=['a.brand_id',"=",$brandid];
         }
         $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status'])
             :"";
         if($status!==""){
-            $where[]=['status',"=",$status];
+            $where[]=['gb.status',"=",$status];
             $condit[]=['a.status',"=",$status];
         }
         $is_stock = isset($this->post['is_stock']) && $this->post['is_stock'] !== "" ? intval($this->post['is_stock']) : '';
         if ($is_stock!=='') {
-            $where[] = ['is_stock', "=", $is_stock];
+            $where[] = ['gb.is_stock', "=", $is_stock];
         }
         $start = isset($this->post['start']) && $this->post['start']!=="" ? $this->post['start']:"";
         if($start!==""){
-            $where[]=['addtime',">=",date('Y-m-d H:i:s',strtotime($start))];
+            $where[]=['gb.addtime',">=",date('Y-m-d H:i:s',strtotime($start))];
             $condit[]=['a.addtime',">=",date('Y-m-d H:i:s',strtotime($start))];
         }
         $end = isset($this->post['end']) && $this->post['end']!=="" ? $this->post['end']:"";
         if($end!==""){
-            $where[]=['addtime',"<",date('Y-m-d H:i:s',strtotime($end)+24*3600)];
+            $where[]=['gb.addtime',"<",date('Y-m-d H:i:s',strtotime($end)+24*3600)];
             $condit[]=['a.addtime',"<",date('Y-m-d H:i:s',strtotime($end)+24*3600)];
         }
         $isonline = isset($this->post['isonline']) && $this->post['isonline']!=="" ? $this->post['isonline']:"";
@@ -116,8 +116,8 @@ class Goodup extends Base
               ->group("a.spuCode")
               ->column('a.spuCode');
 
-            if($isonline==1) $where[]=["spuCode","in",$sta];
-            else  $where[]=["spuCode","not in",$sta];
+            if($isonline==1) $where[]=["gb.spuCode","in",$sta];
+            else  $where[]=["gb.spuCode","not in",$sta];
         }
         $token = isset($this->post['token']) ? trim($this->post['token']) : "";
         if($token==""){
@@ -135,17 +135,29 @@ class Goodup extends Base
 //            }
 //            $check = checkRole($useinfo['roleid'],115);
 //            if($check){
-//                $where[]=['createrid', "=" ,$rm];
+//                $where[]=['gb.createrid', "=" ,$rm];
 //            }
 //        }
         $role=$this->checkRole();
         if(!empty($role['write'])){
-            $where[]=["createrid","in",$role['write']];
+            $where[]=["gb.createrid","in",$role['write']];
         }
-        $count = Db::name('good_basic')->where($where)->count();
+        $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
+        if ($company_name !== "") $where[] = ["gb.createrid", 'in', get_company_item_user_by_name($company_name)];
+
+
+        $count = Db::name('good_basic')->alias('gb')->where($where)->count();
         $total = ceil($count / $size);
         $page = $page >= $total ? $total : $page;
-        $list = Db::name('good_basic')->where($where)->page($page,$size)->order("addtime desc")->select()->toArray();
+        $list = Db::name('good_basic')
+            ->alias('gb')
+            ->field('gb.*,u.itemid')
+            ->leftJoin("depart_user u", "u.uid=gb.createrid AND u.is_del=0")
+            ->where($where)
+            ->page($page,$size)
+            ->order("addtime desc")
+            ->select()
+            ->toArray();
         $data=[];
 
         //查询一下这些spucode是否在平台上成功上线
@@ -172,7 +184,9 @@ class Goodup extends Base
                     $value['is_online'] = 1;
                 }
 
-                $data[]=$value;
+            $value['company_name'] = implode('/', array_column(GetPart($value['itemid']), 'name'));
+
+            $data[] = $value;
         }
         return app_show(0,"获取成功",['list'=>$data,'count'=>$count]);
     }

+ 26 - 8
app/admin/controller/Specs.php

@@ -53,32 +53,50 @@ class Specs 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]];
         $spec_name = isset($this->post['spec_name']) && $this->post['spec_name'] !=="" ? trim($this->post['spec_name']):"";
         if($spec_name!=""){
-            $where[]=['spec_name',"like","%$spec_name%"];
+            $where[]=['s.spec_name',"like","%$spec_name%"];
         }
         $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status'])
             :"";
         if($status!==""){
-            $where[]=['status',"=",$status];
+            $where[]=['s.status',"=",$status];
         }
         $creater = isset($this->post['creater']) && $this->post['creater'] !=="" ? intval($this->post['creater']):"";
         if($creater!=""){
-            $where[]=['creater',"like","%$creater%"];
+            $where[]=['s.creater',"like","%$creater%"];
         }
         $start = isset($this->post['start']) && $this->post['start']!=="" ? $this->post['start']:"";
         if($start!==""){
-            $where[]=['addtime',">=",date('Y-m-d H:i:s',strtotime($start))];
+            $where[]=['s.addtime',">=",date('Y-m-d H:i:s',strtotime($start))];
         }
         $end = isset($this->post['end']) && $this->post['end']!=="" ? $this->post['end']:"";
         if($end!==""){
-            $where[]=['addtime',"<",date('Y-m-d H:i:s',strtotime($end)+24*3600)];
+            $where[]=['s.addtime',"<",date('Y-m-d H:i:s',strtotime($end)+24*3600)];
         }
-        $count = Db::name('specs') ->where($where)->count();
+        $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)];
+
+        $count = Db::name('specs')
+            ->alias('s')
+            ->where($where)
+            ->count();
         $total = ceil($count / $size);
         $page = $page >= $total ? $total : $page;
-        $list = Db::name('specs')->where($where)->page($page,$size)->order("addtime desc")->select();
+        $list = Db::name('specs')
+            ->alias('s')
+            ->field('s.*,u.itemid')
+            ->leftJoin("depart_user u", "u.uid=s.createrid AND u.is_del=0")
+            ->where($where)
+            ->append(['company_name'])
+            ->withAttr('company_name',function($val,$data){
+                return implode('/', array_column(GetPart($data['itemid']), 'name'));
+            })
+            ->page($page,$size)
+            ->order("addtime desc")
+            ->select()
+            ->toArray();
         return app_show(0,"获取成功",['list'=>$list,'count'=>$count]);
     }
     public function status(){

+ 30 - 10
app/admin/controller/Unit.php

@@ -51,34 +51,54 @@ class Unit 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=[["u.is_del","=",0]];
         $unit = isset($this->post['unit']) && $this->post['unit'] !=="" ? trim($this->post['unit']):"";
         if($unit!==""){
-            $where[]=['unit',"like","%$unit%"];
+            $where[]=['u.unit',"like","%$unit%"];
         }
         $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status'])
             :"";
         if($status!==""){
-            $where[]=['status',"=",$status];
+            $where[]=['u.status',"=",$status];
         }
         $creater = isset($this->post['creater']) && $this->post['creater'] !=="" ? trim($this->post['creater']):"";
         if($creater!=""){
-            $where[]=['creater',"like","%$creater%"];
+            $where[]=['u.creater',"like","%$creater%"];
         }
         $start = isset($this->post['start']) && $this->post['start']!=="" ? $this->post['start']:"";
         if($start!==""){
-           // $where[]=['addtime',">=",date('Y-m-d H:i:s')];//,strtotime($start)
-            $where[]=['addtime',">=",$start];
+           // $where[]=['u.addtime',">=",date('Y-m-d H:i:s')];//,strtotime($start)
+            $where[]=['u.addtime',">=",$start];
         }
         $end = isset($this->post['end']) && $this->post['end']!=="" ? $this->post['end']:"";
         if($end!==""){
-           // $where[]=['addtime',"<",date('Y-m-d H:i:s')];//,strtotime($end)+24*3600
-            $where[]=['addtime',"<=",$end];
+           // $where[]=['u.addtime',"<",date('Y-m-d H:i:s')];//,strtotime($end)+24*3600
+            $where[]=['u.addtime',"<=",$end];
         }
-        $count = Db::name('unit') ->where($where)->count();
+        $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
+        if ($company_name !== "") $where[] = ["u.createrid", 'in', get_company_item_user_by_name($company_name)];
+
+
+        $count = Db::name('unit')
+            ->alias('u')
+            ->leftJoin("depart_user user", "user.uid=u.createrid AND user.is_del=0")
+            ->where($where)
+            ->count();
         $total = ceil($count / $size);
         $page = $page >= $total ? $total : $page;
-        $list = Db::name('unit')->where($where)->page($page,$size)->order("addtime desc")->select();
+        $list = Db::name('unit')
+            ->alias('u')
+            ->field('u.*,user.itemid')
+            ->leftJoin("depart_user user", "user.uid=u.createrid AND user.is_del=0")
+            ->where($where)
+            ->append(['company_name'])
+            ->withAttr('company_name',function($val,$data){
+                return implode('/', array_column(GetPart($data['itemid']), 'name'));
+            })
+            ->page($page,$size)
+            ->order("addtime desc")
+            ->select()
+            ->toArray();
         return app_show(0,"获取成功",['list'=>$list,'count'=>$count]);
     }
     public function edit(){