sugar1569 7 năm trước cách đây
mục cha
commit
26f3daba97
31 tập tin đã thay đổi với 412 bổ sung237 xóa
  1. 2 0
      application/admin/controller/article/Article.php
  2. 1 1
      application/admin/controller/setting/SystemConfig.php
  3. 1 1
      application/admin/controller/setting/SystemConfigTab.php
  4. 1 1
      application/admin/model/system/SystemConfig.php
  5. 1 1
      application/admin/model/system/SystemConfigTab.php
  6. 1 1
      application/admin/view/setting/system_config_tab/sonconfigtab.php
  7. 20 17
      composer.lock
  8. 20 19
      vendor/composer/installed.json
  9. 13 5
      vendor/xaboy/form-builder/README.md
  10. 4 3
      vendor/xaboy/form-builder/composer.json
  11. 107 11
      vendor/xaboy/form-builder/src/Form.php
  12. 63 20
      vendor/xaboy/form-builder/src/FormComponentDriver.php
  13. 1 6
      vendor/xaboy/form-builder/src/Helper.php
  14. 4 4
      vendor/xaboy/form-builder/src/Json.php
  15. 9 16
      vendor/xaboy/form-builder/src/components/Cascader.php
  16. 2 8
      vendor/xaboy/form-builder/src/components/Checkbox.php
  17. 2 8
      vendor/xaboy/form-builder/src/components/ColorPicker.php
  18. 9 1
      vendor/xaboy/form-builder/src/components/DatePicker.php
  19. 6 1
      vendor/xaboy/form-builder/src/components/Frame.php
  20. 5 0
      vendor/xaboy/form-builder/src/components/Hidden.php
  21. 14 15
      vendor/xaboy/form-builder/src/components/Input.php
  22. 11 1
      vendor/xaboy/form-builder/src/components/InputNumber.php
  23. 2 8
      vendor/xaboy/form-builder/src/components/Radio.php
  24. 5 0
      vendor/xaboy/form-builder/src/components/Rate.php
  25. 6 13
      vendor/xaboy/form-builder/src/components/Select.php
  26. 8 0
      vendor/xaboy/form-builder/src/components/Slider.php
  27. 5 0
      vendor/xaboy/form-builder/src/components/Switches.php
  28. 9 1
      vendor/xaboy/form-builder/src/components/TimePicker.php
  29. 10 1
      vendor/xaboy/form-builder/src/components/Tree.php
  30. 10 8
      vendor/xaboy/form-builder/src/components/Upload.php
  31. 60 66
      vendor/xaboy/form-builder/src/view/formScript.php

+ 2 - 0
application/admin/controller/article/Article.php

@@ -131,6 +131,8 @@ class Article extends AuthController
             ['visit',0],
             ['sort',0],
             'url',
+            ['is_banner',0],
+            ['is_hot',0],
             ['status',1],],$request);
         $data['cid'] = implode(',',$data['cid']);
         $content = $data['content'];

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 1 - 1
application/admin/controller/setting/SystemConfig.php


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 1 - 1
application/admin/controller/setting/SystemConfigTab.php


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 1 - 1
application/admin/model/system/SystemConfig.php


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 1 - 1
application/admin/model/system/SystemConfigTab.php


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 1 - 1
application/admin/view/setting/system_config_tab/sonconfigtab.php


+ 20 - 17
composer.lock

