1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <?php
- namespace app\admin\controller\shop;
- use app\common\controller\Backend;
- /**
- * 区块表
- *
- * @icon fa fa-th-large
- */
- class Block extends Backend
- {
- /**
- * Block模型对象
- */
- protected $model = null;
- protected $noNeedRight = ['selectpage_type'];
- public function _initialize()
- {
- parent::_initialize();
- $this->model = new \app\admin\model\shop\Block;
- $this->view->assign("statusList", $this->model->getStatusList());
- }
- public function index()
- {
- $typeArr = \app\admin\model\shop\Block::distinct('type')->column('type');
- $this->view->assign('typeList', $typeArr);
- $this->assignconfig('typeList', $typeArr);
- return parent::index();
- }
- public function selectpage_type()
- {
- $list = [];
- $word = (array)$this->request->request("q_word/a");
- $field = $this->request->request('showField');
- $keyValue = $this->request->request('keyValue');
- if (!$keyValue) {
- if (array_filter($word)) {
- foreach ($word as $k => $v) {
- $list[] = ['id' => $v, $field => $v];
- }
- }
- $typeArr = \app\admin\model\shop\Block::column('type');
- $typeArr = array_unique($typeArr);
- foreach ($typeArr as $index => $item) {
- $list[] = ['id' => $item, $field => $item];
- }
- } else {
- $list[] = ['id' => $keyValue, $field => $keyValue];
- }
- return json(['total' => count($list), 'list' => $list]);
- }
- /**
- * 添加
- */
- public function add()
- {
- if ($this->request->isPost()) {
- $row = $this->request->post("row/a", []);
- if (isset($row['parsetpl']) && $row['parsetpl']) {
- $this->token();
- }
- }
- $values = [];
- $fields = [];
- $this->view->assign('fields', $fields);
- $this->view->assign('values', $values);
- return parent::add();
- }
- public function edit($ids = null)
- {
- if ($this->request->isPost()) {
- $row = $this->request->post("row/a", []);
- if (isset($row['parsetpl']) && $row['parsetpl']) {
- $this->token();
- }
- }
- $values = \app\admin\model\shop\Block::get($ids);
- if (!$values) {
- $this->error(__('No Results were found'));
- }
- $values = $values->toArray();
- $fields = [];
- $this->view->assign('fields', $fields);
- $this->view->assign('values', $values);
- return parent::edit($ids);
- }
- }
|