'use strict';

import { IRptTpl, IOrgGroupField } from '../interface/basic';
import { JV } from './jpc_value_define';

export const JpcParam = {
    createNew(rptTpl: IRptTpl) {
        let JpcParamResult = {};
        let me = this;
        if (rptTpl.离散参数_集合) {
            for (let i = 0; i < rptTpl.离散参数_集合.length; i++) {
                me.createSingle(rptTpl.离散参数_集合[i], JpcParamResult, i);
            }
        }
        return JpcParamResult;
    },
    createSingle(paramNode: IOrgGroupField, parentObj: Record<string, IOrgGroupField | {}>, sequence: number) {
        if (paramNode && paramNode.ID) {
            const item = {
                ID: paramNode.ID,
                Name: paramNode.Name,
                DataType: paramNode.DataType,
                Default_Value: (paramNode.Default_Value) ? paramNode.Default_Value : null,
                DataSeq: sequence
            };
            parentObj[JV.PROP_ID + '_' + paramNode.ID] = item;
        }
    }
};
