1.1.3 • Published 5 years ago

d-tree-form v1.1.3

Weekly downloads
7
License
MIT
Repository
github
Last release
5 years ago

d-tree-form

Build Status NPM Download NPM Version NPM License PRs Welcome Automated Release Notes by gren

short description + sample image(png/gif/mp4)

Table of Contents

Introduction

一个通过脚手架参数转化成树形动态表单的组件

⬆ Back to Top

Features

  1. 目前支持 input,textarea,select 三种表单项
  2. type=select 时支持多层子节点
  3. 目前仅支持 required 的校验规则

Data Structure

Demo

image.png

[
  {
    label: '作者',
    type: 'input',
    prop: 'author',
    value: '',
    tooltips: 'xxx',
    componentProps: {
      placeholder: '请输入内容',
    },
    rules: [{required: true, message: '这是必填'}],
  },
  {
    label: '路由',
    type: 'select',
    prop: 'router',
    value: '',
    options: [
      {
        label: 'mongo',
        value: 'mongo',
      },
      {
        label: 'mysql',
        value: 'mysql',
      },
      {
        label: 'none',
        value: 'none',
      },
    ],
  },

  {
    label: '配置中心',
    type: 'select',
    prop: 'configCenter',
    value: '',
    options: [
      {
        label: 'apollo',
        value: 'apollo',
      },
      {
        label: 'none',
        value: 'none',
      },
    ],
  },
  {
    label: 'APM',
    type: 'select',
    prop: 'apm',
    value: '',
    options: [
      {
        label: 'skywalking',
        value: 'skywalking',
        childNodes: [
          {
            label: 'skywalking Servers地址:',
            type: 'input',
            prop: 'skywalkingServers',
            value: '',
            labelWidth: '200px',
            rules: [
              {required: true, message: '请输入skywalking Servers地址'},
            ],
          },
          {
            label: 'skywalking Servers地址2:',
            type: 'input',
            prop: 'skywalkingServers2',
            value: '',
            labelWidth: '200px',
            rules: [
              {required: true, message: '请输入skywalking Servers地址'},
            ],
          },
        ]
      },
      {
        label: 'none',
        value: 'none',
      }
    ],
  },
],

form-item props

参数类型说明必须默认值备注
labelString字段中文名--
propString字段的 key,必须唯一--
valueStringNumberBoolean字段的值空字符串-
typeString该表单项的类型仅支持inputselecttextarea
labelWidthString字段中文名的宽度
tooltipsString问号提示语
rulesArray校验规则,详看下面
optionsArray下拉框选项,详看下面type="select"时必填
componentPropsObject传给表单的属性对象,详看下面
childrenArray子节点每一项和 formitem 属性一致

select options

参数类型说明必须默认值备注
labelString下拉选项的显示值--
valueStringNumberBoolean下拉选项的用于提交的值
childNodesArray该 option 子节点选中该 option 需要子节点时使用,数组的项为 form-item,不支持子节点下还有子节点

rules

支持 Element-ui Form 的校验规则,不支持函数校验参考:https://element.eleme.cn/#/zh-CN/component/form#biao-dan-yan-zheng基本用法:image.png常用字段

参数类型说明必须默认值备注
typeString校验的类型stringimage.png
requiredBoolean是否必填falsetrue 是在表单项前面会有一个星
messageString校验不通过提示语-
patternString校验正则-正则校验使用字符串形式,因为 JSON 中不支持存储正则表达式类型
triggerString验证触发方式changeblur 失去焦点时change 改变值时
minNumber最小长度
maxNumber最大长度
lenNumber最大长度如果 len 属性与最小和最大范围属性组合,则 len 优先。
...

更多高级用法  https://github.com/yiminghe/async-validator

⬆ Back to Top

Links

⬆ Back to Top

Install

⬆ Back to Top

Contributing

For those who are interested in contributing to this project, such as:

  • report a bug
  • request new feature
  • fix a bug
  • implement a new feature

Please refer to our contributing guide.

⬆ Back to Top

Contributors

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

⬆ Back to Top

License

MIT

⬆ Back to Top

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago