operations.ziplist.Index.js 4.37 KB
webpackJsonp([119],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {

	/**
	 * Created by ty on 2016/7/5.
	 * app图片包
	 */

	var $ = __webpack_require__(1),
	    common = __webpack_require__(2);

	new common.dropDown({el: "#status-filter"});
	new common.dropDown({el: "#platform-filter"});
	var edit = new common.edit2("#base-form");

	var Bll = {
	    __time: function (time) {
	        var t = new Date(time * 1000);
	        var formatted = common.util.__dateFormat(t, "yyyy-MM-dd hh:mm:ss");
	        return formatted;
	    },
	    platformArr: {
	        iphone:"IOS手机",
	        ipad:"IOS Pad",
	        android:"安卓手机",
	        androidpad:"安卓Pad",
	        h5:"手机网站",
	        web:"网站",
	        platform:"平台",
	    },
	    toast: function (url) {
	        var dialog = common.dialog.confirm("上传图片包",
	            common.util.__template2($("#toast-template").html(), {}),
	            function () {
	                if(edit.validate()) {
	                    common.util.__ajax({
	                        url: url,
	                        data: {zip: $("#zip").val(), platform: $("#platform").val()}
	                    }, function () {
	                        dialog.close();
	                        g.reload();
	                    });
	                }
	                return false;
	            });
	        new common.dropDown({el: "#platform"});
	        $("#uploadBox").ajaxfileupload({
	            'action': '/ajax/upload',
	            'params': {
	                bucket: "yhb-iconZip01",
	                __type: "upload"
	            },
	            onComplete: function (response) {
	                if (response.status && response.code == 200) {
	                    if(response.data){
	                        common.util.__tip(response.message, "success");
	                        $("#zip").val(response.data);
	                    }
	                } else {
	                    common.util.__tip(response.message);
	                }
	            },
	            valid_extensions: ["zip"]
	        });
	    }
	};

	var g = new common.grid({
	    el: "#content-list",
	    parms: function() {
	        return {
	            platform: common.util.__input("platform-filter"),
	            status: common.util.__input("status-filter")
	        }
	    },
	    columns: [
	        {display: "ID", name: 'id'},
	        {display: "zip包路径", name: 'zip'},
	        {display: "显示平台", render: function (item) {
	            return Bll.platformArr[item.platform];
	        }},
	        {display: "添加时间", render: function (item) {
	            if(item.createTime) {
	                return Bll.__time(item.createTime);
	            }
	        }},
	        {display: "更新时间", render: function (item) {
	            if(item.updateTime) {
	                return Bll.__time(item.updateTime);
	            }
	        }},
	        {display: "状态", render: function (item) {
	            if(item.status == 1) {
	                return "已开启";
	            } else {
	                return "已关闭";
	            }
	        }},
	        {display: "操作",
	            render: function(items) {
	                var HtmArr = [];
	                if(items.status == 1) {
	                    HtmArr.push('<a href="javascript:;" data-id="' + items.id + '" class="btn btn-danger btn-xs closeStatus">关闭</a>');
	                } else {
	                    HtmArr.push('<a href="javascript:;" data-id="' + items.id + '" class="btn btn-success btn-xs publishStatus">启用</a>');
	                }
	                return HtmArr.join('');
	            }
	        }
	    ]
	});

	g.init("/icon/getZipList");

	//筛选
	$(document).on("click", "#filter-btn", function () {
	    g.reload(1);
	});

	//关闭图片包
	$(document).on("click", ".closeStatus", function () {
	    common.util.__ajax({
	        url: "/icon/closeZip",
	        data: {id: $(this).data("id")}
	    }, function () {
	        g.reload();
	    });
	});

	//启用图片包
	$(document).on("click", ".publishStatus", function () {
	    common.util.__ajax({
	        url: "/icon/publishZip",
	        data: {id: $(this).data("id")}
	    }, function () {
	        g.reload();
	    });
	});

	//弹窗
	$(document).on("click", "#uploadZip", function () {
	    Bll.toast("/icon/addZip");
	});

	$(document).on("click", "#chooseFile", function () {
	    $("#uploadBox").click();
	});

/***/ }
]);