liuyg
2021-09-27 8c6cf205affbbc8ada74f00a7ca25ebca867e9ed
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
        #table {
            color: #000;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-direction: column;
        }
        /* .print-header {
            width: 100%;
            text-align: center;
        } */
        
        .print {
            position: relative;
            left: 47%;
            margin-top: 30px;
            width: 7%;
            height: 30px;
            border: 0px;
            border-radius: 6px;
            color: #fff;
            background-color: #1D5CE4;
            letter-spacing: 4px;
        }
        
        .user-info-table {
            margin-top: 30px;
            width: 90%;
            height: 60%;
            border: 1px solid #000;
            background-color: #fff;
        }
        
        .user-info-tr {
            height: 50px;
        }
        
        .avatar {
            width: 140px;
            height: 190px;
        }
        
        .title {
            margin-top: 20px;
        }
        
        .avatar {
            width: 140px;
            height: 190px;
        }
        
        .my-picture {
            width: 150px;
            /* height: 200px; */
        }
    </style>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
</head>
 
 
<body>
    <div>
 
        <!--startprint-->
        <div id="table">
            <!-- <span class="title">准考证信息</span>
            <table class="user-info-table" border="1px" align="center" cellspacing="0" cellpadding="10">
                <tr class="user-info-tr">
                    <td width="150px">姓名</td>
                    <td width="150px"></td>
                    <td width="150px">身份证号</td>
                    <td width="150px"></td>
                    <td rowspan="4" align="center" width="150px" v-if="data.avatar == ''">
                        照片
                    </td>
                </tr>
 
                <tr class="user-info-tr">
                    <td>准考证号</td>
                    <td></td>
                    <td width="150px">性别</td>
                    <td width="150px" v-if="data.sex == 1">男</td>
                </tr>
 
                <tr class="user-info-tr">
                    <td>考点名称</td>
                    <td colspan="3"></td>
                </tr>
 
                <tr class="user-info-tr">
                    <td>考点地址</td>
                    <td colspan="3"></td>
                </tr>
 
                <tr class="user-info-tr" style="height:5px">
                    <td colspan="5"></td>
                </tr>
 
                <tr class="user-info-tr">
                    <td>考试名称</td>
                    <td>考试类型</td>
                    <td>考试时间</td>
                    <td>考场号</td>
                    <td>座位号</td>
                </tr>
 
                <tr class="user-info-tr">
                    <td>{{data.examName}}</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
 
            </table>-->
        </div>
        <!--endprint-->
 
 
        <div class="print-header">
            <button onclick="preview(1)" class="print">打印</button>
        </div>
    </div>
    <script>
        var getData = function(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]);
            return null;
        };
        var id = JSON.parse(getData("data")).id;
        var examType = JSON.parse(getData("data")).examType;
        // console.log(JSON.parse(getData("data")), 111);
 
        axios.get('http://223.82.109.183:2080/api/apply/getApplyInfo?id=' + id + "&applyExamType=" + examType).then(function(res) {
            // axios.get('http://localhost:81/apply/getApplyInfo?id=' + id + "&applyExamType=" + examType).then(function(res) {
            var data = res.data.data;
            var str = `<span class="title">${data.examName}</span>
                    <span class="title">准考证信息</span>
                    <table class="user-info-table" border="1px" align="center" cellspacing="0" cellpadding="10">
                        <tr class="user-info-tr">
                            <td width="150px">姓名</td>
                            <td width="150px">${data.realName}</td>
                            <td width="150px">身份证号</td>
                            <td width="150px">${data.idCardNo}</td>
                            <td rowspan="4" align="center" width="150px"">
                                <img class="my-picture" src="${data.myPicture}" />
                            </td>
                        </tr>
 
                        <tr class="user-info-tr">
                            <td>准考证号</td>
                            <td>${data.candidateNo}</td>
                            <td width="150px">性别</td>
                            <td width="150px">${data.sex==1?"男":(data.sex==2?"女":"")}</td>
                        </tr>
 
                        <tr class="user-info-tr">
                            <td>考点名称</td>
                            <td colspan="3"></td>
                        </tr>
 
                        <tr class="user-info-tr">
                            <td>考点地址</td>
                            <td colspan="3"></td>
                        </tr>
 
                        <tr class="user-info-tr" style="height:5px">
                            <td colspan="5"></td>
                        </tr>
 
                        <tr class="user-info-tr">
                            <td>考试名称</td>
                            <td width="120px">考试类型</td>
                            <td width="180px">考试时间</td>
                            <td>考场号</td>
                            <td>座位号</td>
                        </tr>
 
                        <tr class="user-info-tr">
                            <td>${data.examName}</td>
                            <td width="120px"></td>
                            <td width="180px">${data.stringTime}</td>
                            <td></td>
                            <td></td>
                        </tr>
 
                    </table>`
 
            var dom = $('#table');
            dom.empty();
            dom.append(str);
        })
 
        function preview(oper) {
            if (oper < 10) {
                bdhtml = window.document.body.innerHTML;
                // 打印开始的标志
                sprnstr = "<!--startprint-->";
                // 打印结束的标志
                eprnstr = "<!--endprint-->";
                // 从打印开始的位置截取到末尾
                prnhtml = bdhtml.substr(bdhtml.indexOf(sprnstr));
                // 从开始截取到打印结束的位置
                prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr));
                // 替换html
                window.document.body.innerHTML = prnhtml;
                // 打印
                window.print();
                window.document.body.innerHTML = bdhtml;
            } else {
                window.print();
            }
        }
    </script>
</body>
 
</html>