dever 6 years ago
parent
commit
2c7df8cc79

+ 32 - 10
journal/assets/manage/html/journal.html

@@ -1,22 +1,44 @@
 <div class="layui-fluid layadmin-cmdlist-fluid">
-  <div class="layui-row layui-col-space30">
-    <div class="layui-col-md2 layui-col-sm4">
+  <ul class="layui-row layui-col-space30" id="sortable">
+    <li class="layui-col-md2 layui-col-sm4" id="data">
         <div class="cmdlist-container">
-            <a href="javascript:;">
+            <div href="javascript:;" style="height:auto;text-align: center;">
               <img src="../../layuiadmin/style/res/template/portrait.png">
-            </a>
+            </div>
             <a href="javascript:;">
               <div class="cmdlist-text">
                 <p class="info">2018春夏季新款港味短款白色T恤+网纱中长款chic半身裙套装两件套</p>
                 <div class="price">
-                    <b>¥79</b>
+                    <b></b>
+                </div>
+
+                <div class="text"></div>
+                
+
+                <div style="margin-top:10px;text-align:center;">
+                <div class="layui-table-cell"><a href="javascript:;" class="edit" onclick=""><button type="button" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 layui-btn layui-btn-xs">编辑</button></a>&nbsp;&nbsp;<a href="#" class="oper_delete"><button type="button" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 layui-btn layui-btn-danger layui-btn-xs"><span class="am-icon-trash-o"></span>删除</button></a>&nbsp;&nbsp;</div>
                 </div>
               </div>
             </a>
         </div>
-    </div>
-    <div class="layui-col-md12 layui-col-sm12">
-        <div id="demo0"></div>
-    </div>
-  </div>
+    </li>
+  </ul>
 </div>
+
+<script id="url">var url = ""</script>
+<script>
+  $( function() {
+    var sort = $( "#sortable" ).sortable({
+        opacity: 0.7,
+        stop:function(){
+          var arr = $( "#sortable" ).sortable('toArray');
+          arr = arr.join(',');
+          $.post(url, {data:arr}, function()
+          {
+
+          })
+        }
+    });
+    $( "#sortable" ).disableSelection();
+  } );
+  </script>

+ 19 - 5
journal/database/content.php

@@ -2,9 +2,9 @@
 
 $type = array
 (
+    3 => '图文内容',
     1 => '全屏图',
     2 => '长图',
-    3 => '图文内容',
     11 => '关联图文',
     12 => '关联视频',
     13 => '关联直播',
@@ -65,7 +65,7 @@ return array
         (
             'type'      => 'int-11',
             'name'      => '类型',
-            'default'   => '1',
+            'default'   => '3',
             'desc'      => '类型',
             'match'     => 'is_numeric',
             'update'    => 'radio',
@@ -73,6 +73,20 @@ return array
             'control'   => 'type',
         ),
 
+        'name'      => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '标题',
+            'default'   => '',
+            'desc'      => '标题',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'list'      => true,
+            //增加预览
+            'preview'   => true,
+            'show'      => 'type=3',      
+        ),
+
         'focus'     => array
         (
             'type'      => 'text-255',
@@ -215,7 +229,7 @@ return array
             //'update'    => 'text',
             'search'    => 'order',
             'list'      => true,
-            'order'     => 'desc',
+            'order'     => 'asc',
             'edit'      => true,
         ),
         
@@ -245,14 +259,14 @@ return array
     (
         'insert' => false,
         'edit' => false,
-        'delete' => false,
+        //'delete' => false,
         'num' => false,
         'page_list_table' => 'journal',
 
         # 自定义快捷新增和编辑
         'button' => array
         (
-            '新增' => array('fast'),
+            '新增内页' => array('fasts'),
         ),
     ),
 );

+ 2 - 1
journal/database/content_text.php

@@ -78,8 +78,9 @@ return array
             'default'   => '1',
             'desc'      => '显示位置',
             'match'     => 'is_numeric',
-            'update'    => 'radio',
+            'update'    => 'hidden',
             'option'    => $location,
+            'value'     => Dever::input('search_option_location'),
         ),
 
         'color'     => array

+ 81 - 0
journal/lib/Manage.php

@@ -137,4 +137,85 @@ class Manage
     {
         return $this->search('video/live');
     }
