goods.cod.Brand.js 8.52 KB
webpackJsonp([42],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {

	/**
	 * Created by wangqianjun on 16/4/11.
	 * 货到付款设置
	 */
	'use strict';
	var $ = __webpack_require__(1),
	    common = __webpack_require__(2);

	var ENUM = {

	    tips: {
	        "1": 0,
	        "2": 0,
	        "all": 0
	    },
	    status: {
	        '1': "开启",
	        '0': "关闭"

	    },
	    tab: {
	        "1": 100,
	        "2": 300,
	        "all": 'all'
	    }
	};

	var currentTab = 'all';

	/*下拉选择*/
	common.dropDown({
	    el: "#brandId",
	    ajax: "brand",
	    params:function(){
	        return{userLimitFlag:true};
	    }
	});

	new common.dropDown({
	    el: "#isPayDelivery",
	    ajax: ""
	});

	var currentBtnType;
	var currentSelItem;

	var t = new common.tab({
	    el: "#basicTab",
	    click: function() {
	        var columnname = $(this).find('a').attr('columnname');
	        currentTab = ENUM.tab[columnname];
	        layoutGridCloum(currentTab);
	        g.init('/payDelivery/queryTotalBrandPayDelivery');
	    },
	    columns: [{
	        name: "1",
	        display: "待审核({1})",
	        value: ''
	    }, {
	        name: "2",
	        display: "驳回({2})",
	        value: ''
	    }, {
	        name: "all",
	        display: "全部({3})",
	        value: ''
	    }]
	}).init(ENUM.tips);

	var g = new common.grid({
	    el: '#basicTable',
	    parms: function() {
	        return {
	            brandId: common.util.__input("brandId"),
	            isPayDelivery: common.util.__input("isPayDelivery"),
	            checkStatus: (currentTab && currentTab != 'all') ? currentTab : 400//ENUM.tab[t.active] //(t.active && t.active!='all') ? t.active : 400
	        };
	    },
	    columns: [{
	        display: '品牌',
	        name: 'brandName'
	        },
	        // 审核状态(全部商品是显示) 1
	        {
	            display: "状态",
	            render: function(item) {
	                var html = [];
	                html.push("<p>" + ENUM.status[item.isPayDelivery] + "</p>");
	                return html.join('');
	            }
	        },
	        { //2
	            display: "申请人",
	            hidden: true,

	            render: function(item) {
	                var html = [];
	                html.push("<p>" + common.util.__filterNull(item, 'applicant') + "</p>");
	                return html.join('');
	            }
	        }, { //3
	            display: "申请时间",
	            hidden: true,
	            render: function(item) {
	                var html = [];
	                html.push("<p>" + common.util.__filterNull(item, 'createTime') + "</p>");
	                return html.join('');
	            }
	        },{
	            // 4
	            display: '驳回理由',
	            hidden: true,
	            name: 'status', //  8待上架,2待审核,3驳回,4通过,1已上架,0已下架,5再上架待审核,6再上架驳回,7再上架通过
	            render: function(item) {
	                return '<p style="color:red;">' + common.util.__filterNull(item, 'rejectReason') + '</p>' ;

	            }
	        }, { // 5
	            display: "操作",
	            render: function(item) {
	                var html = [];
	                if (item.isPayDelivery == 1) { // 待审核
	                    html.push('<a data-index="' + item.__index + '" href="JavaScript:;" class="btn operation btn-danger btn-xs edit-class-btn" id="btn-item-close" data-type="close">关闭</a>');
	                } else {
	                    html.push('<a data-index="' + item.__index + '" href="JavaScript:;" class="btn operation btn-success btn-xs edit-class-btn" id="btn-item-open" data-type="open">开启</a>');
	                }
	                return html.join('');
	            }
	        },{ // 6
	            display: "操作",
	            hidden: true,
	            render: function(item) {
	                var html = [];
	                html.push('<a data-index="' + item.__index + '" href="JavaScript:;" class="btn operation btn-danger btn-xs edit-class-btn" id="btn-item-reject" data-type="reject">驳回</a>');
	                html.push('<a data-index="' + item.__index + '" href="JavaScript:;" class="btn operation btn-success btn-xs edit-class-btn" id="btn-item-pass" data-type="pass">通过</a>');
	                return html.join('');
	            }
	        }
	    ]
	});
	g.init('/payDelivery/queryTotalBrandPayDelivery');

	function layoutGridCloum(tabname) {
	    if (tabname == 'all') {
	        g.options.columns[1].hidden = false;
	        g.options.columns[2].hidden = true;
	        g.options.columns[3].hidden = true;
	        g.options.columns[4].hidden = true;
	        g.options.columns[5].hidden = false;
	        g.options.columns[6].hidden = true;

	    } else if(tabname == 100) {
	        g.options.columns[1].hidden = true;
	        g.options.columns[2].hidden = false;
	        g.options.columns[3].hidden = false;
	        g.options.columns[4].hidden = true;
	        g.options.columns[5].hidden = true;
	        g.options.columns[6].hidden = false;
	    } else {
	        g.options.columns[1].hidden = true;
	        g.options.columns[2].hidden = false;
	        g.options.columns[3].hidden = false;
	        g.options.columns[4].hidden = false;
	        g.options.columns[5].hidden = true;
	        g.options.columns[6].hidden = true;
	    }
	}

	// tab初始化
	var loadTab = function() {
	    t.active = undefined;
	    setTimeout(function() {
	        common.util.__ajax({
	            url: "/payDelivery/queryCountBrandPayDelivery",
	            data: g.options.parms()
	        }, function(res) {
	            var __dt = $.extend({}, ENUM.tips, res.data);
	            t.init(__dt);
	        }, true);
	    }, 800);
	};

	var reloadTab = function() {
	    t.active = undefined;
	    setTimeout(function() {
	        common.util.__ajax({
	            url: "/payDelivery/queryCountBrandPayDelivery",
	            data: g.options.parms()
	        }, function(res) {
	            var __dt = $.extend({}, ENUM.tips, res.data);
	            t.load(__dt);
	        }, true);
	    }, 800);
	};

	loadTab();
	// 筛选
	$(document).on('click', "#filter-btn", function() {
	    reloadTab();
	    //g.options.columns[1].hidden = false;
	    //g.options.columns[2].hidden = true;
	    //g.options.columns[3].hidden = true;
	    //g.options.columns[4].hidden = true;
	    //g.options.columns[5].hidden = false;
	    //g.options.columns[6].hidden = true;
	    layoutGridCloum(currentTab);
	    g.reload();
	});


	$(document).on('click', ".edit-class-btn", function() {
	    currentBtnType = $(this).data('type');
	    var url = '';
	    var alertContent;
	    currentSelItem = g.rows[$(this).data("index")];
	    var data = function() {
	        var reason = $('#reason').val();
	        if (reason === '' || $.trim(reason) === '') {
	            if(currentBtnType == 'reject') {
	                return "请填写驳回原因";
	            }
	        }
	        return {
	            brandName: currentSelItem.brandName,
	            brandId: currentSelItem.brandId,
	            rejectReason: reason,
	            isPayDelivery: currentBtnType=='open'?1:0,
	            checkStatus: currentBtnType=='pass'?200:300,
	            id: currentSelItem.id

	        };
	    };

	    switch (currentBtnType) {
	        case 'open':
	        {
	            url = '/payDelivery/addPayDeliveryCheck';
	            alertContent = '开启货到付款无需组长审核,您确定开启吗?';
	        }
	            break;

	        case 'close':
	        {
	            url = '/payDelivery/addPayDeliveryCheck';
	            alertContent = '关闭货到付款需组长审核,您确定提交此申请吗?';

	        }
	            break;

	        case 'pass':
	        {
	            url = '/payDelivery/reviewPayDeliveryCheck';
	            alertContent = '您确定要通过申请吗?';
	        }
	            break;

	        case 'reject':
	        {
	            url = '/payDelivery/reviewPayDeliveryCheck';
	            alertContent = $("#template").html();
	        }
	            break;

	        default :
	        {
	            url = '';
	            alertContent = '未知弹框~';
	        }
	            break;
	    }

	    common.dialog.confirm("温馨提示", alertContent, function() {
	        common.util.__ajax({
	            url: url,
	            data: data()
	        }, function() {
	            g.reload();
	            reloadTab();
	        });
	    });
	});

	$('#export-btn').on('click', function() {
	    window.open("/ajax/down?queryConf=" + JSON.stringify(g.options.parms()) + "&type=brandPayDeliveryExport");
	});


/***/ }
]);