searchWords.HotBrand.Index.js 5.5 KB
webpackJsonp([155],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {

	/**
	 * Created by jiangmin on 2016/5/9.
	 * 反馈管理
	 */
	var $ = __webpack_require__(1);
	common = __webpack_require__(2);
	datepicker = __webpack_require__(9);
	/**
	 * 下拉框
	 */
	new common.dropDown({
	    el: "#status-filter"
	});

	/**
	 * 列表
	 * @type {common.grid}
	 */
	var g = new common.grid({
	    el: '#content-list',
	    parms: function () {
	        return {
	            brandName: common.util.__input('brandName-filter'),
	            status: common.util.__input('status-filter')
	        };
	    },
	    columns: [
	        {
	            display: "ID",
	            name: "id"
	        }, {
	            display: "品牌名称",
	            name: "brandName"
	        }, {
	            display: "状态",
	            name: 'status',
	            render: function (item) {
	                if (item.status == 1) {
	                    return "可用"
	                }
	                return "不可用"
	            }
	        }, {
	            display: '排序',
	            name: "orderBy"
	        }, {
	            display: '添加人',
	            name: "creatorName"
	        }, {
	            display: '添加时间',
	            name: "createTime",
	            render: function (item) {
	                if (item.createTime) {
	                    return "<p>" + Bll.__time(item.createTime) + "</p>";
	                }
	                return ""
	            }

	        }, {
	            display: '修改人',
	            name: "modifyName"
	        }, {
	            display: '修改时间',
	            name: "modifyTime",
	            render: function (item) {
	                if (item.modifyTime) {
	                    return "<p>" + Bll.__time(item.modifyTime) + "</p>";
	                }
	                return ""
	            }
	        }, {
	            display: '操作',
	            render: function (item) {
	                var HtmArr = [];
	                HtmArr.push('<a data-index="' + item.__index + '" href="JavaScript:;" class="btn btn-info btn-xs update">修改</a>');
	                HtmArr.push('<a data-index="' + item.__index + '" href="JavaScript:;" class="btn btn-danger btn-xs delete">删除</a>');
	                return HtmArr.join('');
	            }
	        }]
	});
	g.init('/hotSearchBrand/queryHotBrandList');
	var edit = new common.edit2(".modal-body");
	var Bll = {
	    module: null,
	    __time: function (time) {
	        var t = new Date(time * 1000);
	        var formatted = common.util.__dateFormat(t, "yyyy-MM-dd hh:mm:ss");
	        return formatted;
	    },
	    __render: function (selecter, templater, data) {
	        $(selecter).html(common.util.__template2($("#" + templater).html(), data));
	    },
	    //弹框
	    toast: function (url, module, hint) {
	        Bll.module = module;
	        var d = new common.dialog({
	            title: hint,
	            content: common.util.__template2($("#template").html(), Bll.module),
	            width: '30%',
	            button: [
	                {
	                    value: "保存",
	                    callback: function () {
	                        if (edit.validate()) {
	                            common.util.__ajax({
	                                url: url,
	                                data: Bll.module
	                            }, function () {
	                                g.reload();
	                                d.close();
	                            });
	                        }
	                        return false;
	                    },
	                    css: "btn-primary"
	                },
	                {
	                    "value": "取消",
	                    "css": "btn-info"
	                }
	            ]
	        });
	        Bll.__editRender();
	    },
	    renderDialog: function (templater) {
	        Bll.__render(".modal-body", templater, Bll.module);
	        Bll.__editRender();
	    },
	    __editRender: function () {
	        edit.init();

	    }
	};
	/**
	 * 监听输入框变化
	 */
	$(document).on("change", ".observe", function () {
	    var $this = $(this);
	    var name = $this.data("field");
	    Bll.module = common.util.__buildobj(name, '.', Bll.module, function (obj, name1) {
	        obj[name1] = $this.val();
	    });
	});

	/**
	 * 添加--点击事件
	 */
	$('#addHotBrand').on('click', function () {
	    var item = {
	        "brandName": "",
	        "orderBy": 1,
	        "status": 0
	    };
	    item._state = "add";
	    Bll.toast("/hotSearchBrand/addHotBrand", item, "添加");
	});

	/**
	 * 编辑--点击事件
	 */
	$(document).on('click', '.update', function () {
	    var item = g.rows[$(this).data("index")];
	    item._state = "update";
	    item.createTime = item.createTime ? Bll.__time(item.createTime) : "";
	    item.modifyTime = item.modifyTime ? Bll.__time(item.modifyTime) : "";
	    Bll.toast('/hotSearchBrand/updateHotBrand', item, "修改");
	});

	/**
	 * 删除--点击事件
	 */
	$(document).on('click', '.delete', function () {
	    var item = g.rows[$(this).data("index")];
	    common.dialog.confirm("警告",
	        "确认删除?",
	        function () {
	            common.util.__ajax({
	                url: '/hotSearchBrand/delHotBrand',
	                data: {
	                    id: item.id
	                }
	            }, function () {
	                g.reload();
	            });
	        });
	});

	/**
	 * 查询按钮--点击事件
	 */
	$(document).on('click', '#filter-btn', function () {
	    g.reload(1);
	});


/***/ }
]);