2 Star 28 Fork 25

jjxliu306 / ngtool

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

ngtool

介绍

ng-form动态表单生态之后端校验、pdf生成等工具集

简介

配套ng-form前端动态表单的后端服务,ng-form前端组件一览:

element-ui版本地址: https://gitee.com/jjxliu306/ng-form-element

iview版本地址: https://gitee.com/jjxliu306/ng-form-iview

element-plus版本地址: https://gitee.com/jjxliu306/ng-form-elementplus

安装

<dependency>
	<groupId>io.github.jjxliu306</groupId>
	<artifactId>ng-form-core</artifactId>
	<version>1.0.1</version>
</dependency>

使用示例

package com.ng;

import java.io.IOException;

import org.apache.commons.io.IOUtils;

import com.alibaba.fastjson.JSON;
import com.ng.form.validator.NgFormValidator;
import com.ng.form.validator.entity.FormValidator;

public class TestValidator {

	public void test1() throws IOException {
		
		String template = IOUtils.toString(getClass().getResource("/template.json") , "UTF-8");
		String value = IOUtils.toString(getClass().getResource("/value.json") , "UTF-8");
		
		NgFormValidator validator = new NgFormValidator();
		FormValidator fv = validator.validator(template, value);
		
		System.out.println(JSON.toJSONString(fv));
		
	}
	
	
	public static void main(String[] args) throws IOException {
		TestValidator test = new TestValidator();
		test.test1();
	}
}

其中template.json如下

{
	"list": [
		{
			"type": "input",
			"label": "姓名",
			"options": {
				"type": "text",
				"width": "100%",
				"defaultValue": "",
				"placeholder": "请输入",
				"clearable": false,
				"maxLength": 0,
				"prepend": "",
				"append": "",
				"tooptip": "",
				"hidden": false,
				"disabled": false,
				"dynamicHide": false,
				"dynamicHideValue": ""
			},
			"model": "name",
			"key": "input_1628755200021",
			"rules": [
				{
					"required": true,
					"message": "姓名不能为空",
					"trigger": [
						"blur"
					]
				}
			]
		},
		{
			"type": "textarea",
			"label": "地址",
			"options": {
				"width": "100%",
				"maxLength": 0,
				"defaultValue": "",
				"rows": 4,
				"clearable": false,
				"tooptip": "",
				"hidden": false,
				"disabled": false,
				"placeholder": "请输入",
				"dynamicHide": false,
				"dynamicHideValue": ""
			},
			"model": "address",
			"key": "textarea_1628755200021",
			"rules": [
				{
					"required": true,
					"message": "地址不能为空",
					"trigger": [
						"blur"
					]
				}
			]
		},
		{
			"type": "radio",
			"label": "性别",
			"options": {
				"disabled": false,
				"hidden": false,
				"defaultValue": "1",
				"dynamic": 0,
				"tooptip": "",
				"remoteFunc": "",
				"dataPath": "",
				"remoteValue": "",
				"remoteLabel": "",
				"linkage": false,
				"options": [
					{
						"value": "1",
						"label": "男"
					},
					{
						"value": "2",
						"label": "女"
					}
				],
				"dynamicHide": false,
				"dynamicHideValue": ""
			},
			"model": "sex",
			"key": "radio_1628755200021",
			"rules": [
				{
					"required": false,
					"message": "性别不能为空",
					"trigger": [
						"change",
						"blur"
					]
				}
			]
		},
		{
			"type": "textarea",
			"label": "男性输入",
			"options": {
				"width": "100%",
				"maxLength": 0,
				"defaultValue": "",
				"rows": 4,
				"clearable": false,
				"tooptip": "",
				"hidden": false,
				"disabled": false,
				"placeholder": "请输入",
				"dynamicHide": false,
				"dynamicHideValue": ""
			},
			"model": "nanInput",
			"key": "textarea_1628755202176",
			"rules": [
				{
					"required": false,
					"message": "男性输入不能为空",
					"trigger": [
						"blur"
					]
				},
				{
					"vtype": 2,
					"pattern": "",
					"script": "if($.sex == 1){\nreturn $.nanInput\n}else{\nreturn true\n}",
					"message": "男性输入不能为空",
					"required": false,
					"trigger": [
						"change",
						"blur"
					]
				}
			]
		}
	],
	"config": {
		"labelPosition": "left",
		"labelWidth": 100,
		"size": "mini",
		"outputHidden": true,
		"hideRequiredMark": true,
		"customStyle": ""
	}
}

value.json如下

{"name":"小米" , "address":"" , "sex":1 }

最终输出结果如下


{
    "failField":[
        {
            "fieldName":"地址",
            "message":"地址不能为空",
            "model":"address",
            "type":"textarea"
        },
        {
            "fieldName":"男性输入",
            "message":"男性输入不能为空",
            "model":"nanInput",
            "type":"textarea"
        }
    ],
    "result":false
}

api说明

在线api地址: https://apidoc.gitee.com/jjxliu306/ngtool/

交流

点击链接加入qq群聊,可以直接提问及反馈bug 【交流群:203205848】 vue-form-design

MIT License Copyright (c) 2021 jjxliu306 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

ng-form动态表单生态之后端校验、pdf生成等工具集 展开 收起
Java
MIT
取消

发行版 (1)

全部

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/jjxliu306/ngtool.git
git@gitee.com:jjxliu306/ngtool.git
jjxliu306
ngtool
ngtool
master

搜索帮助