Wlps.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace app\admin\controller;
  3. use think\Db;
  4. class Wlps extends Auth
  5. {
  6. private $org_Id=103;
  7. public function index(){
  8. if(request()->isAjax()){
  9. //分页参数
  10. $length = input('rows',10,'intval'); //每页条数
  11. $page = input('page',1,'intval'); //第几页
  12. $start = ($page - 1) * $length; //分页开始位置
  13. //排序
  14. $sortRow = input('sidx','id','trim'); //排序列
  15. $sort = input('sord','desc','trim'); //排序方式
  16. $order = $sortRow.' '.$sort;
  17. $bh = input('bh','','trim');
  18. if($bh){
  19. $map[] = ['jjddjbh','=',$bh];
  20. }
  21. if ($this->orgId != $this->org_Id) {
  22. $map[] = ['order_id','=',-1];
  23. }
  24. $map= empty($map) ? true: $map;
  25. //数据查询
  26. // $lists = Db::connect('db_config_jili')->name('wlps')->where($map)->limit($start,$length)->order($order)->select();
  27. $lists = Db::name('wlps')->where($map)->limit($start,$length)->order($order)->select();
  28. //数据返回
  29. // $totalCount = Db::connect('db_config_jili')->name('wlps')->where($map)->count();
  30. $totalCount = Db::name('wlps')->where($map)->count();
  31. $totalPage = ceil($totalCount/$length);
  32. $result['page'] = $page;
  33. $result['total'] = $totalPage;
  34. $result['records'] = $totalCount;
  35. $result['rows'] = $lists;
  36. return json($result);
  37. }else{
  38. return $this->fetch();
  39. }
  40. }
  41. public function deal(){
  42. $id = input('id','','intval');
  43. // $info = Db::connect('db_config_jili')->name('wlps')->where('id',$id)->find();
  44. $info = Db::name('wlps')->where('id',$id)->find();
  45. if(!$info){
  46. $this->error('记录不存在');
  47. }
  48. if($info['is_deal'] != 2 || $info['is_qx'] != 'N'){
  49. $this->error('该状态无法执行此操作');
  50. }
  51. $ret = model('Wlps')->deal_wlps($info);
  52. if($ret){
  53. $this->success('操作成功');
  54. }else{
  55. $this->error('操作失败,'.model('Wlps')->getError());
  56. }
  57. }
  58. }