Browse Source

file preview

ljy121 1 year ago
parent
commit
2085d92316

+ 16 - 27
zjugis-workflow/src/main/resources/static/js/filePreview.js

@@ -135,34 +135,22 @@
          */
         getFileUrl: function (id) {
             var _this = this;
-            if(this.options.fileUrl){
-                _this.rooting(z.ui.comm.getEntranceUrl(this.options.fileUrl));
-            }
-            // var currentFileSite = this.options.fileSite;
-            // z.ui.jsonpAjax({
-            //     url: currentFileSite + "/FileInfo/getFileById",
-            //     data: {id: id, getUrl: true, browserType: distinguishBrowser()},
-            //     success: function (data, b, c) {
-            //         if (data && data.error_code) {
-            //             z.ui.alertWarning(data.msg, 1000);
-            //             return;
-            //         }
-            //         if(data.noSupport) {
-            //             if (data.fileName) {
-            //                 z.ui.comm.downLoadFile(currentFileSite + "/FileInfo/getFileById?id=" + id, data.fileName);
-            //             }
-            //             _this.noSuportPreview();
-            //             return;
-            //         }
-            //         if (data.isStreamFile) {
-            //             _this.rooting(data.fileUrl, data.fileSuffix);
-            //         } else {
-            //             _this.rooting(data.fileUrl.replace(/\+/g, "%20"));
-            //         }
-            //     }
-            // });
+            var currentFileSite = this.options.fileSite;
+            z.ui.ajax({
+                url: currentFileSite + "/file/get-list?ids=" + id,
+                type: 'get',
+                data: {},
+                success: function (data, b, c) {
+                    if(data.code !== 0){
+                        z.ui.alertWarning(data.msg);
+                        return;
+                    }
+                    var file = data.data[0];
+                    _this.rooting(file.url.replace(/\+/g, "%20"),null,file.name);
+                }
+            });
         },
-        rooting: function (fileUrl, fileSuffix) {
+        rooting: function (fileUrl, fileSuffix,fileName) {
             if (!fileSuffix) {
                 fileSuffix = fileUrl.split('.')[fileUrl.split('.').length - 1];
             }
@@ -206,6 +194,7 @@
                     break;
                 default:
                     this.noSuportPreview();
+                    // z.ui.comm.downLoadFile(fileUrl, fileName);
                     break;
             }
         },

+ 4 - 4
zjugis-workflow/src/main/resources/templates/IFlowMaterialsFile/js/fileInnerPreview.js

@@ -38,8 +38,7 @@ $(function () {
 		_this.tabObj = $("[name='fileTabContain']");
 		_this.previewObj = new z.fileManagement.files.file_preview().init({
 			options: {
-				fileUrl: window.fileConfig.url,
-				fileSite: window.fileConfig.url,
+				fileSite: window.fileConfig.fileServer,
 				elem: '#fileInnerContainer'
 			}
 		});
@@ -80,7 +79,8 @@ $(function () {
 				"mfid": item.id,
 				"fileId": item.fileId,
 				"title": item.name + item.suffix,
-				"fileName": item.name + item.suffix
+				"fileName": item.name + item.suffix,
+				"fileUrl": item.fileUrl
 			}).data("data", item).html("<i class='fa'></i>");
 			if (item.fileId == thatFile.fileId) {
 				_this.on(tabItem);
@@ -138,7 +138,7 @@ $(function () {
 	materialspreview.prototype.render = function () {
 		var _this = this;
 		if (!_this.onTab) return;
-		_this.previewObj.show(_this.onTab.attr("fileId"));
+		_this.previewObj.show(_this.onTab.attr("fileId"),_this.onTab.attr("fileUrl"));
 	}
 	materialspreview.prototype.download = function () {
 		var _this = this;

+ 3 - 3
zjugis-workflow/src/main/resources/templates/IFlowMaterialsFile/js/materialPreview.js

@@ -25,7 +25,7 @@
     //显示附件材料
     function viewMaterial() {
         z.ui.loading(true, true);
-        previewObj.show($(".title").attr("file-id"));
+        previewObj.show($(".title").attr("file-id"), $(".title").attr("file-url"));
         z.ui.loading(false);
         //获取当前流程所有的材料
         var fileId = z.ui.comm.getUrlParam("fileId");
@@ -99,7 +99,7 @@
         $(".title").attr("file-id", fileItem.fileId);
         $(".title").attr("file-url", fileItem.fileUrl);
         $(".title").text(fileItem.name + fileItem.suffix);
-        previewObj.show(fileItem.fileId);
+        previewObj.show(fileItem.fileId,fileItem.fileUrl);
         z.ui.loading(false);
     }
 
@@ -123,4 +123,4 @@
             z.ui.alertWarning("您组件没装,请先安装绿建组件!");
         });
     }
-}());
+}());