+
+    # 显示杂志内页
+    public function journalContent()
+    {
+        $where['info_id'] = Dever::input('search_option_info_id');
+        $where['state'] = Dever::input('search_option_state');
+        $data = Dever::db('journal/content')->all($where);
+
+        $database = Dever::load('manage/database');
+
+        if ($data) {
+            foreach ($data as $k => $v) {
+                if ($v['type'] <= 2) {
+                    $data[$k]['name'] = '';
+                } elseif ($v['type'] == 3) {
+                    $data[$k]['pic'] = $v['focus'];
+                }
+
+                if ($v['type'] == 2) {
+                    $data[$k]['text'] = $this->text($database, $v['id'], $where['info_id']);
+                } else {
+                    $data[$k]['text'] = '';
+                }
+
+                $link = $database->url('edit', $v['id']) . '&search_option_info_id=' . $where['info_id'];
+
+                $data[$k]['edit'] = "fastEdit($(this), '".$link."', '编辑内页', '', 1)";
+
+                $data[$k]['delete'] = $database->url('delete', $v['id']);
+            }
+        }
+
+        return $data;
+    }
+
+    public function text($database, $content_id, $info_id)
+    {
+        $id = 1;
+        $link = $database->url('edit') . '&search_option_info_id=' . $info_id . '&search_option_content_id=' . $content_id . '&table=content_text&where_id=' . $id;
+        $edit = 
+
+        $html = '<table class="layui-table">
+  <tbody>
+    <tr>
+      <td><a href="javascript:;" onclick="fastEdit($(this), \''.$link . '&search_option_location=1'.'\', \'编辑上左文字\', \'\')">上左</a></td>
+      <td>上中</td>
+      <td>上右</td>
+    </tr>
+    <tr>
+      <td>中左</td>
+      <td>正中</td>
+      <td>中右</td>
+    </tr>
+    <tr>
+      <td>下左</td>
+      <td>下中</td>
+      <td>下右</td>
+    </tr>
+  </tbody>
+</table>';
+
+        return $html;
+    }
+
+    public function updateJournalContent_api()
+    {
+        $data = Dever::input('data');
+
+        if ($data) {
+            $data = explode(',', str_replace('data-', '', $data));
+            foreach ($data as $k => $v) {
+                $k = $k + 1;
+                $where['where_id'] = $v;
+                $where['reorder'] = $k;
+                Dever::db('journal/content')->update($where);
+            }
+
+        }
+
+        return $data;
+    }
 }

+ 59 - 0
journal/template/manage/journal.php

@@ -0,0 +1,59 @@
+<?php
+
+/*
+|--------------------------------------------------------------------------
+| home
+|--------------------------------------------------------------------------
+ */
+$view
+
+->fetch('.layui-fluid@test', '公告')
+
+->fetch('#url', 'var url="<{Dever::url("journal/lib/manage.updateJournalContent")}>"')
+
+->loop
+(
+    '.layui-col-md2',
+    'journal/lib/manage.journalContent',
+    array
+    (
+        'self' => array
+        (
+            'id' => 'data-<{$v.id}>',
+        ),
+        'b' => array
+        (
+            'html' => '<{date("Y/m/d", $v.cdate)}>',
+            'html' => '',
+        ),
+
+        'img' => array
+        (
+            'src' => '<{$v.pic}>',
+            'width' => '150',
+        ),
+
+        '.info' => array
+        (
+            'html' => '<{$v.name}>',
+        ),
+
+        '.edit' => array
+        (
+            'onclick' => '<{$v.edit}>',
+        ),
+
+        '.oper_delete' => array
+        (
+            'href' => '<{$v.delete}>',
+        ),
+
+        '.text' => array
+        (
+            'html' => '<{$v.text}>',
+        ),
+    )
+)
+
+# display
+->display();

+ 5 - 1
tag/lib/Core.php

@@ -66,7 +66,7 @@ class Core
         }
 
         $insert = array();
-        if (!$data) {
+        if (!$data && $keyword) {
             $insert[0]['name'] = $keyword . '[新增]';
             $insert[0]['value'] = $keyword;
         }
@@ -86,6 +86,10 @@ class Core
             $data = $insert + $data;
         }
 
+        if (!$data) {
+            Dever::alert('暂无数据');
+        }
+
         return $data;
     }
 }