rabin 3 rokov pred
rodič
commit
a8a847bc70
3 zmenil súbory, kde vykonal 65 pridanie a 2 odobranie
  1. 42 0
      database/company.php
  2. 13 0
      database/menu_group.php
  3. 10 2
      src/Menu.php

+ 42 - 0
database/company.php

@@ -2,6 +2,22 @@
 
 # 常用的col
 $col = '*';
+
+$is_project = array
+(
+    1 => '全部可用',
+    2 => '部分可用',
+);
+$project = function()
+{
+    $array = array();
+    $data = Dever::db('manage/menu_group')->state();
+    if($data)
+    {
+        $array += $data;
+    }
+    return $array;
+};
 return array
 (
     # 表名
@@ -39,6 +55,32 @@ return array
             'list'      => true,
             'search'    => 'fulltext',
         ),
+
+        'is_project'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '项目可用状态',
+            'default'   => '1',
+            'desc'      => '项目可用状态',
+            'match'     => 'is_numeric',
+            'option'    => $is_project,
+            'update'    => 'radio',
+            'list'      => true,
+            'control'   => 'is_project',
+        ),
+
+        'project'        => array
+        (
+            'type'      => 'varchar-2000',
+            'name'      => '可用项目',
+            'default'   => '',
+            'desc'      => '选择项目',
+            'match'     => 'is_string',
+            'option'    => $project,
+            'update'    => 'checkbox',
+            'show'      => 'is_project=2',
+            //'list'      => true,
+        ),
         
         'state'     => array
         (

+ 13 - 0
database/menu_group.php

@@ -126,5 +126,18 @@ return array
 			'order' => array('reorder' => 'desc', 'id' => 'asc'),
 			'col' => 'id,id as value, name',
 		),
+
+		'getIds' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'ids' => array('yes-id', 'in'),
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 'id' => 'desc'),
+			'col' => '*|id',
+		),
 	),
 );

+ 10 - 2
src/Menu.php

@@ -636,8 +636,16 @@ class Menu
 
     private function getGroup()
     {
+        $company_id = Dever::load('manage/company')->get();
+        $where = array();
+        if ($company_id) {
+            $company = Dever::db('manage/company')->find($company_id);
+            if ($company && $company['is_project'] == 2 && $company['project']) {
+                $where['ids'] = $company['project'];
+            }
+        }
         if ($this->group) {
-            $group = Dever::db('manage/menu_group')->state();
+            $group = Dever::db('manage/menu_group')->getIds($where);
             foreach ($group as $k => $v) {
                 if (!isset($this->group[$k])) {
                     unset($group[$k]);
@@ -646,7 +654,7 @@ class Menu
 
             return $group;
         } else {
-            $this->group = Dever::db('manage/menu_group')->state();
+            $this->group = Dever::db('manage/menu_group')->getIds($where);
         }
 
         return $this->group;