dever 6 years ago
parent
commit
1d84865ce5
2 changed files with 43 additions and 28 deletions
  1. 5 0
      database/admin.php
  2. 38 28
      src/Lib/Input.php

+ 5 - 0
database/admin.php

@@ -199,6 +199,11 @@ return array
 			'list'		=> true,
 			# 在手机版或者小屏幕下,列表页的表格是否展示,1为展示,2、3、4、5、6均为在一定宽度下展示,详细参考:https://github.com/nadangergeo/RWD-Table-Patterns
 			'level'		=> 1,
+
+			//直接上传到云端
+			//'upload'	=> 'qiniu',
+			//上传大数据
+			//'large' 	=> true,
 		),
 
 		# 比较特殊的一些设置,不断添加中:

+ 38 - 28
src/Lib/Input.php

@@ -185,9 +185,11 @@ class Input
         return '<textarea style="height:100px;" update_type="value" class="update_value form-control ' . (isset($param['valid']) ? $param['valid'] : '') . '" name="' . $param['name'] . '" value="' . (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : '')) . '">' . (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : '')) . '</textarea>';
     }
 
-    private function qiniu($param)
+    private function uploadHandle($param)
     {
-        $html = '';
+        $html = $style = '';
+        $div = array('', '');
+        $type = 'button';
         if (isset($param['upload']) && $param['upload'] == 'qiniu') {
             $upload = Dever::load('upload/qiniu.token');
             $domain = $upload['domain'];
@@ -201,9 +203,25 @@ class Input
 
         if (isset($param['large']) && $param['large']) {
             $html .= ' l="1" ';
+            $type = 'file';
+            $div = array('<div class="layui-input"  style=" position: relative;
+    display: inline-block;
+    border-radius: 2px;
+    color: black;
+    text-decoration: none;
+    text-indent: 0;
+    line-height: 37px;
+    height: 37px;
+    width: 97px;
+    padding-left: 19px;">', '本地上传</div>');
+            $style = 'position: absolute;
+    font-size: 21px;
+    right: 0;
+    top: 0;
+    opacity: 0;';
         }
 
-        return $html;
+        return array($html, $type, $div, $style);
     }
 
     /**
@@ -224,29 +242,9 @@ class Input
         if (layadmin()) {
             $class .= 'padding-left:0px;';
         }
-        $type = 'button';
-        $qiniu = self::qiniu($param);
-        if (strstr($qiniu, 'l="1"')) {
-            $type = 'file';
+        $upload = self::uploadHandle($param);
 
-            $button = '<div class="layui-input"  style=" position: relative;
-    display: inline-block;
-    border-radius: 2px;
-    color: black;
-    text-decoration: none;
-    text-indent: 0;
-    line-height: 37px;
-    height: 37px;
-    width: 97px;
-    padding-left: 19px;"><input type="'.$type.'" style="'.$class.';position: absolute;
-    font-size: 21px;
-    right: 0;
-    top: 0;
-    opacity: 0;" class="form-control image_upload" '.$qiniu.' v="' . $param['name'] . '_' . $param['index'] . '" id="file_' . $param['name'] . '_' . $param['index'] . '" key="' . $param['key'] . '" value="本地上传"/>本地上传</div>';
-
-        } else {
-            $button = '<input type="'.$type.'" style="'.$class.'" class="form-control image_upload" '.$qiniu.' v="' . $param['name'] . '_' . $param['index'] . '" id="file_' . $param['name'] . '_' . $param['index'] . '" key="' . $param['key'] . '" value="本地上传"/>';
-        }
+        $button = $upload[2][0] . '<input type="'.$upload[1].'" style="'.$class.$upload[3].'" class="form-control image_upload" '.$upload[0].' v="' . $param['name'] . '_' . $param['index'] . '" id="file_' . $param['name'] . '_' . $param['index'] . '" key="' . $param['key'] . '" value="本地上传"/>' . $upload[2][1];
         return $button .'
 
         <input type="button" style="'.$class.'" class="form-control upload_show" v="' . $param['name'] . '_' . $param['index'] . '" id="file_show_' . $param['name'] . '_' . $param['index'] . '" key="' . $param['key'] . '" value="图库"/>
@@ -277,7 +275,11 @@ class Input
         if (layadmin()) {
             $class .= 'padding-left:0px;';
         }
-        return '<input type="button" style="'.$class.'" class="form-control image_upload" mul="yes" v="' . $param['name'] . '_' . $param['index'] . '" id="file_' . $param['name'] . '_' . $param['index'] . '" key="' . $param['key'] . '" value="本地上传"/>
+
+        $upload = self::uploadHandle($param);
+
+        $button = $upload[2][0] . '<input type="'.$upload[1].'" style="'.$class.$upload[3].'" class="form-control image_upload" '.$upload[0].' mul="yes" v="' . $param['name'] . '_' . $param['index'] . '" id="file_' . $param['name'] . '_' . $param['index'] . '" key="' . $param['key'] . '" value="本地上传"/>' . $upload[2][1];
+        return $button . '
 
         <input type="button" style="'.$class.'" class="form-control upload_show" mul="yes" v="' . $param['name'] . '_' . $param['index'] . '" id="file_show_' . $param['name'] . '_' . $param['index'] . '" key="' . $param['key'] . '" value="图库"/>
 
@@ -302,7 +304,11 @@ class Input
         if (layadmin()) {
             $class .= 'padding-left:0px;';
         }
-        return '<input type="button" style="'.$class.'" class="form-control image_upload" t="file" v="' . $param['name'] . '_' . $param['index'] . '" id="file_' . $param['name'] . '_' . $param['index'] . '" key="' . $param['key'] . '" value="本地上传"/>
+
+        $upload = self::uploadHandle($param);
+
+        $button = $upload[2][0] . '<input type="'.$upload[1].'" style="'.$class.$upload[3].'" class="form-control image_upload" '.$upload[0].' t="file" v="' . $param['name'] . '_' . $param['index'] . '" id="file_' . $param['name'] . '_' . $param['index'] . '" key="' . $param['key'] . '" value="本地上传"/>' . $upload[2][1];
+        return $button .'
 
         <input type="button" style="'.$class.'" class="form-control upload_show" t="file" v="' . $param['name'] . '_' . $param['index'] . '" id="file_show_' . $param['name'] . '_' . $param['index'] . '" key="' . $param['key'] . '" value="文件库"/>
 
@@ -335,7 +341,11 @@ class Input
         if (layadmin()) {
             $class .= 'padding-left:0px;';
         }
-        return '<input type="button" style="'.$class.'" class="form-control image_upload" t="file" mul="yes" v="' . $param['name'] . '_' . $param['index'] . '" id="file_show_' . $param['name'] . '_' . $param['index'] . '" key="' . $param['key'] . '" value="本地上传"/>
+
+        $upload = self::uploadHandle($param);
+
+        $button = $upload[2][0] . '<input type="'.$upload[1].'" style="'.$class.$upload[3].'" class="form-control image_upload" '.$upload[0].' t="file" mul="yes" v="' . $param['name'] . '_' . $param['index'] . '" id="file_' . $param['name'] . '_' . $param['index'] . '" key="' . $param['key'] . '" value="本地上传"/>' . $upload[2][1];
+        return $button .'
 
         <input type="button" style="'.$class.'" class="form-control upload_show" t="file" mul="yes" v="' . $param['name'] . '_' . $param['index'] . '" id="file_' . $param['name'] . '_' . $param['index'] . '" key="' . $param['key'] . '" value="文件库"/>