Hiddendanger.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. <?php
  2. namespace app\admin\controller;
  3. use app\common\model\Config;
  4. use think\App;
  5. use think\Db;
  6. use think\Exception;
  7. use think\Model;
  8. class Hiddendanger extends Auth
  9. {
  10. public function __construct(App $app = null) {
  11. parent::__construct($app);
  12. $this->model= new \app\common\model\Hiddendanger();
  13. $this->table = 'hiddendanger';
  14. }
  15. public function index(){
  16. if(request()->isAjax()){
  17. //分页参数
  18. $length = input('rows',10,'intval'); //每页条数
  19. $page = input('page',1,'intval'); //第几页
  20. $start = ($page - 1) * $length; //分页开始位置
  21. //排序
  22. $sortRow = input('sidx','id','trim'); //排序列
  23. $sort = input('sord','desc','trim'); //排序方式
  24. $order = $sortRow.' '.$sort;
  25. $content = input('content','','trim');
  26. if($content){
  27. $map[] = ['content','like','%'.$content.'%'];
  28. }
  29. $user = input('user','','trim');
  30. if($user != ''){
  31. $userIds = Db::name('user')->where('del',0)->where('real_name','like','%'.$user.'%')->column('id');
  32. $map[] = ['create_user_id','in',$userIds];
  33. }
  34. $st = input('start','','trim');
  35. if($st !=''){
  36. $map[] = ['create_time','>=',$st.' 00:00:00'];
  37. }
  38. $et = input('end','','trim');
  39. if($et !=''){
  40. $map[] = ['create_time','<=',$et.' 23:59:59'];
  41. }
  42. $map[] = ['del','=',0];
  43. $map[] = ['org_id','=',$this->orgId];
  44. $from = input('from', '', 'trim');
  45. if ($from!='') {
  46. if($from == 1){
  47. $map[] = ['order_id','>',0];
  48. $map[] = ['bus_type','<>',0];
  49. $map[] = ['to_from','=',0];
  50. }else{
  51. $map[] = ['order_id','>',0];
  52. $map[] = ['bus_type','<>',0];
  53. $map[] = ['to_from','<>',0];
  54. }
  55. }
  56. $map= empty($map) ? true: $map;
  57. //数据查询
  58. $lists = db($this->table)->where($map)
  59. ->limit($start,$length)->order($order)->select();
  60. foreach ($lists as $k=>$v){
  61. $lists[$k]['depName'] = Db::name('dep')
  62. ->where('id',$v['dep_id'])
  63. ->value('title');
  64. $lists[$k]['fromName'] = '';
  65. if($v['order_id'] > 0 && $v['bus_type'] != 0){
  66. if($v['to_from']){
  67. $lists[$k]['fromName'] = '一键呼叫';
  68. }else{
  69. $lists[$k]['fromName'] = '投诉';
  70. }
  71. }
  72. $lists[$k]['worktypemode'] = '';
  73. if($v['order_id'] > 0 && in_array($v['bus_type'],[0,1])){
  74. $worktype = Db::name('orders')
  75. ->alias('o')
  76. ->join('work_type_mode w','o.work_type_mode = w.id')
  77. ->where('o.id',$v['order_id'])
  78. ->value('w.name');
  79. $lists[$k]['worktypemode'] = $worktype?$worktype:'';
  80. }
  81. $lists[$k]['realName'] = Db::name('user')
  82. ->where('id',$v['create_user_id'])
  83. ->value('real_name');
  84. // $lists[$k]['statusTxt'] = $v['status']==1?'已处理':"未处理";
  85. $orderMode = 0;
  86. if($v['order_id'] > 0){
  87. $orderMode = Db::name('orders')->where('id',$v['order_id'])->value('order_mode');
  88. }
  89. $lists[$k]['statusTxt'] = model('Hiddendanger')->formatStatus($v['status'],$v['order_id'],$v['id']);
  90. $lists[$k]['order_mode'] = $orderMode;
  91. }
  92. //数据返回
  93. $totalCount = db($this->table)->where($map)->count();
  94. $totalPage = ceil($totalCount/$length);
  95. $result['page'] = $page;
  96. $result['total'] = $totalPage;
  97. $result['records'] = $totalCount;
  98. $result['rows'] = $lists;
  99. return json($result);
  100. }else{
  101. return $this->fetch('index');
  102. }
  103. }
  104. public function del($id=0){
  105. if(!$id){
  106. $this->error('参数错误');
  107. }
  108. $res = Db::name($this->table)
  109. ->where('id',$id)
  110. ->update([
  111. 'del'=>1,
  112. 'del_user_id'=>$this->userId,
  113. 'del_time'=>getTime(),
  114. ]);
  115. if(!$res){
  116. $this->error('删除失败');
  117. }
  118. $this->success('删除成功');
  119. }
  120. public function edit($id){
  121. if(request()->isGet()){
  122. $this->assign('id',$id);
  123. return $this->fetch();
  124. }else{
  125. $info = Db::name($this->table)
  126. ->where('id',$id)
  127. ->find();
  128. if(!$info){
  129. $this->error('记录不存在');
  130. }
  131. if($info['status'] == 1){
  132. $this->error('该记录已处理');
  133. }
  134. $curRoles = Db::name('user_roles')
  135. ->where('user_id',$this->userId)
  136. ->value('roles_id');
  137. $data = array(
  138. 'curr_roles_id' => $curRoles,
  139. 'note' => input('note',TRUE),
  140. 'status' => 1,
  141. 'update_time' => date('Y-m-d H:i:s'),
  142. 'hand_user_id' => $this->userId
  143. );
  144. $res =Db::name($this->table)
  145. ->where(array('id'=>$id))
  146. ->update($data);
  147. $res?$this->success('处理成功'):$this->error('处理失败');
  148. }
  149. }
  150. public function detail($id){
  151. $info = Db::name($this->table)
  152. ->where('id',$id)
  153. ->find();
  154. $info['depName'] = Db::name('dep')
  155. ->where('id',$info['dep_id'])
  156. ->value('title');
  157. $info['realName'] = Db::name('user')
  158. ->where('id',$info['create_user_id'])
  159. ->value('real_name');;
  160. // $info['statusTxt'] = $info['status']==1?'已处理':"未处理";
  161. $info['images'] = !empty($info['images'])?explode(',',$info['images']):'';
  162. $orderMode = 0;
  163. if($info['order_id'] > 0){
  164. $orderMode = Db::name('orders')->where('id',$info['order_id'])->value('order_mode');
  165. }
  166. $info['statusTxt'] = model('Hiddendanger')->formatStatus($info['status'],$info['order_id'],$info['id']);
  167. $info['order_mode'] = $orderMode;
  168. $this->assign('info',$info);
  169. return $this->fetch();
  170. }
  171. public function yhDetail($id){
  172. $info = Db::name($this->table)
  173. ->where('id',$id)
  174. ->find();
  175. $info['depName'] = Db::name('dep')
  176. ->where('id',$info['dep_id'])
  177. ->value('title');
  178. $info['realName'] = Db::name('user')
  179. ->where('id',$info['create_user_id'])
  180. ->value('real_name');;
  181. // $info['statusTxt'] = $info['status']==1?'已处理':"未处理";
  182. $info['images'] = !empty($info['images'])?explode(',',$info['images']):'';
  183. $orderMode = 0;
  184. if($info['order_id'] > 0){
  185. $orderMode = Db::name('orders')->where('id',$info['order_id'])->value('order_mode');
  186. }
  187. $info['statusTxt'] = model('Hiddendanger')->formatStatus($info['status'],$info['order_id'],$info['id']);
  188. $info['order_mode'] = $orderMode;
  189. $this->assign('info',$info);
  190. return $this->fetch();
  191. }
  192. //派单
  193. public function send($id) {
  194. if (request()->isGet()) {
  195. $this->assign('id', $id);
  196. $hiddendanger = Db::name($this->table)->where('id',$id)->find();
  197. $this->assign('hiddendanger',$hiddendanger);
  198. $order_type = (new \app\common\model\OrderType())->getList();
  199. $address = (new \app\common\model\Address())->getListByType(1);
  200. $this->assign('order_type_list', $order_type);
  201. $this->assign('address_list', $address);
  202. $order_repair = Db::name('order_repair')
  203. ->where('order_id', $id)
  204. ->find();
  205. $this->assign('order_repair', $order_repair);
  206. $workType = Db::name('work_type_mode')
  207. ->where('type',1)
  208. ->select();
  209. $config = Db::name('config')
  210. ->where('name','web_order_transfer_type')
  211. ->value('value');
  212. if(empty($config)){
  213. $workType = [];
  214. }else{
  215. $ll = explode('|',$config);
  216. foreach ($workType as $kk=>$vv){
  217. if(!in_array($vv['id'],$ll)){
  218. unset($workType[$kk]);
  219. }
  220. }
  221. }
  222. foreach ($workType as $k=>$v){
  223. $this->assign('send_user_num'.$v['id'], model('Orders')->sendUserNum($v['id'], $this->orgId));
  224. $this->assign('user_list'.$v['id'], (new \app\common\model\WorkTypeMode())->getRolesUserByNum($v['id'], $this->orgId, 1));
  225. $two_dispatch_roles = model('user')->get_two_dispatch_role($this->orgId, $v['id']);
  226. $this->assign('dispatch_roles'.$v['id'], $two_dispatch_roles);
  227. }
  228. $this->assign('dispatch_type', check_two_dispatch($this->userId));
  229. $this->assign('two_dispatch_off', two_dispatch_off($this->orgId));
  230. $this->assign('workType', $workType);
  231. $address = (new \app\common\model\Address())->getListByType(2);
  232. $conveyCate = (new \app\common\model\ConveyCate());
  233. $priority = $conveyCate->priority;
  234. $order_convey = $conveyCate->getList();
  235. $order_device = (new \app\common\model\ConveyDevice())->getList();
  236. $this->assign('address', $address);
  237. $this->assign('priority', $priority);
  238. $this->assign('order_convey_type', $order_convey);
  239. $this->assign('order_device', $order_device);
  240. $oCid = Db::name('order_convey')
  241. ->where('order_id',-1)
  242. ->find();
  243. $opt = Db::name('order_convey_patient')
  244. ->where('order_id',-1)
  245. ->find();
  246. $this->assign('ocid',$oCid);
  247. $this->assign('opt',$opt);
  248. $this->assign('ps',empty($opt)?1:0);
  249. $auths = [1,2,3,4,15,0];
  250. if(!is_admin($this->userId)){
  251. $auth = get_dispatch_auth($this->userId);
  252. if($auth){
  253. $auths = array_intersect($auths,$auth);
  254. }else{
  255. $auths = [];
  256. }
  257. }
  258. $this->assign('auths',$auths);
  259. return $this->fetch();
  260. }
  261. else {
  262. $data = request()->post();
  263. $data['org_id'] = $this->orgId;
  264. $res = model('Hiddendanger')->send($id, $this->userId, $data);
  265. if (!$res) {
  266. $this->error(model('Hiddendanger')->getError());
  267. }
  268. $this->success('操作成功');
  269. }
  270. }
  271. //转单
  272. public function ts_send($id) {
  273. if (request()->isGet()) {
  274. $this->assign('id', $id);
  275. $hiddendanger = Db::name($this->table)->where('id',$id)->find();
  276. $this->assign('hiddendanger',$hiddendanger);
  277. $order_type = (new \app\common\model\OrderType())->getList();
  278. $address = (new \app\common\model\Address())->getListByType(1);
  279. $this->assign('order_type_list', $order_type);
  280. $this->assign('address_list', $address);
  281. $order_repair = Db::name('order_repair')
  282. ->where('order_id', $id)
  283. ->find();
  284. $this->assign('order_repair', $order_repair);
  285. $workType = Db::name('work_type_mode')
  286. ->where('type',1)
  287. ->select();
  288. $config = Db::name('config')
  289. ->where('name','web_order_transfer_type')
  290. ->value('value');
  291. if(empty($config)){
  292. $workType = [];
  293. }else{
  294. $ll = explode('|',$config);
  295. foreach ($workType as $kk=>$vv){
  296. if(!in_array($vv['id'],$ll)){
  297. unset($workType[$kk]);
  298. }
  299. }
  300. }
  301. foreach ($workType as $k=>$v){
  302. $this->assign('send_user_num'.$v['id'], model('Orders')->sendUserNum($v['id'], $this->orgId));
  303. $this->assign('user_list'.$v['id'], (new \app\common\model\WorkTypeMode())->getRolesUserByNum($v['id'], $this->orgId, 1));
  304. $two_dispatch_roles = model('user')->get_two_dispatch_role($this->orgId, $v['id']);
  305. $this->assign('dispatch_roles'.$v['id'], $two_dispatch_roles);
  306. }
  307. foreach ($workType as $k=>$v){
  308. if($v['id']!==0){
  309. unset($workType[$k]);
  310. }
  311. }
  312. $this->assign('dispatch_type', check_two_dispatch($this->userId));
  313. $this->assign('two_dispatch_off', two_dispatch_off($this->orgId));
  314. $this->assign('workType', $workType);
  315. $address = (new \app\common\model\Address())->getListByType(2);
  316. $conveyCate = (new \app\common\model\ConveyCate());
  317. $priority = $conveyCate->priority;
  318. $order_convey = $conveyCate->getList();
  319. $order_device = (new \app\common\model\ConveyDevice())->getList();
  320. $this->assign('address', $address);
  321. $this->assign('priority', $priority);
  322. $this->assign('order_convey_type', $order_convey);
  323. $this->assign('order_device', $order_device);
  324. $oCid = Db::name('order_convey')
  325. ->where('order_id',-1)
  326. ->find();
  327. $opt = Db::name('order_convey_patient')
  328. ->where('order_id',-1)
  329. ->find();
  330. $this->assign('ocid',$oCid);
  331. $this->assign('opt',$opt);
  332. $this->assign('ps',empty($opt)?1:0);
  333. $auths = [1,2,3,4,15,0];
  334. if(!is_admin($this->userId)){
  335. $auth = get_dispatch_auth($this->userId);
  336. if($auth){
  337. $auths = array_intersect($auths,$auth);
  338. }else{
  339. $auths = [];
  340. }
  341. }
  342. $this->assign('auths',$auths);
  343. return $this->fetch();
  344. }
  345. else {
  346. $data = request()->post();
  347. $data['org_id'] = $this->orgId;
  348. $res = model('Hiddendanger')->zd_send($id, $data,$this->userId);
  349. if (!$res) {
  350. $this->error(model('Hiddendanger')->getError());
  351. }
  352. $this->success('操作成功');
  353. }
  354. }
  355. public function summary($id){
  356. if(request()->isGet()){
  357. $info = Db::name('hiddendanger')
  358. ->where('id',$id)
  359. ->find();
  360. $this->assign('info',$info);
  361. $this->assign('id',$id);
  362. return $this->fetch();
  363. }else{
  364. $data = array(
  365. 'summary' => input('summary','','trim'),
  366. 'update_time' => date('Y-m-d H:i:s'),
  367. );
  368. $res =Db::name($this->table)
  369. ->where(array('id'=>$id))
  370. ->update($data);
  371. $res?$this->success('操作成功'):$this->error('操作失败');
  372. }
  373. }
  374. public function export(){
  375. $meta_title = '隐患订单';
  376. if (request()->isGet()) {
  377. $content = input('content','','trim');
  378. if($content){
  379. $map[] = ['content','like','%'.$content.'%'];
  380. }
  381. $user = input('user','','trim');
  382. if($user != ''){
  383. $userIds = Db::name('user')->where('del',0)->where('real_name','like','%'.$user.'%')->column('id');
  384. $map[] = ['create_user_id','in',$userIds];
  385. }
  386. $st = input('start','','trim');
  387. if($st !=''){
  388. $map[] = ['create_time','>=',$st.' 00:00:00'];
  389. }
  390. $et = input('end','','trim');
  391. if($et !=''){
  392. $map[] = ['create_time','<=',$et.' 23:59:59'];
  393. }
  394. $map[] = ['del','=',0];
  395. $map[] = ['org_id','=',$this->orgId];
  396. $from = input('from', '', 'trim');
  397. if ($from!='') {
  398. if($from == 1){
  399. $map[] = ['order_id','>',0];
  400. $map[] = ['bus_type','<>',0];
  401. $map[] = ['to_from','=',0];
  402. }else{
  403. $map[] = ['order_id','>',0];
  404. $map[] = ['bus_type','<>',0];
  405. $map[] = ['to_from','<>',0];
  406. }
  407. }
  408. $map= empty($map) ? true: $map;
  409. //数据查询
  410. $lists = db($this->table)->where($map)
  411. ->order('id','desc')->select();
  412. foreach ($lists as $k=>$v){
  413. $lists[$k]['depName'] = Db::name('dep')
  414. ->where('id',$v['dep_id'])
  415. ->value('title');
  416. // $lists[$k]['fromName'] =$this->model->from[$v['from']];
  417. $lists[$k]['fromName'] = '';
  418. if($v['order_id'] > 0 && $v['bus_type'] != 0){
  419. if($v['to_from']){
  420. $lists[$k]['fromName'] = '一键呼叫';
  421. }else{
  422. $lists[$k]['fromName'] = '投诉';
  423. }
  424. }
  425. $lists[$k]['realName'] = Db::name('user')
  426. ->where('id',$v['create_user_id'])
  427. ->value('real_name');
  428. // $lists[$k]['statusTxt'] = $v['status']==1?'已处理':"未处理";
  429. $orderMode = 0;
  430. if($v['order_id'] > 0){
  431. $orderMode = Db::name('orders')->where('id',$v['order_id'])->value('order_mode');
  432. }
  433. $lists[$k]['statusTxt'] = model('Hiddendanger')->formatStatus($v['status'],$v['order_id'],$v['id']);
  434. $lists[$k]['order_mode'] = $orderMode;
  435. }
  436. include_once env('root_path').'/extend/phpexcel/Classes/PHPExcel.php';
  437. //实例化PHPExcel类
  438. $objPHPExcel = new \PHPExcel();
  439. //激活当前的sheet表
  440. $objPHPExcel->setActiveSheetIndex(0);
  441. //设置表格头(即excel表格的第一行)
  442. $objPHPExcel->setActiveSheetIndex(0)
  443. ->setCellValue('A1', '编号')
  444. ->setCellValue('B1', '时间')
  445. ->setCellValue('C1', '内容')
  446. ->setCellValue('D1', '部门')
  447. ->setCellValue('E1', '用户')
  448. ->setCellValue('F1', '状态')
  449. ->setCellValue('G1', '来源')
  450. ->setCellValue('H1', '去向');
  451. // 设置表格头水平居中
  452. $objPHPExcel->setActiveSheetIndex(0)->getStyle('A1')->getAlignment()
  453. ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  454. $objPHPExcel->setActiveSheetIndex(0)->getStyle('B1')->getAlignment()
  455. ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  456. $objPHPExcel->setActiveSheetIndex(0)->getStyle('C1')->getAlignment()
  457. ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  458. $objPHPExcel->setActiveSheetIndex(0)->getStyle('D1')->getAlignment()
  459. ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  460. $objPHPExcel->setActiveSheetIndex(0)->getStyle('E1')->getAlignment()
  461. ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  462. $objPHPExcel->setActiveSheetIndex(0)->getStyle('F1')->getAlignment()
  463. ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  464. $objPHPExcel->setActiveSheetIndex(0)->getStyle('G1')->getAlignment()
  465. ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  466. $objPHPExcel->setActiveSheetIndex(0)->getStyle('H1')->getAlignment()
  467. ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  468. //设置列水平居中
  469. $objPHPExcel->setActiveSheetIndex(0)->getStyle('A')->getAlignment()
  470. ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  471. $objPHPExcel->setActiveSheetIndex(0)->getStyle('B')->getAlignment()
  472. ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  473. $objPHPExcel->setActiveSheetIndex(0)->getStyle('C')->getAlignment()
  474. ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  475. $objPHPExcel->setActiveSheetIndex(0)->getStyle('D')->getAlignment()
  476. ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  477. $objPHPExcel->setActiveSheetIndex(0)->getStyle('E')->getAlignment()
  478. ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  479. $objPHPExcel->setActiveSheetIndex(0)->getStyle('F')->getAlignment()
  480. ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  481. $objPHPExcel->setActiveSheetIndex(0)->getStyle('G')->getAlignment()
  482. ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  483. $objPHPExcel->setActiveSheetIndex(0)->getStyle('H')->getAlignment()
  484. ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  485. //设置单元格宽度
  486. $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('A')->setWidth(20);
  487. $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('B')->setWidth(20);
  488. $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('C')->setWidth(20);
  489. $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('D')->setWidth(20);
  490. $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('E')->setWidth(20);
  491. $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('F')->setWidth(20);
  492. $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('G')->setWidth(20);
  493. $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('H')->setWidth(20);
  494. //循环刚取出来的数组,将数据逐一添加到excel表格。
  495. for ($i = 0; $i < count($lists); $i++) {
  496. $objPHPExcel->getActiveSheet()->setCellValue('A' . ($i + 2), $lists[$i]['id']);
  497. $objPHPExcel->getActiveSheet()->setCellValue('B' . ($i + 2), $lists[$i]['create_time']);
  498. $objPHPExcel->getActiveSheet()->setCellValue('C' . ($i + 2), $lists[$i]['content']);
  499. $objPHPExcel->getActiveSheet()->setCellValue('D' . ($i + 2), $lists[$i]['depName']);
  500. $objPHPExcel->getActiveSheet()->setCellValue('E' . ($i + 2), $lists[$i]['realName']);
  501. $objPHPExcel->getActiveSheet()->setCellValue('F' . ($i + 2), $lists[$i]['statusTxt']);
  502. if($lists[$i]['from'] > 0){
  503. $objPHPExcel->getActiveSheet()->setCellValue('G' . ($i + 2), '隐患');
  504. }else{
  505. $objPHPExcel->getActiveSheet()->setCellValue('G' . ($i + 2), '');
  506. }
  507. $objPHPExcel->getActiveSheet()->setCellValue('H' . ($i + 2), $lists[$i]['fromName']);
  508. }
  509. //设置保存的Excel表格名称
  510. $filename = $meta_title.'_' . date('YmdHis', time()) . '.xls';
  511. //设置当前激活的sheet表格名称
  512. $objPHPExcel->getActiveSheet()->setTitle($meta_title);
  513. //设置浏览器窗口下载表格
  514. ob_end_clean();
  515. header("Content-Type: application/force-download");
  516. header("Content-Type: application/octet-stream");
  517. header("Content-Type: application/download");
  518. header('Content-Disposition:inline;filename="' . $filename);
  519. //生成excel文件
  520. $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
  521. //下载文件在浏览器窗口
  522. return $objWriter->save('php://output');
  523. }
  524. }
  525. }