├── .eslintignore
├── .npmrc
├── src
├── index.js
└── components
│ └── element-common-form
│ ├── index.js
│ └── ElementCommonForm.vue
├── .babelrc
├── .gitignore
├── .eslintrc.js
├── LICENSE
├── README.md
└── package.json
/.eslintignore:
--------------------------------------------------------------------------------
1 | dist/*.js
2 | config/*.js
3 |
--------------------------------------------------------------------------------
/.npmrc:
--------------------------------------------------------------------------------
1 | registry=https://registry.npmjs.org/
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | export * from './components/element-common-form/index'
2 |
--------------------------------------------------------------------------------
/src/components/element-common-form/index.js:
--------------------------------------------------------------------------------
1 | import ElementCommonForm from './ElementCommonForm.vue'
2 | export { ElementCommonForm }
3 |
--------------------------------------------------------------------------------
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | "es2015"
4 | ],
5 | "plugins": [
6 | "jsx-v-model",
7 | "transform-vue-jsx",
8 | "transform-runtime",
9 | "transform-decorators-legacy"
10 | ]
11 | }
12 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by .ignore support plugin (hsz.mobi)
2 | ### Example user template template
3 | ### Example user template
4 |
5 | # IntelliJ project files
6 | .idea
7 | *.iml
8 | out
9 | gen
10 | node_modules
11 | npm-debug.log
12 |
13 | *.log
14 | lib
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | // http://eslint.org/docs/user-guide/configuring
2 |
3 | module.exports = {
4 | root: true,
5 | parserOptions: {
6 | parser: 'babel-eslint'
7 | },
8 | env: {
9 | browser: true
10 | },
11 | extends: [
12 | // https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
13 | // consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.
14 | 'plugin:vue/strongly-recommended',
15 | // https://github.com/standard/standard/blob/master/docs/RULES-en.md
16 | 'standard'
17 | ],
18 | // required to lint *.vue files
19 | plugins: [
20 | 'vue'
21 | ],
22 | // add your custom rules here
23 | rules: {
24 | // vue规则 - tag自动闭合不强制
25 | 'vue/html-self-closing': 'off',
26 | 'vue/max-attributes-per-line': 'off',
27 |
28 | // allow async-await
29 | 'generator-star-spacing': 'off',
30 | // allow debugger during development
31 | 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 檀卫杰
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ### 介绍
2 | element-ui 通用表单组件
3 |
4 | ### 使用文档
5 |
6 | **1、使用方法**
7 |
8 | **安装**
9 | ```
10 | npm i element-common-form
11 | ```
12 | **使用**
13 | ```
14 |
15 | ```
16 | 接收的props:
17 |
18 | **isResetFormFlag**:是否更新表单内容标志,用于触发更新表单的**formModel**
19 |
20 | **formOption**:表单配置,下有详细配置说明
21 |
22 | **isDisabled**:表单是否可编辑
23 |
24 | **2、单一表单组配置**
25 |
26 | ```
27 | {
28 | name: 'channel-form',
29 | data: {},
30 | items: [
31 | {
32 | label: '类型',
33 | name: 'type',
34 | type: 'select',
35 | dataList: [{
36 | index: 1,
37 | text: '相机'
38 | }, {
39 | index: 6,
40 | text: '其他'
41 | }]
42 | }
43 | ],
44 | rules: {
45 | name: [{ required: true, message: '请输入产品名称', trigger: 'blur' }]
46 | },
47 | btnList: [{
48 | text: '保存,下一步',
49 | type: 'primary',
50 | onClick: this.commitForm
51 | }]
52 | }
53 |
54 | ```
55 |
56 | **3、多表单组配置**
57 |
58 | ```
59 | formOption: {
60 | name: 'channel-form',
61 | data: {},
62 | groups: [{
63 | title: '',// 组标题
64 | tips: ''// 组提示
65 | items: [] // 组表单项,和单一组配置一致
66 | }]
67 | }
68 | ```
69 | **4、配置文档**
70 |
71 | | 节点 | 描述 | 类型 |是否必须|备注|
72 | | ------------- |-------------| -----| -----| -----|
73 | | name| 表单名 | String|否|默认名 oa-form|
74 | | data| 表单数据 | Object|否|用于编辑场景异步请求的表单填充数据|
75 | | groups| 表单组 | Array|否|groups 和 items 不应该同时存在,groups 中包含了items,如果groups为空取外部的items渲染,groups不为空仅渲染groups组内容|
76 | | items| 表单项 | Array|否|支持的type类型:输入框:input、textarea;多选框:checkbox;单选框:radio;下拉菜单:select|
77 | | rules| 表单校验规则 | Object|否|节点名需要与items配置的name一一对应|
78 | | btnList| 按钮列表 | Array|否|会在回调函数包含表单的数据及表单引用|
79 |
80 | **5、备注**
81 |
82 | 当前仅支持少数表单项,可以clone到本地或者直接拷贝`ElementCommonForm.vue`源码到项目中根据具体项目进行扩展
83 |
84 | ### License
85 | MIT
86 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "element-common-form",
3 | "version": "1.0.1",
4 | "scripts": {
5 | "dev": "cross-env NODE_ENV=development webpack --config build/webpack.config.js --watch",
6 | "build": "node build/build.js",
7 | "unit": "cross-env NODE_ENV=testing karma start test/unit/karma.conf.js --single-run"
8 | },
9 | "description": "element common form",
10 | "main": "lib/index.js",
11 | "module": "lib/index.js",
12 | "keywords": [
13 | "element",
14 | "vue",
15 | "vue-component",
16 | "component"
17 | ],
18 | "repository": {
19 | "type": "git",
20 | "url": "https://github.com/mrtanweijie/element-common-form.git"
21 | },
22 | "author": "twj",
23 | "license": "MIT",
24 | "devDependencies": {
25 | "babel-core": "^6.25.0",
26 | "babel-eslint": "^7.2.3",
27 | "babel-helper-vue-jsx-merge-props": "^2.0.3",
28 | "babel-loader": "^6.4.1",
29 | "babel-plugin-istanbul": "^4.1.4",
30 | "babel-plugin-jsx-v-model": "^2.0.3",
31 | "babel-plugin-transform-decorators-legacy": "^1.3.5",
32 | "babel-plugin-transform-runtime": "^6.23.0",
33 | "babel-plugin-transform-vue-jsx": "^3.7.0",
34 | "babel-preset-es2015": "^6.24.1",
35 | "babel-preset-stage-2": "^6.24.1",
36 | "chai": "^4.1.1",
37 | "chalk": "^2.1.0",
38 | "chromedriver": "^2.32.3",
39 | "copy-webpack-plugin": "^4.0.1",
40 | "cross-env": "^3.2.4",
41 | "cross-spawn": "^5.1.0",
42 | "css-loader": "^0.27.3",
43 | "eslint": "^4.4.1",
44 | "eslint-config-standard": "^10.2.1",
45 | "eslint-friendly-formatter": "^3.0.0",
46 | "eslint-loader": "^1.9.0",
47 | "eslint-plugin-html": "^3.1.1",
48 | "eslint-plugin-import": "^2.7.0",
49 | "eslint-plugin-node": "^5.1.1",
50 | "eslint-plugin-promise": "^3.5.0",
51 | "eslint-plugin-standard": "^3.0.1",
52 | "eslint-plugin-vue": "^5.2.2",
53 | "eventsource-polyfill": "^0.9.6",
54 | "extract-text-webpack-plugin": "^2.1.2",
55 | "file-loader": "^0.10.1",
56 | "html-webpack-plugin": "^2.30.1",
57 | "img-loader": "^2.0.0",
58 | "inject-loader": "^3.0.1",
59 | "karma": "^1.7.0",
60 | "karma-chrome-launcher": "^2.2.0",
61 | "karma-coverage": "^1.1.1",
62 | "karma-mocha": "^1.3.0",
63 | "karma-sinon-chai": "^1.3.1",
64 | "karma-sourcemap-loader": "^0.3.7",
65 | "karma-spec-reporter": "^0.0.31",
66 | "karma-webpack": "^2.0.4",
67 | "less": "^2.7.2",
68 | "less-loader": "^4.0.5",
69 | "lodash.isplainobject": "^4.0.6",
70 | "lolex": "^2.1.2",
71 | "mocha": "^3.5.0",
72 | "nightwatch": "^0.9.16",
73 | "optimize-css-assets-webpack-plugin": "^3.0.0",
74 | "ora": "^1.3.0",
75 | "postcss-px-to-viewport": "^0.0.3",
76 | "rimraf": "^2.6.1",
77 | "selenium-server": "^3.5.0",
78 | "semver": "^5.4.1",
79 | "shelljs": "^0.7.8",
80 | "sinon": "^3.2.0",
81 | "sinon-chai": "^2.13.0",
82 | "swiper": "^3.4.2",
83 | "url-loader": "^0.5.9",
84 | "vee-validate": "2.0.0-rc.25",
85 | "vue": "^2.5.17",
86 | "vue-class-component": "^7.1.0",
87 | "vue-html-loader": "^1.2.3",
88 | "vue-loader": "^11.0.0",
89 | "vue-style-loader": "^2.0.5",
90 | "vue-template-compiler": "^2.5.16",
91 | "webpack": "^3.6.0",
92 | "webpack-merge": "^4.1.0"
93 | },
94 | "dependencies": {},
95 | "engines": {
96 | "node": ">= 6.0.0",
97 | "npm": ">= 3.0.0"
98 | }
99 | }
--------------------------------------------------------------------------------
/src/components/element-common-form/ElementCommonForm.vue:
--------------------------------------------------------------------------------
1 |
227 |
228 |
269 |
--------------------------------------------------------------------------------