• 导入导出


    <!-- 导入页面 -->
    <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";
    }

  • 相关阅读:
    [JSOI2010]满汉全席 2sat
    (转)MongoDB实战开发 【零基础学习,附完整Asp.net示例】
    (转)ASP.NET的Cookie跨域问题
    (转)发一个自己写的账号管理软件
    (转)Silverlight学习点滴之一——使用WCF RIA构建应用
    (转)再议依赖注入
    (转)【探索发现】winform 网络传输时候封包与解包心得
    (转)使用Entity Framework和WCF Ria Services开发SilverLight之1:简单模型
    (转)LINQ to Entities 多条件动态查询
    (转)最老程序员创业札记:全文检索、数据挖掘、推荐引擎应用15
  • 原文地址:https://www.cnblogs.com/benmumu/p/10437413.html
Copyright © 2020-2023  润新知