sysFileHtmlDialog.jsp 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <%@ page import="com.hotent.core.util.AppConfigUtil" %>
  2. <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
  3. <%@include file="/commons/include/html_doctype.html"%>
  4. <%
  5. String max = request.getParameter("max");
  6. String type = request.getParameter("type");
  7. String maxUploadSize = AppConfigUtil.get("maxUploadSize");
  8. %>
  9. <html ng-app='app'>
  10. <head>
  11. <%@include file="/commons/include/get.jsp"%>
  12. <title>系统附件上传</title>
  13. <f:link href="bootstrap/bootstrap.css"></f:link>
  14. <f:link href="bootstrap/bootstrap-responsive.min.css"></f:link>
  15. <f:link href="bootstrap/bootstrap-responsive.css"></f:link>
  16. <f:link href="bootstrap/bootstrap-dialog.min.css"></f:link>
  17. <f:link href="bootstrap/bootstrap-combined.min.css"></f:link>
  18. <f:link href="bootstrap/bootstrap.min.css"></f:link>
  19. <script type="text/javascript" src="${ctx}/js/angular/angular.min.js"></script>
  20. <script type="text/javascript" src="${ctx}/js/angular/angular-sanitize.min.js"></script>
  21. <script type="text/javascript" src="${ctx}/js/angular/service/baseServices.js"></script>
  22. <script type="text/javascript" src="${ctx}/js/angular/bootstrap.min.js"></script>
  23. <script type="text/javascript" src="${ctx}/js/angular/service/commonListService.js"></script>
  24. <script type="text/javascript" src="${ctx}/js/angular/service/arrayToolService.js"></script>
  25. <script type="text/javascript" src="${ctx}/js/angular/angular-file-upload.js"></script>
  26. <style type="text/css">
  27. .my-drop-zone { border: dotted 3px lightgray; }
  28. td{vertical-align: middle!important;}
  29. </style>
  30. <script type="text/javascript">
  31. var type = '<%=type%>',
  32. max = <%=max%>,
  33. maxUploadSize = <%=maxUploadSize%>;
  34. function getData(){
  35. var scope = $("body").scope();
  36. return scope;
  37. }
  38. angular.module("app", [ 'angularFileUpload' ])
  39. .controller('uploadCtrl',[ '$scope', 'FileUploader', function($scope, FileUploader) {
  40. var url = __ctx + "/platform/system/sysFile/fileUpload.ht";
  41. var uploader = $scope.uploader = new FileUploader({
  42. url : url
  43. });
  44. if(max&&typeof max=='number'){
  45. //上传文件数目上限过滤器
  46. uploader.filters.push({
  47. name : 'countFilter',
  48. fn : function(item, options) {
  49. var result = this.queue.length < max;
  50. !result&&($.ligerDialog.warn("最多只能上传"+max+"个文件"));
  51. return result;
  52. }
  53. });
  54. }
  55. if(type){
  56. var reg = new RegExp("^.*.("+type+")$");
  57. //上传文件的文件类型过滤器
  58. uploader.filters.push({
  59. name : 'typeFilter',
  60. fn : function(item, options) {
  61. var result = reg.test(item.name);
  62. !result&&($.ligerDialog.warn("文件类型只能是"+type));
  63. return result;
  64. }
  65. });
  66. }
  67. if(maxUploadSize&&typeof maxUploadSize=='number'){
  68. //上传文件的大小过滤器
  69. uploader.filters.push({
  70. name : 'sizeFilter',
  71. fn : function(item, options) {
  72. var result = item.size <= maxUploadSize;
  73. !result&&($.ligerDialog.warn("单个文件大小不能超过"+maxUploadSize/1024/1024+"M"));
  74. return result;
  75. }
  76. });
  77. }
  78. uploader.onSuccessItem = function(fileItem, response) {
  79. fileItem.json = {fileId:response.fileId,fileName:response.fileName};
  80. console.log(fileItem.json);
  81. };
  82. }]);
  83. </script>
  84. </head>
  85. <body ng-controller="uploadCtrl" nv-file-drop uploader="uploader" filters="countFilter,typeFilter,sizeFilter">
  86. <div class="container-fluid">
  87. <div class="row" style="margin: 0 10px;">
  88. <div class="pull-left" style="margin:15px 0 10px 10px;width:300px;">
  89. <input type="file" nv-file-select uploader="uploader" multiple />
  90. <div style="margin-top:10px;">
  91. <a href="#" ng-click="uploader.uploadAll()" ng-disabled="!uploader.getNotUploadedItems().length" class="btn btn-primary fa-save"><span>全部上传</span></a>
  92. <a href="#" ng-click="uploader.cancelAll()" ng-disabled="!uploader.isUploading" class="btn btn-default fa-undo"><span>全部取消</span></a>
  93. <a href="#" ng-click="uploader.clearQueue()" ng-disabled="!uploader.queue.length" class="btn btn-danger fa-remove"><span>全部删除</span></a>
  94. </div>
  95. </div>
  96. <div class="pull-right" ng-if="uploader.isHTML5" style="margin-top:10px;width:410px;" nv-file-drop="" uploader="uploader">
  97. <div nv-file-over="" uploader="uploader" over-class="another-file-over-class" class="well my-drop-zone">
  98. <p>将文件拖拽至此区域</p>
  99. </div>
  100. </div>
  101. </div>
  102. <div class="row" style="margin: 0 10px;">
  103. <div class="easyui-panel" title="上传队列" style="padding: 0 10px;">
  104. <table class="table">
  105. <thead>
  106. <tr>
  107. <th width="80">序号</th>
  108. <th>文件</th>
  109. <th width="100" ng-show="uploader.isHTML5">大小</th>
  110. <th width="100" ng-show="uploader.isHTML5">进度</th>
  111. <th width="50">状态</th>
  112. <th width="200">操作</th>
  113. </tr>
  114. </thead>
  115. <tbody>
  116. <tr ng-repeat="item in uploader.queue">
  117. <td>{{$index+1}}</td>
  118. <td>
  119. <div style="width:200px;overflow:hidden;" title="{{ item.file.name }}">
  120. <strong>{{ item.file.name }}</strong>
  121. </div>
  122. </td>
  123. <td ng-show="uploader.isHTML5" nowrap><span>{{ item.file.size/1024/1024|number:2 }} MB</span></td>
  124. <td ng-show="uploader.isHTML5">
  125. <div class="progress" style="margin-bottom: 0;">
  126. <div class="progress-bar" role="progressbar" ng-style="{ 'width': item.progress + '%' }"></div>
  127. </div>
  128. </td>
  129. <td class="text-center">
  130. <span ng-show="item.isSuccess"><i class="glyphicon glyphicon-ok"></i></span>
  131. <span ng-show="item.isCancel"><i class="glyphicon glyphicon-ban-circle"></i></span>
  132. <span ng-show="item.isError"><i class="glyphicon glyphicon-remove"></i></span>
  133. </td>
  134. <td nowrap>
  135. <a href="#" ng-click="item.upload()" ng-disabled="item.isReady || item.isUploading || item.isSuccess" class="btn btn-primary fa-save"><span>上传</span></a>
  136. <a href="#" ng-click="item.cancel()" ng-disabled="!item.isUploading" class="btn btn-default fa-undo"><span>取消</span></a>
  137. <a href="#" ng-click="item.remove()" class="btn btn-danger fa-remove"><span>删除</span></a>
  138. </td>
  139. </tr>
  140. </tbody>
  141. </table>
  142. </div>
  143. </div>
  144. </div>
  145. </body>
  146. </html>