Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
VueElementTemplate
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄瑜
VueElementTemplate
Commits
5a9a7b40
Commit
5a9a7b40
authored
Mar 30, 2018
by
王康
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
form
parent
629a3014
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
10 deletions
+21
-10
HmComplexForm.vue
src/views/haomo/components/forms/HmComplexForm.vue
+19
-8
index.vue
src/views/haomo/components/forms/index.vue
+2
-2
No files found.
src/views/haomo/components/forms/HmComplexForm.vue
View file @
5a9a7b40
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
label-width=
"200px"
label-width=
"200px"
style=
"width:80%;margin:0 auto"
>
style=
"width:80%;margin:0 auto"
>
<el-form-item
v-for=
"column in showUserColumns"
<el-form-item
v-for=
"column in showUserColumns"
v-show=
"!column.hide"
:key=
"column.id"
:key=
"column.id"
:label=
"column.name"
:label=
"column.name"
:rules=
"column.rule?column.rule:null"
:rules=
"column.rule?column.rule:null"
...
@@ -155,19 +156,22 @@
...
@@ -155,19 +156,22 @@
/**
/**
* 必传,指定要显示的表单字段及类型。数组的元素为对象类型,对象的属性有name、codeCamel、widgetType、disabled、
* 必传,指定要显示的表单字段及类型。数组的元素为对象类型,对象的属性有name、codeCamel、widgetType、disabled、
* options、multiple、dateType等,不同的表单类型需配置的属性不同,
* options、multiple、dateType等,不同的表单类型需配置的属性不同,
* codeCamel属性必须有,表示要显示的表单字段,
* codeCamel属性,表示要显示的表单字段, 如果其他字段都不需要传,可以只写codeCamel的值,比如['username','departmentId']
* name属性表示自定义的字段名,如果不传,默认为数据库中的字段名,
* name属性可选,表示自定义的字段名,如果不传,默认为数据库中的字段名,
* widgetType属性表示该字段要显示的表单类型(普通输入框、文本域、富文本、下拉框...),不传默认为普通input
* change属性可选,值为函数类型,表示input的change事件的执行方法,参数即为input输入内容
* change属性,值为函数类型,表示input的change事件的执行方法,参数即为input输入内容
* default属性可选(复选框不支持),设置默认值,取值规范参考form/index.vue
* hide属性可选,设置该表单字段是否显示,值为boolean
* widgetType属性可选,表示该字段要显示的表单类型(普通输入框、文本域、富文本、下拉框...),不传默认为普通input
* 取值1-8(1表示普通输入框,2表示下拉框,3表示复选框,4表示文本域,5表示富文本,6表示日期,7表示单选框,8表示文件上传),
* 取值1-8(1表示普通输入框,2表示下拉框,3表示复选框,4表示文本域,5表示富文本,6表示日期,7表示单选框,8表示文件上传),
* 若表单类型为下拉框/复选框/单选框,还需传入options字段,值为数组(数组元素是下拉框/复选框/单选框的选项),
* 若表单类型为下拉框/复选框/单选框,还需传入options字段,值为数组(数组元素是下拉框/复选框/单选框的选项),
* 对于复选框,如果只有一个备选项则不必传options,
* 对于复选框,如果只有一个备选项则不必传options,
* 若表单类型为下拉框,还可传入multiple字段,取值bolean类型,true/false,表示是否多选,默认false
* 若表单类型为下拉框,还可传入multiple字段,取值bo
o
lean类型,true/false,表示是否多选,默认false
* 若表单类型为时间日期,可传入dateType字段,值为'date'(只显示日期)或'datetime'(显示日期和时间),如果不传,
* 若表单类型为时间日期,可传入dateType字段,值为'date'(只显示日期)或'datetime'(显示日期和时间),如果不传,
* 默认只显示日期; 可传入dateFormate字段,为日期格式,取值遵循elementUI DatePicker组件中的日期格式,
* 默认只显示日期; 可传入dateFormate字段,为日期格式,取值遵循elementUI DatePicker组件中的日期格式,
* 比如 只显示日期取值'yyyy-MM-dd',显示日期和时间取值'yyyy-MM-dd HH:mm:ss',如果不传默认为只显示日期取值'yyyy-MM-dd',date字段和dateFormate字段取值须对应
* 比如 只显示日期取值'yyyy-MM-dd',显示日期和时间取值'yyyy-MM-ddHH:mm:ss',
* 所有的表单类型都可传入disabled属性,取值bolean类型,true/false,表示是否禁用,默认不禁用
* 如果不传默认为只显示日期取值'yyyy-MM-dd',date字段和dateFormate字段取值须对应
* input类表单还可传入rule属性来进行自定义验证规则,rule取值规范参照elementUI,下面有简单示例
* disabled属性可选,取值boolean类型,true/false,表示是否禁用,默认不禁用
* rule属性可选,进行自定义验证规则,rule取值规范参照elementUI,下面有简单示例
* 示例:[
* 示例:[
{ name: '用户名称', codeCamel: 'username', widgetType: 1, disabled: true,
{ name: '用户名称', codeCamel: 'username', widgetType: 1, disabled: true,
rule: { required: true, message: '用户名不能为空', trigger: 'blur' }
rule: { required: true, message: '用户名不能为空', trigger: 'blur' }
...
@@ -617,8 +621,15 @@
...
@@ -617,8 +621,15 @@
* 清空所有输入及提示信息。
* 清空所有输入及提示信息。
*/
*/
resetForm
(
callback
)
{
resetForm
(
callback
)
{
const
self
=
this
console
.
log
(
'重置'
)
console
.
log
(
'重置'
)
this
.
$refs
.
form
.
resetFields
()
this
.
$refs
.
form
.
resetFields
()
console
.
log
(
self
.
formModel
)
// // 清空
// _.each(self.formModel, function(value, index) {
// self.formModel[index] = ''
// })
// 执行回调
if
(
typeof
(
callback
)
===
'function'
)
{
if
(
typeof
(
callback
)
===
'function'
)
{
callback
()
callback
()
}
}
...
...
src/views/haomo/components/forms/index.vue
View file @
5a9a7b40
...
@@ -28,12 +28,12 @@
...
@@ -28,12 +28,12 @@
showUserColumns
:
[
showUserColumns
:
[
// 1普通input
// 1普通input
{
name
:
'用户名称'
,
codeCamel
:
'username'
,
widgetType
:
1
,
disabled
:
false
,
default
:
'默认值'
,
{
name
:
'用户名称'
,
codeCamel
:
'username'
,
widgetType
:
1
,
disabled
:
false
,
default
:
'默认值'
,
change
:
this
.
inputChange
change
:
this
.
inputChange
,
hide
:
true
// rule: { required: true, message: '用户名不能为空', trigger: 'blur' }
// rule: { required: true, message: '用户名不能为空', trigger: 'blur' }
},
},
// 5富文本
// 5富文本
{
name
:
'电子邮件'
,
codeCamel
:
'email'
,
widgetType
:
5
,
disabled
:
false
,
{
name
:
'电子邮件'
,
codeCamel
:
'email'
,
widgetType
:
5
,
disabled
:
false
,
change
:
this
.
inputChange
change
:
this
.
inputChange
,
hide
:
false
// rule: [
// rule: [
// { required: true, message: '请输入邮箱地址', trigger: 'blur' },
// { required: true, message: '请输入邮箱地址', trigger: 'blur' },
// { type: 'email', message: '请输入正确的邮箱地址', trigger: 'blur,change' }
// { type: 'email', message: '请输入正确的邮箱地址', trigger: 'blur,change' }
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment