decoration-index.js 2.26 KB
'use strict';
var $ = require('jquery'),
	common = require('../common/common');


var ENUM = {
	checkStatus: {
		100: '暂存',
		200: '待审核',
		300: '审核通过',
		900: '驳回'
	}
};
new common.dropDown({
	el: "#brand-name",
	ajax: "brand"
});
new common.dropDown({
	el: "#supplier-name",
	ajax: "supplier"
});
new common.dropDown({
	el: "#shop-name",
	ajax: "shopsRest"
});

new common.dropDown({
	el: "#status"
});
var g = new common.grid({
	el: '#basicTable',
	parms: function() {
		return {
			//shopsId: common.util.__input("shop-name"),
			shopsId: 20,
			checkStatus: common.util.__input("status"),
			supplierId: common.util.__input("supplier-name"),
			brandId: common.util.__input("brand-name")
		};
	},
	columns: [{
		display: "店铺ID",
		name: "id"
	}, {
		display: "店铺名称",
		name: "shopsName"
	}, {
		display: "包含品牌",
		name: "brands",
		render: function(item) {
			console.log(item);
			if (item.brands instanceof Array && item.brands.length > 0) {
				var html = '';
				$.each(item.brands, function(i, value) {
					html += value.brandName + '<br>';
				});

				return html;
			} else {
				return '';
			}
		}
	}, {
		display: "创建时间",
		name: "createTime",
		render: function(item) {
			if (item.createTime) {
				return common.util.__dateFormat(new Date(item.createTime * 1000), "yyyy-MM-dd hh:mm:ss");
			} else {
				return '';
			}
		}
	}, {
		display: "更新时间",
		name: "updateTime",
		render: function(item) {
			if (item.updateTime) {
				return common.util.__dateFormat(new Date(item.updateTime * 1000), "yyyy-MM-dd hh:mm:ss");
			} else {
				return '';
			}
		}
	}, {
		display: "状态",
		name: "checkStatus",
		render: function(item) {
			if (item.checkStatus) {
				return ENUM.checkStatus[item.checkStatus]
			} else {
				return '';
			}
		}
	}, {
		display: "操作",
		render: function(item) {
			/*var HtmArr = [];
			HtmArr.push('<a href="javascript:void(0);" data-index="' + item.__index + '" class="edit btn btn-info btn-xs">店铺信息</a>');
			HtmArr.push('<a href="javascript:void(0);" data-index="' + item.__index + '" class="delete btn btn-danger btn-xs">删除</button>');
			return HtmArr.join('');*/
		}
	}]
});

g.init($("#gridurl").val());

// 筛选
$(document).on('click', "#filter-btn", function() {
	g.reload();
});