Bladeren bron

企业修改时提交pdf文件提示成功及可预览临时文件

sugangqiang 2 jaren geleden
bovenliggende
commit
f656ddc57f

+ 5 - 5
app/enterprise/view/api/to_add.html

@@ -65,7 +65,7 @@
                                     {eq name="ecr.imgurl_is_img" value="1"}
                                     <img src="{$ecr.imgurl|getStoragePath}" style="height:60px;" onclick="Feng.showImg(this)">
                                     {else/}
-                                    <img src="/static/img/Pdf.png" style="height:60px;" onclick="Feng.showPdf('{$ecr.imgurl|getStoragePath}', 'imgurl')">
+                                    <img src="/static/img/Pdf.png" style="height:60px;" data-url="{$ecr.imgurl|getStoragePath}">
                                     {/eq}
                                     {else/}
                                     <img src="/static/img/yyzz.png" style="height:60px;">
@@ -119,7 +119,7 @@
                                     {eq name="ecr.bankImg_is_img" value="1"}
                                     <img src="{$ecr.bankImg|getStoragePath}" style="height:60px;" onclick="Feng.showImg(this)" >
                                     {else/}
-                                    <img src="/static/img/Pdf.png" style="height:60px;" onclick="Feng.showPdf('{$ecr.bankImg|getStoragePath}', 'bankImg')">
+                                    <img src="/static/img/Pdf.png" style="height:60px;" data-url="{$ecr.bankImg|getStoragePath}">
                                     {/eq}
                                     {else/}
                                     <img src="/static/img/yyzz.png" style="height:60px;">
@@ -203,7 +203,7 @@
                                         {eq name="ecr.domainImg_is_img" value="1"}
                                         <img src="{$ecr.domainImg|getStoragePath}" style="height:60px;" onclick="Feng.showImg(this)" >
                                         {else/}
-                                        <img src="/static/img/Pdf.png" style="height:60px;" onclick="Feng.showPdf('{$ecr.domainImg|getStoragePath}', 'domainImg')">
+                                        <img src="/static/img/Pdf.png" style="height:60px;" data-url="{$ecr.domainImg|getStoragePath}">
                                         {/eq}
                                         {else/}
                                         <img src="/static/img/yyzz.png" style="height:60px;">
@@ -241,7 +241,7 @@
                                         {eq name="ecr.typeImg_is_img" value="1"}
                                         <img src="{$ecr.typeImg|getStoragePath}" style="height:60px;" onclick="Feng.showImg(this)" >
                                         {else/}
-                                        <img src="/static/img/Pdf.png" style="height:60px;" onclick="Feng.showPdf('{$ecr.typeImg|getStoragePath}', 'typeImg')">
+                                        <img src="/static/img/Pdf.png" style="height:60px;" data-url="{$ecr.typeImg|getStoragePath}">
                                         {/eq}
                                         {else/}
                                         <img src="/static/img/yyzz.png" style="height:60px;">
@@ -285,7 +285,7 @@
                                     {eq name="ecr.beian_is_img" value="1"}
                                     <img src="{$ecr.beian|getStoragePath}" style="height:60px;" onclick="Feng.showImg(this)" >
                                     {else/}
-                                    <img src="/static/img/Pdf.png" style="height:60px;" onclick="Feng.showPdf('{$ecr.beian|getStoragePath}', 'beian')">
+                                    <img src="/static/img/Pdf.png" style="height:60px;" data-url="{$ecr.beian|getStoragePath}">
                                     {/eq}
                                     {else/}
                                     <img src="/static/img/yyzz.png" style="height:60px;">

+ 5 - 5
app/enterprise/view/api/to_update.html

@@ -68,7 +68,7 @@
                                     {eq name="ecr.imgurl_is_img" value="1"}
                                     <img src="{$ecr.newImgurl|getStoragePath}" style="height: 60px;" onclick="Feng.showImg(this)">
                                     {else/}
-                                    <img src="/static/img/Pdf.png" style="height: 60px;" onclick="Feng.showPdf('{$ecr.newImgurl|getStoragePath}', 'imgurl')">
+                                    <img src="/static/img/Pdf.png" style="height: 60px;" data-url="{$ecr.newImgurl|getStoragePath}">
                                     {/eq}
                                     {else/}
                                     <img src="/static/img/yyzz.png" style="height: 60px;">
@@ -122,7 +122,7 @@
                                     {eq name="ecr.bankImg_is_img" value="1"}
                                     <img src="{$ecr.newBankImg|getStoragePath}" style="height: 60px;" onclick="Feng.showImg(this)" >
                                     {else/}
