importEmployee.ejs 2.6 KB
<!DOCTYPE html>
 
    <script src="/js/libs/jquery.ui.widget.js"></script>
     <script src="/js/libs/jquery.iframe-transport.js"></script>
     <script src="/js/libs/jquery.fileupload.js"></script> 
    <div class="import-head">
        <div class="route-btn">
          <div class="btn-back grey lighten-2">
            <i class="fa fa-long-arrow-left fa-3x"></i>
            <div class="btn-info">返回上一页</div>
          </div>
        </div>
        <div class="head-title center-align">
          <div class="head-title-wrap">
          <h5>邀请加入正式员工</h5>
          <p> 新的正式成员将自动添加到#企云在线<a href="#">编辑/添加</a></p>
          </div>
        </div>
        <div class="route-btn">
          <div class="btn-close grey lighten-2">
            <i class="fa fa-close fa-3x"></i>
            <div class="btn-info">关闭页面</div>
          </div>
        </div>
    </div>
    <div class="import-body">
        <div class="employee-body"> 
          <input id="fileupload" type="file" name="files[]" data-url="/hr/importEmployees" multiple>
          <div class="file-wrap"></div>
          <div class="submit-btn card-panel teal lighten-2 center-align waves-effect waves-light">
            <a href="#" >导入此文件</a>
          </div>
        </div>
    </div>
    <script type="text/javascript">
        $(function () {
            var fileData;
            $('#fileupload').fileupload({
                dataType: 'json',
                done: function (e, data) {
                  console.log(e);
                  console.log(data); 
                },
                add: function (e, data) {
                  fileData=data; 
                  $.each(data.files, function (index, file) {
                      $('.file-wrap').html("");
                      $('<p/>').text(file.name).appendTo('.file-wrap');
                  });
                },
                progressall: function (e, data) {
                  var progress = parseInt(data.loaded / data.total * 100, 10);
                  console.log(progress); 
                }
            });  
            $('.submit-btn').click(function(e){
                e.preventDefault(); 
                var jqXHR = fileData.submit()
                      .success(function (result, textStatus, jqXHR) {
                          console.log(result);
                      })
                      .error(function (jqXHR, textStatus, errorThrown) {

                      })
                      .complete(function (result, textStatus, jqXHR) {

                      });
            });
        });
    </script>