shootMeter.TryModel.Index.js 7.85 KB
webpackJsonp([144],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {

	/**
	 * Created by JiangMin on 2016/3/17.
	 * 模特管理
	 */
	var $ = __webpack_require__(1);
	var common = __webpack_require__(2);
	//日期插件
	$('.hasDatepicker').fdatepicker({
	    format: 'yyyy-mm-dd'
	});
	/**
	 * 列表显示数据
	 * @type {common.grid}
	 */
	var g = new common.grid({
	    el: '#content-list',
	    hash: false,
	//查询参数
	    parms: function () {
	        return {
	            modelName: common.util.__input('content-filter1'),
	            beginTime: ((new Date($('#beginTime').val())).getTime()) / 1000 || "",
	            endTime: ((new Date($('#endTime').val())).getTime()) / 1000 || "",
	            modelType: 2
	        };
	    },
	//列表显示
	    columns: [
	        {display: "ID", name: "id"},
	        {display: "姓名", name: "modelName"},
	        {
	            display: "头像", name: "avatar", render: function (item) {
	            if (item.avatar) {
	                return '<img src="' + item.avatar + '?imageView/0/w/78/h/78" width="100" height="60"/>'
	            }
	            return ""
	        }
	        },//图片显示
	        {display: "身高", name: "height"},
	        {display: "体重", name: "weight"},
	        {
	            display: "胸围", render: function (item) {
	            var a = item.vitalStatistics.split(/[,|/]/g);
	            return a[0];
	        }
	        },
	        {
	            display: "腰围", render: function (item) {
	            var a = item.vitalStatistics.split(/[,|/]/g);
	            return a[1];
	        }
	        },
	        {
	            display: "臀围", render: function (item) {
	            var a = item.vitalStatistics.split(/[,|/]/g);
	            return a[2];
	        }
	        },
	        {
	            display: "创建时间", name: "createTime",
	            render: function (item) {
	                var t = new Date(item.createTime * 1000);
	                var formatted = common.util.__dateFormat(t, "yyyy-MM-dd hh:mm:ss");
	                return "<p>" + formatted + "</p>";
	            }
	        },
	        {
	            display: "操作", name: "", render: function (item) {
	            var arr = [];
	            arr.push('<a class="btn btn-xs btn-info 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("/meterManage/tryModel/index1");
	/*验证*/
	var e = new common.edit2(".modal-body");
	var Bll = {
	    module: null,
	    __render: function (selecter, templater, data) {
	        $(selecter).html(common.util.__template2($("#" + templater).html(), data));
	    },
	    edit: function () {
	        var avatar = $.trim($("#avatarpic").attr("src"));
	        if (avatar == "" || undefined || null) {
	            return "头像必传"
	        }
	//验证英文名
	        var englishName = $.trim($("#englishName").val());
	        if (englishName == "" || undefined || null) {
	            return "英文名必填"
	        }

	        var modelName = $.trim($("#modelName").val());
	        if (modelName == "" || undefined || null) {
	            return "中文名必填"
	        }

	//验证身高
	        var height = $.trim($("#height").val());
	        if (height == null || height == "" || height == undefined) {
	            return "身高必填"
	        }
	//验证体重
	        var weight = $.trim($("#weight").val());
	        if (weight == null || weight == "" || weight == undefined) {
	            return "体重必填"
	        }

	//验证胸围
	        var Bust = $.trim($("#Bust").val());
	        if (Bust == null || Bust == "" || Bust == undefined) {
	            return "胸围必填"
	        }
	//验证腰围
	        var waist = $.trim($("#waist").val());
	        if (waist == null || waist == "" || waist == undefined) {
	            return "腰围必填"
	        }
	//验证臀围
	        var hips = $.trim($("#hips").val());
	        if (hips == null || hips == "" || hips == undefined) {
	            return "臀围必填"
	        }
	    },
	    toast: function (url, item, hint) {
	        //     Bll.edit();
	        Bll.module = item;
	        var a = common.dialog({
	            title: hint,
	            content: common.util.__template2($("#template").html(), Bll.module),
	            width: "40%",
	            button: [{
	                value: "确认",
	                css: "btn btn-primary",
	                callback: function () {
	                    Bll.module.vitalStatistics = [Bll.module.Bust, Bll.module.waist, Bll.module.hips].join("|");
	                    var msg = Bll.edit();
	                    if (!msg) {
	                        common.util.__ajax({
	                            url: url,
	                            data: Bll.module
	                        }, function () {
	                            g.reload(1);//重新加载界面
	                            a.close();//关闭模态框
	                        })
	                    } else {
	                        common.util.__tip(msg, "warning");
	                    }
	                    return false;
	                }
	            }, {
	                value: "取消",
	                css: "btn",
	                callback: function () {
	                    g.reload(1);//重新加载界面
	                }
	            }]
	        });
	        Bll.__editRender();
	    },
	    renderDialog: function (templater) {
	        Bll.__render(".modal-body", templater, Bll.module);
	        Bll.__editRender();
	    },
	    __editRender: function () {

	        e.init();
	        e.on("file_onComplete", function (obj) {
	            var names = obj.field;
	            Bll.module = common.util.__buildobj(names, '.', Bll.module, function (o, name) {
	                o[name] = obj.data;
	            });
	            Bll.renderDialog("template");
	        });

	    }
	};

	/**
	 * 监听输入框变化
	 */
	$(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 = {
	        "__state": "add",
	        'height': "",//身高
	        'modelName': "",//名称
	        'modelType': 2,//模特类型:1 拍摄模特 2 试穿模特
	        'status': 1,//模特状态:0 禁用 1 启用
	        'vitalStatistics': "",//三围
	        "Bust": "",//胸围
	        "waist": "",//腰围
	        "hips": "",//臀围
	        'weight': "",//体重
	        'avatar': ""//头像
	    };
	    Bll.toast('/meterManage/tryModel/addModel', item, "添加模特");
	});

	//修改模特--点击事件
	$(document).on('click', '.update', function () {
	    var item = g.rows[$(this).data("index")];
	    var a = item.vitalStatistics.split(/[,|/]/g);
	    item.Bust = a[0];
	    item.waist = a[1];
	    item.hips = a[2];
	    Bll.toast('/meterManage/tryModel/updateModel', item, "修改模特");
	});

	//删除--点击事件
	$(document).on('click', '.delete', function () {
	    var item = g.rows[$(this).data("index")];
	    common.dialog.confirm("警告",
	        "确认删除?",
	        function () {
	            common.util.__ajax({
	                url: '/meterManage/tryModel/delModel',
	                data: {
	                    id: item.id
	                }
	            }, function () {
	                g.reload(1);
	            });
	        });
	});
	//删除图片
	$(document).on('click', '.remove1', function () {
	    var title = $(this).data("link");
	    Bll.module[title] = "";
	    Bll.renderDialog("template");
	});
	//查询按钮--点击事件
	$(document).on('click', '#filter-btn', function () {
	    g.reload(1);
	});






/***/ }
]);