zoukankan      html  css  js  c++  java
  • 导入导出

    <!-- 导入页面 -->
    <div class="modal-dialog" id='ImportMoadl' style='display:none;'>
    <div class="modal-content" style='z-index: 9999;'>
    <div class="modal-header">
    <button type="button" onclick='onExit()' class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
    <h4 class="modal-title">导入终端信息</h4>
    </div>
    <div class="modal-body">
    <form id="terminalUploadForm" >
    <div class="row">
    <div class="col-sm-6 form-group">
    <input id="filePath" name="filePath" class="file-loading"
    type="file" multiple accept=".xls,.xlsx" data-min-file-count="1"
    data-show-preview="true">
    <input class="form-control" id="fileName" name="fileName" type=hidden
    data-bv-remote-name="value" disabled="disabled" />
    </div>
    <div class="col-sm-6 form-group">
    <a onclick="onImportModel()" style="cursor: pointer; " >请下载导入的模板</a>
    </div>
    </div>

    </form>
    </div>
    <div class="modal-footer text-center">
    <button type="button" class="btn btn-primary" onclick="uploadInfo();">提交</button>
    <button type="button" class="btn btn-default" onclick="onExit();">取消</button>
    </div>
    </div>
    <div class="modal-backdrop fade in"></div>
    </div>

    js部分

    //导入
    function onImport(){
    $('#ImportMoadl').show();
    }
    //导入提交
    function uploadInfo(){
    alert(1)
    var filePath = document.getElementById("filePath");
    if (filePath.value == null || filePath.value == "" || filePath.value == undefined || filePath.value.length == 0) {
    return;
    } else {
    filePath = filePath.value;
    if (checkFiles(filePath) == ".xlsx" || checkFiles(filePath) == ".xls") {
    $.ajaxFileUpload({
    type : "get",
    url : '/sncp/terminal/onImport',
    fileElementId : 'filePath',// file标签的id
    dataType : 'json',// 返回数据的类型
    success : function(data) {
    $('#ImportMoadl').hide();
    if (data.success == false) {
    alertModal("导入成功!");
    $("#fileName").val(data.data);
    } else {
    alertModal("导入失败!");
    $('#ImportloserMoadl').show(); //显示失败下载弹框

    }
    },
    error : function(data) {
    alertModal("导入失败!");
    }
    });
    } else {
    alertModal('格式不正确!');
    }
    }
    }
    //检查文件后缀名
    function checkFiles(file_name) {
    var result = /.[^.]+/.exec(file_name);
    return result;
    }
    //导入取消
    function onExit(){
    alert(2);
    $('#ImportMoadl').hide();
    $('#ImportloserMoadl').hide();
    }
    //导入失败点击下载
    function onImportDefeatedModel(){

    }

    function onExport(){
    window.location.href = $ctx +"/t_user/onExport";
    }

  • 相关阅读:
    线段树(区间合并) LA 3989 "Ray, Pass me the dishes!"
    BIT LA 4329 Ping pong
    并查集(路径更新) LA 3027 Corporative Network
    log4j.properties配置详解与实例-全部测试通过
    ActiveMQ入门实例
    activemq安全设置 设置admin的用户名和密码
    Freemarker入门小案例(生成静态网页的其中一种方式)
    maven项目在myeclipse中不出现Maven Dependencies 和maven标识的解决方法
    Mysql,SqlServer,Oracle主键自动增长的设置
    常用SQL语句
  • 原文地址:https://www.cnblogs.com/benmumu/p/10437413.html
Copyright © 2011-2022 走看看