123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- <?php
- namespace app\modules\admin\models;
- use Yii;
- /**
- * This is the model class for table "{{%resource}}".
- *
- * @property string $hash 当前资源HASH
- * @property string $parent_hash 父级资源HASH
- * @property string $name 资源名称
- * @property string $icon_class 图标样式
- * @property string $btn_class 按钮样式
- * @property string $block 菜单所属板块
- * @property string $module 模块名称
- * @property string $controller 控制器名称
- * @property string $action 方法名称
- * @property string $data 附加参数,如type=1
- * @property string $url 外链
- * @property int $menu_type 作为菜单 1:左侧菜单 2:内页菜单 3:内页动作 4:底部菜单 5:隐藏菜单
- * @property int $pop_large 弹出大框
- * @property string $show_function 显示该菜单时,先用此方法判断
- * @property string $name_function 初始化资源名称
- * @property string|null $title_field 如果存在该值,弹窗标题显示该值
- * @property int $list_order 序号
- * @property int $is_system 系统菜单
- * @property int $disabled 状态 0:启用 1:禁用
- */
- class Resource extends \app\common\models\EActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%resource}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['hash', 'name'], 'required'],
- [['block'], 'string'],
- [['menu_type', 'pop_large', 'list_order', 'is_system', 'disabled'], 'integer'],
- [['hash', 'parent_hash'], 'string', 'max' => 32],
- [['name', 'module', 'controller', 'action'], 'string', 'max' => 50],
- [['icon_class', 'btn_class', 'data', 'url', 'title_field'], 'string', 'max' => 255],
- [['show_function', 'name_function'], 'string', 'max' => 1000],
- [['hash'], 'unique'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'hash' => Yii::t('attr','resource.hash'),
- 'parent_hash' => Yii::t('attr','resource.parent_hash'),
- 'name' => Yii::t('attr','resource.name'),
- 'icon_class' => Yii::t('attr','resource.icon_class'),
- 'btn_class' => Yii::t('attr','resource.btn_class'),
- 'block' => Yii::t('attr','resource.block'),
- 'module' => Yii::t('attr','resource.module'),
- 'controller' => Yii::t('attr','resource.controller'),
- 'action' => Yii::t('attr','resource.action'),
- 'data' => Yii::t('attr','resource.data'),
- 'url' => Yii::t('attr','resource.url'),
- 'menu_type' => Yii::t('attr','resource.menu_type'),
- 'pop_large' => Yii::t('attr','resource.pop_large'),
- 'show_function' => Yii::t('attr','resource.show_function'),
- 'name_function' => Yii::t('attr','resource.name_function'),
- 'title_field' => Yii::t('attr','resource.title_field'),
- 'list_order' => Yii::t('attr','resource.list_order'),
- 'is_system' => Yii::t('attr','resource.is_system'),
- 'disabled' => Yii::t('attr','resource.disabled'),
- ];
- }
- //菜单类型
- public static function menutypeOptions($k=0)
- {
- $options = array(
- '1'=>'左侧菜单',
- '2'=>'表头菜单(跳转)',
- '3'=>'表头菜单(批量操作)',
- '4'=>'表头菜单(批量删除)',
- '5'=>'表头菜单(弹框带按钮)',
- '6'=>'表头菜单(弹框不带按钮)',
- '7'=>'表头菜单(弹框全屏带按钮)',
- '8'=>'表头菜单(弹框全屏不带按钮)',
- '9'=>'表头菜单(AJAX请求)',
- '10'=>'表头菜单(刷新)',
- '11'=>'记录操作(弹框带按钮)',
- '12'=>'记录操作(弹框不带按钮)',
- '13'=>'记录操作(弹框全屏带按钮)',
- '14'=>'记录操作(弹框全屏不带按钮)',
- '15'=>'记录操作(删除)',
- '16'=>'记录操作(跳转)',
- '17'=>'记录操作(AJAX请求)',
- '18'=>'隐藏操作',
- );
- if($k)
- {
- return $options[$k];
- }
- return $options;
- }
- }
|