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
b2bfc72a
Commit
b2bfc72a
authored
Feb 13, 2018
by
王康
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
表单页面
parent
150e7ba4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
51 deletions
+50
-51
HmComplexForm.vue
src/views/haomo/components/forms/HmComplexForm.vue
+50
-51
No files found.
src/views/haomo/components/forms/HmComplexForm.vue
View file @
b2bfc72a
...
@@ -61,9 +61,10 @@
...
@@ -61,9 +61,10 @@
</el-col>
</el-col>
</el-form-item>
</el-form-item>
</el-form>
-->
</el-form>
-->
<el-form
label-width=
"110px"
status-icon
style=
"width:80%;margin:0 auto"
>
<el-form
ref=
"form"
:model=
"formModel"
:rules=
"rules"
label-width=
"110px"
status-icon
style=
"width:80%;margin:0 auto"
>
<el-form-item
v-for=
"(column,index) in showFields"
:key=
"index"
:label=
"column.name"
>
<el-form-item
v-for=
"(column,index) in showFields"
:key=
"index"
:label=
"column.name"
:prop=
"column.codeCamel"
>
<el-input
:placeholder=
"column.name"
v-model=
"formModel[column.codeCamel]"
></el-input>
<el-input
v-if=
"column.codeCamel==='password'"
type=
"password"
:placeholder=
"column.name"
v-model=
"formModel[column.codeCamel]"
></el-input>
<el-input
v-if=
"column.codeCamel!=='password'"
:placeholder=
"column.name"
v-model=
"formModel[column.codeCamel]"
></el-input>
</el-form-item>
</el-form-item>
<el-form-item>
<el-form-item>
<el-col
:span=
"12"
>
<el-col
:span=
"12"
>
...
@@ -123,7 +124,7 @@
...
@@ -123,7 +124,7 @@
return
{
return
{
form
:
null
,
form
:
null
,
formModel
:
{},
// 双向绑定的数据变量
formModel
:
{},
// 双向绑定的数据变量
showFields
:
[]
// 要显示的字段
showFields
:
[]
,
// 要显示的字段
// form: {
// form: {
// name: '',
// name: '',
// gender: '男',
// gender: '男',
...
@@ -138,32 +139,25 @@
...
@@ -138,32 +139,25 @@
// email: '',
// email: '',
// address: ''
// address: ''
// },
// },
// rules: {
rules
:
{
// name: [
username
:
[
// { required: true, message: '请输入姓名', trigger: 'blur' },
{
required
:
true
,
message
:
'请输入用户名'
,
trigger
:
'blur'
},
// { min: 2, max: 5, message: '长度在 2 到 5 个字符', trigger: 'blur' }
{
min
:
2
,
max
:
10
,
message
:
'长度在 2 到 10 个字符'
,
trigger
:
'blur'
}
// ],
],
// age: [
loginid
:
[
// { required: true, message: '请输入年龄', trigger: 'blur' },
{
required
:
true
,
message
:
'请输入登陆ID'
,
trigger
:
'blur'
}
// { type: 'number', message: '年龄必须为数字', trigger: 'change' }
],
// ],
password
:
[
// website: [
{
required
:
true
,
message
:
'请输入密码'
,
trigger
:
'blur'
},
// { required: true, message: '请输入网址', trigger: 'blur' },
{
pattern
:
/^
(?![
0-9
]
+$
)(?![
a-zA-Z
]
+$
)[
0-9A-Za-z
]{6,20}
$/
,
message
:
'密码必须同时包含数字和字母 6-20位'
,
trigger
:
'change'
}
// { pattern: /[a-zA-z]+:\/\/[^\s]*/, message: '请输入正确的网址', trigger: 'change' }
],
// ],
mobile
:
[
// password: [
{
pattern
:
/^
((
0
\d{2,3}
-
\d{7,8})
|
(
1
[
3584
]\d{9}))
$/
,
message
:
'请输入正确的电话号码或手机号'
,
trigger
:
'blur&change'
}
// { required: true, message: '请输入密码', trigger: 'blur' },
],
// { pattern: /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,20}$/, message: '密码必须同时包含数字和字母 6-20位', trigger: 'change' }
email
:
[
// ],
{
type
:
'email'
,
message
:
'请输入正确的邮箱地址'
,
trigger
:
'blur&change'
}
// phone: [
]
// { type: 'number', required: true, message: '请输入手机号', trigger: 'blur' },
}
// { pattern: /^1[34578]\d{9}$/, message: '请输入正确的手机号', trigger: 'change' }
// ],
// email: [
// { required: true, message: '请输入邮箱地址', trigger: 'blur' },
// { type: 'email', message: '请输入正确的邮箱地址', trigger: 'blur,change' }
// ]
// }
}
}
},
},
...
@@ -178,21 +172,21 @@
...
@@ -178,21 +172,21 @@
if
(
!
self
.
fields
||
!
self
.
fields
.
length
)
{
if
(
!
self
.
fields
||
!
self
.
fields
.
length
)
{
_
.
each
(
self
.
schema
[
'columns'
],
function
(
column
)
{
_
.
each
(
self
.
schema
[
'columns'
],
function
(
column
)
{
const
tmp
=
JSON
.
parse
(
JSON
.
stringify
(
column
))
const
tmp
=
JSON
.
parse
(
JSON
.
stringify
(
column
))
self
.
$set
(
tmp
,
'code'
,
tmp
.
code
.
toLowerCase
())
//
self.$set(tmp, 'code', tmp.code.toLowerCase())
self
.
showFields
.
push
(
tmp
)
self
.
showFields
.
push
(
tmp
)
})
})
console
.
log
(
self
.
showFields
)
//
console.log(self.showFields)
}
else
{
// 如果传入了fields,则只显示传入的字段
}
else
{
// 如果传入了fields,则只显示传入的字段
self
.
showFields
=
JSON
.
parse
(
JSON
.
stringify
(
self
.
fields
))
self
.
showFields
=
JSON
.
parse
(
JSON
.
stringify
(
self
.
fields
))
console
.
log
(
'1111111'
)
console
.
log
(
'1111111'
)
console
.
log
(
self
.
showFields
)
//
console.log(self.showFields)
// 将字符串对象进行替换处理
// 将字符串对象进行替换处理
_
.
each
(
self
.
showFields
,
function
(
column
,
index
)
{
_
.
each
(
self
.
showFields
,
function
(
column
,
index
)
{
if
(
typeof
column
===
'string'
)
{
if
(
typeof
column
===
'string'
)
{
// 生成一个新对象
// 生成一个新对象
var
tmp
=
_
.
keyBy
(
self
.
schema
[
'columns'
],
'code'
)[
column
.
toUpperCase
()]
const
tmp
=
_
.
keyBy
(
self
.
schema
[
'columns'
],
'code'
)[
column
.
toUpperCase
()]
console
.
log
(
tmp
)
//
console.log(tmp)
self
.
$set
(
tmp
,
'code'
,
tmp
.
code
.
toLowerCase
())
//
self.$set(tmp, 'code', tmp.code.toLowerCase())
self
.
$set
(
self
.
showFields
,
index
,
tmp
)
self
.
$set
(
self
.
showFields
,
index
,
tmp
)
}
}
})
})
...
@@ -218,22 +212,27 @@
...
@@ -218,22 +212,27 @@
* 验证失败,禁止提交并给出提示
* 验证失败,禁止提交并给出提示
*/
*/
onSubmit
()
{
onSubmit
()
{
// this.formModel['X-Auth-Token'] = '111'
const
self
=
this
// console.log(this.formModel)
console
.
log
(
self
.
formModel
)
// console.log(this.schema)
self
.
$refs
.
form
.
validate
((
valid
)
=>
{
request
(
this
.
schema
.
modelUnderscorePlural
+
'/new'
,
{
if
(
valid
)
{
params
:
this
.
formModel
console
.
log
(
'提交成功!'
)
}).
then
(
resp
=>
{
request
(
self
.
schema
.
modelUnderscorePlural
+
'/new'
,
{
console
.
log
(
resp
.
data
)
method
:
'post'
,
headers
:
{
'Content-Type'
:
'application/x-www-form-urlencoded;charset=UTF-8'
},
data
:
self
.
formModel
}).
then
(
resp
=>
{
console
.
log
(
resp
.
data
)
})
}
else
{
console
.
log
(
'提交失败!!'
)
return
false
}
})
})
// this.$refs.form.validate((valid) => {
// paramsSerializer: function(data) {
// if (valid) {
// const keys = Object.keys(data)
// console.log('提交成功!')
// return encodeURI(keys.map(name => `${name}=${data[name]}`).join('&'))
// } else {
// }
// console.log('提交失败!!')
// return false
// }
// })
},
},
// 重置
// 重置
/**
/**
...
...
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