Block.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace app\admin\controller\blog;
  3. use app\common\controller\Backend;
  4. /**
  5. * 区块表
  6. *
  7. * @icon fa fa-th-large
  8. */
  9. class Block extends Backend
  10. {
  11. /**
  12. * Block模型对象
  13. */
  14. protected $model = null;
  15. protected $noNeedRight = ['selectpage_type'];
  16. public function _initialize()
  17. {
  18. parent::_initialize();
  19. $this->model = new \app\admin\model\BlogBlock;
  20. $this->view->assign("statusList", $this->model->getStatusList());
  21. }
  22. public function index()
  23. {
  24. $typeArr = \app\admin\model\BlogBlock::distinct('type')->column('type');
  25. $this->view->assign('typeList', $typeArr);
  26. $this->assignconfig('typeList', $typeArr);
  27. return parent::index();
  28. }
  29. public function selectpage_type()
  30. {
  31. $list = [];
  32. $word = (array)$this->request->request("q_word/a");
  33. $field = $this->request->request('showField');
  34. $keyValue = $this->request->request('keyValue');
  35. if (!$keyValue) {
  36. if (array_filter($word)) {
  37. foreach ($word as $k => $v) {
  38. $list[] = ['id' => $v, $field => $v];
  39. }
  40. }
  41. $typeArr = \app\admin\model\BlogBlock::column('type');
  42. $typeArr = array_unique($typeArr);
  43. foreach ($typeArr as $index => $item) {
  44. $list[] = ['id' => $item, $field => $item];
  45. }
  46. } else {
  47. $list[] = ['id' => $keyValue, $field => $keyValue];
  48. }
  49. return json(['total' => count($list), 'list' => $list]);
  50. }
  51. public function import()
  52. {
  53. return parent::import();
  54. }
  55. }