operations.activitytemplate.Index.js 2.47 KB
webpackJsonp([98],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {

	/**
	 * Created by ty on 2016/7/4.
	 * 活动模板管理
	 */

	var $ = __webpack_require__(1),
	    common = __webpack_require__(2);

	var statusArr = ["已关闭", "已开启"];

	var g = new common.grid({
	    el: '#content-list',
	    usepagesize:true,
	    parms: function () {
	        return {
	            title: common.util.__input('title'),
	        };
	    },
	    columns: [
	        {
	            display: "ID",
	            name: "id"
	        },
	        {
	            display: '模板标题',
	            name: "title",
	            style:"width:20%;word-break:break-all;"
	        },
	        {
	            display: '图片地址',
	            render: function (item) {
	               if(item.image) {
	                   return "<img src='"+ item.image +"' height='100px'/>";
	               }
	            }
	        },
	        {
	            display: 'SKN数量',
	            name: "productCount"
	        },
	        {
	            display: "状态",
	            render: function (item) {
	                return "<p>" + statusArr[item.status] + "</p>";
	            }
	        },
	        {
	            display: '操作',
	            render: function (item) {
	                var HtmArr = [];
	                HtmArr.push('<a href="/operations/activitytemplate/product/'+ item.id +'" class="btn btn-info btn-xs addProduct">添加商品</a>');
	                HtmArr.push('<a href="/operations/activitytemplate/edit/'+ item.id +'" class="btn btn-primary btn-xs">编辑</a>');
	                if(item.status == 1) {
	                    HtmArr.push('<a data-index="' + item.__index + '" href="JavaScript:;" class="btn btn-danger btn-xs auditStatus">关闭模板</a>');
	                } else {
	                    HtmArr.push('<a data-index="' + item.__index + '" href="JavaScript:;" class="btn btn-success btn-xs auditStatus">开启模板</a>');
	                }
	                return HtmArr.join('');
	            }
	        }]
	});

	g.init("/activityTemplate/selectTemplateList");

	$(document).on("click", ".auditStatus", function () {
	    var item = g.rows[$(this).data("index")];
	    var url = item.status == 1 ? "/activityTemplate/closeTemplate" : "/activityTemplate/publishTemplate";
	    common.util.__ajax({
	        url: url,
	        data: {id: item.id}
	    }, function () {
	        g.reload();
	    });
	});
	$("#filter-btn").click(function () {
	    g.reload();
	});


/***/ }
]);