dever 6 years ago
parent
commit
7407b2ba54
4 changed files with 155 additions and 3 deletions
  1. 82 0
      assets/html/show.html
  2. 2 1
      database/cate.php
  3. 27 1
      database/file.php
  4. 44 1
      src/View.php

+ 82 - 0
assets/html/show.html

@@ -0,0 +1,82 @@
+
+<style>
+  #component-anim .layui-card-body{padding: 15px;}
+
+  #component-anim .component-anim-demo{font-size: 0;}
+  #component-anim .component-anim-demo li{display: inline-block; vertical-align: middle; width: 127px; line-height: 25px; padding: 20px 0; font-size: 14px; text-align: center; color: #666; transition: all .3s; -webkit-transition: all .3s;}
+  #component-anim .component-anim-demo li .layui-icon{display: inline-block; font-size: 36px;}
+
+  #component-anim .component-anim-demo li .fontclass{display: none;}
+  #component-anim .component-anim-demo li .name{color: #c2c2c2;}
+  #component-anim .component-anim-demo li:hover{background-color: #f2f2f2; color: #000;}
+
+  #component-anim .component-anim-demo li{width: 168px;}
+  #component-anim .component-anim-demo .layui-anim{cursor: pointer;}
+  #component-anim .component-anim-demo .layui-anim{width:150px;height:100px;}
+  #component-anim .component-anim-demo .code{height:25px;}
+
+  #component-anim .component-anim-demo .layui-anim-yes
+  {
+  	border:1px solid #0000ff;
+  }
+  #component-anim .component-anim-demo .layui-anim-no
+  {
+  	border: 1px solid #e2e2e2;
+  }
+  </style>
+
+<div class="layui-card"  id="component-anim">
+  <div class="layui-card-header">
+  	<input type="hidden" class="file_key" value="<{$config.id}>">
+  	<input type="hidden" class="file_pg" value="<{$search_pg}>">
+  	<input type="hidden" class="file_cur" value="<{$cur}>">
+  	<div class="layui-inline"><div class="layui-input-inline"><input type="text" style="width: 100%;" class="layui-input file_filename" value="<{$search_name}>" autocomplete="new-password" placeholder="文件名"></div></div>
+
+  	<div class="layui-inline" style="display: none;"><div class="layui-input-inline"><input type="text" style="width: 100%;"  class="layui-input file_tag" value="<{$search_tag}>" autocomplete="new-password" placeholder="标签"></div></div>
+
+  	<div class="layui-inline"><div class="layui-input-inline"><select lay-ignore="" class="layui-input file_cate" style="width: 100%;"><option parent="" value="-1" selected="">选择分类</option>
+  		<{loop($cate):}>
+  		<option parent="" value="<{$v.id}>" <{if($v.id == $search_cate):}>selected<{endif}>><{$v.name}></option>
+  		<{endloop}>
+  	</select></div></div>
+
+  	<div class="layui-inline" class="file-search" onclick="showUploadFilesSearch($(this))"><div class="layui-input-inline"><button type="button" class="layui-btn"><i class="fa fa-save"></i> 搜索</button></div></div>
+
+  </div>
+  <div class="layui-card-body">
+    
+    <ul class="component-anim-demo">
+    	<{loop($file):}>
+      <li class="<{if(strstr($cur, $v1.url)):}>layui-anim-yes<{else:}>layui-anim-no<{endif}>">
+        <div class="layui-anim" data-anim="layui-anim-up" onclick="showUploadFilesSet($(this), '<{$v1.name}>','<{$v1.url}>')"><img src="<{$v1.pic}>" style="max-width: 150px;max-height: 100px;margin-left: 10px;"/></div>
+        <div class="code"><{$v1.source_name}></div>
+      </li>
+      <{endloop}>
+    </ul>
+    <div id="file-page"></div>
+</div>
+
+  
+
+<script>
+layui.use('laypage', function(){
+  var laypage = layui.laypage;
+  
+  //执行一个laypage实例
+  laypage.render({
+    elem: 'file-page' //注意,这里的 test1 是 ID,不用加 # 号
+    ,count: <{$total}> //数据总数,从服务端得到
+    ,limit:12
+    ,curr:<{$search_pg}>
+    ,jump: function(obj, first){
+	    //首次不执行
+	    if(!first){
+	      $('.file_pg').val(obj.curr);
+	    	showUploadFilesSearch($('.file_pg'));
+	    }
+	  }
+  });
+});
+</script>
+
+</div>

