導入導出

<!-- 導入頁面 -->
<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>ajax

js部分json

//導入
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(){

}ide

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