xaboy 7 年 前
コミット
291226f885

+ 2 - 1
composer.json

@@ -20,7 +20,8 @@
         "source": "https://github.com/xaboy/form-builder"
     },
     "require": {
-        "php": ">=5.4.0"
+        "php": ">=5.4.0",
+        "ext-json": "*"
     },
     "minimum-stability": "stable",
     "branch-alias": {

+ 77 - 6
src/Form.php

@@ -28,6 +28,7 @@ use FormBuilder\traits\form\FormTimePickerTrait;
 use FormBuilder\traits\form\FormTreeTrait;
 use FormBuilder\traits\form\FormUploadTrait;
 use FormBuilder\traits\form\FormOptionTrait;
+use FormBuilder\traits\form\FormValidateTrait;
 
 /**
  * Class Form
@@ -52,7 +53,8 @@ class Form
         FormTimePickerTrait,
         FormTreeTrait,
         FormStyleTrait,
-        FormOptionTrait;
+        FormOptionTrait,
+        FormValidateTrait;
 
     /**
      * 三级联动 加载省市数据
@@ -92,6 +94,24 @@ class Form
     ];
 
     /**
+     * 加载 jquery
+     * @var bool
+     */
+    protected $linkJq = true;
+
+    /**
+     * 加载 vue
+     * @var bool
+     */
+    protected $linkVue = true;
+
+    /**
+     * 加载 iview
+     * @var bool
+     */
+    protected $linkIview = true;
+
+    /**
      * @var string
      */
     protected $successScript = '';
@@ -120,6 +140,10 @@ class Form
      */
     protected $method = 'post';
 
+    protected $resetBtn = false;
+
+    protected $submitBtn = true;
+
     /**
      * 表单配置
      * @var array|mixed
@@ -147,6 +171,30 @@ class Form
     }
 
     /**
+     * @param bool $linkJq
+     */
+    public function setLinkJq($linkJq)
+    {
+        $this->linkJq = (bool)$linkJq;
+    }
+
+    /**
+     * @param bool $linkVue
+     */
+    public function setLinkVue($linkVue)
+    {
+        $this->linkVue = (bool)$linkVue;
+    }
+
+    /**
+     * @param bool $linkIview
+     */
+    public function setLinkIview($linkIview)
+    {
+        $this->linkIview = (bool)$linkIview;
+    }
+
+    /**
      * @return bool
      */
     public function isLoadCityData()
@@ -334,6 +382,7 @@ class Form
     }
 
     /**
+     * 是否需要引入省市区数据
      * @param FormComponentDriver $component
      */
     protected function checkLoadData(FormComponentDriver $component)
@@ -411,12 +460,16 @@ class Form
     {
         $_script = $this->script;
         $script = [
-            $_script['iview-css'],
-            $_script['jq'],
-            $_script['vue'],
-            $_script['iview'],
             $_script['form-create']
         ];
+        if($this->linkVue)
+            $script[] = $_script['vue'];
+        if($this->linkJq)
+            $script[] = $_script['jq'];
+        if($this->linkIview){
+            $script[] = $_script['iview-css'];
+            $script[] = $_script['iview'];
+        }
         if ($this->loadCityAreaData == true)
             $script[] = $_script['city-area-data'];
         if ($this->loadCityData == true)
@@ -425,6 +478,24 @@ class Form
     }
 
     /**
+     * 是否隐藏提交按钮(默认显示)
+     * @param bool $isShow
+     */
+    public function hiddenSubmitBtn($isShow = false)
+    {
+        $this->submitBtn = (bool)$isShow;
+    }
+
+    /**
+     * 是否隐藏重置按钮(默认隐藏)
+     * @param bool $isShow
+     */
+    public function hiddenResetBtn($isShow = false)
+    {
+        $this->resetBtn = (bool)$isShow;
+    }
+
+    /**
      * 生成表单快捷方法
      * @param string $action
      * @param array $components
@@ -432,6 +503,6 @@ class Form
      */
     public static function create($action, array $components = [])
     {
-        return new self($action, $components);
+        return new static($action, $components);
     }
 }

+ 63 - 20
src/FormComponentDriver.php

@@ -8,11 +8,13 @@
 namespace FormBuilder;
 
 use FormBuilder\components\Col;
