峰峰执法平台简易案件程序板块 pad端
yang
2022-10-17 4107256a8d1fa9a2db0969122bfc760994b12421
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<template>
  <el-dialog :visible.sync="isShowYulan" :before-close="cancel" width="60%" append-to-body>
    <div class="docWrap">
      <!-- 预览文件的地方(用于渲染) -->
      <div ref="word"></div>
    </div>
  </el-dialog>
</template>
 
<script>
    import {viewD, exportDoc, urlToBase64, viewWithImg, exportDocWidthImg} from "@/libs/word"
    export default {
        props: ['isShowYulan'],
        components: {
        },
        data() {
            return {
                dataForm:{},
                imgList:[]
            };
        },
        methods: {
            initMS(obj,url,arry,imgSize) {  //行政处罚没收财物处理审批表返回的数据和其它表不一样(没有publicOpinion对象)
                let that = this
                if(arry.length > 0) {
                    for (let i=0; i< arry.length; i++) {
                        urlToBase64(obj[arry[i]], function(baseStr) {
                            obj[arry[i]] = baseStr
                            that.$set(obj,arry[i],obj[arry[i]])
                        })
                    }
                    setTimeout(() => {
                        viewWithImg(obj,url,this.$refs.word,imgSize);
                    },1000)
                }
            },
            initMore(obj,url,arry,imgSize) {  //页面有多张签名照片的
                let that = this
                if(arry.length > 0) {
                    for (let i=0; i< arry.length; i++) {
                        if(obj.publicOpinion) {
                            urlToBase64(obj.publicOpinion[arry[i]], function(baseStr) {
                                obj.publicOpinion[arry[i]] = baseStr
                                that.$set(obj,arry[i],obj.publicOpinion[arry[i]])
                            })
                        }
                    }
                    setTimeout(() => {
                        viewWithImg(obj,url,this.$refs.word,imgSize);
                    },1000)
                }
            },
            init(obj,url,type,imgSize){  //页面只有一处有照片回显的(包含一处有多张图片)
                console.log(type,'type====')
                if (type != null && type != '' &&  type != undefined) {
                    // let aabb = "http://localhost:8080/admin/sys-file/platform/75968ac641154184bce1a1c38b486291.png"
                    if(obj[type] != '') {
                        let img = obj[type].split(',')
                        let that = this;
                        let imgList = []
                        for (let i=0; i< img.length; i++) {
                            urlToBase64(img[i],function(baseStr) {
                                img[i] = baseStr;
                                imgList.push({
                                    img: img[i]
                                })
                            })
                            that.$set(obj,'imgList',imgList)
                        }
                        setTimeout(() => {
                            viewWithImg(obj,url,that.$refs.word,imgSize);
                        },1000)
                    }else {
                        viewD(obj,url,this.$refs.word);
                    }
                }else {
                    viewD(obj,url,this.$refs.word);
                }
 
            },
            exportDocMS(obj,url,name, arry,imgSize) { //行政处罚没收财物处理审批表返回的数据和其它表不一样(没有publicOpinion对象)
                let that = this
                if(arry.length > 0) {
                    for(let i=0; i<arry.length; i++) {
                        urlToBase64(obj[arry[i]], function(baseStr) {
                            obj[arry[i]] = baseStr
                            that.$set(obj,arry[i],obj[arry[i]])
                        })
                    }
                }
                setTimeout(() => {
                    exportDocWidthImg(obj,url,name,imgSize)
                },1000)
            },
            exportDocMore(obj,url,name, arry,imgSize) { //页面有多张签名照片的
                let that = this
                if(arry.length > 0) {
                    for(let i=0; i<arry.length; i++) {
                        if(obj.publicOpinion) {
                            urlToBase64(obj.publicOpinion[arry[i]], function(baseStr) {
                                obj.publicOpinion[arry[i]] = baseStr
                                that.$set(obj,arry[i],obj.publicOpinion[arry[i]])
                            })
                        }
                    }
                }
                setTimeout(() => {
                    exportDocWidthImg(obj,url,name,imgSize)
                },1000)
            },
            exportDoc(obj,url,name, type,imgSize) {
                this.imgList = []
                let that = this
                if(type != null && type != '') {
                    let img = obj[type].split(',')
                    for (let i=0; i< img.length; i++) {
                        urlToBase64(img[i],function(baseStr) {
                            img[i] = baseStr;
                            that.imgList.push({
                                img: img[i]
                            })
                        })
                        that.$set(obj,'imgList',that.imgList)
                        // exportDocWidthImg(obj,url,name,imgSize);
                    }
 
                    setTimeout(() => {
                        exportDocWidthImg(obj,url,name,imgSize)
                    },1000)
                    // await exportDocWidthImg(obj,url,name,imgSize);
                }else {
                    exportDoc(obj, url, name);
                }
 
            },
            cancel() {
                this.$emit('cancel', false)
            }
        }
    };
</script>
 
<style>
  .docx-wrapper {
    background: white !important;
  }
  .docx p{
    text-align: center;
  }
  .docx p:nth-child(0)>span:nth-child(3){
    margin-left: -45px;
  }
</style>