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
7d433993
Commit
7d433993
authored
Feb 12, 2018
by
赵帅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
column传入
parent
6a56acf6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
8 deletions
+70
-8
HmComplexDetail.vue
src/views/haomo/components/details/HmComplexDetail.vue
+66
-6
index.vue
src/views/haomo/components/details/index.vue
+4
-2
No files found.
src/views/haomo/components/details/HmComplexDetail.vue
View file @
7d433993
...
@@ -32,6 +32,32 @@
...
@@ -32,6 +32,32 @@
type
:
Object
,
type
:
Object
,
required
:
true
required
:
true
},
},
/**
* 指定要显示的列。默认为根据schema得到的所有列。完整示例为:
* [
* {
* "name": "姓名",
* "code": "username",
* "render": function(value){
* return "<a href='value'></a>"
* }
* },
* "mobile",
* "sexual"
* ]
*/
columns
:
{
type
:
Array
,
required
:
false
,
validator
:
function
(
value
)
{
if
(
typeof
value
!==
'object'
)
{
console
.
warn
(
`传入的columns不符合要求,必须是数组`
)
return
false
}
return
true
}
},
/*
/*
* 在详情页需要传入用户的id用来带出用户信息
* 在详情页需要传入用户的id用来带出用户信息
* */
* */
...
@@ -52,17 +78,51 @@
...
@@ -52,17 +78,51 @@
filters
:
{
filters
:
{
},
},
created
()
{
created
()
{
this
.
init
()
this
.
getList
()
this
.
getList
()
this
.
init
()
},
},
methods
:
{
methods
:
{
validate
()
{
const
self
=
this
// this.columns数组元素本身必须是string或者object. 且必须是schema中定义的列
// 由于vue中不允许通过其他的props来验证当前props,只能在created里进行调用
_
.
each
(
self
.
columns
,
function
(
item
)
{
if
(
!
item
)
{
return
0
}
if
(
typeof
item
!==
'string'
&&
typeof
item
!==
'object'
)
{
console
.
error
(
`传入的columns不符合要求,数组元素必须是字符串或对象`
)
}
if
(
typeof
item
===
'string'
&&
!
_
.
keyBy
(
self
.
schema
[
'columns'
],
'code'
)[
item
.
toUpperCase
()])
{
console
.
error
(
`传入的columns不符合要求,字符串元素[
${
item
}
]必须是schema中定义的列[code]`
)
}
if
(
typeof
item
===
'object'
&&
!
_
.
keyBy
(
self
.
schema
[
'columns'
],
'code'
)[
item
[
'code'
].
toUpperCase
()])
{
console
.
error
(
`传入的columns不符合要求,元素的code属性[
${
item
[
'code'
]}
]必须是schema中定义的列[code]`
)
}
})
},
init
()
{
init
()
{
const
self
=
this
const
self
=
this
console
.
log
(
self
.
schema
);
// 处理要显示的列
if
(
!
self
.
columns
||
!
self
.
columns
.
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
.
showColumns
.
push
(
tmp
)
self
.
showColumns
.
push
(
tmp
)
})
})
}
else
{
self
.
showColumns
=
[];
// 将字符串对象进行替换处理
_
.
each
(
self
.
schema
[
'columns'
],
function
(
column
)
{
_
.
each
(
self
.
columns
,
function
(
item
){
if
(
column
.
codeCamel
===
item
){
const
tmp
=
JSON
.
parse
(
JSON
.
stringify
(
column
))
self
.
showColumns
.
push
(
tmp
)
}
})
})
}
if
(
!
request
.
defaults
.
baseURL
)
{
if
(
!
request
.
defaults
.
baseURL
)
{
request
.
defaults
.
baseURL
=
'/org/api'
request
.
defaults
.
baseURL
=
'/org/api'
}
}
...
...
src/views/haomo/components/details/index.vue
View file @
7d433993
<
template
>
<
template
>
<div>
<div>
<hm-complex-detail
:schema=
"schema['HmUser']"
:userId=
"userId"
>
<hm-complex-detail
:schema=
"schema['HmUser']"
:userId=
"userId"
:columns=
"showUserColumns"
>
</hm-complex-detail>
</hm-complex-detail>
</div>
</div>
</
template
>
</
template
>
...
@@ -18,7 +18,9 @@
...
@@ -18,7 +18,9 @@
'hm-complex-detail'
:
HmComplexDetail
'hm-complex-detail'
:
HmComplexDetail
},
},
data
()
{
data
()
{
return
{}
return
{
showUserColumns
:
[
'mobile'
,
'loginid'
]
}
},
},
computed
:
{
computed
:
{
},
},
...
...
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