shop.modular.Index.js 4.58 KB
webpackJsonp([159],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {

	'use strict';
	var $ = __webpack_require__(1),
	    common=__webpack_require__(2);

	var ENUM = {
	    decoratorStatus: {0: "待装修", 1: "待审核", 2: "已发布", 3: "驳回"}
	}

	var g;

	// 有货店铺、BLK店铺切换
	var t = new common.tab({
	    el: "#basicTab",
	    columns: [
	        {name: "all", display: "有货"},
	        {name: "1", display: "BLK"}
	    ],
	    click: function() {
	        g.reload(1);
	    }
	}).init({});

	// 初始化筛选框
	new common.dropDown({el: "#shop-name", ajax: "shopsRest"});
	new common.dropDown({el: "#supplier-name", ajax: "supplier"});
	new common.dropDown({el: "#brand-name", ajax: "brand"});
	new common.dropDown({el: "#open-status"});
	new common.dropDown({el: "#decorator-status"});

	// 装修列表
	g = new common.grid({
	    el: "#basicTable",
	    parms: function() {
	        return {
	            "shopId": common.util.__input("shop-name"),
	            "supplierId": common.util.__input("supplier-name"),
	            "brandId": common.util.__input("brand-name"),
	            "openStatus": common.util.__input("open-status"),
	            "decoratorStatus": common.util.__input("decorator-status"),
	            "appType": +t.active ? 1 : 0
	        };
	    },
	    columns: [
	        {name: "shopId", display: "店铺ID"},
	        {name: "shopName", display: "店铺名称"},
	        {display: "品牌", render: function(item) {
	            if(item.brandNames) {
	                var brandArr = item.brandNames.split(',');
	                var _brands = [];
	                $.each(brandArr, function(i, value) {
						if($.inArray(value, _brands) === -1) {
							_brands.push(value);
						}
					});

	                var htmlArr = [];
	                htmlArr.push('<span>');
	                htmlArr.push(_brands[0]);
	                htmlArr.push('</span>');

	                if(_brands.length > 1) {
	                    htmlArr.push('<div class="hover-me">');
	                    htmlArr.push('<div class="brand-tips" style="display: none;"><div class="hover-left"></div>');
	                    htmlArr.push('<div class="hover-pop"><div class="pop-arrow"></div><div class="hover-right"><p>');
	                    htmlArr.push(_brands.join('</p><p>'));
	                    htmlArr.push('</p></div></div></div>');
	                }
	                return htmlArr.join(' ');
	            } else {
	                return '';
	            }
	        }},
	        {display: "发布时间", render: function(item) {
	            if (item.publishTime && item.publishTime != 0) {
					return common.util.__dateFormat(new Date(item.publishTime * 1000), "yyyy-MM-dd hh:mm:ss");
				} else {
					return '';
				}
	        }},
	        {display: "状态", render: function(item) {
	            if (item.status) {
					return ENUM.decoratorStatus[item.status];
				} else {
					return '待装修';
				}
	        }},
	        {display: "操作人", render: function(item) {
	            if (item.operator) {
	                return item.operator;
	            } else {
	                return '';
	            }
	        }},
	        {display: "操作", render: function(item) {
	            var HtmArr = [];

	            HtmArr.push('<div>');

	            if(+item.decoratorStatus == 2) {
	                // 店铺装修模板发布之后,才涉及开店、关店
	                if(+item.shopStatus == 1){
	                    // 1开启 0 关闭
	                    HtmArr.push('<a data-index="'+item.__index+'" href="javascript:void(0);" class="closeshops btn btn-danger btn-xs">关店</a>');
	                }else{
	                    HtmArr.push('<a data-index="'+item.__index+'" href="javascript:void(0);" class=" openshops btn btn-success btn-xs">开店</a>');
	                }
	            } else {
	                var uri = '/shop/decorator/modulartool?shopId=' + item.shopId;
	                uri += '&shopName=' + encodeURIComponent(item.shopName);
	                uri += '&appType=' + (+t.active ? 1 : 0);
	                HtmArr.push('<a href="' + uri + '" target="_blank" class="btn btn-primary btn-xs">装修</a>');
	            }

	            HtmArr.push('</div>');
	            return HtmArr.join('');
	        }}
	    ]
	});


	$('#filter-btn').on('click', function () {
	    g.reload(1);
	});
	g.init('/shop/ModularDecoratorRest/findShopsDecorator');

	$(document).on('mouseover', '.hover-me', function() {
	    $(this).parent().find('.brand-tips').show();
	});

	$(document).on('mouseout', '.hover-me', function() {
	    $(this).parent().find('.brand-tips').hide();
	});

/***/ }
]);