ソースを参照

文件上传添加文件大小展示项,调用收藏类文件上传时,取消文件大小限制

徐滕 1 ヶ月 前
コミット
d6294793bb

+ 8 - 5
src/main/webapp/WEB-INF/tags/table/fileUpload.tag

@@ -133,8 +133,8 @@
                 <th width="30%">文件预览</th>
                 <th width="80px">上传人</th>
                 <th width="160px">上传时间</th>
-                <th width="100px">文件大小(MB)</th>
                 <th width="30%">文件描述</th>
+                <th width="100px">文件大小(MB)</th>
                 <th width="140px">操作</th>
                 <th class="hide"></th>
             </tr>
@@ -179,12 +179,13 @@
                             <%-- 上传时间 --%>
                         <td><fmt:formatDate value="${attach.createDate}" type="both"/></td>
 
-                            <%-- 文件大小 --%>
-                        <td>${attach.fileSize}</td>
 
                             <%-- 文件描述 --%>
                         <td style="padding:0px"><input id="workAttachments${status.index + 1}_description" name="workAttachments[${status.index + 1}].description" type="text" value="${attach.description}"  class="form-control layui-input" placeholder="请输入文件描述" style="width: 100%;height: 100%;padding:0px;background-color: #FFFFFF;" readonly="true" onclick="openInfo('workAttachments${status.index + 1}',this.value)"/></td>
 
+                            <%-- 文件大小 --%>
+                        <td>${attach.fileSize}</td>
+
                             <%-- 操作按钮 --%>
                         <td class="op-td">
                             <div class="op-btn-box">
@@ -323,7 +324,8 @@
             $("#${baseId}_addFile").show();
             var fileCount = $("#${baseId}_fileCount").val();
             $("#${baseId}_fileCount").val(parseInt(fileCount)+1);
-            multipartUploadWithStsOnProcessAccessoryAndFileSize("${storeAs}", file, attachmentId, attachmentFlag, uploadPath, divId, ${baseId}_size, fileCount);
+            var collectType = file.collectType;
+            multipartUploadWithStsOnProcessAccessoryAndFileSize("${storeAs}", file, attachmentId, attachmentFlag, uploadPath, divId, ${baseId}_size, fileCount,collectType);
         }
     }
 
@@ -447,7 +449,8 @@
             $("#addFile" + divId).show();
             var fileCount = $("#${baseId}_fileCount").val();
             $("#${baseId}_fileCount").val(parseInt(fileCount)+1);
-            multipartUploadWithStsCollectionCollectOnFileSize(storeAs, file,attachmentId,attachmentFlag,uploadPath,divId,size,fileCount);
+            var collectType = file.collectType;
+            multipartUploadWithStsCollectionCollectOnFileSize(storeAs, file,attachmentId,attachmentFlag,uploadPath,divId,size,fileCount,collectType);
         }
     }
 </script>

+ 16 - 8
src/main/webapp/static/oss/ossupload.js

@@ -3675,7 +3675,7 @@ function multitestOnFileSize (ossClient, storeAs, file,attachmentId,attachmentFl
     });
 };
 
-function multipartUploadWithStsOnProcessAccessoryAndFileSize(storeAs, file,attachmentId,attachmentFlag,uploadPath,divId,size, fileCount) {
+function multipartUploadWithStsOnProcessAccessoryAndFileSize(storeAs, file,attachmentId,attachmentFlag,uploadPath,divId,size, fileCount,collectType) {
     file.name.replace(" ","")
     file.name.replace(/—/g,"")
     var fileName = file.name;
@@ -3739,12 +3739,12 @@ function multipartUploadWithStsOnProcessAccessoryAndFileSize(storeAs, file,attac
             timeout:timeout
         });
         storeAs = "attachment-file/" + storeAs +"/"+today+new Date().getTime()+ file.name;
-        multitestOnProcessAccessoryAndFileSize(client, storeAs, file,attachmentId,attachmentFlag,uploadPath.replace('http://dmtest-test.oss-cn-shanghai.aliyuncs.com', result.AliyunUrl),divId,size, fileCount);
+        multitestOnProcessAccessoryAndFileSize(client, storeAs, file,attachmentId,attachmentFlag,uploadPath.replace('http://dmtest-test.oss-cn-shanghai.aliyuncs.com', result.AliyunUrl),divId,size, fileCount,collectType);
     })
 };
 
 