-                                    <img src="/static/img/Pdf.png" style="height: 60px;" onclick="Feng.showPdf('{$ecr.newBankImg|getStoragePath}', 'bankImg')">
+                                    <img src="/static/img/Pdf.png" style="height: 60px;" data-url="{$ecr.newBankImg|getStoragePath}">
                                     {/eq}
                                     {else/}
                                     <img src="/static/img/yyzz.png" style="height: 60px;">
@@ -206,7 +206,7 @@
                                         {eq name="ecr.domainImg_is_img" value="1"}
                                         <img src="{$ecr.newDomainImg|getStoragePath}" style="height: 60px;" onclick="Feng.showImg(this)" >
                                         {else/}
-                                        <img src="/static/img/Pdf.png" style="height: 60px;" onclick="Feng.showPdf('{$ecr.newDomainImg|getStoragePath}', 'domainImg')">
+                                        <img src="/static/img/Pdf.png" style="height: 60px;" data-url="{$ecr.newDomainImg|getStoragePath}">
                                         {/eq}
                                         {else/}
                                         <img src="/static/img/yyzz.png" style="height: 60px;">
@@ -244,7 +244,7 @@
                                         {eq name="ecr.typeImg_is_img" value="1"}
                                         <img src="{$ecr.newTypeImg|getStoragePath}" style="height: 60px;" onclick="Feng.showImg(this)" >
                                         {else/}
-                                        <img src="/static/img/Pdf.png" style="height: 60px;" onclick="Feng.showPdf('{$ecr.newTypeImg|getStoragePath}', 'typeImg')">
+                                        <img src="/static/img/Pdf.png" style="height: 60px;" data-url="{$ecr.newTypeImg|getStoragePath}">
                                         {/eq}
                                         {else/}
                                         <img src="/static/img/yyzz.png" style="height: 60px;">
@@ -288,7 +288,7 @@
                                     {eq name="ecr.beian_is_img" value="1"}
                                     <img src="{$ecr.newBeian|getStoragePath}" style="height: 60px;" onclick="Feng.showImg(this)" >
                                     {else/}
-                                    <img src="/static/img/Pdf.png" style="height: 60px;" onclick="Feng.showPdf('{$ecr.newBeian|getStoragePath}', 'beian')">
+                                    <img src="/static/img/Pdf.png" style="height: 60px;" data-url="{$ecr.newBeian|getStoragePath}">
                                     {/eq}
                                     {else/}
                                     <img src="/static/img/yyzz.png" style="height: 60px;">

+ 13 - 1
public/static/js/common/Feng.js

@@ -501,6 +501,18 @@ var Feng = {
             }
         });
     },
+    pdfReader:function(url,filename){
+        filename = typeof filename == "undefined" ? "临时文件" : filename;
+        var index = layer.open({
+            type: 2,
+            title: "查看PDF文件 - " + filename,
+            area: ['80%', '80%'], //宽高
+            fix: false, //不固定
+            maxmin: true,
+            content: url
+        });
+        return index;
+    },
     showPdf : function(url,id,title){
         if(Feng.isEmptyStr(id)){
             id = "id";
@@ -515,7 +527,7 @@ var Feng = {
             type: 2,
             shade: 0,
             title: title,
-            area: ['600px', '350px'], //宽高
+            area: ['80%', '80%'], //宽高
             fix: false, //不固定
             maxmin: true,
             content: url,

+ 16 - 0
public/static/modular/gate/enterprise/enterprise_change_edit.js

@@ -552,9 +552,25 @@ $("#imgurl,#bankImg,#beian,#domainImg,#typeImg").change(function (e) {
             $(that).prev("img").attr("src", imgSrc);
         } else {
             $(that).prev("img").attr("src", Feng.ctxPath + "/static/img/Pdf.png");
+            Feng.info("上传成功!<span style='color:red;'>*点击图标可预览</span>");
         }
     };
 });
+$("img").click(function () {
+    var fileInput = $(this).next("input");
+    var file = fileInput[0].files[0];
+    if (typeof file != "undefined" && file.type == "application/pdf") {
+        var url = URL.createObjectURL(file);
+        var filename = file.name;
+        //window.open(url)
+        Feng.pdfReader(url, filename);
+    } else {
+        var url = $(this).data("url");
+        if (typeof url != "undefined") {
+            Feng.showPdf(url);
+        }
+    }
+})
 EpChangeEdit.agencyTypeChange = function () {
     var agencyType = $("#newAgencyType").val();
     switch (agencyType) {