You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.5 KiB
64 lines
1.5 KiB
<?php
|
|
|
|
namespace app\admin\controller\project;
|
|
|
|
use app\common\controller\Backend;
|
|
|
|
/**
|
|
* 省市区数据
|
|
*
|
|
* @icon fa fa-circle-o
|
|
*/
|
|
class Area extends Backend
|
|
{
|
|
|
|
/**
|
|
* Area模型对象
|
|
* @var \app\admin\model\project\Area
|
|
*/
|
|
protected $model = null;
|
|
|
|
public function _initialize()
|
|
{
|
|
parent::_initialize();
|
|
$this->model = new \app\admin\model\project\Area;
|
|
$this->view->assign("dispList", $this->model->getDispList());
|
|
}
|
|
|
|
public function add()
|
|
{
|
|
if ($this->request->isPost()) {
|
|
$id = $this->request->post('row.id');
|
|
$res = $this->model->get($id);
|
|
if ($res) {
|
|
$res->disp = 1;
|
|
$res->save();
|
|
$this->success();
|
|
}
|
|
}
|
|
return parent::add();
|
|
}
|
|
|
|
|
|
public function index()
|
|
{
|
|
//设置过滤方法
|
|
$this->request->filter(['strip_tags', 'trim']);
|
|
if (false === $this->request->isAjax()) {
|
|
return $this->view->fetch();
|
|
}
|
|
//如果发送的来源是 Selectpage,则转发到 Selectpage
|
|
if ($this->request->request('keyField')) {
|
|
return $this->selectpage();
|
|
}
|
|
[$where, $sort, $order, $offset, $limit] = $this->buildparams();
|
|
$list = $this->model
|
|
->where($where)
|
|
->where('level', 2)
|
|
->order('disp', 'desc')
|
|
->paginate($limit);
|
|
$result = ['total' => $list->total(), 'rows' => $list->items()];
|
|
return json($result);
|
|
}
|
|
|
|
}
|
|
|