Import.js 1.37 KB
'use strict';

var $ = require('jquery'), common = require('../../common/common');
var importConfig = { "bizType" : "vipBatch" };
var importConfig1 = { "bizType" : "vipReturnCoinBatch" };
$('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();
        },
        onComplete: function(response) {
            if (loadModal) {
                loadModal.close();
            }
            console.log("批量接口返回数据",response);
            var msg = response.data.result;
            if (response.code == 200) {
                common.util.__tip(msg, 'success');
                $("#message").html("");
            } else if (msg) {
                $("#message").html(msg);
                common.util.__tip("导入失败", 'warning');
            } else {
                common.util.__tip("导入失败", 'warning');
            }
        }
    }
}

common.edit.ajaxfileupload('#importProductBatch', batchImport('#sort-file', importConfig.bizType));

common.edit.ajaxfileupload('#importReturnCoinBatch', batchImport('#sort-file', importConfig1.bizType));