table)->alias('hz') ->join('user_company uc','hz.uc_id = uc.id','LEFT') ->field('hz.*,uc.projectname') ->where('hz.company_id',$this->auth->company_id) ->where($map) ->order('hz.id desc') ->paginate(); $total = $list->total(); $list = $list->items(); $rs = [ 'list' => $list, 'total'=> $total, ]; $this->success(1,$rs); } public function add(){ $uc_id = input('uc_id',''); $uc_info = Db::name('user_company')->where('id',$uc_id)->where('company_id',$this->auth->company_id)->find(); if(empty($uc_info)){ $this->error('不存在的客户'); } $data = [ 'company_id' => $this->auth->company_id, 'uc_id' => $uc_id, 'createtime' => time(), 'title' => input('title',''), 'finishtime' => input('finishtime','','strtotime'), 'remark' => input('remark',''), 'status' => input('status',1), ]; Db::name($this->table)->insertGetId($data); $this->success(); } public function info(){ $id = input('id',0); $info = Db::name($this->table)->where('id',$id)->where('company_id',$this->auth->company_id)->find(); $this->success(1,$info); } public function edit(){ $id = input('id',0); $info = Db::name($this->table)->where('id',$id)->where('company_id',$this->auth->company_id)->find(); if(empty($info)){ $this->error('没找到该信息,请刷新重试'); } $data = [ 'title' => input('title',''), 'finishtime' => input('finishtime','','strtotime'), 'remark' => input('remark',''), 'status' => input('status',1), ]; Db::name($this->table)->where('id',$id)->update($data); $this->success(); } public function del(){ $ids = input('ids',''); $ids = explode(',',$ids); if (empty($ids)) { $this->error(); } Db::name($this->table)->where('id','IN',$ids)->where('company_id',$this->auth->company_id)->delete(); $this->success(); } }