operations.search.templetIndex.js 2.43 KB
webpackJsonp([118],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {

	'use strict';
	var $ = __webpack_require__(1),
	    common = __webpack_require__(2);
	__webpack_require__(9);


	var g = new common.grid({
	    el: '#basicTable',
	    size: 10,
	    parms: function() {
	        return {};
	    },
	    columns: [{
	       display: "ID",
	        name: "id"
	    }, {
	        display: '名称',
	        name: "caption"
	    },{
	        display: '状态',
	        name: "status",
	        render: function(item) {
	            if(item.status==1){
	                var name ="开启" ;
	            }else {
	                var name ="关闭" ;
	            }
	            return name;
	        }
	    }, {
	        display: '操作',
	        name: "status",
	        render: function(items) {
	            var HtmArr = [];
	            HtmArr.push('<a href="/search/templetEdit/' + items.id + '" class="btn btn-info btn-xs edit-templet">修改</a>');
	            if (items.status === '1') {
	                HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-danger btn-xs close-templet">关闭</a>');
	            } else {
	                HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-warning btn-xs open-templet">开启</a>');
	            }
	            return HtmArr.join('');
	        }
	    }]
	})
	g.init('/operations/search/getTempletList');


	//关闭操作
	$('tbody').on('click', '.close-templet', function() {
	    var item = g.rows[$(this).data("index")];

	    common.util.__ajax({
	        url: '/operations/search/updateTempletStatus',
	        data: {
	            id: item.id,
	            status: 0
	        }
	    }, function(res) {
	        if (res.code == 200) {
	            common.util.__tip('关闭成功', 'success');
	            g.reload();
	        } else {
	            common.util.__tip(res.message);
	        }
	    }, true);
	});
	//开启操作
	$('tbody').on('click', '.open-templet', function() {
	    var item = g.rows[$(this).data("index")];
	    common.util.__ajax({
	        url: '/operations/search/updateTempletStatus',
	        data: {
	            id: item.id,
	            status: 1
	        }
	    }, function(res) {
	        if (res.code == 200) {
	            common.util.__tip('开启成功', 'success');
	            g.reload();
	        } else {
	            common.util.__tip(res.message);
	        }
	    }, true);
	});

/***/ }
]);