Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
V
vue3-quasar-ts-study01
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hucy
vue3-quasar-ts-study01
Commits
5f4985ad
Commit
5f4985ad
authored
Dec 29, 2022
by
hucy
☘
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:AgGrid细节表格学习
parent
d1b7ac7d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
132 additions
and
7 deletions
+132
-7
IndexPage.vue
src/modules/page9/IndexPage.vue
+18
-6
AgGridDetailGrids.vue
src/modules/page9/element/AgGridDetailGrids.vue
+113
-0
AgGridMaster.vue
src/modules/page9/element/AgGridMaster.vue
+0
-0
routes.ts
src/router/routes.ts
+1
-1
No files found.
src/modules/page9/IndexPage.vue
View file @
5f4985ad
...
@@ -2,6 +2,11 @@
...
@@ -2,6 +2,11 @@
* 动画2
* 动画2
* https://www.youtube.com/@OnlineTutorialsYT/playlists
* https://www.youtube.com/@OnlineTutorialsYT/playlists
-->
-->
<
script
lang=
"ts"
>
export
default
{
name
:
'PAGE9'
,
};
</
script
>
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
{
ref
}
from
'vue'
;
import
{
ref
}
from
'vue'
;
import
TextVue
from
'./element/TextVue.vue'
;
import
TextVue
from
'./element/TextVue.vue'
;
...
@@ -10,7 +15,8 @@ import SvgLineDrawingAnimation from './element/SvgLineDrawingAnimation.vue';
...
@@ -10,7 +15,8 @@ import SvgLineDrawingAnimation from './element/SvgLineDrawingAnimation.vue';
import
FlyingTextAnimationEffects
from
'./element/FlyingTextAnimationEffects.vue'
;
import
FlyingTextAnimationEffects
from
'./element/FlyingTextAnimationEffects.vue'
;
import
TransformationAnimation
from
'./element/TransformationAnimation.vue'
;
import
TransformationAnimation
from
'./element/TransformationAnimation.vue'
;
import
AgGridStudy
from
'./element/AgGridStudy2.vue'
;
import
AgGridStudy
from
'./element/AgGridStudy2.vue'
;
import
AgGridGroup1
from
'./element/AgGridGroup1.vue'
;
import
AgGridMaster
from
'./element/AgGridMaster.vue'
;
import
AgGridDetailGrids
from
'./element/AgGridDetailGrids.vue'
;
const
listData
=
[
const
listData
=
[
{
{
...
@@ -38,13 +44,17 @@ const listData = [
...
@@ -38,13 +44,17 @@ const listData = [
name
:
'ag-grid-study'
,
name
:
'ag-grid-study'
,
},
},
{
{
title
:
'AG grid 分组1'
,
title
:
'AG grid 细节表格'
,
name
:
'ag-grid-group1'
,
name
:
'ag-grid-master'
,
},
{
title
:
'Vue Data Grid: Master / Detail - Detail Grids'
,
name
:
'ag-grid-detail-grids'
,
},
},
];
];
const
isShow
=
ref
(
true
);
const
isShow
=
ref
(
true
);
const
elementName
=
ref
(
'ag-grid-
group1
'
);
const
elementName
=
ref
(
'ag-grid-
detail-grids
'
);
const
elementTitle
=
ref
(
'
AG grid 分组1
'
);
const
elementTitle
=
ref
(
'
Vue Data Grid: Master / Detail - Detail Grids
'
);
function
onclick
(
data
:
any
)
{
function
onclick
(
data
:
any
)
{
elementTitle
.
value
=
data
.
title
;
elementTitle
.
value
=
data
.
title
;
...
@@ -55,6 +65,7 @@ function goBack() {
...
@@ -55,6 +65,7 @@ function goBack() {
isShow
.
value
=
false
;
isShow
.
value
=
false
;
}
}
</
script
>
</
script
>
<
template
>
<
template
>
<div>
<div>
<div
v-if=
"isShow"
class=
"main"
>
<div
v-if=
"isShow"
class=
"main"
>
...
@@ -82,7 +93,8 @@ function goBack() {
...
@@ -82,7 +93,8 @@ function goBack() {
v-if=
"elementName === 'transformation-animation'"
v-if=
"elementName === 'transformation-animation'"
/>
/>
<ag-grid-study
v-if=
"elementName === 'ag-grid-study'"
/>
<ag-grid-study
v-if=
"elementName === 'ag-grid-study'"
/>
<ag-grid-group1
v-if=
"elementName === 'ag-grid-group1'"
/>
<ag-grid-master
v-if=
"elementName === 'ag-grid-master'"
/>
<ag-grid-detail-grids
v-if=
"elementName === 'ag-grid-detail-grids'"
/>
</div>
</div>
</div>
</div>
<div
v-else
>
<div
v-else
>
...
...
src/modules/page9/element/AgGridDetailGrids.vue
0 → 100644
View file @
5f4985ad
<!--
* AG-grid 细节网格细节配置
* https://www.ag-grid.com/vue-data-grid/master-detail-grids/
-->
<
script
setup
lang=
"ts"
>
import
{
ref
,
reactive
,
onMounted
}
from
'vue'
;
import
{
AgGridVue
}
from
'ag-grid-vue3'
;
import
'ag-grid-enterprise'
;
import
'ag-grid-community/styles/ag-grid.css'
;
import
'ag-grid-community/styles/ag-theme-alpine.css'
;
const
defaultColDef
=
{
flex
:
1
,
suppressMenu
:
true
,
// 禁用标题行菜单
};
const
gridApi
=
ref
<
any
>
(
null
);
const
gridColumnApi
=
ref
<
any
>
(
null
);
const
detailCellRendererParams
=
reactive
({
// 提供要在细节网格上使用的网格选项
detailGridOptions
:
{
columnDefs
:
[
{
field
:
'callId'
,
headerName
:
'呼叫标识'
},
{
field
:
'direction'
,
headerName
:
'方向'
},
{
field
:
'number'
,
headerName
:
'号码'
},
{
field
:
'duration'
,
headerName
:
'持续时间'
,
valueFormatter
:
'x.toLocaleString() + "秒"'
,
},
{
field
:
'switchCode'
,
headerName
:
'开关代码'
},
],
defaultColDef
,
rowSelection
:
'multiple'
,
suppressRowClickSelection
:
true
,
// 抑制行点击选择
enableRangeSelection
:
true
,
// 启用范围选择
pagination
:
true
,
paginationAutoPageSize
:
true
,
},
// 获得每个细节网格的行数
getDetailRowData
:
(
params
:
any
)
=>
{
params
.
successCallback
(
params
.
data
.
callRecords
||
[]);
},
});
const
state
=
reactive
({
columnDefs
:
[
{
field
:
'name'
,
headerName
:
'姓名'
,
cellRenderer
:
'agGroupCellRenderer'
},
{
field
:
'account'
,
headerName
:
'帐户'
},
{
field
:
'calls'
,
headerName
:
'呼叫'
},
{
field
:
'minutes'
,
headerName
:
'分钟'
,
valueFormatter
:
'x.toLocaleString() + "分钟"'
,
},
],
rowData
:
[]
as
any
,
});
onMounted
(()
=>
{
fetch
(
'https://www.ag-grid.com/example-assets/master-detail-data.json'
)
.
then
((
result
)
=>
result
.
json
())
.
then
((
remoteRowData
)
=>
{
state
.
rowData
=
remoteRowData
;
console
.
log
(
'rowData'
,
state
.
rowData
[
0
]);
});
// .then((remoteRowData) => (state.rowData = remoteRowData));
});
function
onGridReady
(
params
:
any
)
{
gridApi
.
value
=
params
.
api
;
gridColumnApi
.
value
=
params
.
columnApi
;
}
function
isRowMaster
(
dataItem
:
any
)
{
let
flag
;
if
(
dataItem
&&
dataItem
.
callRecords
&&
dataItem
.
callRecords
.
length
>
0
)
{
flag
=
true
;
}
else
{
flag
=
false
;
}
return
flag
;
}
</
script
>
<
template
>
<div
class=
"box"
>
<!--
rowSelection="multiple":多选,按住control键多选;【control+shift+鼠标点击】可选中多行
animateRows=true:启用行动画
:masterDetail="true" 启用展开的细节网格行
:isRowMaster="isRowMaster" 确定哪一个行该展开
-->
<div>
<ag-grid-vue
style=
"height: 700px"
class=
"ag-theme-alpine"
:columnDefs=
"state.columnDefs"
:rowData=
"state.rowData"
:defaultColDef=
"defaultColDef"
:animateRows=
"true"
:masterDetail=
"true"
:isRowMaster=
"isRowMaster"
:detailCellRendererParams=
"detailCellRendererParams"
@
grid-ready=
"onGridReady"
>
</ag-grid-vue>
</div>
</div>
</
template
>
<
style
lang=
"scss"
scoped
></
style
>
src/modules/page9/element/AgGrid
Group1
.vue
→
src/modules/page9/element/AgGrid
Master
.vue
View file @
5f4985ad
File moved
src/router/routes.ts
View file @
5f4985ad
...
@@ -10,7 +10,7 @@ const routes: RouteRecordRaw[] = [
...
@@ -10,7 +10,7 @@ const routes: RouteRecordRaw[] = [
path
:
''
,
path
:
''
,
name
:
'LaoutIndexPage'
,
name
:
'LaoutIndexPage'
,
component
:
()
=>
import
(
'pages/IndexPage.vue'
),
component
:
()
=>
import
(
'pages/IndexPage.vue'
),
redirect
:
'/page
10
'
,
redirect
:
'/page
9
'
,
children
:
[
children
:
[
{
{
path
:
'page1'
,
path
:
'page1'
,
...
...
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