printPurchaseApply.vue
6.31 KB
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
227
228
229
230
231
232
<template>
<div class="print-purchase-apply">
<div class="content-wrapper">
<!-- 申请单信息 -->
<div class="row info-row">
<div class="col-sm-4">
<span>{{ $t('purchaseApplyDetail.applyNo') }}{{ printPurchaseApplyInfo.applyOrderId }}</span>
</div>
<div class="col-sm-4">
<span>{{ $t('purchaseApplyDetail.applicant') }}{{ printPurchaseApplyInfo.endUserName }}</span>
</div>
<div class="col-sm-4">
<span>{{ $t('purchaseApplyDetail.contactPhone') }}{{ printPurchaseApplyInfo.endUserTel }}</span>
</div>
</div>
<!-- 采购明细表格 -->
<table class="table table-bordered margin-top">
<thead>
<tr>
<th scope="col" class="text-center">{{ $t('purchaseApplyDetail.serialNumber') }}</th>
<th scope="col" class="text-center">{{ $t('purchaseApplyDetail.itemName') }}</th>
<th scope="col" class="text-center">{{ $t('purchaseApplyDetail.itemCode') }}</th>
<th scope="col" class="text-center">{{ $t('purchaseApplyDetail.purchasePrice') }}</th>
<th scope="col" class="text-center">{{ $t('purchaseApplyDetail.applyQuantity') }}</th>
<th scope="col" class="text-center">{{ $t('purchaseApplyDetail.purchaseQuantity') }}</th>
<th scope="col" class="text-center">{{ $t('purchaseApplyDetail.remark') }}</th>
</tr>
</thead>
<tbody>
<tr v-for="(item, index) in printPurchaseApplyInfo.purchaseApplyDetailVo" :key="index">
<th scope="row" class="text-center">{{ index + 1 }}</th>
<td class="text-center">{{ item.resName }}</td>
<td class="text-center">{{ item.resCode }}</td>
<td class="text-center">{{ item.purchasePrice }}</td>
<td class="text-center">{{ item.quantity }}</td>
<td class="text-center">{{ item.purchaseQuantity ? item.purchaseQuantity : '-' }}</td>
<td class="text-center">{{ item.remark }}</td>
</tr>
<tr>
<th scope="row" class="text-center">{{ $t('purchaseApplyDetail.remark') }}</th>
<td colspan="4">{{ printPurchaseApplyInfo.description }}</td>
<td class="text-center">{{ $t('purchaseApplyDetail.actualPurchaseTotalPrice') }}</td>
<td>{{ printPurchaseApplyInfo.purchaseTotalPrice }}</td>
</tr>
<tr height="60px">
<td colspan="2" class="text-center" style="vertical-align:middle;">{{ $t('purchaseApplyDetail.manufacturerSignature') }}</td>
<td colspan="2"></td>
<td colspan="3" class="text-center" style="vertical-align:middle;">{{ $t('purchaseApplyDetail.time') }}</td>
</tr>
<tr height="60px">
<td colspan="2" class="text-center" style="vertical-align:middle;">{{ $t('purchaseApplyDetail.purchaserSignature') }}</td>
<td colspan="2"></td>
<td colspan="3" class="text-center" style="vertical-align:middle;">{{ $t('purchaseApplyDetail.time') }}</td>
</tr>
</tbody>
</table>
<!-- 操作按钮 -->
<div id="print-btn" class="button-wrapper">
<el-button type="warning" @click="closePage" style="margin-right:20px;">
{{ $t('purchaseApplyDetail.cancel') }}
</el-button>
<el-button type="primary" @click="printPurchaseApplyDiv">
<i class="el-icon-printer"></i> {{ $t('purchaseApplyDetail.print') }}
</el-button>
</div>
</div>
</div>
</template>
<script>
import { listPurchaseApplys } from '@/api/resource/purchaseApplyManageApi'
import { messages } from './purchaseApplyDetailLang'
export default {
name: 'PrintPurchaseApply',
i18n: {
messages
},
data() {
return {
printPurchaseApplyInfo: {
applyOrderId: '',
endUserName: '',
endUserTel: '',
description: '',
purchaseTotalPrice: '',
purchaseApplyDetailVo: []
},
printFlag: '0'
}
},
created() {
this.initPrintPurchaseApplyDateInfo()
},
methods: {
// 初始化采购申请数据
initPrintPurchaseApplyDateInfo() {
const applyOrderId = this.$route.query.applyOrderId
const resOrderType = this.$route.query.resOrderType
if (!applyOrderId) {
this.$message.error('缺少申请单号参数')
return
}
const params = {
page: 1,
row: 1,
applyOrderId: applyOrderId,
resOrderType: resOrderType
}
listPurchaseApplys(params).then(res => {
if (res.purchaseApplys && res.purchaseApplys.length > 0) {
this.printPurchaseApplyInfo = res.purchaseApplys[0]
} else {
this.$message.error('未找到采购申请信息')
}
}).catch(error => {
console.error('获取采购申请信息失败:', error)
this.$message.error('获取采购申请信息失败')
})
},
// 打印
printPurchaseApplyDiv() {
this.printFlag = '1'
const printBtn = document.getElementById('print-btn')
if (printBtn) {
printBtn.style.display = 'none'
}
window.print()
// 打印后关闭窗口
setTimeout(() => {
window.opener = null
window.close()
}, 100)
},
// 关闭页面
closePage() {
window.opener = null
window.close()
}
}
}
</script>
<style scoped>
.print-purchase-apply {
padding: 20px;
background: #fff;
}
.content-wrapper {
margin: 0 auto;
}
.info-row {
margin-bottom: 20px;
display: flex;
justify-content: space-between;
}
.col-sm-4 {
flex: 1;
padding: 0 10px;
}
.col-sm-4 span {
font-size: 14px;
color: #333;
}
.margin-top {
margin-top: 20px;
}
/* 原生表格样式 */
.table {
width: 100%;
border-collapse: collapse;
margin-bottom: 20px;
}
.table-bordered {
border: 1px solid #ddd;
}
.table-bordered th,
.table-bordered td {
border: 1px solid #ddd;
padding: 8px;
}
.table thead th {
background-color: #f5f7fa;
font-weight: bold;
color: #333;
}
.text-center {
text-align: center;
}
.button-wrapper {
text-align: right;
margin-top: 30px;
padding: 20px 0;
}
/* 打印样式 */
@media print {
.print-purchase-apply {
padding: 0;
}
#print-btn {
display: none !important;
}
.table-bordered th,
.table-bordered td {
page-break-inside: avoid;
}
}
</style>