rabin 6 months ago
parent
commit
b7cada05c9

+ 2 - 1
src/collect/api/Test.php

@@ -9,6 +9,7 @@ class Test
 
     public function web()
     {
-        return Dever::load('web', 'collect')->run(1, 1);
+        Dever::load('web', 'collect')->run(1, 1);
+        return 'ok';
     }
 }

+ 71 - 15
src/collect/lib/Web.php

@@ -6,6 +6,7 @@ class Web
 {
     protected $web;
     protected $path;
+    protected $domain;
     protected $param = array();
 
     # 执行某个业务接口
@@ -18,6 +19,7 @@ class Web
         if (isset($param['host'])) {
             $this->web['host'] = $param['host'];
         }
+        $this->domain = $this->web['host'];
         $this->path = Dever::db('web_path', 'collect')->find(array('web_id' => $this->web['id'], 'id' => $web_path_id));
         if (!$this->path) {
             return false;
@@ -157,31 +159,31 @@ class Web
         $where['web_path_id'] = $web_path_id;
         $info = Dever::db('web_data', 'collect')->select($where, $set);
         $data['head'] = $data['body'] = array();
-        $col = Dever::db('web_path_col', 'collect')->select(array('web_path_id' => $web_path_id));
+        $col = Dever::db('web_path_col', 'collect')->select(array('web_path_id' => $web_path_id, 'status' => 1));
         if (!$col || !$info) {
             return $data;
         }
-        print_r($col);die;
+        $config = array();
         foreach ($col as $k => $v) {
-
+            $config['field'][$v['key']] = array('name' => $v['key'], 'type' => 'show');
         }
 
+        $page = Dever::load('common', 'manage')->page('collect/web_data', $config);
+        $data['field'] = $page->setting('field', $data['head']);
         foreach ($info as $k => $v) {
-            $content = Dever::json_decode($v['content']);
+            $body = array();
+            $content = Dever::json_decode($v['value']);
             foreach ($content as $key => $value) {
-                $content[$key] = $page->getValue($key, $value, $content);
-            }
-            $content['id'] = $v['id'];
-            $data['body'][] = $content;
-        }
-        if ($data['head']) {
-            $head = array();
-            foreach ($data['head'] as $k => $v) {
-                if ($v['type'] == 'show') {
-                    $head[] = $v;
+                if (isset($config['field'][$key])) {
+                    $body[$key] = $page->getValue($key, $value, $content);
+                    $button = $page->button('data_button', $v);
+                    if ($button) {
+                        $body['button'] = $button;
+                    }
                 }
             }
-            $data['head'] = $head;
+            $body['id'] = $v['id'];
+            $data['body'][] = $body;
         }
         return $data;
     }
@@ -303,4 +305,58 @@ class Web
 
         Dever::excelExport($body, $header, $file);
     }
+
+    public function view($page)
+    {
+        # 这里获取基本信息
+        //print_r($page->info);die;
+        $info[] = array
+        (
+            # 类型,desc描述 table表格,表格有head和body即可
+            'type' => 'desc',
+            'name' => '详细信息',
+            # 每行展示数量
+            'column' => 1,
+            # 是否有边框
+            'border' => true,
+            # 排列方向:horizontal横向 vertical纵向
+            'direction' => 'horizontal',
+
+            'content' => array
+            (
+                array
+                (
+                    'name' => '标题',
+                    # 类型,text普通文本,tag标签,link链接,image图片 progress进度条 stat统计 timeline时间线 table表格
+                    'type' => 'text',
+                    'content' => '<a style="color:red">内容</a>',
+                    # 样式primary success warning danger info exception
+                    'style' => 'primary',
+                ),
+                array
+                (
+                    'name' => '标题',
+                    'type' => 'tag',
+                    'content' => '内容',
+                    'style' => 'warning',
+                ),
+                array
+                (
+                    'name' => '标题',
+                    'type' => 'link',
+                    'content' => '内容',
+                ),
+                array
+                (
+                    'name' => '图片',
+                    'type' => 'image',
+                    'content' => 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg',
+                    # 'fill', 'contain', 'cover', 'none', 'scale-down'
+                    'fit' => 'fill',
+                ),
+            ),
+        );
+
+        return array('info' => $info);
+    }
 }

+ 8 - 4
src/collect/table/manage/web_data.php

@@ -1,17 +1,19 @@
 <?php
+$set = Dever::input('set');
 return array
 (
     'list' => array
     (
         'data'      => 'collect/web.getData', 
-        'data_button' => array
-        (
-            //'编辑' => 'edit',
-        ),
         'button' => array
         (
             //'新增' => 'add',
         ),
+        # 列表页每条数据的按钮,默认是快速编辑和删除
+        'data_button' => array
+        (
+            '详情' => array('view', 'collect/web_data?type=view&id=id&set=' . Dever::json_encode($set)),
+        ),
         'search' => array
         (
             'value' => array
@@ -50,4 +52,6 @@ return array
             ),
         ),
     ),
+    # 详情页配置
+    'view' => 'collect/web.view',
 );

+ 1 - 1
src/collect/table/manage/web_info.php

@@ -18,7 +18,7 @@ return array
                 'path' => 'collect/web_path_manage',
                 'param' => array
                 (
-                    'set' => array('web_id' => 'id', 'menu' => 'collect/web_info', 'parent' => 'collect/web_path_manage'),
+                    'set' => array('web_id' => 'id', 'menu' => 'collect/web_info', 'parent' => 'collect/web_info'),
                 ),
             ), 'ChatLineSquare'),
         ),

+ 1 - 2
src/collect/table/manage/web_path_col.php

@@ -25,7 +25,6 @@ return array
             (
                 'type' => 'textarea',
             ),
-            /*
             'status' => array
             (
                 'width' => '40',
@@ -33,7 +32,7 @@ return array
                 'show'  => '{status}',
                 'active_value' => 1,
                 'inactive_value' => 2,
-            ),*/
+            ),
         ),
         'drag' => 'sort',
     ),

+ 2 - 2
src/collect/table/manage/web_path_manage.php

@@ -20,7 +20,7 @@ return array
                 'path' => 'collect/web_data',
                 'param' => array
                 (
-                    'set' => array('web_path_id' => 'id', 'menu' => 'collect/web_path_manage', 'parent' => 'collect/web_data'),
+                    'set' => array('web_path_id' => 'id', 'menu' => 'collect/web_info', 'parent' => 'collect/web_path_manage', 'parent_param' => array('web_id' => $web_id, 'menu' => 'collect/web_info', 'parent' => 'collect/web_info')),
                 ),
             ), 'ChatLineSquare'),
         ),
@@ -57,7 +57,7 @@ return array
 1、采集规则:如采集标题,.text_box a,如需要采集某个链接中的字段,则输入类似link->.article p,link->为link字段获取到的链接<br />
 2、采集属性:采集的属性,如html、href等,如带有s,则采集多条,如果值为list,则获取多条,仅限->模式<br />
 3、过滤规则:加号为保留某标签,减号为过滤span标签<br />
-4、回调方法:支持php内置方法和Dever内置方法,如Dever::getFile({c}, {domain}, 1),就是将文件做转换,第三个参数不传就不保存到本地',
+4、回调方法:支持php内置方法和Dever内置方法,如Dever::load("view", "upload")->file({c}, {domain}, 1),就是将文件做转换,第三个参数不传就不保存到本地',
             ),
             'page_rule',
             'page_num',