| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- namespace addons\SmartForm\backend\controllers;
- use Yii;
- use common\controllers\AddonsController;
- use common\enums\StatusEnum;
- use PHPUnit\Util\Exception;
- use addons\SmartForm\common\models\AddonsSmartFormComponents; # 装修表单组件
- /**
- * 组件控制器
- *
- * Class ComponentsController
- * @package addons\SmartForm\backend\controllers
- */
- class ComponentsController extends BaseController
- {
-
- /**
- * @method actionIndex
- * 组件列表
- * @author zqh
- * @datetime 2022-04-27T16:30:11+0800
- * @return [type] [description]
- */
- public function actionIndex()
- {
- $retuest = Yii::$app->request;
- if ($retuest->isAjax) {
- if ($retuest->isGet) {
- $get = Yii::$app->request->get();
- // 检查提交的参数
- $res = Yii::$app->services->validate->validate($get,[
- [['id','keyword'], 'safe'],
- [['limit'],'default','value' => '15'],
- ]);
- if($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- # 搜索条件
- $where = [];
- if($get['keyword']) $where[] = ['like', 'name', $get['keyword']];
- $where[] = ['>=', 'status', StatusEnum::DISABLED];
- # 排序
- $order = 'sort,created_at desc';
- # 显示字段
- $select = "id,code,title,group,icon,permission";
- $params = array('where' => $where, 'order'=>$order, 'select'=>$select, 'limit' => $get['limit']);
- # 分页返回
- $list = AddonsSmartFormComponents::listPage($params, false, true);
- $this->success('获取成功', $list);
- }
- } else {
- return $this->render($this->action->id,[
- ]);
- }
-
- }
- }
|