Resource.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. namespace app\modules\admin\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "{{%resource}}".
  6. *
  7. * @property string $hash 当前资源HASH
  8. * @property string $parent_hash 父级资源HASH
  9. * @property string $name 资源名称
  10. * @property string $icon_class 图标样式
  11. * @property string $btn_class 按钮样式
  12. * @property string $block 菜单所属板块
  13. * @property string $module 模块名称
  14. * @property string $controller 控制器名称
  15. * @property string $action 方法名称
  16. * @property string $data 附加参数,如type=1
  17. * @property string $url 外链
  18. * @property int $menu_type 作为菜单 1:左侧菜单 2:内页菜单 3:内页动作 4:底部菜单 5:隐藏菜单
  19. * @property int $pop_large 弹出大框
  20. * @property string $show_function 显示该菜单时,先用此方法判断
  21. * @property string $name_function 初始化资源名称
  22. * @property string|null $title_field 如果存在该值,弹窗标题显示该值
  23. * @property int $list_order 序号
  24. * @property int $is_system 系统菜单
  25. * @property int $disabled 状态 0:启用 1:禁用
  26. */
  27. class Resource extends \app\common\models\EActiveRecord
  28. {
  29. /**
  30. * {@inheritdoc}
  31. */
  32. public static function tableName()
  33. {
  34. return '{{%resource}}';
  35. }
  36. /**
  37. * {@inheritdoc}
  38. */
  39. public function rules()
  40. {
  41. return [
  42. [['hash', 'name'], 'required'],
  43. [['block'], 'string'],
  44. [['menu_type', 'pop_large', 'list_order', 'is_system', 'disabled'], 'integer'],
  45. [['hash', 'parent_hash'], 'string', 'max' => 32],
  46. [['name', 'module', 'controller', 'action'], 'string', 'max' => 50],
  47. [['icon_class', 'btn_class', 'data', 'url', 'title_field'], 'string', 'max' => 255],
  48. [['show_function', 'name_function'], 'string', 'max' => 1000],
  49. [['hash'], 'unique'],
  50. ];
  51. }
  52. /**
  53. * {@inheritdoc}
  54. */
  55. public function attributeLabels()
  56. {
  57. return [
  58. 'hash' => Yii::t('attr','resource.hash'),
  59. 'parent_hash' => Yii::t('attr','resource.parent_hash'),
  60. 'name' => Yii::t('attr','resource.name'),
  61. 'icon_class' => Yii::t('attr','resource.icon_class'),
  62. 'btn_class' => Yii::t('attr','resource.btn_class'),
  63. 'block' => Yii::t('attr','resource.block'),
  64. 'module' => Yii::t('attr','resource.module'),
  65. 'controller' => Yii::t('attr','resource.controller'),
  66. 'action' => Yii::t('attr','resource.action'),
  67. 'data' => Yii::t('attr','resource.data'),
  68. 'url' => Yii::t('attr','resource.url'),
  69. 'menu_type' => Yii::t('attr','resource.menu_type'),
  70. 'pop_large' => Yii::t('attr','resource.pop_large'),
  71. 'show_function' => Yii::t('attr','resource.show_function'),
  72. 'name_function' => Yii::t('attr','resource.name_function'),
  73. 'title_field' => Yii::t('attr','resource.title_field'),
  74. 'list_order' => Yii::t('attr','resource.list_order'),
  75. 'is_system' => Yii::t('attr','resource.is_system'),
  76. 'disabled' => Yii::t('attr','resource.disabled'),
  77. ];
  78. }
  79. //菜单类型
  80. public static function menutypeOptions($k=0)
  81. {
  82. $options = array(
  83. '1'=>'左侧菜单',
  84. '2'=>'表头菜单(跳转)',
  85. '3'=>'表头菜单(批量操作)',
  86. '4'=>'表头菜单(批量删除)',
  87. '5'=>'表头菜单(弹框带按钮)',
  88. '6'=>'表头菜单(弹框不带按钮)',
  89. '7'=>'表头菜单(弹框全屏带按钮)',
  90. '8'=>'表头菜单(弹框全屏不带按钮)',
  91. '9'=>'表头菜单(AJAX请求)',
  92. '10'=>'表头菜单(刷新)',
  93. '11'=>'记录操作(弹框带按钮)',
  94. '12'=>'记录操作(弹框不带按钮)',
  95. '13'=>'记录操作(弹框全屏带按钮)',
  96. '14'=>'记录操作(弹框全屏不带按钮)',
  97. '15'=>'记录操作(删除)',
  98. '16'=>'记录操作(跳转)',
  99. '17'=>'记录操作(AJAX请求)',
  100. '18'=>'隐藏操作',
  101. );
  102. if($k)
  103. {
  104. return $options[$k];
  105. }
  106. return $options;
  107. }
  108. }