shop.batch.importShopsPromote.js 2.23 KB
webpackJsonp([156],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {

	'use strict';


	var $ = __webpack_require__(1),
	common = __webpack_require__(2);
	var importConfig = {
		"bizType" : "shopsPromote",
		"callBackApi" : "/product/queryBatchImportShopsPromoteResult"
	};
	$('input[type="file"]').after('<div class="file-name btn btn-default">请选择文件</div>');
	var loadModal = null;

	function batchImport(el, type) {

	    return {
	        params: {
	            type: type,            
	            __type: "batch-import"
	        },
	        onStart: function(params) {
	            console.log("params",params);
	            loadModal = common.dialog.load();
	            $("#message").html('');

	            //$(el).parents('td').find('.file-name').text($(el).val().replace("C:\\fakepath\\", ""));
	        },
	        onComplete: function(response) {
	            console.log("批量接口返回数据",response);
	            $("#message").html('');
	            if (response.code == 200&&response.data.taskId) {
	                __ajaxExeclById(response.data.taskId);
	                // common.util.__tip(response.message, 'success');
	                return;
	            }
	            if (loadModal) {
	                loadModal.close();
	            }
	            if(response.data&&response.data.failFileReason.length){
	                $("#message").html(response.data.failFileReason.join('<br/>'));
	                return false;
	            }
	            common.util.__tip(response.message, 'warning');
	        }
	    }
	}

	/*店铺推广*/
	common.edit.ajaxfileupload('#batchImportShopsPromote', batchImport('#sort-file', importConfig.bizType));

	function __ajaxExeclById(unquid){
	    var params={param:unquid};

	    common.util.__ajax({
	        url: importConfig.callBackApi,
	        data:params
	    },function(res){
	        if(res.data.length){
	            
	            //成功操作
	            if (loadModal) {
	                loadModal.close();
	            }
	             common.util.__tip(res.message, 'success');

	        }else{
	           setTimeout(function(){
	             __ajaxExeclById.call(null,unquid);
	           },5000);
	        }
	        $("#message").html(res.message);
	    },true);
	}

/***/ }
]);