+use FormBuilder\components\Validate;
 use FormBuilder\interfaces\FormComponentInterFace;
 use FormBuilder\traits\component\CallPropsTrait;
 
 /**
  * Class FormComponentDriver
+ *
  * @package FormBuilder
  */
 abstract class FormComponentDriver implements FormComponentInterFace
@@ -20,54 +22,66 @@ abstract class FormComponentDriver implements FormComponentInterFace
     use CallPropsTrait;
     /**
      * 字段名
+     *
      * @var String
      */
     protected $field;
 
     /**
      * 字段昵称
+     *
      * @var String
      */
     protected $title;
 
     /**
      * 组件名称
+     *
      * @var String
      */
     protected $name;
 
     /**
      * 组件的规则
+     *
      * @var array
      */
     protected $props = [];
 
     /**
      * 字段的值
+     *
      * @var
      */
     protected $value = '';
 
     /**
      * 栅格规则
+     *
      * @var array
      */
     protected $col = [];
 
     /**
      * 字段验证规则
+     *
      * @var array
      */
     protected $validate = [];
 
+
+    protected $validateHandler = null;
+
     /**
      * 组件属性设置规则
+     *
      * @var array
      */
     protected static $propsRule = [];
 
     /**
      * FormComponentDriver constructor.
+     *
      * @param String $field 字段名
      * @param String $title 字段昵称
      * @param String $value 字段值
@@ -94,9 +108,9 @@ abstract class FormComponentDriver implements FormComponentInterFace
      */
     public function col($span)
     {
-        if($span instanceof Col)
+        if ($span instanceof Col)
             $this->col = $span->build();
-        else if(is_numeric($span))
+        else if (is_numeric($span))
             $this->col['span'] = $span;
         return $this;
     }
@@ -104,6 +118,7 @@ abstract class FormComponentDriver implements FormComponentInterFace
 
     /**
      * 批量设置组件的规则
+     *
      * @param array $props
      * @return $this
      */
@@ -117,6 +132,7 @@ abstract class FormComponentDriver implements FormComponentInterFace
 
     /**
      * 获取组件的规则
+     *
      * @param $name
      * @return mixed|null
      */
@@ -127,7 +143,8 @@ abstract class FormComponentDriver implements FormComponentInterFace
 
     /**
      * 设置组件的值
-     * @param $value
+     *
+     * @param        $value
      * @param string $default
      * @return $this
      */
@@ -140,6 +157,7 @@ abstract class FormComponentDriver implements FormComponentInterFace
 
     /**
      * 获取组件的值
+     *
      * @return string
      */
     public function getValue()
@@ -149,6 +167,7 @@ abstract class FormComponentDriver implements FormComponentInterFace
 
     /**
      * 获取组件的字段名
+     *
      * @return String
      */
     public function getField()
@@ -158,6 +177,7 @@ abstract class FormComponentDriver implements FormComponentInterFace
 
     /**
      * 设置组件的昵称
+     *
      * @return String
      */
     public function getTitle()
@@ -166,40 +186,63 @@ abstract class FormComponentDriver implements FormComponentInterFace
     }
 
     /**
-     * @param bool $required
+     * @param string|null $message
      * @return $this
      */
-    public function required($required = true)
+    public function required($message = null)
     {
-        $this->props['required'] = (bool)$required;
+        $this->validate()->required($message ?: $this->getPlaceHolder());
+        $this->props['required'] = true;
         return $this;
     }
 
     /**
-     * 设置组件的值为必填
-     * @param null $message
-     * @return $this
+     * @param string $pre
+     * @return string
      */
-    protected function setRequired($message = '', $trigger = 'change', $type = null)
+    protected function getPlaceHolder($pre = '请选择')
     {
-        $validate = [
-            'required' => true,
-            'message' => $message,
-            'trigger' => $trigger
-        ];
-        if ($type !== null) $validate['type'] = $type;
-        $this->validate[] = $validate;
-        return $this;
+        return $pre . $this->title;
     }
 
     /**
      * 添加验证规则
+     *
      * @param array $validate
      * @return $this
      */
