shop.modular.Index.js 5.37 KB
webpackJsonp([180],[
/* 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.decoratorStatus) {
					return ENUM.decoratorStatus[item.decoratorStatus];
				} else {
					return '待装修';
				}
	        }},
	        {display: "操作人", render: function(item) {
	            if (item.operatorName) {
	                return item.operatorName;
	            } else {
	                return '';
	            }
	        }},
	        {display: "操作", render: function(item) {
	            var HtmArr = [];

	            HtmArr.push('<div>');
	            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">APP装修</a>');
	            HtmArr.push('<a href="/supplier/store/decorationDetail/'+item.shopId+'/'+item.shopsType+'/editor/" class="btn btn-info btn-xs">PC装修</a>');
	            if(+item.shopStatus == 1){
	                // 1开启 0 关闭
	                HtmArr.push('<a data-shop-id="'+item.shopId+'" href="javascript:void(0);" class="closeshops btn btn-danger btn-xs">关店</a>');
	            }else{
	                HtmArr.push('<a data-shop-id="'+item.shopId+'" href="javascript:void(0);" class="openshops btn btn-success 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();
	});

	$(document).on('click', '.openshops', function() {
	    var shopId = $(this).data('shop-id');
	    common.dialog.confirm("温馨提示", "确定要开启此有货店铺吗?", function() {
	        common.util.__ajax({
	            url: '/supplier/store/openShops',
	            data: {
	                shopsId: shopId
	            }
	        }, function() {
	            g.reload();
	        });
	    })
	});

	$(document).on('click', '.closeshops', function() {
	    var shopId = $(this).data('shop-id');
	    common.dialog.confirm("温馨提示", "确定要关闭此有货店铺吗?", function() {
	        common.util.__ajax({
	            url: '/supplier/store/closeShops',
	            data: {
	                shopsId: shopId
	            }
	        }, function() {
	            g.reload();
	        });
	    })
	})

/***/ }
]);