Jiance.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?php
  2. namespace app\company\controller;
  3. use app\common\controller\Apic;
  4. use think\Db;
  5. /**
  6. * 检测下发
  7. */
  8. class Jiance extends Apic
  9. {
  10. protected $noNeedLogin = [];
  11. protected $noNeedRight = [];
  12. protected $table = 'jiance';
  13. public function index(){
  14. $search = [];
  15. $bianhao = input('bianhao','');
  16. $uc_id = input('uc_id','');
  17. $worker_id = input('worker_id','');
  18. if(!empty($bianhao)){
  19. $search['jiance.bianhao'] = ['LIKE','%'.$bianhao.'%'];
  20. }
  21. if(!empty($uc_id)){
  22. $search['jiance.uc_id'] = $uc_id;
  23. }
  24. if(!empty($worker_id)){
  25. $search['jiance.worker_id'] = $worker_id;
  26. }
  27. $list = Db::name($this->table)
  28. ->field('jiance.*,uc.projectname,worker.truename as worker_truename,worker.mobile as worker_mobile')
  29. ->join('worker','jiance.worker_id = worker.id','LEFT')
  30. ->join('user_company uc','jiance.uc_id = uc.id','LEFT')
  31. ->where('jiance.company_id',$this->auth->company_id)
  32. ->where('jiance.deletetime',NULL)
  33. ->where($search)
  34. ->paginate();
  35. $total = $list->total();
  36. $list = $list->items();
  37. $rs = [
  38. 'list' => $list,
  39. 'total'=> $total,
  40. ];
  41. $this->success(1,$rs);
  42. }
  43. public function add(){
  44. $project_ids = input('project_ids','');
  45. $jiance_number = 0;
  46. if(!empty($project_ids)){
  47. $jiance_number = Db::name('jiance_project')->where('id','IN',$project_ids)->where('pid',0)->count();
  48. }
  49. $data = [
  50. 'company_id' => $this->auth->company_id,
  51. 'uc_id' => input('uc_id',''),
  52. 'worker_id' => input('worker_id',''),
  53. 'bianhao' => input('bianhao',''),
  54. 'status' => 0,
  55. 'jiance_number' => $jiance_number,
  56. 'project_ids' => $project_ids,
  57. ];
  58. Db::name($this->table)->insertGetId($data);
  59. $this->success();
  60. }
  61. public function info(){
  62. $id = input('id',0);
  63. $info = Db::name($this->table)->where('id',$id)->where('company_id',$this->auth->company_id)->where('deletetime',NULL)->find();
  64. $this->success(1,$info);
  65. }
  66. public function edit(){
  67. $id = input('id',0);
  68. $info = Db::name($this->table)->where('id',$id)->where('company_id',$this->auth->company_id)->where('deletetime',NULL)->find();
  69. if(empty($info)){
  70. $this->error('没找到该信息,请刷新重试');
  71. }
  72. //
  73. $project_ids = input('project_ids','');
  74. $jiance_number = 0;
  75. if(!empty($project_ids)){
  76. $jiance_number = Db::name('jiance_project')->where('id','IN',$project_ids)->where('pid',0)->count();
  77. }
  78. $data = [
  79. 'uc_id' => input('uc_id',''),
  80. 'worker_id' => input('worker_id',''),
  81. 'bianhao' => input('bianhao',''),
  82. 'jiance_number' => $jiance_number,
  83. 'project_ids' => $project_ids,
  84. ];
  85. Db::name($this->table)->where('id',$id)->update($data);
  86. $this->success();
  87. }
  88. public function del(){
  89. $ids = input('ids','');
  90. $ids = explode(',',$ids);
  91. if (empty($ids)) {
  92. $this->error();
  93. }
  94. Db::name($this->table)->where('id','IN',$ids)->where('company_id',$this->auth->company_id)->update(['deletetime'=>time()]);
  95. $this->success();
  96. }
  97. //生成报告
  98. public function getpdf(){
  99. }
  100. }