|
@@ -0,0 +1,136 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace app\company\controller;
|
|
|
+
|
|
|
+use app\common\controller\Apic;
|
|
|
+use think\Db;
|
|
|
+/**
|
|
|
+ * 检测下发
|
|
|
+ */
|
|
|
+class Jiance extends Apic
|
|
|
+{
|
|
|
+ protected $noNeedLogin = [];
|
|
|
+ protected $noNeedRight = [];
|
|
|
+
|
|
|
+ protected $table = 'jiance';
|
|
|
+
|
|
|
+ public function index(){
|
|
|
+ $search = [];
|
|
|
+ $bianhao = input('bianhao','');
|
|
|
+ $uc_id = input('uc_id','');
|
|
|
+ $worker_id = input('worker_id','');
|
|
|
+
|
|
|
+ if(!empty($bianhao)){
|
|
|
+ $search['jiance.bianhao'] = ['LIKE','%'.$bianhao.'%'];
|
|
|
+ }
|
|
|
+ if(!empty($uc_id)){
|
|
|
+ $search['jiance.uc_id'] = $uc_id;
|
|
|
+ }
|
|
|
+ if(!empty($worker_id)){
|
|
|
+ $search['jiance.worker_id'] = $worker_id;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $list = Db::name($this->table)
|
|
|
+ ->field('jiance.*,uc.projectname,worker.truename as worker_truename,worker.mobile as worker_mobile')
|
|
|
+ ->join('worker','jiance.worker_id = worker.id','LEFT')
|
|
|
+ ->join('user_company uc','jiance.uc_id = uc.id','LEFT')
|
|
|
+ ->where('jiance.company_id',$this->auth->company_id)
|
|
|
+ ->where('jiance.deletetime',NULL)
|
|
|
+ ->where($search)
|
|
|
+ ->paginate();
|
|
|
+
|
|
|
+ $total = $list->total();
|
|
|
+ $list = $list->items();
|
|
|
+
|
|
|
+ $rs = [
|
|
|
+ 'list' => $list,
|
|
|
+ 'total'=> $total,
|
|
|
+ ];
|
|
|
+
|
|
|
+ $this->success(1,$rs);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function add(){
|
|
|
+ $project_ids = input('project_ids','');
|
|
|
+ $jiance_number = 0;
|
|
|
+
|
|
|
+ if(!empty($project_ids)){
|
|
|
+ $jiance_number = Db::name('jiance_project')->where('id','IN',$project_ids)->where('pid',0)->count();
|
|
|
+ }
|
|
|
+
|
|
|
+ $data = [
|
|
|
+ 'company_id' => $this->auth->company_id,
|
|
|
+ 'uc_id' => input('uc_id',''),
|
|
|
+ 'worker_id' => input('worker_id',''),
|
|
|
+ 'bianhao' => input('bianhao',''),
|
|
|
+ 'status' => 0,
|
|
|
+ 'jiance_number' => $jiance_number,
|
|
|
+ 'project_ids' => $project_ids,
|
|
|
+ ];
|
|
|
+
|
|
|
+ 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)->where('deletetime',NULL)->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)->where('deletetime',NULL)->find();
|
|
|
+ if(empty($info)){
|
|
|
+ $this->error('没找到该信息,请刷新重试');
|
|
|
+ }
|
|
|
+
|
|
|
+ //
|
|
|
+ $project_ids = input('project_ids','');
|
|
|
+ $jiance_number = 0;
|
|
|
+
|
|
|
+ if(!empty($project_ids)){
|
|
|
+ $jiance_number = Db::name('jiance_project')->where('id','IN',$project_ids)->where('pid',0)->count();
|
|
|
+ }
|
|
|
+
|
|
|
+ $data = [
|
|
|
+
|
|
|
+ 'uc_id' => input('uc_id',''),
|
|
|
+ 'worker_id' => input('worker_id',''),
|
|
|
+ 'bianhao' => input('bianhao',''),
|
|
|
+
|
|
|
+ 'jiance_number' => $jiance_number,
|
|
|
+ 'project_ids' => $project_ids,
|
|
|
+ ];
|
|
|
+
|
|
|
+ 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)->update(['deletetime'=>time()]);
|
|
|
+ $this->success();
|
|
|
+ }
|
|
|
+
|
|
|
+ //生成报告
|
|
|
+ public function getpdf(){
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|