Browse Source

fix:[模板管理]导出

lkf
15881625488@163.com 2 months ago
parent
commit
c565174ed1
6 changed files with 42 additions and 37 deletions
  1. +3
    -1
      src/App.vue
  2. +1
    -2
      src/components/Template/BaseInfoFormPackage.vue
  3. +2
    -0
      src/components/Template/Step.vue
  4. +8
    -10
      src/views/business/study/comp/jhbd/Xq.vue
  5. +8
    -9
      src/views/business/study/comp/sqbd/Xq.vue
  6. +20
    -15
      src/views/business/study/comp/tbbd/Xq.vue

+ 3
- 1
src/App.vue View File

@ -329,7 +329,9 @@ td,
th { th {
page-break-inside: avoid; page-break-inside: avoid;
} }
.page-break {
page-break-before: always;
}
.datatable { .datatable {
border-collapse: collapse; border-collapse: collapse;

+ 1
- 2
src/components/Template/BaseInfoFormPackage.vue View File

@ -267,6 +267,7 @@ export default {
.c-Item { .c-Item {
// &:not(:last-child) { // &:not(:last-child) {
margin-bottom: 16px; margin-bottom: 16px;
page-break-inside: avoid;
// } // }
} }
@ -315,12 +316,10 @@ export default {
} }
.flex1 { .flex1 {
page-break-inside: avoid;
flex: 1; flex: 1;
} }
.flex { .flex {
page-break-inside: avoid;
display: flex; display: flex;
} }

+ 2
- 0
src/components/Template/Step.vue View File

@ -495,7 +495,9 @@ export default {
flex:1 flex:1
} }
.step-list { .step-list {
padding-top: 10px;
.step-list-item { .step-list-item {
page-break-inside: avoid;
margin-top: 10px; margin-top: 10px;
border-radius: 6px; border-radius: 6px;
overflow: hidden; overflow: hidden;

+ 8
- 10
src/views/business/study/comp/jhbd/Xq.vue View File

@ -268,7 +268,9 @@ export default {
this.updateWatermark() this.updateWatermark()
this.$refs.jcgjExportList.init(this.jcgjExportList) this.$refs.jcgjExportList.init(this.jcgjExportList)
setTimeout(() => { setTimeout(() => {
this.$refs.html2Pdf.generatePdf()
this.$refs.html2Pdf.generatePdf({
margin:[20,10,20,10]
})
}, 200); }, 200);
}) })
}, },
@ -278,10 +280,9 @@ export default {
const canvas = document.createElement('canvas') const canvas = document.createElement('canvas')
const ctx = canvas.getContext('2d') const ctx = canvas.getContext('2d')
//
const rect = this.$refs.contentArea.getBoundingClientRect()
canvas.width = rect.width
canvas.height = rect.height
// canvas
canvas.width = 300;
canvas.height = 300;
// //
ctx.fillStyle = `rgba(100, 100, 100, ${this.watermarkOpacity})` ctx.fillStyle = `rgba(100, 100, 100, ${this.watermarkOpacity})`
@ -298,10 +299,11 @@ export default {
ctx.translate(canvas.width / 2, canvas.height / 2) ctx.translate(canvas.width / 2, canvas.height / 2)
ctx.rotate(-Math.PI / 4) // 45 ctx.rotate(-Math.PI / 4) // 45
let time=moment().format("YYYY-MM-DD HH:mm:ss")
for (let x = -canvas.width; x < canvas.width * 2; x += stepX) { for (let x = -canvas.width; x < canvas.width * 2; x += stepX) {
for (let y = -canvas.height; y < canvas.height * 2; y += stepY) { for (let y = -canvas.height; y < canvas.height * 2; y += stepY) {
// //
const dynamicText = `${this.watermarkText} - ${this.getCurrentTime()}`
const dynamicText = `${this.watermarkText} - ${time}`
ctx.fillText(dynamicText, x, y) ctx.fillText(dynamicText, x, y)
} }
} }
@ -322,10 +324,6 @@ export default {
z-index: 9999; z-index: 9999;
` `
//
this.$refs.contentArea.style.position = 'relative'
this.$refs.contentArea.appendChild(watermarkLayer)
// //
setTimeout(() => resolve(), 100) setTimeout(() => resolve(), 100)
}) })

+ 8
- 9
src/views/business/study/comp/sqbd/Xq.vue View File

