operations.generateLinks.Index.js 2.2 KB
webpackJsonp([111],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {

	/**
	 * Created by ty on 2016/6/17.
	 * 批量生成链接
	 */

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

	var module = {
	        channelId: 2,
	        linkType: "app",
	        urlType:2
	    },
	    singleModule = {
	        action: "go.brand",
	        linkType: "app",
	        urlType:2
	    };
	var edit = new common.edit2("#generate-content");
	var role = $("#wrap-content").attr("role"),
	     url = $("#wrap-content").attr("url");

	var Bll = {
	    __render: function () {
	        $("#generate-content").html(common.util.__template2($("#content-template").html(), role == "complex" ? module : singleModule));
	        edit.init();
	    }
	};

	Bll.__render();
	if(role == "single") {
	    $("#exportsearch").hide();
	}

	//生成
	$(document).on("click", "#submitsearch", function () {
	    if(edit.validate()) {
	        module.linkType = $("#linkType").val();
	        singleModule.linkType = $("#linkType").val();
	        module.urlType = $("#urlType").val();
	        singleModule.urlType = $("#urlType").val();
	        common.util.__ajax({
	            url: url,
	            data: role == "complex" ? module : singleModule
	        }, function (res) {
	            module.data = res.data;
	            singleModule.data = res.data;
	            Bll.__render();
	        });
	    }
	});

	//导出
	$(document).on("click", "#exportsearch", function () {
	    if(edit.validate()) {
	        module.linkType = $("#linkType").val();
	        module.urlType = $("#urlType").val();
	        var temp = $.extend(true, {}, module);
	        delete temp.data;
	        window.open("/ajax/down?queryConf=" + JSON.stringify(temp) + "&type=linkExport");
	    }
	});

	$(document).on("change", ".observe", function () {
	    var name = $(this).data("field");
	    module[name] = $(this).val();
	    singleModule[name] = $(this).val();
	});

	//复制
	$(document).on("click", ".copy", function() {
	    var Url2=document.getElementById($(this).data("link"));
	    Url2.select(); // 选择对象
	    document.execCommand("Copy"); // 执行浏览器复制命令
	    common.util.__tip("链接复制成功", "success");
	});


/***/ }
]);