operations.gate.Index.js 2.3 KB
webpackJsonp([106],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {

	/*
	 * @author: LiQZ
	 */
	var $ = __webpack_require__(1), common = __webpack_require__(2);

	// 下拉框
	new common.dropDown({
	    el: "#status"
	});

	var platforms = new Object();
	platforms["iphone"]="IOS手机";
	platforms["ipad"]="IOS Pad";
	platforms["android"]="安卓手机";
	platforms["androidpad"]="安卓Pad";
	platforms["h5"]="手机网站";
	platforms["web"]="网站";
	platforms["platform"]="平台";


	var tableGird = new common.grid({

	    el: "#table-box",
	    parms: function() {
	      return {
	            status: $("#status").val()
	        }  
	    },
	    columns: [
	    { display: "ID", name: "id" },
	    { display: "平台元值", name: "metaKey"},
	    { display: "平台名称", name: "platform", render: function(item) {
	        if(item.platform) {
	            var arr = [];
	            var ps = item.platform.split(",");
	            for(var i = 0; i < ps.length; i++) {
	                arr.push(platforms[ps[i]]);
	            }
	            return arr.join(" ");
	        }
	    }},
	    { display: "控制器名称", name:"title"},
	    { display: "价格", name:"price"},
	    { display: "控制器链接地址", name:"url"},
	    { display: "控制状态", name:"status", render: function(item) {
	            return item.status == 0 ? "已关闭":"已开启";
	    }},
	    { display: "操作", render: function(items) {
	            var HtmArr = [];
	            HtmArr.push('<a href="/operations/gate/' + items.id + '" class="btn btn-primary btn-xs">编辑</a>');
	            HtmArr.push('<a href="javascript:void(0);" data-index="' + items.__index + '" class="btn btn-danger btn-xs delete">删除</a>');
	            return HtmArr.join('');
	        }
	    }]
	});

	tableGird.init('/operations/gate/list');

	$(document).on("click", "#filter-btn", function () {
	    tableGird.reload();
	});

	/** 删除 */
	$(document).on("click", ".delete", function () {
	    var item = tableGird.rows[$(this).data("index")];
	    common.dialog.confirm("警告", "确定删除就该开关吗?", function () {
	        common.util.__ajax({
	            url: "/operations/gate/delete",
	            data: {id: item.id }
	        }, function () {
	            tableGird.reload();
	        }, true)
	    })
	});



/***/ }
]);