1.html
<div class="c_btn c_btn_active lh46 w200" ngf-select="handleFiles($file)" ngf-multiple="false"><span class="import_icon"></span>导入表格</div>
2.js
// 导入表格 application/vnd.ms-excel
$scope.handleFiles = function (file) {
if (file) {
if(/(xlsx|xls)$/g.test(file.name)){
var fd = new FormData();
fd.append('myfiles', file);
$http({
method: 'POST',
url: serverAddr.normal + "/quality/api/v2/manage/saveQDFile",
data: fd,
headers: {'Content-Type': undefined},
transformRequest: angular.identity
})
.success(function (response) {
//上传成功的操作
document.querySelector('input[type=file]').files[0] = null;
if(response.error_code === 0){
alertP('上传成功');
manageQDListFun();
}else{
alertP(response.error_info || '服务器有故障');
}
}).error(function (err) {
alertP('上传失败');
});
}else{
alertP('请上传excel表格')
}
}
};
// 提示框
function alertP(msg,time){
var t=time||1000;
vm.boostTip=msg;
vm.boostTipFlag=true;
var a=$timeout(function(){
vm.boostTipFlag=false;
$timeout.cancel(a);
},t)
}