/**
 * Created by Tony on 2019/5/17.
 */
'use strict';

import { IRptTpl } from '../interface/basic';
import { IEventType } from '../interface/enum';
import { JV } from './jpc_value_define';

export const JpcEvent = {
    createNew(rptTpl: IRptTpl) {
        let rst = {
            GRP_ON_CREATE: {},          //bylish
            FLOW_CONTENT_ON_CREATE: {}  //bylish
        };
        if (rptTpl.事件_集合) {
            for (let i = 0; i < rptTpl.事件_集合.length; i++) {
                let item = { ...rptTpl.事件_集合[i] };
                // let propArr = Object.getOwnPropertyNames(rptTpl[JV.NODE_EVENTS][i]);
                // for (let key of propArr) {
                //     item[key] = rptTpl[JV.NODE_EVENTS][i][key];
                // }
                const event_type = [IEventType.GRP_ON_CREATE, IEventType.FLOW_CONTENT_ON_CREATE]
                switch (event_type.indexOf(item.type)) {
                    case JV.EVENT_IDX_GRP_ON_CREATE:
                        rst.FLOW_CONTENT_ON_CREATE = item;
                        break;
                    case JV.EVENT_IDX_FLOW_CONTENT_ON_CREATE:
                        rst.FLOW_CONTENT_ON_CREATE = item;
                        break;
                    default:
                        break;
                }
                //rst.push(item);
            }
        }
        return rst;
    }
};

