$(function(){
    var $uploadBtn=$("#uploadBtn");
    var $execlUpload=$("#execlUpload");
    var $tmlTip=$(".tml-tip");
    var $path=$("#path");
    $uploadBtn.on("click",function(e){
        if(!$execlUpload.val()){
            $uploadBtn.removeAttr("data-dismiss");
            alert("请选择一个上传模板");
            return;
        }
        if($uploadBtn.attr("data-dismiss")){
            $path.val("/uploads/execltemplate/"+$execlUpload[0].files[0].name);
            $execlUpload.val("");
        }
    });
    $execlUpload.on("change",function(){
        //var fileName=$execlUpload[0].files[0].name;
        var fileSize=$execlUpload[0].files[0].size;
        var fileType=$execlUpload[0].files[0].type;
        //console.log("文件名:"+fileName+"文件大小:"+fileSize+"文件类型:"+fileType);
        if(fileSize>104857600){
            $tmlTip.html("*超过文件最大上传大小");
            $uploadBtn.removeAttr("data-dismiss");
        }else if(fileType!=".csv"
                &&fileType!="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
                &&fileType!="application/vnd.ms-excel"){
                    $tmlTip.html("*上传文件类型错误");
                    $uploadBtn.removeAttr("data-dismiss");
        }else{
            $tmlTip.html("*上传文件最大不超过100M");
            $uploadBtn.attr("data-dismiss","modal");
        }
    });   
});