-    public function validate(array $validate)
+    public function validateAs(array $validate)
+    {
+        $this->validate = array_merge($this->validate, $validate);
+        return $this;
+    }
+
+    /**
+     * @return Validate
+     */
+    abstract protected function getValidateHandler();
+
+    /**
+     * @param bool $clear
+     * @return Validate
+     */
+    public function validate($clear = false)
+    {
+        if ($clear || is_null($this->validateHandler))
+            $this->validateHandler = $this->getValidateHandler();
+
+        return $this->validateHandler;
+    }
+
+    public function validateFn($callback, $clear = false)
+    {
+        if (is_callable($callback)) $callback($this->validate($clear));
+        return $this;
+    }
+
+    public function setValidate(Validate $validate)
     {
-        $this->validate = array_merge($this->validate,$validate);
+        $this->validateHandler = $validate;
         return $this;
     }
 

+ 1 - 6
src/Helper.php

@@ -28,11 +28,6 @@ class Helper
         return $var;
     }
 
-    public static function getVar($var, $default)
-    {
-        return $var === null ? $default : $var;
-    }
-
     public static function getVarType($var)
     {
         if (is_array($var)) return 'array';
@@ -56,7 +51,7 @@ class Helper
         }
         $type = self::getVarType($var);
         if (!in_array($type, $verify))
-            throw new \Exception($title . '类型为' . implode(',', $verify));
+            throw new \Exception($title . '类型为' . implode(',', $verify));
     }
 
     public static function getDate($date)

+ 4 - 4
src/Json.php

@@ -17,22 +17,22 @@ class Json
 
     public static function succ($msg, $data = [])
     {
-        return self::result(200, $msg, $data);
+        return static::result(200, $msg, $data);
     }
 
     public static function fail($msg, $data = [])
     {
-        return self::result(400, $msg, $data);
+        return static::result(400, $msg, $data);
     }
 
     public static function uploadSucc($filePath, $msg = '上传成功', $data = [])
     {
         $data['filePath'] = $filePath;
-        return self::succ($msg, $data);
+        return static::succ($msg, $data);
     }
 
     public static function uploadFail($msg = '上传失败', $data = [])
     {
-        return self::fail($msg, $data);
+        return static::fail($msg, $data);
     }
 }

+ 9 - 16
src/components/Cascader.php

@@ -75,22 +75,7 @@ class Cascader extends FormComponentDriver
      */
     protected function init()
     {
-        $this->placeholder('请选择' . $this->title);
-    }
-
-    /**
-     * @param string $message
-     * @param string $trigger
-     * @return $this
-     */
-    public function required($message = null, $trigger = 'change')
-    {
-        $this->setRequired(
-            Helper::getVar($message, $this->props['placeholder']),
-            $trigger,
-            'array'
-        );
-        return $this;
+        $this->placeholder($this->getPlaceHolder());
     }
 
     /**
@@ -141,6 +126,14 @@ class Cascader extends FormComponentDriver
     }
 
     /**
+     * @return Validate
+     */
+    protected function getValidateHandler()
+    {
+        return Validate::arr();
+    }
+
+    /**
      * @return array
      */
     public function build()

+ 2 - 8
src/components/Checkbox.php

@@ -56,15 +56,9 @@ class Checkbox extends FormComponentDriver
         return $this;
     }
 
-    /**
-     * @param null $message
-     * @param string $trigger
-     * @return $this
-     */
-    public function required($message = null, $trigger = 'change')
+    protected function getValidateHandler()
     {
-        $this->setRequired(Helper::getVar($message,'请选择'.$this->title),$trigger,'array');
-        return $this;
+        return Validate::arr();
     }
 
     /**

+ 2 - 8
src/components/ColorPicker.php

@@ -60,15 +60,9 @@ class ColorPicker extends FormComponentDriver
         return $this;
     }
 
-    /**
-     * @param string $message
-     * @param string $trigger
-     * @return $this
-     */
-    public function required($message = null, $trigger = 'change')
+    public function getValidateHandler()
     {
-        parent::setRequired(Helper::getVar($message, '请选择' . $this->title), $trigger);
-        return $this;
+        return Validate::str();
     }
 
     /**

+ 9 - 1
src/components/DatePicker.php

@@ -94,7 +94,7 @@ class DatePicker extends FormComponentDriver
      */
     protected function init()
     {
-        $this->placeholder('请选择' . $this->title);
+        $this->placeholder($this->getPlaceHolder());
     }
 
     /**
@@ -114,6 +114,14 @@ class DatePicker extends FormComponentDriver
         return $this;
     }
 
+    public function getValidateHandler()
+    {
+        if(in_array($this->props['type'],['datetimerange','daterange']))
+            return Validate::arr();
+        else
+            return Validate::date();
+    }
+
     /**
      * @return array
      */

