Remotereport.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace app\manage\controller;
  3. use think\Controller;
  4. use think\Db;
  5. use think\Session;
  6. use think\Config;
  7. use think\Cookie;
  8. use think\Request;
  9. use app\common\library\SysLogs;
  10. use app\common\library\UUIDs;
  11. class Remotereport extends Base {
  12. public function index() {
  13. return $this->fetch();
  14. }
  15. public function datas() {
  16. $page = empty($_GET["page"]) ? 1 : $_GET["page"];
  17. $pagesize = empty($_GET["rows"]) ? 1 : $_GET["rows"];
  18. if (empty($page) || $page < 1) {
  19. $page = 1;
  20. }
  21. if (empty($pagesize) || $pagesize < 1) {
  22. $pagesize = 30;
  23. }
  24. $info = DB::table('remotereport')->page($page, $pagesize)->select();
  25. $num = DB::table('remotereport')->count();
  26. $data = array();
  27. $data['total'] = $num;
  28. $data['rows'] = $info;
  29. echo json_encode($data);
  30. }
  31. /**
  32. * 编辑窗口
  33. * @return type
  34. */
  35. public function edit() {
  36. if (isset($_GET["id"])) {
  37. $id = $_GET["id"];
  38. if ($id != null) {
  39. $remotereport = Db::table("remotereport")->where("id", $id)->find();
  40. if (count($remotereport) > 0) {
  41. $this->assign("remotereport", $remotereport);
  42. }
  43. }
  44. }
  45. return $this->fetch('edit');
  46. }
  47. public function save() {
  48. $a = DB::table('remotereport')->where('id', $_GET['id'])->update($_GET);
  49. SysLogs::log("remotereport", "U", 'id = ' . $_GET['id'] . " --> " . json_encode($_GET));
  50. if ($a) {
  51. return 'success';
  52. } else {
  53. return 'fail';
  54. }
  55. }
  56. /**
  57. * 软删除记录
  58. */
  59. public function delete() {
  60. if (isset($_GET["ids"])) {
  61. $ids = $_GET["ids"];
  62. if (!empty($ids)) {
  63. $idArr = explode(",", $ids);
  64. if (count($idArr) > 0) {
  65. Db::table("remotereport")->where("id", "in", $idArr)->update(['status' => 1]);
  66. SysLogs::log("remotereport", "U", 'id in ' . $ids . " --> status = 0");
  67. }
  68. echo "delete_ok";
  69. return;
  70. }
  71. }
  72. echo "fail";
  73. }
  74. }