@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "ae2e50326d8e83fd299c3350bb0f87d1",
+    "content-hash": "3dd0118e5d08ef728cb0c2f4f7de15a5",
     "packages": [
         {
             "name": "doctrine/cache",
@@ -871,16 +871,16 @@
         },
         {
             "name": "topthink/framework",
-            "version": "v5.0.11",
+            "version": "v5.0.21",
             "source": {
                 "type": "git",
                 "url": "https://github.com/top-think/framework.git",
-                "reference": "926c9edb0c2682b14f563cac2c8a93f42f729016"
+                "reference": "ab826da071a7a47116a7f1d01f72228d6bcf212a"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/top-think/framework/zipball/926c9edb0c2682b14f563cac2c8a93f42f729016",
-                "reference": "926c9edb0c2682b14f563cac2c8a93f42f729016",
+                "url": "https://api.github.com/repos/top-think/framework/zipball/ab826da071a7a47116a7f1d01f72228d6bcf212a",
+                "reference": "ab826da071a7a47116a7f1d01f72228d6bcf212a",
                 "shasum": ""
             },
             "require": {
@@ -918,7 +918,7 @@
                 "orm",
                 "thinkphp"
             ],
-            "time": "2017-09-13T03:30:29+00:00"
+            "time": "2018-09-04T09:18:48+00:00"
         },
         {
             "name": "topthink/think-captcha",
@@ -1078,16 +1078,16 @@
         },
         {
             "name": "tp5er/tp5-databackup",
-            "version": "1.0.0",
+            "version": "dev-master",
             "source": {
                 "type": "git",
                 "url": "https://github.com/tp5er/tp5-databackup.git",
-                "reference": "10abd4383cf78844e1c22584fd823ef1d18e75dc"
+                "reference": "101477abe810fb91bad5c1304a93c5f461db6dc8"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/tp5er/tp5-databackup/zipball/10abd4383cf78844e1c22584fd823ef1d18e75dc",
-                "reference": "10abd4383cf78844e1c22584fd823ef1d18e75dc",
+                "url": "https://api.github.com/repos/tp5er/tp5-databackup/zipball/101477abe810fb91bad5c1304a93c5f461db6dc8",
+                "reference": "101477abe810fb91bad5c1304a93c5f461db6dc8",
                 "shasum": ""
             },
             "require": {
@@ -1110,23 +1110,24 @@
                 }
             ],
             "description": "Implement the database backup restore",
-            "time": "2017-12-29T05:36:58+00:00"
+            "time": "2018-04-07T11:20:53+00:00"
         },
         {
             "name": "xaboy/form-builder",
-            "version": "1.2.3",
+            "version": "1.2.5",
             "source": {
                 "type": "git",
                 "url": "https://github.com/xaboy/form-builder.git",
-                "reference": "1b11a518429db5828147d5840ea18480586caa0c"
+                "reference": "73cb5be3d9f57680f64d01ab424c4ac5c462f1b8"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/xaboy/form-builder/zipball/1b11a518429db5828147d5840ea18480586caa0c",
-                "reference": "1b11a518429db5828147d5840ea18480586caa0c",
+                "url": "https://api.github.com/repos/xaboy/form-builder/zipball/73cb5be3d9f57680f64d01ab424c4ac5c462f1b8",
+                "reference": "73cb5be3d9f57680f64d01ab424c4ac5c462f1b8",
                 "shasum": ""
             },
             "require": {
+                "ext-json": "*",
                 "php": ">=5.4.0"
             },
             "type": "library",
@@ -1147,13 +1148,15 @@
             ],
             "description": "PHP表单生成器,快速生成现代化的form表单。包含复选框、单选框、输入框、下拉选择框等元素以及,省市区三级联动,时间选择,日期选择,颜色选择,文件/图片上传等功能。",
             "homepage": "https://github.com/xaboy/form-builder",
-            "time": "2018-08-07T06:29:30+00:00"
+            "time": "2018-11-13T12:44:31+00:00"
         }
     ],
     "packages-dev": [],
     "aliases": [],
     "minimum-stability": "stable",
