export type ParasStrItemType = {
|
value: string;
|
|
children: ParasStrItemType[];
|
};
|
|
/**
|
*
|
* @param rowParas 当前行参数
|
* @param dict 参数 key 的中文字典翻译
|
* @returns
|
*/
|
export const getParasStr = (rowParas, dict?) => {
|
const paras = rowParas ?? {};
|
const parasStr: ParasStrItemType[] = [];
|
for (const key in paras) {
|
if (Object.prototype.hasOwnProperty.call(paras, key)) {
|
const value = paras[key];
|
// 需要通过字典翻译 key
|
let keyStr = key;
|
if (dict) {
|
keyStr = Array.isArray(paras) ? key : dict[key];
|
}
|
// value 也可能需要转换,例如 ID 转为 Name,unitTypeCode 转为 Name
|
const parasStrItem: ParasStrItemType = {
|
value: '',
|
children: [],
|
};
|
let valueStr = '';
|
if (typeof value === 'object') {
|
const childParas = getParasStr(value, dict);
|
parasStrItem.children = childParas;
|
}
|
// else if (key === 'UnitType' || key === 'XUnitType' || key === 'YUnitType') {
|
// valueStr = unitTypeCodeMap.value?.[value]?.Name;
|
// getRowUnitValue(formatParas);
|
// }
|
|
// else if (key === 'UnitValue' || key === 'XUnitValue' || key === 'YUnitValue') {
|
// const unitType = formatParas?.UnitType ?? formatParas?.XUnitType ?? formatParas?.YUnitType;
|
// const foundUnitValue = allUnitValue.value[unitType]?.find((item) => item.Code + '' == value + '');
|
|
// if (foundUnitValue) {
|
// valueStr = foundUnitValue.Name;
|
// }
|
// }
|
else {
|
valueStr = value;
|
}
|
parasStrItem.value = `${keyStr}: ${valueStr}`;
|
|
parasStr.push(parasStrItem);
|
}
|
}
|
|
return parasStr;
|
};
|