+ 2 - 1
database/cate.php

@@ -19,7 +19,7 @@ return array
             'desc'      => '',
             'match'     => 'is_numeric',
             'search'    => 'order',
-            //'list'        => true,
+            'list'        => true,
         ),
 
         'name'      => array
@@ -30,6 +30,7 @@ return array
             'desc'      => '分类名称',
             'match'     => 'option',
             'update'    => 'text',
+            'search'    => 'fulltext',
             'list'      => true,
         ),
 

+ 27 - 1
database/file.php

@@ -108,9 +108,11 @@ return array
 			'update'	=> 'select',
 			'search'	=> 'select',
 			//'control'	=> 'type',
-			//'list'		=> true,
+			'list'		=> true,
+			'edit'		=> true,
 		),
 
+		/*
 		'tag'		=> array
 		(
 			'type' 		=> 'text-255',
@@ -124,6 +126,7 @@ return array
 			//'control'	=> 'type',
 			//'list'		=> true,
 		),
+		*/
 
 		'key'		=> array
 		(
@@ -205,6 +208,12 @@ return array
 			'list'		=> 'date("Y-m-d H:i:s", {cdate})',
 		),
 	),
+
+	'manage' => array
+	(
+		'insert' => false,
+		'delete' => false,
+	),
 	
 	# request 请求接口定义
 	'request' => array
@@ -227,5 +236,22 @@ return array
 			),
 			'type' => 'one',
 		),
+
+		'getData' => array
+		(
+			'option' => array
+			(
+				'state' => 1,
+				'upload' => 'yes',
+				'cate' => 'yes',
+				'source_name' => array('yes', 'like'),
+				//'source_name' => array('yes', 'like', 'and('),
+				//'name' => array('yes', 'like', 'or)'),
+				
+			),
+			'order' => array('id' => 'desc'),
+			'type' => 'all',
+			'page' => array(12, 'list')
+		),
 	)
 );

+ 44 - 1
src/View.php

@@ -12,11 +12,53 @@ use Upload\Src\Lib\Img;
 
 class View
 {
+    public function files()
+    {
+        $data = array();
+
+        $key = Dever::input('key');
+        $cate = Dever::input('cate');
+        $name = Dever::input('name');
+        $tag = Dever::input('tag');
+        $data['cur'] = Dever::input('cur');
+        $data['search_pg'] = Dever::input('pg', 1);
+
+        $param = array();
+        $param['upload'] = $key;
+        if ($name) {
+            $param['source_name'] = $name;
+            $param['name'] = $name;
+        }
+        if ($cate && $cate > 0) {
+            $param['cate'] = $cate;
+        }
+
+        $data['search_cate'] = $cate;
+        $data['search_tag'] = $tag;
+        $data['search_name'] = $name;
+
+        $data['file'] = Dever::db('upload/file')->getData($param);
+        $data['total'] = Dever::total();
+        $data['cate'] = Dever::db('upload/cate')->state();
+        $data['config'] = Dever::db('upload/upload')->one($key);
+
+        if ($data['file']) {
+            foreach ($data['file'] as $k => $v) {
+                $data['file'][$k]['url'] = Dever::upload('{uploadRes}' . $v['file']);
+                $data['file'][$k]['pic'] = Dever::upload('{uploadRes}' . $v['file']);
+            }
+        }
+
+        $data = Dever::render('show', $data);
+        Dever::out($data);
+    }
+
     public function kindeditorFile()
     {
         $key = Dever::input('key');
         $param['upload'] = $key;
         $file = Dever::db('upload/file')->state();
+        $config = Dever::db('upload/upload')->one($key);
         $list = array();
         if ($file) {
 
@@ -31,6 +73,7 @@ class View
                     $list[$i]['is_photo'] = true;
                     $list[$i]['filetype'] = str_replace('.', '', $v['ext']);
                     $list[$i]['filename'] = $v['source_name'];
+                    $list[$i]['path'] = '';
                     $list[$i]['file'] = Dever::upload('{uploadRes}' . $v['file']);
                     $list[$i]['datetime'] = date('Y-m-d H:i:s', filemtime(Dever::local($list[$i]['file'])));
                     $i++;
@@ -40,7 +83,7 @@ class View
 
         $result = array();
         //相对于根目录的上一级目录
-        $result['moveup_dir_path'] = '';
+        $result['moveup_dir_path'] = $config['id'];
         //相对于根目录的当前目录
         $result['current_dir_path'] = '';
         //当前目录的URL