fix: 列表查询pageNum设为1

This commit is contained in:
TsMask
2023-11-06 14:33:40 +08:00
parent de16c3d1f5
commit ca0913a8cf
42 changed files with 2652 additions and 199 deletions

View File

@@ -37,49 +37,19 @@ export async function getParamConfigTopTab(neType: string) {
return result;
}
/**
* 查询配置参数标签栏对应JSON信息
* @param neType 网元类型
* @returns object
*/
export async function getParamConfigTopTabJson(neType: string, topTag: string) {
// 发起请求
const result = await request({
url: `/api/rest/databaseManagement/v1/elementType/omc_db/objectType/param_config`,
method: 'get',
params: {
SQL: `SELECT param_json FROM param_config WHERE ne_type = '${neType}' AND top_tag='${topTag}'`,
},
});
// 解析数据
if (result.code === RESULT_CODE_SUCCESS && Array.isArray(result.data.data)) {
let data = result.data.data[0];
data = data['param_config'];
if (Array.isArray(data)) {
const v = data[0]['param_json'];
try {
result.data = JSON.parse(v);
} catch (error) {
console.error(error);
result.data = {};
}
}
return result;
}
return result;
}
/**
* 查询配置参数标签栏对应信息
* @param neType 网元类型
* @returns object
* @param topTag
* @param neId
* @returns object { wrRule, dataArr }
*/
export async function getParamConfigInfo(
async function getParamConfigInfo(
neType: string,
topTag: string,
neId: string
) {
const { wrRule, dataArr } = await Promise.allSettled([
return await Promise.allSettled([
// 获取参数规则
request({
url: `/api/rest/databaseManagement/v1/elementType/omc_db/objectType/param_config`,
@@ -134,6 +104,21 @@ export async function getParamConfigInfo(
}
return { wrRule, dataArr };
});
}
/**
* 查询配置参数标签栏对应信息-表格处理
* @param neType 网元类型
* @param topTag
* @param neId
* @returns object
*/
export async function getParamConfigInfoTable(
neType: string,
topTag: string,
neId: string
) {
const { wrRule, dataArr } = await getParamConfigInfo(neType, topTag, neId);
// UPF参数不统一
// if (neType === 'UPF') {
@@ -226,6 +211,7 @@ export async function getParamConfigInfo(
},
];
}
// 多列表
if (Reflect.has(wrRule, 'array')) {
result.data.type = 'array';
@@ -273,6 +259,95 @@ export async function getParamConfigInfo(
return result;
}
/**
* 查询配置参数标签栏对应信息-树结构处理
* @param neType 网元类型
* @param topTag
* @param neId
* @returns object
*/
export async function getParamConfigInfoTree(
neType: string,
topTag: string,
neId: string
) {
const { wrRule, dataArr } = await getParamConfigInfo(neType, topTag, neId);
type TreeNodeType = {
title: string;
key: string;
record: Record<string, any>[];
};
// 拼装数据
const result = {
code: RESULT_CODE_SUCCESS,
msg: RESULT_MSG_SUCCESS,
data: {
type: 'list' as 'list' | 'array',
data: [] as TreeNodeType[],
recordRule: {},
},
};
// kv单列表
if (Reflect.has(wrRule, 'list')) {
result.data.type = 'list';
const ruleArr = Object.freeze(wrRule['list']);
// 列表项数据
const dataList = [];
for (const item of dataArr) {
for (const key of Object.keys(item)) {
// 规则为准
for (const rule of ruleArr) {
if (rule['name'] === key) {
const ruleItem = Object.assign({ optional: 'true' }, rule, {
value: item[key],
});
dataList.push(ruleItem);
break;
}
}
}
}
result.data.data = dataList;
}
// 多列表
if (Reflect.has(wrRule, 'array')) {
result.data.type = 'array';
const ruleArr = Object.freeze(wrRule['array']);
// 列表项数据
const dataArray = [];
for (const item of dataArr) {
const index = item['index'];
let record: Record<string, any>[] = [];
for (const key of Object.keys(item)) {
// 规则为准
for (const rule of ruleArr) {
if (rule['name'] === key) {
const ruleItem = Object.assign({ optional: 'true' }, rule, {
value: item[key],
});
record.push(ruleItem);
break;
}
}
}
dataArray.push({ title: `Index-${index}`, key: index, record });
}
result.data.data = dataArray;
// 无数据时,用于新增
let dataRule: Record<string, any> = {};
for (const rule of ruleArr) {
dataRule[rule.name] = rule;
}
result.data.recordRule = dataRule;
}
return result;
}
/**
* 查询配置参数标签栏对应信息子节点
* @param neType 网元类型