Maplocation.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. namespace app\admin\controller\cwmap;
  3. use app\common\controller\Backend;
  4. /**
  5. * 地图位置管理
  6. *
  7. * @icon fa fa-circle-o
  8. */
  9. class Maplocation extends Backend
  10. {
  11. /**
  12. * Maplocation模型对象
  13. * @var \app\admin\model\Maplocation
  14. */
  15. protected $searchFields = 'id,locationname,detailaddress,phone,email,province,fax,qq,website';//默认搜索字段
  16. protected $model = null;
  17. public function _initialize()
  18. {
  19. parent::_initialize();
  20. $this->model = new \app\admin\model\Maplocation;
  21. }
  22. /**
  23. * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  24. * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  25. * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  26. */
  27. public function import(){
  28. return parent::import();
  29. }
  30. /**
  31. * 查看
  32. */
  33. public function index()
  34. {
  35. //当前是否为关联查询
  36. $this->relationSearch = false;
  37. //设置过滤方法
  38. $this->request->filter(['strip_tags']);
  39. if ($this->request->isAjax())
  40. {
  41. //如果发送的来源是Selectpage,则转发到Selectpage
  42. if ($this->request->request('keyField'))
  43. {
  44. return $this->selectpage();
  45. }
  46. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  47. $total = $this->model
  48. ->where($where)
  49. ->order($sort, $order)
  50. ->count();
  51. $list = $this->model
  52. ->where($where)
  53. ->order($sort, $order)
  54. ->limit($offset, $limit)
  55. ->select();
  56. foreach ($list as $row) {
  57. $row->visible(['id','locationname','longitude','latitude','detailaddress','phone','email','fax','qq','website','province','picture','updatetime']);
  58. }
  59. $list = collection($list)->toArray();
  60. $result = array("total" => $total, "rows" => $list);
  61. return json($result);
  62. }
  63. return $this->view->fetch();
  64. }
  65. /**
  66. * 查找地图
  67. */
  68. public function map()
  69. {
  70. return $this->view->fetch();
  71. }
  72. /**
  73. * 搜索列表
  74. */
  75. public function selectpage()
  76. {
  77. // return parent::selectpage();
  78. }
  79. }