rabin 3 yıl önce
ebeveyn
işleme
dd5ba17254

+ 2 - 5
assets/layadmin/html/project/database/list.html

@@ -127,16 +127,13 @@
       </div>
       <div class="layui-card-body">
 
-        <div style="padding-bottom: 10px;">
+        <div id="list-button" style="padding-bottom: 10px;">
           <a class="layui-btn layuiadmin-btn-list" data-type="add" id="list-parent" style="display:none;margin-right: 10px;">返回上一页</a>
 
           <a class="layui-btn layuiadmin-btn-list" data-type="add" id="list-add" style="margin-left: 0px;">新增</a>
 
-          <span id="list-button" style="margin-left: 10px;"></span>
-
-          
-
         </div>
+        
         <div class="dever_desc" id="info"></div>
         
         <div id="table_1" style="display:none;"></div>

+ 52 - 36
src/Database.php

@@ -72,6 +72,13 @@ class Database
      */
     private $manage_button = false;
 
+    /**
+     * info
+     *
+     * @var array
+     */
+    private $info = array();
+
     /**
      * __construct
      *
@@ -356,6 +363,9 @@ class Database
      */
     public function info()
     {
+        if ($this->info) {
+            return $this->info;
+        }
         $config = $this->config();
 
         $menu = isset($config['lang']) ? $config['lang'] : $this->project . '-' . $this->table;
@@ -367,8 +377,6 @@ class Database
         $top = Dever::load('manage/top.get');
         //print_r($top);die;
 
-        $display = 'margin-left: 0px;';
-
         # 新增权限
         $insert_state = Dever::load('manage/auth.oper', 4);
 
@@ -376,7 +384,7 @@ class Database
             $display .= 'display:none';
         }
 
-        $info = array
+        $this->info = array
         (
             'action' => $this->url('updateAction'),
             'list' => $this->url('list'),
@@ -384,7 +392,6 @@ class Database
             'mul' => $this->url('list'),
             //'add'                 => 'location.href=\'' . $this->url('add') . '\'',
             'add' => $this->url('add'),
-            'add_state' => $display,
 
             'state' => $this->getState(),
             'l' => 'project/database/list',
@@ -411,21 +418,21 @@ class Database
         );
 
         # 此处为了兼容旧版本的一些设置
-        $info['parent'] = Dever::input('oper_table', Dever::input('oper_parent'));
+        $this->info['parent'] = Dever::input('oper_table', Dever::input('oper_parent'));
 
         # 返回上一页
-        if ($info['parent']) {
+        if ($this->info['parent']) {
             $oper = Dever::preInput('oper_');
             if ($oper) {
-                $info['parent'] .= '&' . str_replace('oper_', '', http_build_query($oper));
+                $this->info['parent'] .= '&' . str_replace('oper_', '', http_build_query($oper));
             }
             $search = Dever::preInput('search_');
             if ($search) {
-                $info['parent'] .= '&' . http_build_query($search);
+                $this->info['parent'] .= '&' . http_build_query($search);
             }
             $send = Dever::preInput('send_');
             if ($send) {
-                $info['parent'] .= '&' . http_build_query($send);
+                $this->info['parent'] .= '&' . http_build_query($send);
             }
             $top = Dever::preInput('top_');
             if ($top) {
@@ -434,33 +441,29 @@ class Database
                     foreach ($top as $k => $v) {
                         $temp = explode('.', $v);
                         $k = str_replace('top_', '', $k);
-                        $info['parent'] .= '&oper_' . $k . '=' . $temp[0];
+                        $this->info['parent'] .= '&oper_' . $k . '=' . $temp[0];
                         if (isset($temp[1])) {
-                            $info['parent'] .= '&top_' . $k . '=' . $temp[1];
+                            $this->info['parent'] .= '&top_' . $k . '=' . $temp[1];
                         }
                     }
                 } else {
-                    $info['parent'] .= '&' . str_replace('top_', 'oper_', $top_query);
+                    $this->info['parent'] .= '&' . str_replace('top_', 'oper_', $top_query);
                 }
             }
-            $info['parent_project'] = Dever::input('oper_project');
+            $this->info['parent_project'] = Dever::input('oper_project');
 
-            $info['parent'] = $this->url(Dever::input('oper_index', 'listData'), 0, $info['parent'], '', $info['parent_project']);
-            $info['parent_state'] = 'margin-right: 10px;';
-        } else {
-            $info['parent_state'] = 'margin-right: 10px;display:none';
+            $this->info['parent'] = $this->url(Dever::input('oper_index', 'listData'), 0, $this->info['parent'], '', $this->info['parent_project']);
         }
-
         # 保存页面