-function multitestOnProcessAccessoryAndFileSize (ossClient, storeAs, file,attachmentId,attachmentFlag,uploadPath,divId, size,fileCount) {
+function multitestOnProcessAccessoryAndFileSize (ossClient, storeAs, file,attachmentId,attachmentFlag,uploadPath,divId, size,fileCount,collectType) {
     // 根据文件大小动态配置 parallel
     let parallel;
     if (file.size < 50 * 1024 * 1024) { // 小于 50 MB
@@ -3799,7 +3799,11 @@ function multitestOnProcessAccessoryAndFileSize (ossClient, storeAs, file,attach
                 const bytes = Number(data.fileSize) || 0;
 
                 // 2. 直接计算MB并保留2位小数,拼接单位(核心逻辑一步完成)
-                const fileSizeInMB = (bytes / (1024 * 1024)).toFixed(2);
+                let fileSizeInMB = (bytes / (1024 * 1024)).toFixed(2);
+
+                if(collectType){
+                    fileSizeInMB = data.fileSize
+                }
 
                 var lowerType = data.type.toLowerCase();
                 if(data.status=="Success"){
@@ -3897,7 +3901,7 @@ function multitestOnProcessAccessoryAndFileSize (ossClient, storeAs, file,attach
 };
 
 
-function multipartUploadWithStsCollectionCollectOnFileSize(storeAs, file,attachmentId,attachmentFlag,uploadPath,divId,size, fileCount,idx,prefix,currentUser) {
+function multipartUploadWithStsCollectionCollectOnFileSize(storeAs, file,attachmentId,attachmentFlag,uploadPath,divId,size, fileCount,collectType) {
     console.log("-----------------------start");
     console.log("-----------------------"+realPath);
     var fileUrl=file.linUrl;
@@ -3966,12 +3970,12 @@ function multipartUploadWithStsCollectionCollectOnFileSize(storeAs, file,attachm
             timeout:timeout
         });
         storeAs = url;
-        multitestCollectionCollectOnFileSize(client, storeAs, file,attachmentId,attachmentFlag,uploadPath.replace('http://dmtest-test.oss-cn-shanghai.aliyuncs.com', result.AliyunUrl),divId,size, fileCount,fileUrl,fileSize);
+        multitestCollectionCollectOnFileSize(client, storeAs, file,attachmentId,attachmentFlag,uploadPath.replace('http://dmtest-test.oss-cn-shanghai.aliyuncs.com', result.AliyunUrl),divId,size, fileCount,fileUrl,fileSize,collectType);
     })
 
 };
 
-function multitestCollectionCollectOnFileSize (ossClient, storeAs, file,attachmentId,attachmentFlag,uploadPath,divId, size,fileCount,fileUrl,fileSize) {
+function multitestCollectionCollectOnFileSize (ossClient, storeAs, file,attachmentId,attachmentFlag,uploadPath,divId, size,fileCount,fileUrl,fileSize,collectType) {
 
     var names =  storeAs.split("/");
     var name = names[names.length-1];
@@ -4015,7 +4019,11 @@ function multitestCollectionCollectOnFileSize (ossClient, storeAs, file,attachme
                 const bytes = Number(data.fileSize) || 0;
 
                 // 2. 直接计算MB并保留2位小数,拼接单位(核心逻辑一步完成)
-                const fileSizeInMB = (bytes / (1024 * 1024)).toFixed(2);
+                let fileSizeInMB = (bytes / (1024 * 1024)).toFixed(2);
+
+                if(collectType){
+                    fileSizeInMB = data.fileSize
+                }
 
                 var lowerType = data.type.toLowerCase();
                 if(data.status=="Success"){

+ 3 - 3
src/main/webapp/webpage/include/head.jsp

@@ -93,13 +93,13 @@
             document.write('<script type="text/javascript" src="${ctxStatic}/oss/lib/crypto1/hmac/hmac.js"><\/script>');
             document.write('<script type="text/javascript" src="${ctxStatic}/oss/lib/crypto1/sha1/sha1.js"><\/script>');
             document.write('<script type="text/javascript" src="${ctxStatic}/oss/lib/base64.js"><\/script>');
-            document.write('<script type="text/javascript" src="${ctxStatic}/oss/ie-ossupload.js?20"><\/script>');
+            document.write('<script type="text/javascript" src="${ctxStatic}/oss/ie-ossupload.js?21"><\/script>');
         }
         else
         {
              document.write('<script src="http://gosspublic.alicdn.com/aliyun-oss-sdk-4.4.4.min.js"><\/script>');
             document.write('<script src="${ctxStatic}/bos/node_modules/@baiducloud/sdk/dist/baidubce-sdk.bundle.min.js"><\/script>');
-            document.write('<script type="text/javascript" src="${ctxStatic}/oss/ossupload.js?20"><\/script>');
+            document.write('<script type="text/javascript" src="${ctxStatic}/oss/ossupload.js?21"><\/script>');
             /*document.write('<script type="text/javascript" src="${ctxStatic}/bos/bosupload.js"><\/script>');*/
         }
     }
@@ -107,7 +107,7 @@
     {
          document.write('<script src="http://gosspublic.alicdn.com/aliyun-oss-sdk-4.4.4.min.js"><\/script>');
         document.write('<script src="${ctxStatic}/bos/node_modules/@baiducloud/sdk/dist/baidubce-sdk.bundle.min.js"><\/script>');
-        document.write('<script type="text/javascript" src="${ctxStatic}/oss/ossupload.js?20"><\/script>');
+        document.write('<script type="text/javascript" src="${ctxStatic}/oss/ossupload.js?21"><\/script>');
         /*document.write('<script type="text/javascript" src="${ctxStatic}/bos/bosupload.js"><\/script>');*/
     }
 

+ 1 - 1
src/main/webapp/webpage/include/ossTools.jsp

@@ -9,4 +9,4 @@
 <script type="text/javascript" src="${ctxStatic}/oss/lib/plupload-2.3.6/plupload-2.3.6/js/jquery.plupload.queue/jquery.plupload.queue.js"></script>
 <script type="text/javascript" src="${ctxStatic}/oss/lib/plupload-2.3.6/plupload-2.3.6/js/plupload.dev.js"></script>
 <script type="text/javascript" src="${ctxStatic}/oss/upload.js"></script>
-<script type="text/javascript" src="${ctxStatic}/oss/ossupload.js?20"></script>
+<script type="text/javascript" src="${ctxStatic}/oss/ossupload.js?21"></script>

+ 1 - 1
src/main/webapp/webpage/modules/projectcontentinfo/achievementFileDataForm.jsp

@@ -6,7 +6,7 @@
 	<meta name="decorator" content="default"/>
 	<link href="${ctxStatic}/bootstrap-select-1.12.4/css/bootstrap-select.min.css" rel="stylesheet" />
 	<script src="${ctxStatic}/bootstrap-select-1.12.4/js/bootstrap-select.min.js"></script>
-	<script type="text/javascript" src="${ctxStatic}/oss/ossupload.js?20"></script>
+	<script type="text/javascript" src="${ctxStatic}/oss/ossupload.js?21"></script>
 	<style>
 		label.error{
 			top:40px;

+ 1 - 1
src/main/webapp/webpage/modules/projectcontentinfo/basedDataForm.jsp

@@ -6,7 +6,7 @@
 	<meta name="decorator" content="default"/>
 	<link href="${ctxStatic}/bootstrap-select-1.12.4/css/bootstrap-select.min.css" rel="stylesheet" />
 	<script src="${ctxStatic}/bootstrap-select-1.12.4/js/bootstrap-select.min.js"></script>
-	<script type="text/javascript" src="${ctxStatic}/oss/ossupload.js?20"></script>
+	<script type="text/javascript" src="${ctxStatic}/oss/ossupload.js?21"></script>
 	<style>
 		label.error{
 			top:40px;

+ 27 - 11
src/main/webapp/webpage/modules/workclientinfo/workClientTypeForm.jsp

@@ -52,7 +52,8 @@
                   return false;
               }
               var tableObj = document.getElementById('contentTable').rows[1];
-              if (tableObj == null) {
+              var  contentTableLength = $("table#contentTable tr:visible").length;
+              if (tableObj == null || contentTableLength == 1) {
                   parent.layer.msg("请填写联系人信息!", {icon: 5});
                   return false;
               }
@@ -196,9 +197,9 @@
 					}
 				}
 			});
-            $("#attachment_btn").click(function () {
+            /*$("#attachment_btn").click(function () {
                 $("#attachment_file").click();
-            });
+            });*/
             $('input[name="hasUscc"]').on('ifChecked', function(event){
                 disUscc(event.target.defaultValue);
             });
@@ -417,7 +418,7 @@
             });
         }
 
-        function insertTitle(tValue){
+        /*function insertTitle(tValue){
             var list = "${workClientInfo.workAttachments}";
             var size = (list.split('url')).length-1;
             var files = $("#attachment_file")[0].files;
@@ -430,12 +431,12 @@
 
                 var storeAs = "workClientInfo";
                 var uploadPath = "http://gangwan-app.oss-cn-hangzhou.aliyuncs.com/" + storeAs;
-                /*将这段字符串存到数据库即可*/
+                /!*将这段字符串存到数据库即可*!/
                 var divId = "_attachment";
                 $("#addFile" + divId).show();
                 multipartUploadWithSts(storeAs, file, attachmentId, attachmentFlag, uploadPath, divId, size);
             }
-        }
+        }*/
 
         function disUscc(hasUscc) {
             if("2"==hasUscc){
@@ -886,7 +887,22 @@
             </div>
 
 
-            <div class="form-group layui-row">
+
+            <!-- fileHandlerFuncName="myCustomHandler" 自定义函数名 -->
+            <!-- attachmentFlag="6" 附件标识 -->
+            <!-- storeAs="wrkReimbursement" 存储路径标识 -->
+            <!-- showOperateArea="false" 是否展示新增按钮,默认true -->
+            <table:attachmentManager
+                    title="附件信息"
+                    addBtnText="添加附件"
+                    baseId="attachment"
+                    attachments="${workReimbursement.workAttachments}"
+                    fileHandlerFuncName="insertTitle"
+                    attachmentFlag="5"
+                    storeAs="workClientInfo"
+            />
+
+            <%--<div class="form-group layui-row">
                 <div class="form-group-label"><h2>附件信息</h2></div>
                 <div class="layui-item nav-btns">
                     <a id="attachment_btn" class="nav-btn nav-btn-add" title="添加附件"><i class="fa fa-plus"></i>&nbsp;添加附件</a>
@@ -895,7 +911,7 @@
                     <span id="fileName_attachment"></span>
                     <b><span id="baifenbi_attachment"></span></b>
                     <div class="progress">
-                            <%--进度条--%>
+                            &lt;%&ndash;进度条&ndash;%&gt;
                         <div id="jindutiao_attachment" class="progress-bar" style="width: 0%" aria-valuenow="0">
                         </div>
                     </div>
@@ -907,7 +923,7 @@
                     <table id="upTable" class="table table-bordered table-condensed details">
                         <thead>
                         <tr>
-                                <%-- <th>序号</th>--%>
+                                &lt;%&ndash; <th>序号</th>&ndash;%&gt;
                             <th>文件</th>
                             <th>上传人</th>
                             <th>上传时间</th>
@@ -918,7 +934,7 @@
                         <c:forEach items="${workClientInfo.workAttachments}" var="workClientAttachment"
                                    varStatus="status">
                             <tr>
-                                    <%-- <td>${status.index + 1}</td>--%>
+                                    &lt;%&ndash; <td>${status.index + 1}</td>&ndash;%&gt;
                                         <c:choose>
                                             <c:when test="${workClientInfo.uploadMode == 2}">
                                                 <c:choose>
@@ -985,7 +1001,7 @@
                         </tbody>
                     </table>
                 </div>
-            </div>
+            </div>--%>
             <div class="form-group layui-row page-end"></div>
         </form:form>
     </div>