+ 6 - 1
src/components/Frame.php

@@ -87,7 +87,12 @@ class Frame extends FormComponentDriver
      */
     protected function init()
     {
-        $this->frameTitle('请选择' . $this->title);
+        $this->frameTitle($this->getPlaceHolder());
+    }
+
+    protected function getValidateHandler()
+    {
+        return Validate::arr();
     }
 
     /**

+ 5 - 0
src/components/Hidden.php

@@ -34,6 +34,11 @@ class Hidden extends FormComponentDriver
         static::value($value);
     }
 
+    protected function getValidateHandler()
+    {
+
+    }
+
     /**
      * @return array
      */

+ 14 - 15
src/components/Input.php

@@ -94,34 +94,33 @@ class Input extends FormComponentDriver
      */
     protected function init()
     {
-        $this->placeholder('请输入' . $this->title);
+        $this->placeholder($this->getPlaceHolder());
     }
 
+    protected function getPlaceHolder($pre = '请输入')
+    {
+        return parent::getPlaceHolder($pre);
+    }
 
-    /**
-     * 自适应内容高度,仅在 textarea 类型下有效
-     * @param Number $minRows
-     * @param Number $maxRows
-     * @return $this
-     */
-    public function autoSize($minRows, $maxRows)
+    protected function getValidateHandler()
     {
-        $this->props['autosize'] = compact('minRows', 'maxRows');
-        return $this;
+        return Validate::str(Validate::TRIGGER_BLUR);
     }
 
+
     /**
-     * 组件的值为必填
-     * @param string $message
+     * 自适应内容高度,仅在 textarea 类型下有效
+     * @param Bool|Number $minRows
+     * @param null|Number $maxRows
      * @return $this
      */
-    public function required($message = null, $trigger = 'blur')
+    public function autoSize($minRows = false, $maxRows = null)
     {
-        parent::setRequired(Helper::getVar($message, $this->getProps('placeholder')), $trigger);
+
+        $this->props['autosize'] = $maxRows === null ?  boolval($minRows) : compact('minRows', 'maxRows');
         return $this;
     }
 
-
     /**
      * 生成表单规则
      * @return array

+ 11 - 1
src/components/InputNumber.php

@@ -51,7 +51,17 @@ class InputNumber extends FormComponentDriver
      */
     protected function init()
     {
-        $this->placeholder('请输入' . $this->title);
+        $this->placeholder($this->getPlaceHolder());
+    }
+
+    protected function getPlaceHolder($pre = '请输入')
+    {
+        return parent::getPlaceHolder($pre);
+    }
+
+    protected function getValidateHandler()
+    {
+        return Validate::num(Validate::TRIGGER_BLUR);
     }
 
     /**

+ 2 - 8
src/components/Radio.php

@@ -46,15 +46,9 @@ class Radio extends FormComponentDriver
         return $this;
     }
 
-    /**
-     * @param string $message
-     * @param string $trigger
-     * @return $this
-     */
-    public function required($message = null, $trigger = 'change')
+    protected function getValidateHandler()
     {
-        $this->setRequired(Helper::getVar($message, '请选择' . $this->title), $trigger);
-        return $this;
+        return Validate::str();
     }
 
     /**

+ 5 - 0
src/components/Rate.php

@@ -39,6 +39,11 @@ class Rate extends FormComponentDriver
         'clearable' => 'boolean',
     ];
 
+    protected function getValidateHandler()
+    {
+        return Validate::num();
+    }
+
     /**
      * @return array
      */

+ 6 - 13
src/components/Select.php

