printEquipmentAccountLabelList.vue
6.3 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
<template>
<div class="print-equipment-account-label-container">
<el-card>
<div slot="header" class="flex justify-between">
<span>{{ $t('printEquipmentAccount.machineId') }}:{{ printEquipmentAccountInfo.machineId }}</span>
<span>{{ $t('printEquipmentAccount.printTime') }}:{{ nowTime }}</span>
</div>
<el-table :data="[printEquipmentAccountInfo]" border style="width: 100%; margin-top: 20px; margin-bottom: 0;">
<el-table-column prop="header" label="" colspan="6" align="center">
<template>
<span style="font-size: 40px;">{{ $t('printEquipmentAccount.equipmentLabel') }}</span>
</template>
</el-table-column>
<el-table-column prop="content" label="" colspan="2">
<template slot-scope="scope">
<el-row :gutter="20" style="font-size: 28px;">
<el-col :span="12">
<div>{{ $t('printEquipmentAccount.project') }}:{{ scope.row.yqName }}</div>
</el-col>
<el-col :span="12">
<div>{{ $t('printEquipmentAccount.locationName') }}:{{ scope.row.locationDetail }}</div>
</el-col>
</el-row>
<el-row :gutter="20" style="font-size: 28px;">
<el-col :span="12">
<div>{{ $t('printEquipmentAccount.machineName') }}:{{ scope.row.machineName }}</div>
</el-col>
<el-col :span="12">
<div>{{ $t('printEquipmentAccount.importanceLevel') }}:{{ scope.row.levelName }}</div>
</el-col>
</el-row>
<el-row :gutter="20" style="font-size: 28px;">
<el-col :span="12">
<div>{{ $t('printEquipmentAccount.systemName') }}:{{ scope.row.sysName }}</div>
</el-col>
<el-col :span="12">
<div>{{ $t('printEquipmentAccount.enableDate') }}:{{ scope.row.firstEnableTime }}</div>
</el-col>
</el-row>
<el-row :gutter="20" style="font-size: 28px;">
<el-col :span="12">
<div>{{ $t('printEquipmentAccount.machineBrand') }}:{{ scope.row.brand }}</div>
</el-col>
<el-col :span="12" rowspan="4">
<div id="qrcode" style="width:200px; height:200px;"></div>
</el-col>
</el-row>
<el-row :gutter="20" style="font-size: 28px;">
<el-col :span="12">
<div>{{ $t('printEquipmentAccount.specificationModel') }}:{{ scope.row.model }}</div>
</el-col>
</el-row>
<el-row :gutter="20" style="font-size: 28px;">
<el-col :span="12">
<div>{{ $t('printEquipmentAccount.code') }}:{{ scope.row.machineCode }}</div>
</el-col>
</el-row>
<el-row :gutter="20" style="font-size: 28px;">
<el-col :span="12">
<div>{{ $t('printEquipmentAccount.responsiblePerson') }}:{{ scope.row.chargeUseName }}</div>
</el-col>
</el-row>
<el-row :gutter="20" style="font-size: 28px;">
<el-col :span="24" align="center">
<div>设备标志 严禁损坏</div>
</el-col>
</el-row>
</template>
</el-table-column>
</el-table>
<div id="print-btn" style="margin-top: 20px;">
<el-button type="primary" class="float-right" @click="_printPurchaseApplyDiv">
<i class="el-icon-check"></i> {{ $t('common.print') }}
</el-button>
<el-button type="warning" class="float-right" style="margin-right: 20px;" @click="_closePage">
{{ $t('common.cancel') }}
</el-button>
</div>
</el-card>
</div>
</template>
<script>
import { getEquipmentAccountList } from '@/api/resource/printEquipmentAccountLabelApi'
import QRCode from 'qrcodejs2'
import { getCommunityId } from '@/api/community/communityApi'
export default {
name: 'PrintEquipmentAccountLabelList',
data() {
return {
printEquipmentAccountInfo: {
machineId: '',
machineName: '',
machineCode: '',
brand: '',
model: '',
locationDetail: '',
firstEnableTime: '',
warrantyDeadline: '',
usefulLife: '',
importanceLevel: '',
levelName: '',
state: '',
purchasePrice: '',
netWorth: '',
useOrgId: '',
useOrgName: '',
useUserId: '',
useUserName: '',
useUseTel: '',
chargeOrgId: '',
chargeOrgName: '',
chargeOrgTel: '',
chargeUseId: '',
chargeUseName: '',
remark: '',
yqName: '',
url: ''
},
printFlag: '0',
nowTime: '',
communityId: ''
}
},
created() {
this.communityId = getCommunityId()
this._initPrintRepairDetailDateInfo()
const myDate = new Date()
this.nowTime = myDate.toLocaleDateString()
this.printEquipmentAccountInfo.yqName = this.$store.getters.currentCommunity.name
},
methods: {
async _initPrintRepairDetailDateInfo() {
const machineId = this.$route.query.machineId
try {
const res = await getEquipmentAccountList({
page: 1,
row: 1,
machineId: machineId,
communityId: this.communityId
})
const data = res.data[0]
Object.assign(this.printEquipmentAccountInfo, data)
document.getElementById('qrcode').innerHTML = ''
new QRCode(document.getElementById('qrcode'), {
text: this.printEquipmentAccountInfo.url,
width: 200,
height: 200,
colorDark: '#000000',
colorLight: '#ffffff',
correctLevel: QRCode.CorrectLevel.H
})
} catch (error) {
console.error('请求失败:', error)
}
},
_printPurchaseApplyDiv() {
this.printFlag = '1'
document.getElementById('print-btn').style.display = 'none'
window.print()
window.opener = null
window.close()
},
_closePage() {
window.opener = null
window.close()
}
}
}
</script>
<style scoped>
.print-equipment-account-label-container {
padding: 20px;
}
.float-right {
float: right;
}
.margin-top {
margin-top: 20px;
}
@media print {
#print-btn {
display: none !important;
}
}
</style>