gerson
2025-02-20 a762b59c2c4b459f72ede19716d476bb3513f622
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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;
};