@ -268,7 +268,9 @@ export default {
this.updateWatermark() this.updateWatermark()
this.$refs.jcgjExportList.init(this.jcgjExportList) this.$refs.jcgjExportList.init(this.jcgjExportList)
setTimeout(() => { setTimeout(() => {
this.$refs.html2Pdf.generatePdf()
this.$refs.html2Pdf.generatePdf({
margin:[20,10,20,10]
})
}, 200); }, 200);
}) })
}, },
@ -278,10 +280,9 @@ export default {
const canvas = document.createElement('canvas') const canvas = document.createElement('canvas')
const ctx = canvas.getContext('2d') const ctx = canvas.getContext('2d')
//
const rect = this.$refs.contentArea.getBoundingClientRect()
canvas.width = rect.width
canvas.height = rect.height
// canvas
canvas.width = 300;
canvas.height = 300;
// //
ctx.fillStyle = `rgba(100, 100, 100, ${this.watermarkOpacity})` ctx.fillStyle = `rgba(100, 100, 100, ${this.watermarkOpacity})`
@ -298,10 +299,11 @@ export default {
ctx.translate(canvas.width / 2, canvas.height / 2) ctx.translate(canvas.width / 2, canvas.height / 2)
ctx.rotate(-Math.PI / 4) // 45 ctx.rotate(-Math.PI / 4) // 45
let time=moment().format("YYYY-MM-DD HH:mm:ss")
for (let x = -canvas.width; x < canvas.width * 2; x += stepX) { for (let x = -canvas.width; x < canvas.width * 2; x += stepX) {
for (let y = -canvas.height; y < canvas.height * 2; y += stepY) { for (let y = -canvas.height; y < canvas.height * 2; y += stepY) {
// //
const dynamicText = `${this.watermarkText} - ${this.getCurrentTime()}`
const dynamicText = `${this.watermarkText} - ${time}`
ctx.fillText(dynamicText, x, y) ctx.fillText(dynamicText, x, y)
} }
} }
@ -322,9 +324,6 @@ export default {
z-index: 9999; z-index: 9999;
` `
//
this.$refs.contentArea.style.position = 'relative'
this.$refs.contentArea.appendChild(watermarkLayer)
// //
setTimeout(() => resolve(), 100) setTimeout(() => resolve(), 100)

+ 20
- 15
src/views/business/study/comp/tbbd/Xq.vue View File

@ -64,7 +64,7 @@
<JcgjExportList ref="jcgjExportList" :readonly="true" v-show="jcgjlxExport != 999" /> <JcgjExportList ref="jcgjExportList" :readonly="true" v-show="jcgjlxExport != 999" />
</div> </div>
</div> </div>
<div v-if="showExport" id="watermark-overlay" ref="watermarkContainer" :style="{
<div v-if="showExport" id="watermark-overlay" ref="watermarkContainer" :style="{
'--watermark-text': `'${watermarkText}'`, '--watermark-text': `'${watermarkText}'`,
'--watermark-opacity': opacity, '--watermark-opacity': opacity,
'--watermark-size': '14px', '--watermark-size': '14px',
@ -158,10 +158,10 @@ import moment from "moment";
import VueHtml2pdf from 'vue-html2pdf' import VueHtml2pdf from 'vue-html2pdf'
export default { export default {
name: "Xq", name: "Xq",
components: { JcgjExportList,JcgjList, TemplateTable, VueHtml2pdf },
components: { JcgjExportList, JcgjList, TemplateTable, VueHtml2pdf },
data() { data() {
return { return {
watermarkText:'',
watermarkText: '',
opacity: 0.8, opacity: 0.8,
watermarkOpacity: 0.8, watermarkOpacity: 0.8,
watermarkSize: 40, watermarkSize: 40,
@ -226,7 +226,7 @@ export default {
methods: { methods: {
updateWatermark() { updateWatermark() {
// //
const text = this.nickName +' '+ moment().format("YYYY-MM-DD HH:mm:ss");
const text = this.nickName + ' ' + moment().format("YYYY-MM-DD HH:mm:ss");
const canvas = document.createElement('canvas'); const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d'); const ctx = canvas.getContext('2d');
@ -268,7 +268,14 @@ export default {
this.updateWatermark() this.updateWatermark()
this.$refs.jcgjExportList.init(this.jcgjExportList) this.$refs.jcgjExportList.init(this.jcgjExportList)
setTimeout(() => { setTimeout(() => {
this.$refs.html2Pdf.generatePdf()
this.$refs.html2Pdf.generatePdf({
margin: {
top: 20,
right: 15,
bottom: 20,
left: 15
},
})
}, 200); }, 200);
}) })
}, },
@ -278,10 +285,10 @@ export default {
const canvas = document.createElement('canvas') const canvas = document.createElement('canvas')
const ctx = canvas.getContext('2d') const ctx = canvas.getContext('2d')
//
const rect = this.$refs.contentArea.getBoundingClientRect()
canvas.width = rect.width
canvas.height = rect.height
// canvas
canvas.width = 300;
canvas.height = 300;
// //
ctx.fillStyle = `rgba(100, 100, 100, ${this.watermarkOpacity})` ctx.fillStyle = `rgba(100, 100, 100, ${this.watermarkOpacity})`
@ -297,11 +304,11 @@ export default {
ctx.save() ctx.save()
ctx.translate(canvas.width / 2, canvas.height / 2) ctx.translate(canvas.width / 2, canvas.height / 2)
ctx.rotate(-Math.PI / 4) // 45 ctx.rotate(-Math.PI / 4) // 45
let time=moment().format("YYYY-MM-DD HH:mm:ss")
for (let x = -canvas.width; x < canvas.width * 2; x += stepX) { for (let x = -canvas.width; x < canvas.width * 2; x += stepX) {
for (let y = -canvas.height; y < canvas.height * 2; y += stepY) { for (let y = -canvas.height; y < canvas.height * 2; y += stepY) {
// //
const dynamicText = `${this.watermarkText} - ${this.getCurrentTime()}`
const dynamicText = `${this.watermarkText} - ${time}`
ctx.fillText(dynamicText, x, y) ctx.fillText(dynamicText, x, y)
} }
} }
@ -322,9 +329,6 @@ export default {
z-index: 9999; z-index: 9999;
` `
//
this.$refs.contentArea.style.position = 'relative'
this.$refs.contentArea.appendChild(watermarkLayer)
// //
setTimeout(() => resolve(), 100) setTimeout(() => resolve(), 100)
@ -445,8 +449,9 @@ export default {
padding: 0px; padding: 0px;
font-family: Arial, sans-serif; font-family: Arial, sans-serif;
} }
#watermark-overlay { #watermark-overlay {
position: absolute; position: absolute;
top: -80px; top: -80px;

Loading…
Cancel
Save