网元列表进行特制化排序-初版

This commit is contained in:
lai
2023-12-12 16:44:56 +08:00
parent 752f8ccc70
commit e6d62da386
2 changed files with 78 additions and 2 deletions

View File

@@ -7,6 +7,23 @@ import { parseDateToStr } from '@/utils/date-utils';
* @returns object
*/
export async function listMain() {
// 系统特定顺序
const specificOrder = [
'OMC',
'MME',
'AMF',
'AUSF',
'UDM',
'SMF',
'PCF',
'UPF',
'NRF',
'NSSF',
'IMS',
'N3IWF',
'NEF',
'LMF',
];
const result = await request({
url: '/api/rest/systemManagement/v1/elementType/all/objectType/systemState',
method: 'get',
@@ -43,8 +60,16 @@ export async function listMain() {
return mergedObj;
});
// console.log(mergedData);
// console.log(rowArr)
//通过sort进行冒泡排序
mergedData.sort((a: any, b: any) => {
const typeA = specificOrder.indexOf(a.name.split("_")[0]);
const typeB = specificOrder.indexOf(b.name.split("_")[0]);
if (typeA === -1) return 1; // 如果不在特定顺序中,排到后面
if (typeB === -1) return -1; // 如果不在特定顺序中,排到后面
return typeA - typeB;
});
//console.log(mergedData);
return mergedData;
}