@@ -57,7 +57,9 @@ const expandedArray = ref([])
5757const resourceListTree = ref ()
5858const returnMounted = ref (false )
5959const state = reactive ({
60- curSortType: ' time_desc' ,
60+ curSortType: ' name_asc' ,
61+ curSortTypePrefix: ' name' ,
62+ curSortTypeSuffix: ' _asc' ,
6163 resourceTree: [] as SQTreeNode [],
6264 originResourceTree: [] as SQTreeNode [],
6365 sortType: [],
@@ -134,6 +136,7 @@ const getTree = async () => {
134136 dashboardApi .list_resource (params ).then ((res : SQTreeNode []) => {
135137 state .originResourceTree = res || []
136138 state .resourceTree = _ .cloneDeep (state .originResourceTree )
139+ handleSortTypeChange (' name_asc' )
137140 afterTreeInit ()
138141 })
139142}
@@ -246,16 +249,41 @@ const baseInfoChangeFinish = () => {
246249 getTree ()
247250}
248251
249- const handleSortTypeChange = (sortType : string ) => {
250- state .resourceTree = treeSort (state .originResourceTree , sortType )
251- state .curSortType = sortType
252+ const handleSortTypeChange = (menuSortType : string ) => {
253+ state .curSortTypePrefix = [' name' , ' time' ].includes (menuSortType )
254+ ? menuSortType
255+ : state .curSortTypePrefix
256+ state .curSortTypeSuffix = [' _asc' , ' _desc' ].includes (menuSortType )
257+ ? menuSortType
258+ : state .curSortTypeSuffix
259+ const curMenuSortType = state .curSortTypePrefix + state .curSortTypeSuffix
260+ state .resourceTree = treeSort (state .originResourceTree , curMenuSortType )
261+ state .curSortType = curMenuSortType
252262 wsCache .set (' TreeSort-dashboard' , state .curSortType )
253263}
254264
255- // const sortTypeChange = (sortType: string) => {
256- // state.resourceTree = treeSort(state.originResourceTree, sortType)
257- // state.curSortType = sortType
258- // }
265+ const sortColumnList = [
266+ {
267+ name: t (' dashboard.time' ),
268+ value: ' time' ,
269+ },
270+ {
271+ name: t (' dashboard.name' ),
272+ value: ' name' ,
273+ divided: true ,
274+ },
275+ ]
276+
277+ const sortTypeList = [
278+ {
279+ name: t (' dashboard.sort_asc' ),
280+ value: ' _asc' ,
281+ },
282+ {
283+ name: t (' dashboard.sort_desc' ),
284+ value: ' _desc' ,
285+ },
286+ ]
259287
260288const sortList = [
261289 {
@@ -322,7 +350,12 @@ defineExpose({
322350 </el-icon >
323351 </template >
324352 </el-input >
325- <el-dropdown trigger =" click" @command =" handleSortTypeChange" >
353+ <el-dropdown
354+ popper-class =" tree-sort-menu-custom"
355+ trigger =" click"
356+ placement =" bottom-end"
357+ @command =" handleSortTypeChange"
358+ >
326359 <el-icon class =" filter-icon-span" >
327360 <el-tooltip :offset =" 16" effect =" dark" :content =" sortTypeTip" placement =" top" >
328361 <Icon v-if =" state.curSortType.includes('asc')" name =" dv-sort-asc" class =" opt-icon"
@@ -336,17 +369,28 @@ defineExpose({
336369 </el-tooltip >
337370 </el-icon >
338371 <template #dropdown >
339- <el-dropdown-menu style =" width : 246px " >
340- <template v-for =" ele in sortList " :key =" ele .value " >
372+ <el-dropdown-menu style =" width : 120px " >
373+ <span class =" sort_menu" >{{ t('dashboard.sort_column') }}</span >
374+ <template v-for =" ele in sortColumnList " :key =" ele .value " >
341375 <el-dropdown-item
342376 class =" ed-select-dropdown__item"
343- :class =" ele.value === state.curSortType && 'selected'"
377+ :class =" state.curSortType.includes(ele.value) && 'selected'"
344378 :command =" ele.value"
345379 >
346380 {{ ele.name }}
347381 </el-dropdown-item >
348382 <li v-if =" ele.divided" class =" ed-dropdown-menu__item--divided" ></li >
349383 </template >
384+ <span class =" sort_menu" >{{ t('dashboard.sort_type') }}</span >
385+ <template v-for =" ele in sortTypeList " :key =" ele .value " >
386+ <el-dropdown-item
387+ class =" ed-select-dropdown__item"
388+ :class =" state.curSortType.includes(ele.value) && 'selected'"
389+ :command =" ele.value"
390+ >
391+ {{ ele.name }}
392+ </el-dropdown-item >
393+ </template >
350394 </el-dropdown-menu >
351395 </template >
352396 </el-dropdown >
@@ -555,6 +599,17 @@ defineExpose({
555599 </style >
556600
557601<style lang="less">
602+ .tree-sort-menu-custom {
603+ padding : 0 4px !important ;
604+ li {
605+ border-radius : 4px ;
606+ padding : 0 8px !important ;
607+ & :hover {
608+ // color: var(--primary-color);
609+ background-color : rgba (31 , 35 , 41 , 0.1 ) !important ;
610+ }
611+ }
612+ }
558613.menu-outer-dv_popper {
559614 min-width : 140px ;
560615 margin-top : -2px !important ;
@@ -586,4 +641,10 @@ defineExpose({
586641.color-dataV-disabled {
587642 background : #bbbfc4 !important ;
588643}
644+
645+ .sort_menu {
646+ color : rgba (143 , 149 , 158 , 1 );
647+ font-size : 14px ;
648+ margin-left : 12px ;
649+ }
589650 </style >
0 commit comments