operations.search.postionIndex.js 5.04 KB
webpackJsonp([127],[
/* 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: "title"
	    },{
	        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="#" data-id="' + items.id + '" data-title="' + items.title + '"' + '" class="btn btn-info btn-xs edit-position">修改</a>');

	            if (items.status === 0) {
	                HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-warning btn-xs open-position">开启</a>');
	            }
	            if (items.status === 1) {
	                HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-danger btn-xs close-position">关闭</a>');
	            }
	            return HtmArr.join('');
	        }
	    }]
	})
	g.init('/operations/search/getPositionList');

	//添加操作
	$('#add-position').on('click', function() {
	    if ('' == $("#position-title").val()) {
	        common.util.__tip("名称未填","warning");
	        return;
	    }

	    common.util.__ajax({
	        url:'/operations/search/insertPositionInfo',
	        data: {
	            "title": $("#position-title").val()
	        }
	    },function(rs){
	        common.util.__tip("保存成功!","success");
	        g.reload(1);
	    },true);
	});

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

	    new common.dialog({
	        title: "关闭搜索广告位置",
	        width: "360px",
	        content: '确认关闭搜索广告位置么?',
	        zIndex: 52,
	        button: [
	            {value: "确认", css:"btn-primary", callback: function () {
	                common.util.__ajax({
	                    url: '/operations/search/updatePositionInfo',
	                    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);
	            }},
	            {value: "取消", css:"btn-default"}
	        ]
	    });
	});
	//开启操作
	$('tbody').on('click', '.open-position', function() {
	    var item = g.rows[$(this).data("index")];

	    new common.dialog({
	        title: "开启搜索广告位置",
	        width: "360px",
	        content: '确认开启搜索广告位置么?',
	        zIndex: 52,
	        button: [
	            {value: "确认", css:"btn-primary", callback: function () {
	                common.util.__ajax({
	                    url: '/operations/search/updatePositionInfo',
	                    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);
	            }},
	            {value: "取消", css:"btn-default"}
	        ]
	    });

	});

	// 驳回
	var BllEdit = {
	    toast: function(content, fn) {
	        var $this = $(this);

	        common.dialog.confirm("修改名称", content, function() {
	            common.util.__disButton.call($this);
	            common.util.__ajax({
	                url: '/operations/search/updatePositionInfo',
	                data: fn()
	            }, function() {
	                g.reload();
	            });
	        });
	    }
	}

	//修改操作
	$(document).on("click", ".edit-position", function() {
	        var id = $(this).attr("data-id");
	        

	        var result=function(){
	            var title = $('#edit-title').val();
	            if (title === '' || $.trim(title) === '') {
	                return '请填写名称';
	            }
	           
	            return {
	                "id" : id,
	                "title" : title
	            };
	            
	        }
	        BllEdit.toast.call(this, $("#template").html(), result);
	        //common.util.__tip('请选择导出商品的条件', 'warning');
	        $('#edit-title').val($(this).attr("data-title"));
	});

/***/ }
]);