Przeglądaj źródła

update 手机端报表

linweizeng 3 lat temu
rodzic
commit
d960074182
2 zmienionych plików z 118 dodań i 30 usunięć
  1. 1 0
      package.json
  2. 117 30
      src/business/platform/form/utils/custom/pintText.js

+ 1 - 0
package.json

@@ -70,6 +70,7 @@
     "normalize.css": "^8.0.1",
     "nprogress": "^0.2.0",
     "papaparse": "^5.3.0",
+    "pdfh5": "^1.4.2",
     "pinyin": "^2.11.1",
     "pinyin4js": "^1.3.18",
     "qrcodejs2": "0.0.2",

+ 117 - 30
src/business/platform/form/utils/custom/pintText.js

@@ -1,36 +1,123 @@
 import dialog from '@/utils/dialog'
+import Pdfh5 from "pdfh5";
+import "pdfh5/css/pdfh5.css";
+import { snapshoot } from '@/api/platform/file/attachment' //印章,快照
 
-const getPint =  (tableForm,srcUrl) => {
-    dialog(
+const getPint = (tableForm, srcUrl) => {
+    var flag = true;
+    if (/Mobi|Android|iPhone|iPad/i.test(navigator.userAgent)) {
+        flag = false
+    }
+
+    if (flag) {
+        dialog(
+            {
+                data() {
+                    return {
+                        readonly: false,
+                        data: ''
+                    }
+                },
+
+                template: '<div style="height:100%">' +
+                    '<iframe src="' + srcUrl + '"' +
+                    'id="myiframe"  frameborder="0" scrolling="no" height="100%" width="100%"></iframe>' +
+                    '</div>'
+            },
+            {
+                dialog: {
+                    appendToBody: true,
+                    width: '90%',
+                    top: '1vh',
+                    center: true,
+                    title: '',
+                    'custom-class': 'ibps-dialog-91'
+                }
+            }, (tpl) => {
+                tableForm.dialogTemplate = tpl
+            }
+        ).catch((_this) => {
+            _this.visible = false
+            tableForm.dialogTemplate = null
+        })
+    } else {
+
+        dialog(
+            {
+                data() {
+                    return {
+                        readonly: false,
+                        data: '',
+                        pdfh5: null
+                    }
+                },
+                mounted() {
+                    this.getYab()
+                    this.getMet()
+                },
+                methods: {
+                    getYab(){
+                        let srcUrl1 = srcUrl.split('rpx=')[1]
+                        let srcUrlList = srcUrl1.split('.rpx&id_=')
+                        let name = srcUrlList[0].split('/')
+
+                        let url = tableForm.$getReportFile(srcUrlList[0], `id_=${ srcUrlList[1] }`)
+                        console.log(url)
+                        let params = {
+                            url: url,
+                            name: name[name.length - 1] || '暂无',
+                            type: 'pdf'
+                        }
+                        snapshoot(params).then(res => {
+                            if(res.state == 200){
+                                const data = res.data
+                                this.getMet(data.filePath)
+                            }
+                        })
+                    },
+                    getMet(url) {
+                        let that = this
+                        // //实例化1
+                        that.$nextTick(() => {
+                            that.pdfh5 = new Pdfh5("#demo", {
+                                pdfurl: window.location.origin + '/'+url,
+                                lazy: true
+                            })
+                            that.pdfh5.on("complete", function (status, msg, time) {
+                                // console.log(status, msg, time)
+                            })
+                        });
+                    }
+                },
+                template: '<div style="height:100%"><div id="demo"></div></div>'
+            },
             {
-             data(){
-               return {
-                 readonly:false,
-                 data:''
-               }
-               },
-
-               template:'<div style="height:100%">' +
-               '<iframe src="'+ srcUrl + '"'+
-               'id="myiframe"  frameborder="0" scrolling="no" height="100%" width="100%"></iframe>'+
-               '</div>'
-             },
-             {
-               dialog:{
-                 appendToBody:true,
-                 width: '90%',
-                 top: '1vh',
-                 center: true,
-                 title: '',
-                 'custom-class':'ibps-dialog-91'
-               }
-             },(tpl)=>{
-               tableForm.dialogTemplate =tpl
-               }
-            ).catch((_this)=>{
-               _this.visible = false
-               tableForm.dialogTemplate = null
-             })
+                dialog: {
+                    appendToBody: true,
+                    width: '90%',
+                    top: '1vh',
+                    center: true,
+                    title: '',
+                    'custom-class': 'ibps-dialog-91'
+                }
+            }, (tpl) => {
+                tableForm.dialogTemplate = tpl
+                setTimeout(() => {
+
+                }, 2000);
+                //监听完成事件
+                // this.pdfh5.on("complete", function (status, msg, time) {
+                // })
+
+
+
+            }
+        ).catch((_this) => {
+            _this.visible = false
+            tableForm.dialogTemplate = null
+        })
+    }
+
 }