shop.Index.js 6.46 KB
webpackJsonp([171],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {

	//商家管理
	'use strict';
	var $ = __webpack_require__(1),
	    common=__webpack_require__(2);

	var ENUM={//    审核状态;100 暂存 200 待审核 300 审核通过 900 驳回
	    status  : {100:'暂存',200:'审核中',300:'通过',900:'驳回'},
	    appType : {1:'是', 0 : '否'}
	};

	//basicTab
	var t = new common.tab({
	    el: "#basicTab",
	    click: function () {
	        if (+t.active) {
	            g.options.url = "/supplier/store/ajax/shenhezx";
	            g.options.columns[1].name = "shopsName";
	            g.options.columns[2] = {
	                display: "包含品牌", name: "brands", render: function (item) {
	                    var brandArr = [];
	                    if (item.brands) {
	                        $.each(item.brands, function (index, a) {
	                            if($.inArray(a.brandName, brandArr) === -1) {
	                                brandArr.push(a.brandName);
	                            }
	                        });
	                    }
	                    return '<p>' + brandArr.join('</p><p>') + '</p>';
	                }
	            };
	        } else {
	            g.options.columns[1].name = "shopName";
	            g.options.columns[2] = {
	                display: "包含品牌", name: "shopRelationList", render: function (item) {
	                    var brandArr = [];
	                    if (item.shopRelationList) {
	                        $.each(item.shopRelationList, function (index, a) {
	                            if($.inArray(a.brandName, brandArr) === -1) {
	                                brandArr.push(a.brandName);
	                            }
	                        });
	                    }
	                    return '<p>' + brandArr.join('</p><p>') + '</p>';
	                }
	            };

	            g.options.url = $('#url').val();
	        }
	        g.reload(1);
	    },
	    columns: [
	        {name: "all", display: "信息审核"},
	        {name: "1", display: "装修审核"}
	    ]
	}).init({});

	new common.dropDown({el: "#status"});
	new common.dropDown({el: "#store-type"});
	new common.dropDown({el: "#store-model"});
	new common.dropDown({el: "#brand-name", ajax: "brand"});
	new common.dropDown({el: "#supplier-name", ajax: "supplier"});
	new common.dropDown({el: "#shop-name", ajax: "queryShopNames", params: function() {
	    return {
	        "checkStatus": (+t.active) ? 0 : common.util.__input("status"),
	        "operationStatus": (+t.active) ? 2 : authority.operationStatus, // 店铺表中只有创建和未创建两个状态,没有operation_status为0的店铺信息
	        "checkStatusArr": (+t.active) ? "100,200,300" : authority.checkStatusArr
	    };
	}});

	var authority = JSON.parse($("#authority").val());

	$('#filter-btn').on('click', function () {
	    g.reload(1);
	});

	var g = new common.grid({
	    el: '#basicTable',
	    parms: function () {
	        return {
	            "supplierId": common.util.__input("supplier-name"),
	            "brandId": common.util.__input("brand-name"),
	            "checkStatus": (+t.active) ? 200 : common.util.__input("status"),
	            "operationStatus": authority.operationStatus,
	            "checkStatusArr": authority.checkStatusArr,
	            "blkCheckStatus": 200,
	            "shopsId": common.util.__input("shop-name"),
	            "appType": common.util.__input("appType"),
	            "shopNature": common.util.__input("shopNature")
	        };
	    },
	    columns: [
	        {display: "店铺ID", name: "shopsId"},
	        {display: "店铺名称", name: "shopName"},
	        {
	            display: "包含品牌", name: "shopRelationList", render: function (item) {
	            var brandArr = [];
	            if (item.shopRelationList) {
	                $.each(item.shopRelationList, function (index, a) {
	                    if($.inArray(a.brandName, brandArr) === -1) {
	                        brandArr.push(a.brandName);
	                    }
	                });
	            }

	            return '<p>' + brandArr.join('</p><p>') + '</p>';
	        }
	        },
	        {display: "创建时间", name: "createTime"},
	        {display: "更新时间", name: "updateTime"},
	        {display: "是否BLK", name: "appType", render: function (item) 
	            {
	                return ENUM.appType[item.appType];
	            }
	        },
	        {
	            display: "状态", name: "checkStatus", render: function (item) {
	            var status = '';

	            if (t.active == "1"){
	                if(item.checkStatus){
	                    status += "有货店铺" + ENUM.status[item.checkStatus] + "<br>";
	                }
	                if(item.blkCheckStatus){
	                    status += "BLK店铺" + ENUM.status[item.blkCheckStatus];
	                }
	            }else {
	                status = ENUM.status[item.checkStatus];
	            }
	            return status;
	        }
	        },
	        {
	            display: "操作", name: "", render: function (item) {
	            var HtmArr = [];

	            if (t.active == "1") {  //店铺装修审核
	                if(+item.checkStatus == 200){
	                    HtmArr.push('<a href="/supplier/store/decorationDetail/' + item.shopsId + '/' + item.shopsType + '/check/" class="btn btn-info btn-xs">有货装修查看</a>');
	                }
	                if(+item.blkCheckStatus == 200){
	                    HtmArr.push('<a href="/shop/decoration/blkCheck/'+item.shopsId+'" class="btn btn-info btn-xs">BLK装修查看</a>')
	                }

	            } else {
	                HtmArr.push('<a href="/supplier/store/' + authority.info + '/' + item.shopsId + '" href="javascript:void(0);" class="btn btn-info btn-xs">查看</a>');
	            }

	            //创建
	            if (authority.create) {
	                if (+item.checkStatus == 100 || +item.checkStatus == 900) {
	                    HtmArr.push('<a href="/supplier/store/update/' + item.shopsId + '" href="javascript:void(0);" class="btn btn-success btn-xs">编辑</a>');
	                }
	            }

	            if (authority.btn) {
	                if (+item.checkStatus != 200) {
	                    HtmArr.push('<a href="/supplier/store/update/' + item.shopsId + '" href="javascript:void(0);" class="btn btn-success btn-xs">编辑</a>');
	                }
	            }
	            return HtmArr.join('');
	        }
	        }
	    ]
	})
	g.init($('#url').val());




/***/ }
]);