@@ -68,7 +68,7 @@ class Select extends FormComponentDriver
      */
     protected function init()
     {
-        $this->placeholder('请选择' . $this->title);
+        $this->placeholder($this->getPlaceHolder());
     }
 
     /**
@@ -89,19 +89,12 @@ class Select extends FormComponentDriver
     }
 
 
-    /**
-     * @param null $message
-     * @param string $trigger
-     * @return $this
-     */
-    public function required($message = null, $trigger = 'change')
+    protected function getValidateHandler()
     {
-        $this->setRequired(
-            Helper::getVar($message, '请选择' . $this->title),
-            $trigger,
-            $this->props['multiple'] == true ? 'array' : null
-        );
-        return $this;
+        if($this->props['multiple'] == true)
+            return Validate::arr();
+        else
+            return Validate::str();
     }
 
     /**

+ 8 - 0
src/components/Slider.php

@@ -65,6 +65,14 @@ class Slider extends FormComponentDriver
         return $this;
     }
 
+    protected function getValidateHandler()
+    {
+        if($this->props['range'] == true)
+            return Validate::arr();
+        else
+            return Validate::num();
+    }
+
     /**
      * @return array
      */

+ 5 - 0
src/components/Switches.php

@@ -70,6 +70,11 @@ class Switches extends FormComponentDriver
         return $this;
     }
 
+    protected function getValidateHandler()
+    {
+        return Validate::str();
+    }
+
     /**
      * @return array
      */

+ 9 - 1
src/components/TimePicker.php

@@ -75,7 +75,7 @@ class TimePicker extends FormComponentDriver
      */
     protected function init()
     {
-        $this->placeholder('请选择' . $this->title);
+        $this->placeholder($this->getPlaceHolder());
     }
 
     /**
@@ -109,6 +109,14 @@ class TimePicker extends FormComponentDriver
         return $this;
     }
 
+    protected function getValidateHandler()
+    {
+        if($this->props['type'] == 'timerange')
+            return Validate::arr();
+        else
+            return Validate::str();
+    }
+
     /**
      * @return array
      */

+ 10 - 1
src/components/Tree.php

@@ -40,7 +40,8 @@ class Tree extends FormComponentDriver
      */
     protected $props = [
         'type' => self::TYPE_CHECKED,
-        'data' => []
+        'data' => [],
+        'multiple'=>true
     ];
 
     /**
@@ -95,6 +96,14 @@ class Tree extends FormComponentDriver
         return $this;
     }
 
+    protected function getValidateHandler()
+    {
+        if($this->props['multiple'])
+            return Validate::arr();
+        else
+            return Validate::str();
+    }
+
     /**
      * @return array
      */

+ 10 - 8
src/components/Upload.php

@@ -112,15 +112,9 @@ class Upload extends FormComponentDriver
         return $this;
     }
 
-    /**
-     * @param null $message
-     * @param string $trigger
-     * @return $this
-     */
-    public function required($message = null, $trigger = 'change')
+    protected function getPlaceHolder($pre = '请上传')
     {
-        parent::setRequired(Helper::getVar($message, '请上传' . $this->title), $trigger, 'array');
-        return $this;
+        return parent::getPlaceHolder($pre);
     }
 
     /**
@@ -133,6 +127,14 @@ class Upload extends FormComponentDriver
         return $this;
     }
 
+    protected function getValidateHandler()
+    {
+        if($this->props['maxLength'] == 1)
+            return Validate::str();
+        else
+            return Validate::arr();
+    }
+
     /**
      * @return array
      */

+ 185 - 0
src/components/Validate.php

