['contract_type', 'contract_no', 'status'], ]; } /** * @notes 获取列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author likeadmin * @date 2023/07/18 14:28 */ public function lists(): array { $params=$this->request->param(); $where=[]; if ($this->adminInfo['root'] != 1) { // if($this->adminInfo['role_id'][0]==10){ // if(isset($params['type']) && $params['type']==1){ // $where[] = ['check_status', '=',1]; // }else{ // $where[] = ['status', '=',0]; // $where[] = ['check_status', 'in',[2,3]]; // } // } } if(isset($params['company_id']) && $params['company_id']!=''){ $arr= Company::where('company_name','like','%'.$params['company_id'].'%')->column('id'); if($arr){ $where[]=['party_a|party_b','in',$arr]; } } if(isset($params['area_manager']) && $params['area_manager']!=''){ $arr= Admin::where('name','like','%'.$params['area_manager'].'%')->column('id'); if($arr){ $where[]=['area_manager','in',$arr]; } } return Contract::where($this->searchWhere)->where($where)->with(['companyName','party_a_info','contractType']) // ->field(['id', 'company_id', 'contract_type', 'contract_no', 'status', 'party_a', 'party_b', 'area_manager']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function ($item, $key) { if($item->type==1){ $item->party_b_name=Db::name('company')->where('id',$item->party_b)->value('company_name'); }else{ $item->party_b_name=Db::name('user')->where('id',$item->party_b)->value('nickname'); } if(!empty($item->party_a_info)){ $area_manager_name=Db::name('admin')->where('id',$item->party_a_info->area_manager)->value('name'); if($area_manager_name){ $item->area_manager_name=$area_manager_name; }else{ $item->area_manager_name='暂无片区经理'; } }else{ $item->area_manager_name='暂无片区经理'; } $item->contract_type_name=Db::name('dict_data')->where('id',$item->contract_type)->value('name'); $item->status_name=$item->status==1?'已签约':'未签约'; }) ->toArray(); } /** * @notes 获取数量 * @return int * @author likeadmin * @date 2023/07/18 14:28 */ public function count(): int { return Contract::where($this->searchWhere)->count(); } }