-    "stability-flags": [],
+    "stability-flags": {
+        "tp5er/tp5-databackup": 20
+    },
     "prefer-stable": false,
     "prefer-lowest": false,
     "platform": {

+ 20 - 19
vendor/composer/installed.json

@@ -894,17 +894,17 @@
     },
     {
         "name": "topthink/framework",
-        "version": "v5.0.11",
-        "version_normalized": "5.0.11.0",
+        "version": "v5.0.21",
+        "version_normalized": "5.0.21.0",
         "source": {
             "type": "git",
             "url": "https://github.com/top-think/framework.git",
-            "reference": "926c9edb0c2682b14f563cac2c8a93f42f729016"
+            "reference": "ab826da071a7a47116a7f1d01f72228d6bcf212a"
         },
         "dist": {
             "type": "zip",
-            "url": "https://api.github.com/repos/top-think/framework/zipball/926c9edb0c2682b14f563cac2c8a93f42f729016",
-            "reference": "926c9edb0c2682b14f563cac2c8a93f42f729016",
+            "url": "https://api.github.com/repos/top-think/framework/zipball/ab826da071a7a47116a7f1d01f72228d6bcf212a",
+            "reference": "ab826da071a7a47116a7f1d01f72228d6bcf212a",
             "shasum": ""
         },
         "require": {
@@ -919,7 +919,7 @@
             "phpunit/phpunit": "4.8.*",
             "sebastian/phpcpd": "2.*"
         },
-        "time": "2017-09-13T03:30:29+00:00",
+        "time": "2018-09-04T09:18:48+00:00",
         "type": "think-framework",
         "installation-source": "dist",
         "autoload": {
@@ -1111,25 +1111,25 @@
     },
     {
         "name": "tp5er/tp5-databackup",
-        "version": "1.0.0",
-        "version_normalized": "1.0.0.0",
+        "version": "dev-master",
+        "version_normalized": "9999999-dev",
         "source": {
             "type": "git",
             "url": "https://github.com/tp5er/tp5-databackup.git",
-            "reference": "10abd4383cf78844e1c22584fd823ef1d18e75dc"
+            "reference": "101477abe810fb91bad5c1304a93c5f461db6dc8"
         },
         "dist": {
             "type": "zip",
-            "url": "https://api.github.com/repos/tp5er/tp5-databackup/zipball/10abd4383cf78844e1c22584fd823ef1d18e75dc",
-            "reference": "10abd4383cf78844e1c22584fd823ef1d18e75dc",
+            "url": "https://api.github.com/repos/tp5er/tp5-databackup/zipball/101477abe810fb91bad5c1304a93c5f461db6dc8",
+            "reference": "101477abe810fb91bad5c1304a93c5f461db6dc8",
             "shasum": ""
         },
         "require": {
             "php": ">=5.4.0"
         },
-        "time": "2017-12-29T05:36:58+00:00",
+        "time": "2018-04-07T11:20:53+00:00",
         "type": "library",
-        "installation-source": "dist",
+        "installation-source": "source",
         "autoload": {
             "psr-4": {
                 "tp5er\\": "src/"
@@ -1149,23 +1149,24 @@
     },
     {
         "name": "xaboy/form-builder",
-        "version": "1.2.3",
-        "version_normalized": "1.2.3.0",
+        "version": "1.2.5",
+        "version_normalized": "1.2.5.0",
         "source": {
             "type": "git",
             "url": "https://github.com/xaboy/form-builder.git",
-            "reference": "1b11a518429db5828147d5840ea18480586caa0c"
+            "reference": "73cb5be3d9f57680f64d01ab424c4ac5c462f1b8"
         },
         "dist": {
             "type": "zip",
-            "url": "https://api.github.com/repos/xaboy/form-builder/zipball/1b11a518429db5828147d5840ea18480586caa0c",
-            "reference": "1b11a518429db5828147d5840ea18480586caa0c",
+            "url": "https://api.github.com/repos/xaboy/form-builder/zipball/73cb5be3d9f57680f64d01ab424c4ac5c462f1b8",
+            "reference": "73cb5be3d9f57680f64d01ab424c4ac5c462f1b8",
             "shasum": ""
         },
         "require": {
+            "ext-json": "*",
             "php": ">=5.4.0"
         },
-        "time": "2018-08-07T06:29:30+00:00",
+        "time": "2018-11-13T12:44:31+00:00",
         "type": "library",
         "installation-source": "dist",
         "autoload": {

+ 13 - 5
vendor/xaboy/form-builder/README.md

@@ -1,5 +1,9 @@
-# form-builder
-
+<p align="center">
+    <a href="https://github.com/xaboy/form-builder">
+        <img width="200" src="http://file.lotkk.com/form-builder.png">
+    </a>
+</p>
+<h1 align="center">form-builder</h1>
 <p align="center">
     <img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="MIT" />
   <a href="https://github.com/xaboy">
@@ -17,19 +21,22 @@
 PHP表单生成器,快速生成现代化的form表单。包含复选框、单选框、输入框、下拉选择框等元素以及省市区三级联动、时间选择、日期选择、颜色选择、树型、文件/图片上传等功能。
 </p>
 
+> 1.2.4 版本支持简单字段验证 
 
 #### 如果对您有帮助,您可以点右上角 "Star" 支持一下 谢谢!
  
 #### 本项目还在不断开发完善中,如有建议或问题请[在这里提出](https://github.com/xaboy/form-builder/issues/new)
 
-
 ## 安装
 `composer require xaboy/form-builder`
 
 ## 示例
 
-![https://raw.githubusercontent.com/xaboy/form-builder/master/demo.jpg](https://raw.githubusercontent.com/xaboy/form-builder/master/demo.jpg)
+![https://raw.githubusercontent.com/xaboy/form-create/master/images/sample110.jpg](https://raw.githubusercontent.com/xaboy/form-create/master/images/sample110.jpg)
 
+## 演示地址
+演示站后台:[ crmeb_v2.5 ]
+http://demo25.crmeb.net 账号:demo 密码:crmeb.com
 
 ### 例子 (TP框架)
 
@@ -267,7 +274,8 @@ echo $html;
 ## 以下组件公共方法
 * **col($span)** 配置col栅格规则,传入0-24的数字或`Col`类,默认为24
 * **value($value)** 设置组件的值
-* **validate(array $validate)** 添加验证规则
+* **validateAs(array $validate)** 添加验证规则
+* **validate()** 设置验证规则[规则说明](https://github.com/xaboy/form-builder/blob/master/src/components/Validate.php)
 
 ## 组件
 `namespace \FormBuilder\Form`

+ 4 - 3
vendor/xaboy/form-builder/composer.json

@@ -2,7 +2,7 @@
     "name": "xaboy/form-builder",
     "description": "PHP表单生成器,快速生成现代化的form表单。包含复选框、单选框、输入框、下拉选择框等元素以及,省市区三级联动,时间选择,日期选择,颜色选择,文件/图片上传等功能。",
     "license": "MIT",
-    "keyword": ["form","form-create","form-init","dynamic-form"],
+    "keyword": ["form","form-create","form-init","dynamic-form","php-form"],
     "homepage": "https://github.com/xaboy/form-builder",
     "authors": [
         {
@@ -20,10 +20,11 @@
         "source": "https://github.com/xaboy/form-builder"
     },
     "require": {
-        "php": ">=5.4.0"
+        "php": ">=5.4.0",
+        "ext-json": "*"
     },
     "minimum-stability": "stable",
     "branch-alias": {
-        "dev-master": "1.0.x-dev"
+        "master": "1.0.x-dev"
     }
 }

+ 107 - 11
vendor/xaboy/form-builder/src/Form.php

@@ -9,6 +9,7 @@ namespace FormBuilder;
 
 use FormBuilder\components\Cascader;
 use FormBuilder\components\FormStyle;
+use FormBuilder\components\Hidden;
 use FormBuilder\components\Row;
 use FormBuilder\traits\form\FormCascaderTrait;
 use FormBuilder\traits\form\FormCheckBoxTrait;
@@ -28,6 +29,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 +54,8 @@ class Form
         FormTimePickerTrait,
         FormTreeTrait,
         FormStyleTrait,
-        FormOptionTrait;
+        FormOptionTrait,
+        FormValidateTrait;
 
     /**
      * 三级联动 加载省市数据
@@ -85,12 +88,30 @@ class Form
         //iview 版本 2.14.3
         'iview-css' => '<link href="https://cdn.jsdelivr.net/npm/iview@2.14.3/dist/styles/iview.css" rel="stylesheet">',
         'iview' => '<script src="https://cdn.jsdelivr.net/npm/iview@2.14.3/dist/iview.min.js"></script>',
-        //form-create 版本 1.3.3
-        'form-create' => '<script src="https://cdn.jsdelivr.net/npm/form-create@1.4.0/dist/form-create.min.js"></script>',
+        //form-create 版本 1.4.5
+        'form-create' => '<script src="https://cdn.jsdelivr.net/npm/form-create@1.4.5/dist/form-create.min.js"></script>',
         'city-data' => '<script src="https://cdn.jsdelivr.net/npm/form-create/district/province_city.js"></script>',
         'city-area-data' => '<script src="https://cdn.jsdelivr.net/npm/form-create/district/province_city_area.js"></script>'
     ];
 
+    /**
+     * 加载 jquery
+     * @var bool
+     */
+    protected $linkJq = true;
+
+    /**
+     * 加载 vue
+     * @var bool
+     */
+    protected $linkVue = true;
+
+    /**
+     * 加载 iview
+     * @var bool
+     */
+    protected $linkIview = true;
+
     /**
      * @var string
      */
@@ -120,6 +141,10 @@ class Form
      */
     protected $method = 'post';
 
+    protected $resetBtn = false;
+
+    protected $submitBtn = true;
+
     /**
      * 表单配置
      * @var array|mixed
@@ -146,6 +171,30 @@ class Form
         $this->action = $action;
     }
 
+    /**
+     * @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
      */
@@ -334,6 +383,7 @@ class Form
     }
 
     /**
+     * 是否需要引入省市区数据
      * @param FormComponentDriver $component
      */
     protected function checkLoadData(FormComponentDriver $component)
@@ -361,7 +411,10 @@ class Form
             $component = $this->components[$field];
             if (!($component instanceof FormComponentDriver))
                 continue;
-            $rules[] = $component->build();
+            $rule = $component->build();
+            if(!$component instanceof Hidden)
+                $rule['validate'] = array_merge(isset($rule['validate']) ? $rule['validate'] : [],$component->validate()->build());
+            $rules[] = $rule;
         }
         return $rules;
     }
@@ -397,7 +450,6 @@ class Form
     {
         ob_start();
         $form = $this;
-        $rule = $this->getRules();
         require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'view' . DIRECTORY_SEPARATOR . 'formScript.php';
         $script = ob_get_clean();
         return $script;
@@ -412,17 +464,61 @@ class Form
     {
         $_script = $this->script;
         $script = [
-            $_script['iview-css'],
-            $_script['jq'],
-            $_script['vue'],
-            $_script['iview'],
             $_script['form-create']
         ];
         if ($this->loadCityAreaData == true)
             $script[] = $_script['city-area-data'];
         if ($this->loadCityData == true)
             $script[] = $_script['city-data'];
-        return $script;
+        if($this->linkJq)
+            $script[] = $_script['jq'];
+        if($this->linkIview){
+            $script[] = $_script['iview'];
+            $script[] = $_script['iview-css'];
+        }
+        if($this->linkVue)
+            $script[] = $_script['vue'];
+        return array_reverse($script);
+    }
+
+    /**
+     * 是否隐藏提交按钮(默认显示)
+     * @param bool $isShow
+     * @return Form
+     */
+    public function hiddenSubmitBtn($isShow = false)
+    {
+        $this->submitBtn = !(bool)$isShow;
+
+        return $this;
+    }
+
+    /**
+     * 是否隐藏重置按钮(默认隐藏)
+     * @param bool $isShow
+     * @return Form
+     */
+    public function hiddenResetBtn($isShow = false)
+    {
+        $this->resetBtn = !(bool)$isShow;
+
+        return $this;
+    }
+
+    /**
+     * @return bool
+     */
+    public function isResetBtn()
+    {
+        return $this->resetBtn;
+    }
+
+    /**
+     * @return bool
+     */
+    public function isSubmitBtn()
+    {
+        return $this->submitBtn;
     }
 
     /**
@@ -433,6 +529,6 @@ class Form
      */
     public static function create($action, array $components = [])
     {
-        return new self($action, $components);
+        return new static($action, $components);
     }
 }

+ 63 - 20
vendor/xaboy/form-builder/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
vendor/xaboy/form-builder/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
vendor/xaboy/form-builder/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
vendor/xaboy/form-builder/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());
     }
 
     /**
@@ -140,6 +125,14 @@ class Cascader extends FormComponentDriver
         return $this->props['type'];
     }
 
+    /**
+     * @return Validate
+     */
+    protected function getValidateHandler()
+    {
+        return Validate::arr();
+    }
+
     /**
      * @return array
      */

+ 2 - 8
vendor/xaboy/form-builder/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
vendor/xaboy/form-builder/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
vendor/xaboy/form-builder/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
vendor/xaboy/form-builder/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
vendor/xaboy/form-builder/src/components/Hidden.php

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

+ 14 - 15
vendor/xaboy/form-builder/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
vendor/xaboy/form-builder/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
vendor/xaboy/form-builder/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
vendor/xaboy/form-builder/src/components/Rate.php

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

+ 6 - 13
vendor/xaboy/form-builder/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
vendor/xaboy/form-builder/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
vendor/xaboy/form-builder/src/components/Switches.php

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

+ 9 - 1
vendor/xaboy/form-builder/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
vendor/xaboy/form-builder/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
vendor/xaboy/form-builder/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
      */

+ 60 - 66
vendor/xaboy/form-builder/src/view/formScript.php

@@ -1,77 +1,71 @@
 (function () {
     var getRule = function () {
-        var rule = <?=json_encode($rule)?>;
+        var rule = <?=json_encode($form->getRules())?>;
         rule.forEach(function (c) {
-            if((c.type == 'cascader' || c.type == 'tree') && Object.prototype.toString.call(c.props.data) == '[object String]'){
-				if(c.props.data.indexOf('js.') === 0){
-					c.props.data = window[c.props.data.replace('js.','')];
-				}
+            if ((c.type == 'cascader' || c.type == 'tree') && Object.prototype.toString.call(c.props.data) == '[object String]') {
+                if (c.props.data.indexOf('js.') === 0) {
+                    c.props.data = window[c.props.data.replace('js.', '')];
+                }
             }
         });
         return rule;
-    },vm = new Vue;
-    return function create(el,callback) {
-        var formData = {};
-        if(!el) el = document.body;
-        $f = formCreate.create(getRule(),{
-                el:el,
-                form:<?=json_encode($form->getConfig('form'))?>,
-				row:<?=json_encode($form->getConfig('row'))?>,
-        upload:{
-            onExceededSize:function (file) {
-                vm.$Message.error(file.name + '超出指定大小限制');
-            },
-            onFormatError:function () {
-                vm.$Message.error(file.name + '格式验证失败');
-            },
-            onError:function (error) {
-                vm.$Message.error(file.name + '上传失败,('+ error +')');
-            },
-            onSuccess:function (res) {
-                if(res.code == 200){
-                    return res.data.filePath;
-                }else{
-                    vm.$Message.error(res.msg);
+    }, vm = new Vue,name = 'formBuilderExec<?= !$form->getId() ? '' : '_'.$form->getId() ?>';
+
+    window[name] =  function create(el, callback) {
+        if (!el) el = document.body;
+        $f = formCreate.create(getRule(), {
+            el: el,
+            form:<?=json_encode($form->getConfig('form'))?>,
+            row:<?=json_encode($form->getConfig('row'))?>,
+			submitBtn:<?=$form->isSubmitBtn() ? '{}' : 'false'?>,
+			resetBtn:<?=$form->isResetBtn() ? 'true' : '{}'?>,
+            upload: {
+                onExceededSize: function (file) {
+                    vm.$Message.error(file.name + '超出指定大小限制');
+                },
+                onFormatError: function () {
+                    vm.$Message.error(file.name + '格式验证失败');
+                },
+                onError: function (error) {
+                    vm.$Message.error(file.name + '上传失败,(' + error + ')');
+                },
+                onSuccess: function (res) {
+                    if (res.code == 200) {
+                        return res.data.filePath;
+                    } else {
+                        vm.$Message.error(res.msg);
+                    }
                 }
-            }
-        },
-        //表单提交事件
-        onSubmit: function (formData) {
-            $f.submitStatus({loading: true});
-            $.ajax({
-                url:'<?=$form->getAction()?>',
-                type:'<?=$form->getMethod()?>',
-                dataType:'json',
-                data:formData,
-                success:function (res) {
-                    if(res.code == 200){
-                        vm.$Message.success(res.msg);
-                        formCreate.formSuccess && formCreate.formSuccess(res,$f,formData);
-						callback && callback(0,res,$f,formData);
-                        $f.submitStatus({loading: false});
-                        var index = parent.layer.getFrameIndex(window.name);
-                        parent.layer.close(index);
-                        try{
-                            parent.formSuccess();
-                        }catch(e){
-                            console.log(e);
+            },
+            //表单提交事件
+            onSubmit: function (formData) {
+                $f.submitStatus({loading: true});
+                $.ajax({
+                    url: '<?=$form->getAction()?>',
+                    type: '<?=$form->getMethod()?>',
+                    dataType: 'json',
+                    data: formData,
+                    success: function (res) {
+                        if (res.code == 200) {
+                            vm.$Message.success(res.msg);
+                            formCreate.formSuccess && formCreate.formSuccess(res, $f, formData);
+                            callback && callback(0, res, $f, formData);
+                            //TODO 表单提交成功!
+                        } else {
+                            vm.$Message.error(res.msg);
+                            $f.btn.finish();
+                            callback && callback(1, res, $f, formData);
+                            //TODO 表单提交失败
                         }
-						//TODO 表单提交成功!
-                    }else{
-						vm.$Message.error(res.msg);
+                    },
+                    error: function () {
+                        vm.$Message.error('表单提交失败');
                         $f.btn.finish();
-						callback && callback(1,res,$f,formData);
-                        $f.submitStatus({loading: false});
-						//TODO 表单提交失败
                     }
-                },
-                error:function () {
-                    vm.$Message.error('表单提交失败');
-                    $f.btn.finish();
-                }
-            });
-        }
-    });
-        return formData;
+                });
+            }
+        });
+        return $f;
     };
-}());
+    return window[name];
+}());