|
|
|
@ -9,8 +9,17 @@ export interface fieldTree{ |
|
|
|
child?:fieldTree[] |
|
|
|
} |
|
|
|
|
|
|
|
export interface pageConfig{ |
|
|
|
width:string, |
|
|
|
height:string, |
|
|
|
horizontal:string;//横向 |
|
|
|
pagesize:string; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const props = withDefaults(defineProps<{ |
|
|
|
name:string, |
|
|
|
width:string, |
|
|
|
fieldTree:fieldTree[], |
|
|
|
formData?:any |
|
|
|
}>(),{}) |
|
|
|
@ -18,27 +27,19 @@ const props = withDefaults(defineProps<{ |
|
|
|
|
|
|
|
</script> |
|
|
|
|
|
|
|
<template style="width: 210mm;height: 297mm;"> |
|
|
|
<div id="printContainer" > |
|
|
|
<template> |
|
|
|
<div id="printContainer" :style="{width:props.width}" > |
|
|
|
<h3>{{props.name}}</h3> |
|
|
|
<div v-for="group in props.fieldTree"> |
|
|
|
<div v-if="Array.isArray(group)"> |
|
|
|
<el-descriptions |
|
|
|
class="margin-top" |
|
|
|
:column="2" |
|
|
|
border |
|
|
|
> |
|
|
|
<template v-for="item in group" > |
|
|
|
<el-descriptions-item v-if="item.checked!=2"> |
|
|
|
<template #label> |
|
|
|
<div class="cell-item"> |
|
|
|
{{item.name}} |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
{{item.field}} |
|
|
|
</el-descriptions-item> |
|
|
|
<div v-if="Array.isArray(group)" style="display: grid; grid-template-columns: 1fr 1fr;"> |
|
|
|
<template v-for="item in group" > |
|
|
|
<div v-if="item.checked!=2" class="cell_box"> |
|
|
|
<span class="box_name"> |
|
|
|
{{item.name}} |
|
|
|
</span> |
|
|
|
<span class="content">{{item.field}}</span> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
</el-descriptions> |
|
|
|
</div> |
|
|
|
<div v-else-if="group.type=='divider'" class="title" v-if="group.checked!=2">{{ group.name }}</div> |
|
|
|
<div v-else-if="group.type=='textarea'" class="section" v-if="group.checked!=2"> |
|
|
|
@ -47,32 +48,26 @@ const props = withDefaults(defineProps<{ |
|
|
|
</div> |
|
|
|
<div v-else-if="group.type=='table'" class="section_table" v-if="group.checked!=2"> |
|
|
|
<h5>{{ group.name }}</h5> |
|
|
|
<el-table class="table" :data="group.data" border style="width: 100%;margin:5px 10px 10px 10px"> |
|
|
|
<template v-for="child in group.child"> |
|
|
|
<el-table-column :prop="child.field" :label="child.name" v-if="child.checked!=2" /> |
|
|
|
</template> |
|
|
|
</el-table> |
|
|
|
<div class="bder_table" > |
|
|
|
<el-table class="table" :data="group.data" border > |
|
|
|
<template v-for="child in group.child"> |
|
|
|
<el-table-column :prop="child.field" :label="child.name" v-if="child.checked!=2" /> |
|
|
|
</template> |
|
|
|
</el-table> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div v-else-if="group.type=='tabs'" class="section_tabs" v-if="group.checked!=2"> |
|
|
|
<h5>{{ group.name }}</h5> |
|
|
|
<div v-for="tabs in group.child" class="tabs_item"> |
|
|
|
<div v-if="Array.isArray(tabs)"> |
|
|
|
<el-descriptions |
|
|
|
class="margin-top" |
|
|
|
:column="2" |
|
|
|
border |
|
|
|
> |
|
|
|
<template v-for="item in group" > |
|
|
|
<el-descriptions-item v-if="item.checked!=2"> |
|
|
|
<template #label> |
|
|
|
<div class="cell-item"> |
|
|
|
{{item.name}} |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
{{item.field}} |
|
|
|
</el-descriptions-item> |
|
|
|
<div v-if="Array.isArray(tabs)" style="display: grid; grid-template-columns: 1fr 1fr;"> |
|
|
|
<template v-for="item in tabs" > |
|
|
|
<div v-if="item.checked!=2" class="tabs_cell_box" style="width: auto;"> |
|
|
|
<span class="box_name"> |
|
|
|
{{item.name}}++ |
|
|
|
</span> |
|
|
|
<span class="content">{{item.field}}</span> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
</el-descriptions> |
|
|
|
</div> |
|
|
|
<div v-else-if="tabs.type=='divider'" class="title" v-if="tabs.checked!=2" |
|
|
|
style="font-size: 12px; margin-top: 20px;">{{ tabs.name }}</div> |
|
|
|
@ -82,13 +77,15 @@ const props = withDefaults(defineProps<{ |
|
|
|
</div> |
|
|
|
<div v-else-if="tabs.type=='table'" class="section" v-if="tabs.checked!=2"> |
|
|
|
<h5>{{ tabs.name }}</h5> |
|
|
|
<el-table class="table" border style="width: 100%;"> |
|
|
|
<template v-for="child in tabs.child"> |
|
|
|
<el-table-column :prop="child.field" :label="child.name" v-if="child.checked!=2" /> |
|
|
|
</template> |
|
|
|
</el-table> |
|
|
|
<div class="bder_table" > |
|
|
|
<el-table class="table" border > |
|
|
|
<template v-for="child in tabs.child"> |
|
|
|
<el-table-column :prop="child.field" :label="child.name" v-if="child.checked!=2" /> |
|
|
|
</template> |
|
|
|
</el-table> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div v-else class="cell_box" v-if="tabs.checked!=2"> |
|
|
|
<div v-else class="tabs_cell_box" v-if="tabs.checked!=2"> |
|
|
|
<span class="box_name"> |
|
|
|
{{tabs.name}} |
|
|
|
</span> |
|
|
|
@ -104,9 +101,9 @@ const props = withDefaults(defineProps<{ |
|
|
|
</template> |
|
|
|
<style lang="scss" scoped> |
|
|
|
#printContainer{ |
|
|
|
width: 210mm; |
|
|
|
height: 297mm; |
|
|
|
padding: 30px 0px 15px 0px; |
|
|
|
// width: 210mm; |
|
|
|
// height: 297mm; |
|
|
|
padding: 57px; |
|
|
|
text-align: center; |
|
|
|
display: flex; |
|
|
|
flex-direction: column; |
|
|
|
@ -147,25 +144,20 @@ h5{ |
|
|
|
.section_title{ |
|
|
|
width:100% |
|
|
|
} |
|
|
|
.section_table{ |
|
|
|
width: 96%; |
|
|
|
} |
|
|
|
|
|
|
|
.normal_cell,.normal_cell_field{ |
|
|
|
width: 23%; |
|
|
|
height: 20px; |
|
|
|
background-color: #f5f7fa; |
|
|
|
} |
|
|
|
.normal_cell_field{ |
|
|
|
background-color: white; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
.section{ |
|
|
|
display: flex; |
|
|
|
flex-direction: column; |
|
|
|
} |
|
|
|
|
|
|
|
.section_tabs{ |
|
|
|
margin: 10px; |
|
|
|
margin: 10px 0; |
|
|
|
display: flex; |
|
|
|
flex-wrap: wrap; |
|
|
|
} |
|
|
|
@ -174,14 +166,14 @@ h5{ |
|
|
|
border: 1px solid rgb(182, 181, 181); |
|
|
|
border-radius: 3px; |
|
|
|
min-height: 40px; |
|
|
|
margin: 5px 10px 10px 10px; |
|
|
|
margin: 5px 0px 10px 0px; |
|
|
|
} |
|
|
|
//////////////自动伸缩 |
|
|
|
.tabs_item { |
|
|
|
display: inline-flex; |
|
|
|
min-height: 40px; |
|
|
|
min-width: 50%; /* 默认最小宽度 */ |
|
|
|
|
|
|
|
margin-right: -1px;/* 解决边框重合问题*/ |
|
|
|
/* 默认情况:没有 title/section 时宽度 50% */ |
|
|
|
width: 50%; |
|
|
|
.section{ |
|
|
|
@ -195,29 +187,39 @@ h5{ |
|
|
|
width: 100%; |
|
|
|
} |
|
|
|
|
|
|
|
.bder_table{ |
|
|
|
border: 1px solid rgb(182, 181, 181); |
|
|
|
margin:5px 0px 10px 0px; |
|
|
|
width: 100% !important; /* 确保表格不超出父容器 */ |
|
|
|
overflow-x: hidden; |
|
|
|
} |
|
|
|
|
|
|
|
/* 原有样式(稍作优化) */ |
|
|
|
.cell_box { |
|
|
|
width: 100%; |
|
|
|
border: 1px solid #ebeef5; |
|
|
|
.cell_box, .tabs_cell_box { |
|
|
|
border: 1px solid rgb(182, 181, 181); |
|
|
|
margin-right: -1px; /* 水平排列时用右负margin */ |
|
|
|
margin-bottom: -1px; /* 垂直排列时用下负margin */ |
|
|
|
display: inline-flex; |
|
|
|
|
|
|
|
.box_name { |
|
|
|
background-color: #f5f7fa; |
|
|
|
padding: 8px 11px; |
|
|
|
padding: 8px 2px; |
|
|
|
width: 50%; |
|
|
|
text-wrap: wrap; |
|
|
|
text-overflow: ellipsis; |
|
|
|
max-height: 80px; |
|
|
|
overflow: hidden; /* 配合 ellipsis 需要 */ |
|
|
|
border-right: 1px solid rgb(182, 181, 181); |
|
|
|
} |
|
|
|
|
|
|
|
.content { |
|
|
|
padding: 8px 11px; |
|
|
|
padding: 8px 2px; |
|
|
|
width: 50%; |
|
|
|
text-wrap: wrap; |
|
|
|
word-break: break-all; |
|
|
|
} |
|
|
|
} |
|
|
|
.tabs_cell_box{ |
|
|
|
width: 100%; |
|
|
|
} |
|
|
|
</style> |
|
|
|
|
|
|
|
<style> |
|
|
|
@ -226,15 +228,23 @@ h5{ |
|
|
|
border: 0px solid; |
|
|
|
border-spacing: 1px; |
|
|
|
border-collapse: collapse; |
|
|
|
th{ |
|
|
|
background-color: #e5e5e5; |
|
|
|
border: 1px solid; |
|
|
|
min-width: 180px; |
|
|
|
} |
|
|
|
#printContainer .el-table th.el-table__cell{ |
|
|
|
background: none !important; |
|
|
|
word-wrap: break-word; |
|
|
|
} |
|
|
|
|
|
|
|
#printContainer .el-table .cell{ |
|
|
|
padding: 0 5px; |
|
|
|
text-align: center; |
|
|
|
} |
|
|
|
|
|
|
|
#printContainer table th{ |
|
|
|
font-weight: normal; |
|
|
|
border-right: 1px solid rgb(182, 181, 181); |
|
|
|
} |
|
|
|
td{ |
|
|
|
border: 1px solid; |
|
|
|
min-width: 180px; |
|
|
|
#printContainer table td{ |
|
|
|
border: 1px solid rgb(182, 181, 181); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
</style> |