LogIndex.js 5.9 KB
/**
 * 促销管理
 */
'use strict';
var $ = require('jquery'),
common = require('../../../common/common');
require('../../../common/util/datepicker');
var addEdit=require("./partials/Add");
var jsonUtils=require("./partials/jsonUtils");

var LogList;
var g = new common.grid({
    el: '#basicTable',
    size: 10,
    parms: function() {
        return {           
            type:$("#type").val(),
            promotionId:common.util.__input('promotionId')
        };
    },
    columns: [{
       display: "ID",
        name: "id"
    }, {
        display: "促销id",
        name: "promotionId"        
    }, {
        display: '操作人',
        render: function(item){
            return item.operatorName + "["+ item.operatorId +"]";
        }
    }, {
        display: '编辑时间',
        name: "editTime",
        render: function(item) {
            var date = new Date(item.editTime * 1000);
            return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds();
        }
    }, {
        display: '促销信息',
        name: "promotionInfo"
    }, {
        display: '操作类型',
        name: "type",
        render: function(item) {
            var name;
            switch(item.type){
                case 1:
                    name="新增";  
                    break;
                case 2: name="修改基本信息";break; 
                case 3: name="删除";break;                          
                case 4: name="修改互斥";break;
                case 5: name="修改限制";break;
                case 6: name="修改操作";break;
                case 7: name="修改条件";break;
                case 8: name="修改显示";break;
                case 9: name="修改多档";break;
            }
            
            return name;
        }    
    },  {
        display: '操作',
        name: "",
        render: function(items) {
            var HtmArr = [];
            HtmArr.push("<a href=\"javascript:;\" onclick=\"View.view(" + items.__index + "," + items.type +")\" class=\"btn btn-info btn-xs\">查看</a>");                               
            return HtmArr.join('');
        }
    }]
})
g.init('/promotionInfo/log/list');

//查询
$("#filter-btn").click(function() {
    g.reload(1);    
});




var view={
    view: function(_index){
    if(!g.response || !g.response.list){
        return;
    }
    
    LogList=g.response.list;
   
    if(!LogList || LogList.length===0 || _index>LogList.length || _index<0){
        return;
    }
    var column_data = LogList[_index];
    var type=column_data.type;
    if(!type){
        return;
    }
    /**
     * <option value="1">新增</option>  
    <option value="2">修改基本信息</option> 
    <option value="3">删除</option>                          
    <option value="4">修改互斥</option>
    <option value="5">修改限制</option>
    <option value="6">修改操作</option>
    <option value="7">修改条件</option>
    <option value="8">修改显示</option>
     */
    var tempId, loadData=$.extend(true,{},column_data.promotionInfoBo);
    var content;
    var appendHtml="";
    switch(type){
        case 1:
        case 2:
            tempId="fm_baseInfo";            
            break;
        case 4:
            tempId="fm_reject";
            if(typeof column_data.promotionInfoBo.promotionParams.rejectParam == 'string'){
                var rejectParam= JSON.parse(column_data.promotionInfoBo.promotionParams.rejectParam);
                loadData.promotionParams.rejectParam = rejectParam;
            }
            break;
        case 5:
            tempId="fm_limit";
            
            break;
        case 6:
            tempId="fm_operation";  
            if(typeof column_data.promotionInfoBo.promotionParams.actionParam == 'string'){
                var actionParam=JSON.parse(column_data.promotionInfoBo.promotionParams.actionParam);
                loadData.promotionParams.actionParam = actionParam;
            }          
            
            break;
        case 7:
            tempId="fm_condition";
            var conditionParam=JSON.parse(column_data.promotionInfoBo.promotionParams.conditionParam);
            loadData.promotionParams.conditionParam = conditionParam;
            break;
        case 8:
            tempId="fm_display";     
              
            if(loadData.commonBanner){
                var commonBanner_span = $("<span>促销页图片<br/></span>");  
                var commonBanner_image= $("<image />");
                commonBanner_image.attr("src",loadData.commonBanner);
                commonBanner_span.append(commonBanner_image);                
                appendHtml += commonBanner_span.prop("outerHTML");
                appendHtml += "<br/>";
            }
            if(loadData.shoppingCartBanner){
                var shoppingCartBanner_span = $("<span>促销页图片<br/></span>");  
                var shoppingCartBanner_image= $("<image />");
                shoppingCartBanner_image.attr("src",loadData.shoppingCartBanner);
                shoppingCartBanner_span.append(shoppingCartBanner_image);
                appendHtml += shoppingCartBanner_span.prop("outerHTML");
            }            
            break;
        case 9:
            tempId="fm_multi";
            if(typeof column_data.promotionInfoBo.promotionParams.multiParam == 'string'){
                var multiParam= JSON.parse(column_data.promotionInfoBo.promotionParams.multiParam);
                loadData.promotionParams.multiParam = multiParam;
            }
            break;
    }
    
    
    
    var formatData = jsonUtils.formatJson(loadData);
    content ="<p>"+formatData+"</p>";
    if(appendHtml != ""){
        content+=appendHtml;
    }
    common.dialog.open({
        title: '促销操作数据回放',
        width: 900,
	    content: content,	            
	    backdrop: true
    });
}
}
document.View=view;