Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
10f833d8
Commit
10f833d8
authored
Apr 17, 2020
by
蒋勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d
parent
72976fc9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
84 deletions
+42
-84
iview-admin/src/view/components/tables/forms/forms.vue
+37
-82
iview-admin/src/view/components/tables/tables.vue
+5
-2
No files found.
iview-admin/src/view/components/tables/forms/forms.vue
View file @
10f833d8
<
template
>
<div>
<Card>
<div></div>
<Form
ref=
"formInline"
:model=
"formdata"
:rules=
"ruleInline"
>
<div>
<button
type=
"primary"
@
click=
"testclick"
>
test
</button>
</div>
<Form
ref=
"formInline"
:model=
"formModel"
:rules=
"metaRules"
>
<template
v-for=
"group in forminfo"
>
<Divider
orientation=
"left"
:key=
"group.title"
>
{{
group
.
title
}}
</Divider>
<Row
:key=
"'r'+group.title"
>
<Col
:xs=
"2"
:sm=
"4"
:md=
"6"
:lg=
"8"
v-for=
"ctl in group.ctls"
:key=
"ctl.prop"
>
<FormItem
:label=
"ctl.label"
></FormItem>
<FormItem
:label=
"ctl.label"
:prop=
"ctl.prop"
>
<template
v-if=
"ctl.type=='input'"
>
<input
v-model=
"formModel[ctl.prop]"
/>
</
template
>
</FormItem>
</Col>
</Row>
</template>
...
...
@@ -27,82 +33,47 @@ export default {
return
[];
}
},
refvalidatemethod
:{
type
:
Function
,
default
(){
return
(
rule
,
value
,
callback
)
=>
{
return
callback
()
}
refvalidatemethod
:
{
type
:
Function
,
default
()
{
return
(
rule
,
value
,
callback
)
=>
{
return
callback
()
;
}
;
}
}
},
data
()
{
return
{
forminfo
:
[
{
title
:
"控制信息"
,
col
:
3
,
ctls
:
[
{
type
:
"switch"
,
prop
:
"isAdmin"
,
acText
:
"是管理员"
,
inactText
:
"否"
,
placeHolder
:
"请输入单次使用消耗的宝币数"
,
style
:
""
}
// {"type":"select","refModel":"pmproduct","isMulti":false,"label":"所属产品","prop":"pmproduct_id","labelField":"name","valueField":"id","style":""},
]
},
{
title
:
"基本信息"
,
col
:
3
,
ctls
:
[
{
type
:
"input"
,
label
:
"账号"
,
prop
:
"userName"
,
placeHolder
:
"登录账号"
,
style
:
""
,
rules
:
[{
required
:
true
,
message
:
" "
,
trigger
:
"blur"
}]
},
{
type
:
"input"
,
label
:
"昵称"
,
prop
:
"nickName"
,
placeHolder
:
"昵称"
,
style
:
""
,
rules
:
[{
required
:
true
,
message
:
" "
,
trigger
:
"blur"
}]
},
{
type
:
"input"
,
label
:
"电话"
,
prop
:
"mobile"
,
placeHolder
:
"请输入电话"
,
style
:
""
,
rules
:
[
{
validator
:
"validatex"
,
trigger
:
"blur"
},
{
required
:
true
,
message
:
" "
,
trigger
:
"blur"
}
]
}
// {"type":"select","refModel":"auth.role","isMulti":true,"label":"角色","prop":"roles","labelField":"name","valueField":"id","style":""},
]
}
],
forminfo
:
this
.
fminfo
?
this
.
fminfo
:
[],
formModel
:
{},
metaRules
:{},
metaRules
:
{},
btninfos
:
[]
};
},
watch
:
{
fminfo
(
nf
,
of
)
{
this
.
forminfo
=
nf
;
console
.
log
(
">>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<"
);
this
.
initFormModel
()
}
},
methods
:
{
validatex
(
rule
,
value
,
callback
)
{
if
(
this
.
refvalidatemethod
)
{
return
this
.
refvalidatemethod
(
rule
,
value
,
callback
);
}
else
{
return
callback
();
}
},
testclick
()
{
console
.
log
(
this
.
formModel
);
},
initFormModel
()
{
this
.
forminfo
.
forEach
(
m
=>
{
if
(
!
m
||
!
m
.
ctls
)
{
return
;
}
m
.
ctls
.
forEach
(
ctl
=>
{
// this.$set(this.ctlVisable, ctl.prop, true);
// this.$set(this.ctlVisable, ctl.prop, true);
if
(
ctl
.
rules
)
{
ctl
.
rules
.
forEach
(
r
=>
{
if
(
r
.
validator
)
{
...
...
@@ -118,6 +89,7 @@ export default {
if
(
ctl
.
type
==
"number"
)
{
this
.
$set
(
this
.
formModel
,
ctl
.
prop
,
0
);
}
else
{
console
.
log
(
"============="
)
this
.
$set
(
this
.
formModel
,
ctl
.
prop
,
""
);
}
}
...
...
@@ -125,27 +97,10 @@ export default {
});
}
},
methods
:
{
handleDelete
(
params
)
{
console
.
log
(
params
);
},
exportExcel
()
{
this
.
$refs
.
tables
.
exportCsv
({
filename
:
`table-
${
new
Date
().
valueOf
()}
.csv`
});
},
validatex
(
rule
,
value
,
callback
){
if
(
this
.
refvalidatemethod
){
return
this
.
refvalidatemethod
(
rule
,
value
,
callback
);
}
else
{
return
callback
();
}
},
created
(){
this
.
initFormModel
();
},
mounted
()
{
getTableData
().
then
(
res
=>
{
this
.
tableData
=
res
.
data
;
});
}
};
</
script
>
...
...
iview-admin/src/view/components/tables/tables.vue
View file @
10f833d8
...
...
@@ -3,17 +3,20 @@
<Card>
<tables
ref=
"tables"
editable
searchable
search-place=
"top"
v-model=
"tableData"
:columns=
"columns"
@
on-exec=
"doexec"
/>
<Button
style=
"margin: 10px 0;"
type=
"primary"
@
click=
"exportExcel"
>
导出为Csv文件
</Button>
<Forms
:fminfo=
"forminfo"
></Forms>
</Card>
</div>
</
template
>
<
script
>
import
Tables
from
'_c/tables'
import
Forms
from
'./forms/forms'
import
{
getTableData
}
from
'@/api/data'
export
default
{
name
:
'tables_page'
,
components
:
{
Tables
Tables
,
Forms
},
props
:{
metaName
:
String
,
...
...
@@ -22,7 +25,7 @@ export default {
data
()
{
this
.
metaName
=
"user_info"
return
{
forminfo
:
this
.
metaName
?
this
.
$store
.
getters
[
this
.
metaName
][
"form"
]:[],
columns
:
this
.
metaName
?
this
.
$store
.
getters
[
this
.
metaName
][
"list"
]:[],
tableData
:
[]
}
...
...
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