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
60c63b7a
Commit
60c63b7a
authored
Apr 20, 2020
by
蒋勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d
parent
38be4bbe
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
281 additions
and
68 deletions
+281
-68
iview-admin/src/api/data.js
+5
-3
iview-admin/src/components/tables/tables.vue
+9
-1
iview-admin/src/mock/data.js
+15
-1
iview-admin/src/mock/index.js
+1
-1
iview-admin/src/store/module/metainfo/userinfo.js
+45
-27
iview-admin/src/view/components/tables/forms/forms.vue
+0
-0
iview-admin/src/view/components/tables/tables.vue
+206
-35
No files found.
iview-admin/src/api/data.js
View file @
60c63b7a
import
axios
from
'@/libs/api.request'
export
const
getTableData
=
()
=>
{
export
const
getTableData
=
(
url
,
query
)
=>
{
console
.
log
(
url
)
return
axios
.
request
({
url
:
'get_table_data'
,
method
:
'get'
url
:
url
,
method
:
'post'
,
data
:
query
})
}
...
...
iview-admin/src/components/tables/tables.vue
View file @
60c63b7a
...
...
@@ -19,6 +19,9 @@
<Button
@
click=
"handleSearch"
class=
"search-btn"
type=
"primary"
>
<Icon
type=
"search"
/>
搜索
</Button>
<Button
@
click=
"advSearch"
class=
"search-btn"
type=
"primary"
>
<Icon
type=
"search"
/>
高级
</Button>
</div>
<Table
ref=
"tablesMain"
...
...
@@ -99,6 +102,7 @@ export default {
type
:
Boolean
,
default
:
false
},
border
:
{
type
:
Boolean
,
default
:
false
...
...
@@ -172,6 +176,9 @@ export default {
};
},
methods
:
{
advSearch
(){
this
.
$emit
(
"on-adv-search"
)
},
suportEdit
(
item
,
index
)
{
item
.
render
=
(
h
,
params
)
=>
{
return
h
(
TablesEdit
,
{
...
...
@@ -262,6 +269,7 @@ export default {
return
item
;
},
handleColumns
(
columns
)
{
this
.
insideColumns
=
columns
.
map
((
item
,
index
)
=>
{
let
res
=
item
;
if
(
res
.
editable
)
res
=
this
.
suportEdit
(
res
,
index
);
...
...
@@ -339,7 +347,7 @@ export default {
},
value
(
val
)
{
this
.
handleTableData
();
if
(
this
.
searchable
)
this
.
handleSearch
();
//
if (this.searchable) this.handleSearch();
}
},
mounted
()
{
...
...
iview-admin/src/mock/data.js
View file @
60c63b7a
...
...
@@ -5,6 +5,10 @@ import { treeData } from './data/tree-select'
const
Random
=
Mock
.
Random
export
const
getTableData
=
req
=>
{
let
rtn
=
{}
console
.
log
(
"========================================"
)
let
q
=
JSON
.
parse
(
req
.
body
)
console
.
log
(
q
)
let
tableData
=
[]
doCustomTimes
(
100
,
()
=>
{
tableData
.
push
(
Mock
.
mock
({
...
...
@@ -13,7 +17,17 @@ export const getTableData = req => {
createTime
:
'@date'
}))
})
return
tableData
rtn
.
status
=
0
;
rtn
.
data
=
{
results
:{
count
:
100
,
rows
:
tableData
.
slice
(
0
,
q
.
pageInfo
.
pageSize
)
},
aggresult
:{},
bizmsg
:
null
}
return
rtn
}
export
const
getDragList
=
req
=>
{
...
...
iview-admin/src/mock/index.js
View file @
60c63b7a
...
...
@@ -13,7 +13,7 @@ Mock.setup({
Mock
.
mock
(
/
\/
login/
,
login
)
Mock
.
mock
(
/
\/
get_info/
,
getUserInfo
)
Mock
.
mock
(
/
\/
logout/
,
logout
)
Mock
.
mock
(
/
\/
get_table_data
/
,
getTableData
)
Mock
.
mock
(
/
.*findAndCountAll
/
,
getTableData
)
Mock
.
mock
(
/
\/
get_drag_list/
,
getDragList
)
Mock
.
mock
(
/
\/
save_error_logger/
,
'success'
)
Mock
.
mock
(
/
\/
image
\/
upload/
,
uploadImage
)
...
...
iview-admin/src/store/module/metainfo/userinfo.js
View file @
60c63b7a
...
...
@@ -14,53 +14,70 @@ export default {
],
"form"
:{
name
:
"xxx"
,
data
:[
main
:[
// {
// "title":"控制信息",
// ctls:[
// {"type":"switch","label":"是否管理员","prop":"isAdmin","opentext":"是","closetext":"否","trurcolor":"","falsecolor":"","placeHolder":"请输入单次使用消耗的宝币数","style":""},
// // {"type":"select","refModel":"pmproduct","isMulti":false,"label":"所属产品","prop":"pmproduct_id","labelField":"name","valueField":"id","style":""},
// {"type":"dic-select","dicName":"app_type","isMulti":true,"label":"所属产品","prop":"apptype","placeHolder":"请选择 应用类型"},
// {"type":"model-select","refModel":"user","isMulti":false,"label":"所属产品","prop":"uid","placeHolder":"请选择 应用类型","labelField":"name","valueField":"id"},
// {"type":"remote-select","refModel":"user","isMulti":false,"label":"所属产品x","prop":"xid","placeHolder":"请选择 应用类型","labelField":"name","valueField":"id"},
// {"type":"checkgroup","refModel":"user","label":"所属产品","prop":"mmmid","placeHolder":"请选择 应用类型","labelField":"name","valueField":"id","isBorder":true},
// {"type":"radiogroup","refModel":"user","label":"所属产品","prop":"xmmmid","placeHolder":"请选择 应用类型","labelField":"name","valueField":"id","isBorder":true},
// ]
// },
{
"title"
:
"控制信息"
,
"title"
:
"基本信息"
,
"key"
:
"baseinfo"
,
ctls
:[
{
"type"
:
"switch"
,
"label"
:
"是否管理员"
,
"prop"
:
"isAdmin"
,
"opentext"
:
"是"
,
"closetext"
:
"否"
,
"trurcolor"
:
""
,
"falsecolor"
:
""
,
"placeHolder"
:
"请输入单次使用消耗的宝币数"
,
"style"
:
""
},
// {"type":"select","refModel":"pmproduct","isMulti":false,"label":"所属产品","prop":"pmproduct_id","labelField":"name","valueField":"id","style":""},
{
"type"
:
"dic-select"
,
"dicName"
:
"app_type"
,
"isMulti"
:
true
,
"label"
:
"所属产品"
,
"prop"
:
"apptype"
,
"placeHolder"
:
"请选择 应用类型"
},
{
"type"
:
"model-select"
,
"refModel"
:
"user"
,
"isMulti"
:
false
,
"label"
:
"所属产品"
,
"prop"
:
"uid"
,
"placeHolder"
:
"请选择 应用类型"
,
"labelField"
:
"name"
,
"valueField"
:
"id"
},
{
"type"
:
"remote-select"
,
"refModel"
:
"user"
,
"isMulti"
:
false
,
"label"
:
"所属产品x"
,
"prop"
:
"xid"
,
"placeHolder"
:
"请选择 应用类型"
,
"labelField"
:
"name"
,
"valueField"
:
"id"
},
{
"type"
:
"checkgroup"
,
"refModel"
:
"user"
,
"label"
:
"所属产品"
,
"prop"
:
"mmmid"
,
"placeHolder"
:
"请选择 应用类型"
,
"labelField"
:
"name"
,
"valueField"
:
"id"
,
"isBorder"
:
true
},
{
"type"
:
"radiogroup"
,
"refModel"
:
"user"
,
"label"
:
"所属产品"
,
"prop"
:
"xmmmid"
,
"placeHolder"
:
"请选择 应用类型"
,
"labelField"
:
"name"
,
"valueField"
:
"id"
,
"isBorder"
:
true
},
{
"type"
:
"input"
,
"label"
:
"姓名"
,
"prop"
:
"name"
,
"placeHolder"
:
"登录账号"
,
"style"
:
""
,
rules
:[
{
"required"
:
true
,
"message"
:
' '
,
"trigger"
:
'blur'
},]},
{
"type"
:
"input"
,
"label"
:
"邮件"
,
"prop"
:
"email"
,
"placeHolder"
:
"昵称"
,
"style"
:
""
,
rules
:[
{
"required"
:
true
,
"message"
:
' '
,
"trigger"
:
'blur'
},]},
{
"type"
:
"input"
,
"label"
:
"创建时间"
,
"prop"
:
"createTime"
,
"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":""},
]
},
}
],
lists
:[
{
title
:
"子列表"
,
refBizCode
:
"xxx"
}
]
},
"search"
:{
name
:
"search"
,
main
:[
{
"title"
:
"基本信息"
,
"key"
:
"baseinfo"
,
ctls
:[
{
"type"
:
"input"
,
"label"
:
"
账号"
,
"prop"
:
"userN
ame"
,
"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"
:
"mobil
e"
,
"placeHolder"
:
"请输入电话"
,
"style"
:
""
,
rules
:[
{
"validator"
:
"validatex"
,
"trigger"
:
'blur'
},{
"required"
:
true
,
"message"
:
' '
,
"trigger"
:
'blur'
},]},
{
"type"
:
"input"
,
"label"
:
"
姓名"
,
"prop"
:
"n
ame"
,
"placeHolder"
:
"登录账号"
,
"style"
:
""
,
rules
:[
{
"required"
:
true
,
"message"
:
' '
,
"trigger"
:
'blur'
},]},
{
"type"
:
"input"
,
"label"
:
"
邮件"
,
"prop"
:
"email
"
,
"placeHolder"
:
"昵称"
,
"style"
:
""
,
rules
:[
{
"required"
:
true
,
"message"
:
' '
,
"trigger"
:
'blur'
},]},
{
"type"
:
"input"
,
"label"
:
"
创建时间"
,
"prop"
:
"createTim
e"
,
"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":""},
]
}
]
},
"search"
:[
{
"title"
:
"基本查询"
,
ctls
:[
{
"type"
:
"input"
,
"label"
:
"昵称"
,
"prop"
:
"nickName"
,
"placeHolder"
:
"请输入昵称"
,
"style"
:
""
},
]
},
],
"auths"
:{
"add"
:[
{
"icon"
:
"el-icon-plus"
,
"title"
:
"新增"
,
"type"
:
"
defaul
t"
,
"key"
:
"new"
,
"isOnGrid"
:
true
},
{
"icon"
:
"el-icon-save"
,
"title"
:
"保存"
,
"type"
:
"
defaul
t"
,
"key"
:
"save"
,
"isOnForm"
:
true
},
{
"icon"
:
"el-icon-plus"
,
"title"
:
"新增"
,
"type"
:
"
tex
t"
,
"key"
:
"new"
,
"isOnGrid"
:
true
},
{
"icon"
:
"el-icon-save"
,
"title"
:
"保存"
,
"type"
:
"
tex
t"
,
"key"
:
"save"
,
"isOnForm"
:
true
},
],
"edit"
:[
{
"icon"
:
"el-icon-edit"
,
"title"
:
"修改"
,
"type"
:
"
defaul
t"
,
"key"
:
"edit"
,
"isInRow"
:
true
},
{
"icon"
:
"el-icon-edit"
,
"title"
:
"修改"
,
"type"
:
"
tex
t"
,
"key"
:
"edit"
,
"isInRow"
:
true
},
],
"delete"
:[
{
"icon"
:
"el-icon-remove"
,
"title"
:
"删除"
,
"type"
:
"
defaul
t"
,
"key"
:
"delete"
,
"isInRow"
:
true
},
{
"icon"
:
"el-icon-edit"
,
"title"
:
"停用"
,
"type"
:
"
defaul
t"
,
"key"
:
"stopUser"
,
"isInRow"
:
true
,
"boolProp"
:
"isEnabled"
,
"falseText"
:
"启用"
},
{
"icon"
:
"el-icon-remove"
,
"title"
:
"删除"
,
"type"
:
"
tex
t"
,
"key"
:
"delete"
,
"isInRow"
:
true
},
{
"icon"
:
"el-icon-edit"
,
"title"
:
"停用"
,
"type"
:
"
tex
t"
,
"key"
:
"stopUser"
,
"isInRow"
:
true
,
"boolProp"
:
"isEnabled"
,
"falseText"
:
"启用"
},
],
"common"
:[
{
"icon"
:
"el-icon-cancel"
,
"title"
:
"取消"
,
"type"
:
"default"
,
"key"
:
"cancel"
,
"isOnForm"
:
true
},
{
"icon"
:
"el-icon-cancel"
,
"title"
:
"取消"
,
"type"
:
"text"
,
"key"
:
"cancel"
,
"isOnForm"
:
true
},
{
"icon"
:
"el-icon-cancel"
,
"title"
:
"取消"
,
"type"
:
"text"
,
"key"
:
"cancel-search"
,
"isInSearch"
:
true
},
{
"icon"
:
"el-icon-cancel"
,
"title"
:
"搜索"
,
"type"
:
"text"
,
"key"
:
"start-search"
,
"isInSearch"
:
true
},
],
}
}
\ No newline at end of file
iview-admin/src/view/components/tables/forms/forms.vue
View file @
60c63b7a
This diff is collapsed.
Click to expand it.
iview-admin/src/view/components/tables/tables.vue
View file @
60c63b7a
<
template
>
<div>
<Card>
<tables
ref=
"tables"
editable
searchable
search-place=
"top"
v-model=
"tableData"
:columns=
"colswithauth"
@
on-rapid-query=
"doquery"
@
on-exec=
"doexec"
/>
<Button
style=
"margin: 10px 0;"
type=
"primary"
@
click=
"exportExcel"
>
导出为Csv文件
</Button>
<Forms
:fminfo=
"forminfo"
></Forms>
<Card
style=
"height:100%"
>
<Drawer
placement=
"right"
:closable=
"false"
v-model=
"showsearch"
width=
"600"
>
<Forms
ref=
"searchform"
:fminfo=
"searchinfo"
style=
"height:100%"
>
<template
v-slot:default=
"slotProps"
>
<Button
v-for=
"bt in searchbtns"
:key=
"bt.key"
:type=
"bt.type"
@
click=
"doquery(slotProps.fm,bt.key)"
>
{{
bt
.
title
}}
</Button>
</
template
>
</Forms>
</Drawer>
<div>
<tables
ref=
"tables"
editable
searchable
search-place=
"top"
highlightRow
v-model=
"tableData"
:columns=
"colswithauth"
@
on-rapid-query=
"doquery"
@
on-exec=
"doexec"
@
on-select=
"onsels"
@
on-adv-search=
"advsearch"
/>
<div
style=
"text-align:center"
>
<Page
:total=
"pageInfo.total"
:current
.
sync=
"pageInfo.pageNo"
:page-size=
"pageInfo.pageSize"
show-sizer
@
on-page-size-change=
"onsizeChange"
@
on-change=
"onpagechange"
/>
</div>
</div>
<!-- <Button style="margin: 10px 0;" type="primary" @click="exportExcel">导出为Csv文件</Button> -->
<Drawer
placement=
"right"
:closable=
"false"
v-model=
"showedform"
width=
"70"
>
<Forms
ref=
"edform"
:fminfo=
"forminfo"
style=
"height:100%"
></Forms>
</Drawer>
</Card>
<Modal
v-model=
"isdel"
width=
"360"
>
<p
slot=
"header"
style=
"color:#f60;text-align:center"
>
<Icon
type=
"ios-information-circle"
></Icon>
<span>
Delete confirmation
</span>
</p>
<div
style=
"text-align:center"
>
<p>
After this task is deleted, the downstream 10 tasks will not be implemented.
</p>
<p>
Will you delete it?
</p>
</div>
<div
slot=
"footer"
>
<Button
type=
"error"
size=
"large"
long
:loading=
"modal_loading"
@
click=
"delpost"
>
Delete
</Button>
</div>
</Modal>
</div>
</template>
...
...
@@ -28,58 +72,185 @@ export default {
Forms
},
props
:
{
metaName
:
String
,
default
:
"user_info"
packageName
:
String
,
metaName
:
{
type
:
String
,
default
:
"user_info"
},
isMulti
:
Boolean
,
sumfields
:
{
type
:
Array
,
default
()
{
return
[];
}
},
avgfields
:
{
type
:
Array
,
default
()
{
return
[];
}
},
calcfields
:
{
type
:
Array
,
default
()
{
return
[];
}
}
},
data
()
{
this
.
packageName
=
"auth"
;
this
.
metaName
=
"user_info"
;
return
{
metainfo
:
this
.
$store
.
getters
[
this
.
metaName
],
tableData
:
[]
metainfo
:
this
.
$store
.
getters
[
this
.
metaName
],
tableData
:
[],
isdel
:
false
,
modal_loading
:
false
,
currentRow
:
null
,
currentSels
:
null
,
pageInfo
:
{
pageNo
:
1
,
pageSize
:
10
,
total
:
100
},
searchModel
:
{},
showsearch
:
false
,
showedform
:
false
,
sum_fields
:
this
.
sumfields
?
this
.
sumfields
:
[],
avg_fields
:
this
.
avgfields
?
this
.
avgfields
:
[],
calcdata
:
this
.
calcfields
?
this
.
calcfields
:
[{
label
:
"余额"
,
value
:
1000
}],
sumdata
:
{},
avgdata
:
{}
};
},
methods
:
{
onpagechange
()
{
this
.
fetchData
();
},
buildQuery
(
qobj
)
{
let
rtn
=
{};
if
(
qobj
)
{
rtn
.
search
=
qobj
;
}
else
{
rtn
.
search
=
this
.
$refs
.
searchform
.
formModel
;
}
rtn
.
aggsinfo
=
{
sum
:
this
.
sum_fields
,
avg
:
this
.
avg_fields
};
rtn
.
pageInfo
=
{
pageSize
:
this
.
pageInfo
.
pageSize
,
pageNo
:
this
.
pageInfo
.
pageNo
};
return
rtn
;
},
advsearch
()
{
this
.
showsearch
=
true
;
},
onsizeChange
(
s
)
{
this
.
pageInfo
.
pageSize
=
s
;
},
onsels
(
sels
,
lastsel
)
{
this
.
currentSels
=
currentSels
;
this
.
currentRow
=
lastsel
;
},
delpost
()
{
this
.
modal_loading
=
true
;
setTimeout
(()
=>
{
this
.
isdel
=
false
;
this
.
modal_loading
=
false
;
this
.
currentRow
=
null
;
},
2000
);
},
doexec
(
key
,
row
)
{
if
(
key
==
"delete"
)
{
this
.
currentRow
=
row
;
this
.
isdel
=
true
;
}
if
(
key
==
"edit"
)
{
this
.
showedform
=
true
;
}
console
.
log
(
key
,
row
);
},
doquery
(
q
)
{
console
.
log
(
q
);
doquery
(
q
,
k
)
{
if
(
k
==
"cancel-search"
)
{
this
.
$refs
.
searchform
.
resetForm
();
this
.
showsearch
=
false
;
return
;
}
if
(
k
==
"start-search"
)
{
this
.
showsearch
=
false
;
}
this
.
fetchData
(
q
);
},
exportExcel
()
{
this
.
$refs
.
tables
.
exportCsv
({
filename
:
`table-
${
new
Date
().
valueOf
()}
.csv`
});
},
fetchData
(
q
)
{
let
modelname
=
this
.
metaName
.
split
(
"_"
);
let
url
=
"/web/"
+
this
.
packageName
+
"/"
+
modelname
+
"Ctl/"
+
"findAndCountAll"
;
console
.
log
(
url
);
let
query
=
this
.
buildQuery
(
q
);
getTableData
(
url
,
query
).
then
(
res
=>
{
console
.
log
(
res
.
data
);
this
.
tableData
=
res
.
data
.
data
.
results
.
rows
;
this
.
pageInfo
.
total
=
res
.
data
.
data
.
results
.
count
;
});
}
},
mounted
()
{
getTableData
().
then
(
res
=>
{
this
.
tableData
=
res
.
data
;
});
//从缓存中恢复查询条件
this
.
fetchData
();
},
created
()
{
if
(
this
.
isMulti
&&
this
.
metainfo
)
{
this
.
metainfo
[
"list"
].
unshift
({
type
:
"selection"
,
width
:
60
,
align
:
"center"
});
}
},
computed
:
{
forminfo
(){
return
this
.
metainfo
[
"form"
]
searchinfo
()
{
return
this
.
metainfo
[
"search"
];
},
forminfo
()
{
return
this
.
metainfo
[
"form"
];
},
formbtns
()
{
return
this
.
metainfo
[
"auths"
].
filter
(
bt
=>
{
return
this
.
metainfo
[
"auths"
].
filter
(
bt
=>
{
return
bt
.
isOnForm
;
});
},
searchbtns
()
{
return
this
.
metainfo
[
"auths"
].
filter
(
bt
=>
{
return
bt
.
isInSearch
;
});
},
onlistbtns
()
{
return
this
.
metainfo
[
"auths"
].
filter
(
bt
=>
{
return
bt
.
isOnGrid
;
});
},
colswithauth
(){
let
listbtns
=
this
.
metainfo
[
"auths"
].
filter
(
bt
=>
{
return
bt
.
isInRow
;
});
this
.
metainfo
[
"list"
].
forEach
(
c
=>
{
if
(
c
.
key
==
"handle"
){
c
.
button
.
push
(...
listbtns
)
}
})
return
this
.
metainfo
[
"list"
]
colswithauth
()
{
let
listbtns
=
this
.
metainfo
[
"auths"
].
filter
(
bt
=>
{
return
bt
.
isInRow
;
});
this
.
metainfo
[
"list"
].
forEach
(
c
=>
{
if
(
c
.
key
==
"handle"
)
{
c
.
button
.
push
(...
listbtns
);
}
});
return
this
.
metainfo
[
"list"
];
}
}
};
...
...
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