-        $info['save'] = Dever::input('oper_save_table', Dever::input('oper_save_jump'));
-        if ($info['save']) {
-            $info['save_project'] = Dever::input('oper_save_project');
-            $info['list'] = $this->url(Dever::input('oper_index', 'list'), 0, $info['save'], '', $info['save_project']);
+        $this->info['save'] = Dever::input('oper_save_table', Dever::input('oper_save_jump'));
+        if ($this->info['save']) {
+            $this->info['save_project'] = Dever::input('oper_save_project');
+            $this->info['list'] = $this->url(Dever::input('oper_index', 'list'), 0, $this->info['save'], '', $this->info['save_project']);
         }
 
         $search = Dever::preInput('search_');
         if ($search) {
-            $info['mul'] .= '&' . http_build_query($search);
+            $this->info['mul'] .= '&' . http_build_query($search);
 
             if (layadmin()) {
                 foreach ($search as $k => $v) {
@@ -468,17 +471,16 @@ class Database
                         if (is_array($v)) {
                             $v = implode(',', $v);
                         }
-                        $info['search_param'] .= '<input type="hidden" name="'.$k.'"  value="'.$v.'"/>';
+                        $this->info['search_param'] .= '<input type="hidden" name="'.$k.'"  value="'.$v.'"/>';
                     }
                 }
             }
         }
 
         if ($this->id) {
-            $info['update_header'] = $menu . '-更新数据' . $this->refer('list');
+            $this->info['update_header'] = $menu . '-更新数据' . $this->refer('list');
         }
-
-        return $info;
+        return $this->info;
     }
 
     /**
@@ -1090,18 +1092,32 @@ class Database
             return '';
         }
         */
+        $button = array();
 
         $config = $this->config();
 
         $result = '';
 
+        # 增加返回上一页按钮
+        $info = $this->info();
+        if ($info['parent']) {
+            $button['返回上一页'] = $info['parent'];
+        }
+        if ($info['add']) {
+            $button['新增'] = $info['add'];
+        }
+
         # 增加主动统计按钮
         if (isset($config['manage']['stat'])) {
             $name = '数据统计';
             if (is_string($config['manage']['stat'])) {
                 $name = $config['manage']['stat'];
             }
-            $config['manage']['button'][$name] = $this->url('stat');
+            $button[$name] = $this->url('stat');
+        }
+
+        if (isset($config['manage']['button']) && $config['manage']['button']) {
+            $button += $config['manage']['button'];
         }
 
         # 增加下载报表按钮
@@ -1112,10 +1128,10 @@ class Database
                     if (is_array($v)) {
                         $name = $v[0];
                         $u = $url . '&excel_name='.$v[1].'&excel_load=' . $v[2];
-                        $config['manage']['button'][$name] = 'onclick="jump(\''.$u.'\', \'#form1\')"';
+                        $button[$name] = 'onclick="jump(\''.$u.'\', \'#form1\')"';
                     } else {
                         $name = $v;
-                        $config['manage']['button'][$name] = 'onclick="jump(\''.$url.'\', \'#form1\')"';
+                        $button[$name] = 'onclick="jump(\''.$url.'\', \'#form1\')"';
                     }
                 }
             } else {
@@ -1123,22 +1139,22 @@ class Database
                 if (is_string($config['manage']['excel']) && !strstr($config['manage']['excel'], '.')) {
                     $name = $config['manage']['excel'];
                 }
-                $config['manage']['button'][$name] = 'onclick="jump(\''.$url.'\', \'#form1\')"';
+                $button[$name] = 'onclick="jump(\''.$url.'\', \'#form1\')"';
             }
-            
         }
+        
         # 增加回收站
         if (Dever::load('manage/auth.oper', 5) != false && isset($config['struct']['state']) && (!isset($config['manage']['delete']) || (isset($config['manage']['delete']) && $config['manage']['delete'] && isset($config['manage']['_list']['value']['delete'])))) {
             if ($config['state'] == 2) {
-                $config['manage']['button']['返回数据列表'] = $this->url('list', 0, false, '&search_option_state=1', $this->project);
+                $button['返回数据列表'] = $this->url('list', 0, false, '&search_option_state=1', $this->project);
             } else {
-                $config['manage']['button']['回收站'] = $this->url('list', 0, false, '&search_option_state=2', $this->project);
+                $button['回收站'] = $this->url('list', 0, false, '&search_option_state=2', $this->project);
             }
         }
 
         # 列表页按钮
-        if (isset($config['manage']['button'])) {
-            $result .= $this->list_button_show($config['manage']['button']);
+        if ($button) {
+            $result .= $this->list_button_show($button);
         }
         /*
         if (Dever::load('manage/auth.oper', 6) != false && isset($config['manage']['button'])) {

+ 1 - 8
template/layadmin/project/database/list.php

@@ -14,13 +14,6 @@ $view
 ->fetch('#search_param', 'manage/database.info#search_param')
 ->fetch('#addstyle', 'manage/database.listStyle')    
 #->fetch('#list-desc', 'manage/database.info#list_desc')
-# 新增的链接 @代表属性
-->fetch('#list-add@href', 'manage/database.info#add')
-->fetch('#list-add@style', 'manage/database.info#add_state')
-
-->fetch('#list-parent@href', 'manage/database.info#parent')
-->fetch('#list-parent@style', 'manage/database.info#parent_state')    
-
  
 # 只对一部分数据进行接管,只接管table   
 ->fetch('#table_1@style', 'manage/database.page_list_table#s1')
@@ -56,7 +49,7 @@ $view
 ->loop('#chart@style','manage/database.list_chart_show') 
 
 
-# 数据列表
+# 列表页按钮
 ->fetch('#list-button','manage/database.list_button')    
 
 # 批量管理的表单