log_view.js 6.05 KB
var $ = require('jquery'),
	common = require('../../../../common/common'),
    rejectPromotions=require('./edit_reject');
var baseInfoEdit=require('./edit_baseinfo');
var date_util=require('./_date_util');
var operationEdit=require('./edit_operation');
var conditionEdit=require('./edit_condition');
var displayEdit=require('./edit_display');
var limitEdit=require('./edit_limit');

/*
 *	获取业务数据
 */
window.PromotionInfo={};


var fixDateTime=function(){
    if(PromotionInfo.startTime&&PromotionInfo.startTime>0){
        PromotionInfo.startTimeStr=date_util.getDateStr(PromotionInfo.startTime);
    }
    if(PromotionInfo.endTime&&PromotionInfo.endTime>0){
        PromotionInfo.endTimeStr=date_util.getDateStr(PromotionInfo.endTime);
    }
}


//build Reject Data
var buildRejectData=function(){
    var _reject=[];
    if(PromotionInfo.promotionParams&&PromotionInfo.promotionParams.rejectParam){
        _reject=JSON.parse(PromotionInfo.promotionParams.rejectParam);
    }
    return {
            promotionId : PromotionInfo.id,
            reject:_reject,
            startTimeStr: PromotionInfo.startTimeStr,
            endTimeStr: PromotionInfo.endTimeStr    
        };
}
var buildMultiData=function(){
    var _multi=[];
    if(PromotionInfo.promotionParams&&PromotionInfo.promotionParams.multiParam){
        _multi=JSON.parse(PromotionInfo.promotionParams.multiParam);
    }
    return {
        promotionId : PromotionInfo.id,
        multi:_multi
    };
}
//build Operation Data
var buildOperationData=function(){
    var _promotionType;
    if(PromotionInfo.promotionParams&&PromotionInfo.promotionParams.promotionType){
        _promotionType=PromotionInfo.promotionParams.promotionType;
    }
    var _actionParam;
    if(PromotionInfo.promotionParams&&PromotionInfo.promotionParams.actionParam){
        _actionParam=JSON.parse(PromotionInfo.promotionParams.actionParam);
    }
    return {
        promotionType : _promotionType,
        actionParam : _actionParam,
        promotionId : PromotionInfo.id
    };

}

var logView={
    init :function(_params){
        PromotionInfo=_params.promotionInfo;
        //修复日期格式
        fixDateTime();
    },
    loadTabHtml:function(columnname){
        var _g=this;
        var default_html="<a href='#'>bad error</a>";
        var config_data={
                tabLoader:_g,
                columnName:columnname,
                promotionId : PromotionInfo.id
            };

        var tempId, loadData;
        switch(type){
            case 1:
            case 2:
                tempId="fm_baseInfo";
                

                var html_baseinfo=common.util.__template2($("#fm_baseInfo").html(), PromotionInfo);
                common.dialog.open({
                    title: '促销操作回放',
                    width: 900,
                    content: common.util.__template2($("#"+tempId).html(),loadData),	            
                    backdrop: true
                });
                baseInfoEdit.load(config_data);
                break;
            case 4:
                tempId="fm_reject";
                loadData=column_data.promotionInfoBo.promotionParams;
                break;
            case 5:
                tempId="fm_limit";
                loadData=column_data.promotionInfoBo.promotionParams;
                break;
            case 6:
                tempId="fm_operation";
                loadData=column_data.promotionInfoBo.promotionParams;
                break;
            case 7:
                tempId="fm_condition";
                loadData=column_data.promotionInfoBo.promotionParams;

                var html_condition = $("#fm_condition").html()||default_html;
                $("#modal-body").html(html_condition);
                conditionEdit.load(config_data);
            case 8:
                tempId="fm_display";
                loadData=column_data.promotionInfoBo;
                break;
            case 9:
                tempId="fm_multi";
                loadData=column_data.promotionInfoBo.promotionParams;
                break;
        }
        


        if (columnname === ENUM.tabName[0].en) {//baseinfo        
            
        }else if(columnname === ENUM.tabName[1].en) {//condition
            
        } else if(columnname === ENUM.tabName[2].en) {//operation
            var html_operation = $("#fm_operation").html()||default_html;
            var operationData = buildOperationData(); 
            html_operation= common.util.__template2(html_operation, operationData);      
            $("#modal-body").html(html_operation);

            operationEdit.load($.extend(operationData,config_data));
        }else if(columnname === ENUM.tabName[3].en) {//limit
            var html_limit = $("#fm_limit").html()||default_html;
            var _data= { promotionId: PromotionInfo.id};
            
            if(PromotionInfo.promotionParams && PromotionInfo.promotionParams.limitParam){
                _data["limitParam"] = PromotionInfo.promotionParams.limitParam;
            }
        
            html_limit=common.util.__template2(html_limit, _data);
            $("#modal-body").html(html_limit);
            limitEdit.load( $.extend(_data,config_data));

        }else if(columnname === ENUM.tabName[4].en) {//reject
            // 加载促销列表
            var html_promotions=$("#fm_reject").html();
            $("#modal-body").html(html_promotions);
            var _rejectData=buildRejectData();        
            rejectPromotions.init( $.extend(_rejectData,config_data));
        }else if(columnname === ENUM.tabName[5].en) {//display
            
            var html_display = common.util.__template2($("#fm_display").html(),PromotionInfo);
            
            $("#modal-body").html(html_display);

            displayEdit.load(config_data);
        }else if(columnname === ENUM.tabName[6].en) {//multi
            // 加载促销列表
            var html_promotions=$("#fm_multi").html();
            $("#modal-body").html(html_promotions);
            var _multiData=buildMultiData();
            rejectPromotions.init( $.extend(_multiData,config_data));
        }
    }
};