batch.js 1.08 KB
'use strict';
var $ = require('jquery');
var common = require('../common/common');

function batchExport(el, type) {
    var loadModal = null;
    return {
        params: {
            type: type,
            __type: "batch-import"
        },
        onStart: function (params) {
            console.log("params", params);
            loadModal = common.dialog.load();
        },
        onComplete: function (response) {
            console.log("response",response);
            if (loadModal) {
                loadModal.close();
            }
            if (response.code == 200 && response.data.failFileReason.length == 0) {
                common.util.__tip(response.message, 'success');
                return;
            }
            if (response.data && response.data.failFileReason.length) {
                $("#message").html(response.data.failFileReason.join('/n'));
                return false;
            }
            common.util.__tip(response.message, 'warning');

        }
    }
}

common.edit.ajaxfileupload('#productModelTry', batchExport('#productModelTry', 'productModelTry'));