shootMeter.ShootRequire.Index.js 4.22 KB
webpackJsonp([124],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {

	/**
	 * Created by JiangMin on 2016/3/22.
	 * 拍摄要求管理
	 */
	var $ = __webpack_require__(1);
	var common = __webpack_require__(2);
	/**
	 * 列表显示数据
	 */
	var g = new common.grid({
	    el: '#content-list',
	    hash: false,
	//查询参数
	    parms: function () {
	        return {
	            type: common.util.__input('type-filter')
	        };
	    },
	//列表显示
	    columns: [
	        {display: "名称", name: "name"},
	        {
	            display: "类别", name: "type", render: function (item) {
	            var type = item.type + "";
	            var type1 = type.replace(1, "拍摄类型").replace(2, "拍摄风格")
	                .replace(3, "模特类型").replace(4, "道具类型")
	                .replace(5, "滤镜效果").replace(6, "摄影场景").replace(7, "背景类型")
	                .replace(/\|/g, " ");
	            return type1;
	        }
	        },
	        {
	            display: "操作", name: "", render: function (item) {
	            var arr = [];
	            arr.push('<a class="btn btn-xs btn-primary update" data-index="' + item.__index + '">编辑</a>');
	            arr.push('<a class="btn btn-xs btn-danger delete" data-index="' + item.__index + '">删除</a>');
	            return arr.join('');
	        }
	        }
	    ]
	});
	g.init("/shotManage/shotRequire/index1");
	/*验证*/
	var edit = new common.edit2(".modal-body");
	var Bll = {
	    module: null,
	//弹框
	    toast: function (module, hint, url) {
	        if (module.__type == 'update') {
	            delete module.status;
	        }
	        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 (res) {
	                                if (res.code == '200') {
	                                    g.reload();
	                                    d.close();
	                                }
	                                else {
	                                    common.util.__tip(res.message, "warning");
	                                }
	                            }, true);
	                        }
	                        return false;
	                    },
	                    css: "btn-primary"
	                },
	                {
	                    "value": "取消",
	                    "css": "btn-info"
	                }
	            ]
	        });
	        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();
	    });
	});
	/**
	 * 添加--点击事件
	 */
	$('#add-content').on('click', function () {
	    var item = {
	        "name": "",
	        "type": -1,
	        "status": 1,
	        "__type": "add"
	    };
	    Bll.toast(item, "添加", "/shotManage/shotRequire/add");
	});
	/**
	 * 编辑--点击事件
	 */
	$(document).on('click', '.update', function () {
	    var item = g.rows[$(this).data("index")];
	    item.__type = "update";
	    Bll.toast(item, "编辑", "/shotManage/shotRequire/update");
	});

	//删除--点击事件
	$(document).on('click', '.delete', function () {
	    var item = g.rows[$(this).data("index")];
	    common.dialog.confirm("警告",
	        "确认删除?",
	        function () {
	            item.status = 0;
	            common.util.__ajax({
	                url: '/shotManage/shotRequire/update',
	                data: item
	            }, function () {
	                g.reload();
	            }, true);
	        });
	});
	//查询按钮--点击事件
	$(document).on('click', '#filter-btn', function () {
	    g.reload(1);
	});






/***/ }
]);