1
1
<script setup lang="ts">
2
- import type { Ref } from ' vue' ;
3
- import { onMounted , ref , toRaw } from ' vue' ;
4
- import { IwEvents , IwProps } from ' ../src' ;
5
- import { IwUtils } from ' ../src/utils' ;
2
+ import type { Ref } from ' vue'
3
+ import { onMounted , ref , toRaw } from ' vue'
4
+ import { IwEvents , IwProps } from ' ../src'
5
+ import { IwUtils } from ' ../src/utils'
6
6
7
7
const selectedRecordPks: Ref <any []> = ref ([])
8
8
@@ -123,12 +123,12 @@ const events: IwProps.TableEventProps = {
123
123
}
124
124
if (sorts ) {
125
125
sorts .conds .forEach ((sort ) => {
126
- data = data .sort ((a , b ) => {
126
+ data .sort ((a , b ) => {
127
127
if (sort .orderDesc ) {
128
- return a [sort .columnName ] - b [sort .columnName ]
128
+ return typeof a [sort .columnName ] === ' number ' ? b [ sort . columnName ] - a [ sort . columnName ] : b [sort .columnName ]. localeCompare ( a [ sort . columnName ])
129
129
}
130
130
else {
131
- return b [sort .columnName ] - a [sort .columnName ]
131
+ return typeof a [sort .columnName ] === ' number ' ? a [ sort . columnName ] - b [ sort . columnName ] : a [sort .columnName ]. localeCompare ( b [ sort . columnName ])
132
132
}
133
133
})
134
134
})
@@ -140,7 +140,15 @@ const events: IwProps.TableEventProps = {
140
140
}
141
141
if (byGroupValue && group && group .item ) {
142
142
// 只获取当前分组的数据
143
- data = data .filter (d => d [group .item ! .columnName ] === byGroupValue )
143
+ data = data .filter ((d ) => {
144
+ // eslint-disable-next-line ts/no-use-before-define
145
+ if (columns .find (col => col .name === group .item ! .columnName )?.multiValue ) {
146
+ return d [group .item ! .columnName ].includes (byGroupValue )
147
+ }
148
+ else {
149
+ return d [group .item ! .columnName ] === byGroupValue
150
+ }
151
+ })
144
152
}
145
153
if (group && group .item && ! byGroupValue ) {
146
154
let dataGroup: { [key : string ]: any [] } = IwUtils .groupBy (data , (d ) => { return d [group .item ! .columnName ] })
@@ -433,7 +441,7 @@ const events: IwProps.TableEventProps = {
433
441
},
434
442
435
443
loadCellDictItems : async (columnName : string , filterValue ? : any , slice ? : IwProps .DataQuerySliceReq ): Promise <IwProps .DictItemsResp > => {
436
- if (columnName === ' name ' ) {
444
+ if (columnName === ' creator ' ) {
437
445
let nameDict: IwProps .DictItemProps [] = JSON .parse (JSON .stringify (NAME_DICT ))
438
446
if (filterValue ) {
439
447
nameDict = nameDict .filter ((dict ) => { return dict .title .includes (filterValue ) || dict .value .includes (filterValue ) })
@@ -496,7 +504,7 @@ const events: IwProps.TableEventProps = {
496
504
}
497
505
498
506
const columns: IwProps .SimpleTableColumnProps [] = [
499
- { name: ' no' , title: ' ID' , dataKind: IwProps .DataKind .NUMBER , sortable: true , width: 80 , styles: { cursor: ' pointer' } },
507
+ { name: ' no' , title: ' ID' , dataKind: IwProps .DataKind .NUMBER , sortable: true , width: 80 , styles: { cursor: ' pointer' }, filterable: true },
500
508
{ name: ' pno' , title: ' 父ID' , dataKind: IwProps .DataKind .NUMBER , hide: true },
501
509
{ name: ' name' , title: ' 名称' , sortable: true , width: 300 , render : (record : { [key : string ]: any }, layoutKind : IwProps .LayoutKind ) => {
502
510
if (layoutKind === IwProps .LayoutKind .LIST ) {
@@ -505,36 +513,36 @@ const columns: IwProps.SimpleTableColumnProps[] = [
505
513
else {
506
514
return record .name
507
515
}
508
- } },
509
- { name: ' creator' , title: ' 创建人' , useDict: true , dictEditable: true , sortable: true , groupable: true },
510
- { name: ' stats' , title: ' 状态' , useDict: true , dictEditable: true , multiValue: true , sortable : true , groupable: true },
511
- { name: ' planStartTime' , title: ' 计划开始时间' , dataKind: IwProps .DataKind .DATETIME , sortable: true },
512
- { name: ' planEndTime' , title: ' 计划结束时间' , dataKind: IwProps .DataKind .DATETIME , sortable: true },
516
+ }, aggable: true , filterable: true },
517
+ { name: ' creator' , title: ' 创建人' , useDict: true , dictEditable: true , sortable: true , aggable: true , groupable: true , filterable : true },
518
+ { name: ' stats' , title: ' 状态' , useDict: true , dictEditable: true , multiValue: true , aggable : true , groupable: true , filterable : true },
519
+ { name: ' planStartTime' , title: ' 计划开始时间' , dataKind: IwProps .DataKind .DATETIME , aggable: true , sortable: true , filterable : true },
520
+ { name: ' planEndTime' , title: ' 计划结束时间' , dataKind: IwProps .DataKind .DATETIME , sortable: true , filterable: true },
513
521
{ name: ' actualStartTime' , title: ' 实际开始时间' , dataKind: IwProps .DataKind .DATETIME , sortable: true },
514
522
{ name: ' actualEndTime' , title: ' 实际结束时间' , dataKind: IwProps .DataKind .DATETIME , sortable: true },
515
523
]
516
524
517
525
const layouts: IwProps .SimpleLayoutProps [] = [
518
- // {
519
- // id: 'hi1',
520
- // title: 'gantt demo',
521
- // layoutKind: IwProps.LayoutKind.GANTT,
522
- // columns: [{
523
- // name: 'name',
524
- // }, {
525
- // name: 'creator',
526
- // }, {
527
- // name: 'no',
528
- // }, {
529
- // name: 'planStartTime',
530
- // }, {
531
- // name: 'planEndTime',
532
- // }, {
533
- // name: 'actualStartTime',
534
- // }, {
535
- // name: 'actualEndTime',
536
- // }],
537
- // },
526
+ {
527
+ id: ' hi1' ,
528
+ title: ' gantt demo' ,
529
+ layoutKind: IwProps .LayoutKind .GANTT ,
530
+ columns: [{
531
+ name: ' name' ,
532
+ }, {
533
+ name: ' creator' ,
534
+ }, {
535
+ name: ' no' ,
536
+ }, {
537
+ name: ' planStartTime' ,
538
+ }, {
539
+ name: ' planEndTime' ,
540
+ }, {
541
+ name: ' actualStartTime' ,
542
+ }, {
543
+ name: ' actualEndTime' ,
544
+ }],
545
+ },
538
546
{
539
547
id: ' hi2' ,
540
548
title: ' list demo' ,
@@ -614,7 +622,10 @@ const _tableProps: IwProps.SimpleTableProps = {
614
622
width: 100 ,
615
623
},
616
624
agg: {
617
- items: [],
625
+ items: [
626
+ { columnName: ' name' , aggKind: IwProps .AggregateKind .MIN },
627
+ { columnName: ' stats' , aggKind: IwProps .AggregateKind .MIN },
628
+ ],
618
629
},
619
630
gantt: {
620
631
timelineWidth: 500 ,
0 commit comments