printTemplate.vue
3.12 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
<!--
* @Description:
* @Autor: renchao
* @LastEditTime: 2023-08-24 16:15:01
-->
<template>
<div id="box">
<div
class="tbalede"
v-for="(el, indexx) in datass"
:key="indexx"
style="page-break-after: always"
>
<div class="title">{{ title }}</div>
<table class="xxTable">
<tr v-for="item in columns" :key="item.name">
<td>
{{ item.despriction }}
</td>
<td v-for="(row, index) in el" :key="index + '2'">
{{ row[item.name] }}
</td>
<td
v-show="el.emptycolNum"
v-for="count in emptycolNum"
:key="count"
></td>
</tr>
</table>
</div>
</div>
</template>
<script>
import { datas } from "./qlxxFormData.js";
import { getSjlx } from "@/utils/dictionary.js";
import { getFieldListByQlxx } from "@/api/SysDjbFieldDO.js";
export default {
data() {
return {
title: this.$parent.title,
//列表数据
//空列值个数
emptycolNum: 4,
//列名称对象
columns: [],
datass: [],
};
},
props: {
tableData: {
type: Array,
default: () => [],
},
render:{
type: Boolean,
default: false,
}
},
created() {},
watch: {
tableData: {
handler(newValue, oldValue) {
this.tableData = newValue;
},
},
render: {
handler(newValue, oldValue) {
if(newValue){
this.loadData();
}
},
},
immediate: true,
deep: true,
},
methods: {
/**
* @description: loadData
* @author: miaofang
*/
loadData() {
getFieldListByQlxx({
qllx: this.tableData[0].qllx,
}).then((res) => {
if (res.code === 200) {
this.columns = res.result;
}
});
if (this.tableData.length&&this.datass.length==0) {
for (let i = 0; i < this.tableData.length; i += 4) {
this.datass.push(this.tableData.slice(i, i + 4));
}
let num = this.datass[this.datass.length - 1].length;
if (num < 4) {
this.emptycolNum = 4 - num;
this.datass[this.datass.length - 1].emptycolNum = true;
} else {
this.emptycolNum = 0;
}
}
},
},
};
</script>
<style lang="scss" scoped>
.tbalede {
width: 100%;
// height: 1123px;
margin: auto;
.title {
width: 100%;
font-weight: 700;
font-size: 16px;
text-align: center;
height: 62px;
line-height: 62px;
position: relative;
margin: 0 3px;
}
.xxTable {
width: 100%;
border-collapse: collapse;
tr td {
border: 2px solid rgb(227, 226, 226);
text-align: center;
height: 40px;
font-size: 13px;
min-width: 80px;
z-index: 1;
min-width: 80px;
padding: 5px;
}
td {
width: 20px!important;
word-break: break-all;
// /* 方法一:使用 word-break */
// word-break: break-all;
// // /* 方法二:使用 white-space */
// // white-space: pre-wrap;
// // /* 方法三:使用 overflow-wrap */
// // overflow-wrap: break-word;
}
}
}
</style>