@@ -0,0 +1,185 @@
+<?php
+/**
+ * FormBuilder表单生成器
+ * Author: xaboy
+ * Github: https://github.com/xaboy/form-builder
+ */
+
+namespace FormBuilder\components;
+
+use FormBuilder\interfaces\FormComponentInterFace;
+
+
+class Validate implements FormComponentInterFace
+{
+
+    const TYPE_STRING = 'string';
+
+    const TYPE_ARRAY = 'array';
+
+    const TYPE_NUMBER = 'number';
+
+    const TYPE_DATE = 'date';
+
+    const TRIGGER_CHANGE = 'change';
+
+    const TRIGGER_BLUR = 'blur';
+
+    protected $validate = [];
+
+    protected $type;
+
+    protected $trigger;
+
+    public function __construct($type, $trigger)
+    {
+        $this->type = $type;
+        $this->trigger = $trigger;
+    }
+
+    public static function str($trigger = self::TRIGGER_CHANGE)
+    {
+        return new static(self::TYPE_STRING,$trigger);
+    }
+
+    public static function arr($trigger = self::TRIGGER_CHANGE)
+    {
+        return new static(self::TYPE_ARRAY,$trigger);
+    }
+
+    public static function num($trigger = self::TRIGGER_CHANGE)
+    {
+        return new static(self::TYPE_NUMBER,$trigger);
+    }
+
+    public static function date($trigger = self::TRIGGER_CHANGE)
+    {
+        return new static(self::TYPE_DATE,$trigger);
+    }
+
+    protected function set($validate, $message = null)
+    {
+        $this->validate[] = $validate + [
+                'trigger' => $this->trigger,
+                'type' => $this->type,
+                'message' => $message
+            ];
+    }
+
+    /**
+     * 必须为链接
+     * @param  string|null $message
+     * @return $this
+     */
+    public function url($message = null)
+    {
+        $this->set([
+            'type'=>'url'
+        ],$message);
+        return $this;
+    }
+
+    /**
+     * 必须为邮箱
+     * @param string|null $message
+     * @return $this
+     */
+    public function email($message = null)
+    {
+        $this->set([
+            'type'=>'email'
+        ],$message);
+        return $this;
+    }
+
+    /**
+     * 必填
+     * @param string|null $message
+     * @return $this
+     */
+    public function required($message = null)
+    {
+        $this->set([
+            'required' => true,
+        ], $message);
+        return $this;
+    }
+
+    /**
+     * 长度或值必须在这个范围内
+     * @param int         $min
+     * @param int         $max
+     * @param string|null $message
+     * @return $this
+     */
+    public function range($min, $max, $message = null)
+    {
+        $this->set([
+            'min' => (int)$min,
+            'max' => (int)$max,
+        ], $message);
+        return $this;
+    }
+
+    /**
+     * 长度或值必须大于这个值
+     * @param int         $min
+     * @param string|null $message
+     * @return $this
+     */
+    public function min($min, $message = null)
+    {
+        $this->set([
+            'min' => (int)$min,
+        ], $message);
+        return $this;
+    }
+
+    /**
+     * 长度或值必须小于这个值
+     * @param int         $max
+     * @param string|null $message
+     * @return $this
+     */
+    public function max($max, $message = null)
+    {
+        $this->set([
+            'max' => (int)$max,
+        ], $message);
+        return $this;
+    }
+
+    /**
+     * 长度或值必须等于这个值
+     * @param int         $length
+     * @param string|null $message
+     * @return $this
+     */
+    public function length($length, $message = null)
+    {
+        $this->set([
+            'length' => (int)$length
+        ], $message);
+        return $this;
+    }
+
+    /**
+     * 值必须在 list 中
+     * @param array       $list
+     * @param string|null $message
+     * @return $this
+     */
+    public function enum($list, $message = null)
+    {
+        $this->set([
+            'type'=>'enum',
+            'enum' => (array)$list
+        ], $message);
+        return $this;
+    }
+
+    public function build()
+    {
+        return $this->validate;
+    }
+}

+ 49 - 0
src/traits/form/FormValidateTrait.php

@@ -0,0 +1,49 @@
+<?php
+/**
+ * FormBuilder表单生成器
+ * Author: xaboy
+ * Github: https://github.com/xaboy/form-builder
+ */
+
+namespace FormBuilder\traits\form;
+
+
+use FormBuilder\components\Validate;
+
+trait FormValidateTrait
+{
+    public static function validateStr()
+    {
+        return Validate::str();
+    }
+
+    public static function validateInput()
+    {
+        return Validate::str(Validate::TRIGGER_BLUR);
+    }
+
+    public static function validateArr()
+    {
+        return Validate::arr();
+    }
+
+    public static function validateNum()
+    {
+        return Validate::num();
+    }
+
+    public static function validateNumInput()
+    {
+        return Validate::num(Validate::TRIGGER_BLUR);
+    }
+
+    public static function validateDate()
+    {
+        return Validate::date();
+    }
+
+    public static function validateFrame()
+    {
+        return self::ValidateArr();
+    }
+}

+ 2 - 0
src/view/formScript.php

@@ -17,6 +17,8 @@
             el: el,
             form:<?=json_encode($form->getConfig('form'))?>,
             row:<?=json_encode($form->getConfig('row'))?>,
+			submitBtn:<?=$form->submitBtn ? 'true' : 'false'?>,
+			resetBtn:<?=$form->resetBtn ? 'true' : 'false'?>,
             upload: {
                 onExceededSize: function (file) {
                     vm.$Message.error(file.name + '超出指定大小限制');