Res.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. namespace app\admin\controller;
  3. use app\common\controller\Backend;
  4. use \think\Db;
  5. use \think\Session;
  6. /**
  7. * 检测结果管理管理
  8. *
  9. * @icon fa fa-circle-o
  10. */
  11. class Res extends Backend
  12. {
  13. /**
  14. * Res模型对象
  15. * @var \app\admin\model\Res
  16. */
  17. protected $model = null;
  18. protected $searchFields = 'entrust_no,name,bach,standard_name';
  19. public function _initialize()
  20. {
  21. parent::_initialize();
  22. $this->model = new \app\admin\model\Res;
  23. $this->view->assign("statusList", $this->model->getStatusList());
  24. }
  25. /**
  26. * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  27. * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  28. * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  29. */
  30. /**
  31. * 查看
  32. *
  33. * @return string|Json
  34. * @throws \think\Exception
  35. * @throws DbException
  36. */
  37. public function index()
  38. {
  39. //设置过滤方法
  40. $this->request->filter(['strip_tags', 'trim']);
  41. if (false === $this->request->isAjax()) {
  42. return $this->view->fetch();
  43. }
  44. //如果发送的来源是 Selectpage,则转发到 Selectpage
  45. if ($this->request->request('keyField')) {
  46. return $this->selectpage();
  47. }
  48. [$where, $sort, $order, $offset, $limit] = $this->buildparams();
  49. $user_id = Session::get('admin')['id'];
  50. if ($user_id == 1){//超级管理员
  51. $list = $this->model
  52. ->where($where)
  53. ->order($sort, $order)
  54. ->paginate($limit);
  55. }else{
  56. $userinfo = Db::name('admin')->where('id',$user_id)->find();
  57. $pidList = Db::name('company')->where('pid',$userinfo['company'])->select();
  58. $map = [];
  59. if (!empty($pidList)){//总公司
  60. $pid = [];
  61. foreach ($pidList as $key=>$value){
  62. $pid[$key] = $value['id'];
  63. }
  64. $map['work_unit'] = array('in',$pid);
  65. }else{//分公司
  66. $map['work_unit'] = $userinfo['company'];
  67. }
  68. $list = $this->model
  69. ->where($where)
  70. ->where($map)
  71. ->order($sort, $order)
  72. ->paginate($limit);
  73. }
  74. $result = ['total' => $list->total(), 'rows' => $list->items()];
  75. return json($result);
  76. }
  77. //检测数据查看
  78. public function data(){
  79. $params = input('id');
  80. if (empty($params)){
  81. $this->error('参数错误');
  82. }
  83. $entrust_id = Db::name('res')->where('id',$params)->value('entrust_id');
  84. $gather_id = Db::name('entrust')->where('id',$entrust_id)->find();
  85. if (empty($gather_id['gather_id'])){
  86. $this->error('此委托单还未提交检测,暂无检测数据');
  87. }
  88. //此处根据实际获取到的采集表的数据 gather_tab 去对应表里查数据 重新写一个gc表格页面 js加代码
  89. if ($gather_id['gather_tab'] == 'gather_txt_check_gcms'){
  90. $gather = Db::name('gather_txt_gcms')->where('id',$gather_id['gather_id'])->find();
  91. $data = Db::name('gather_txt_check_gcms')->where('pid',$gather_id['gather_id'])->select();
  92. $this->view->assign('gather', $gather);
  93. $this->view->assign('data', $data);
  94. $this->view->assign('id', $params);
  95. return $this->view->fetch();
  96. }else if ($gather_id['gather_tab'] == 'gather_txt_check_gc'){
  97. $gather = Db::name('gather_txt_gc')->where('id',$gather_id['gather_id'])->find();
  98. $data = Db::name('gather_txt_check_gc')->where('pid',$gather_id['gather_id'])->select();
  99. $this->view->assign('gather', $gather);
  100. $this->view->assign('data', $data);
  101. $this->view->assign('id', $params);
  102. return $this->fetch('datagc');
  103. }
  104. }
  105. //数据报告
  106. public function report(){
  107. $this->error('此功能暂未开发');
  108. }
  109. }