|
@@ -313,10 +313,12 @@ const selectorVisible = ref<{
|
|
|
list: []
|
|
list: []
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
-const open = (row?: any) => {
|
|
|
|
|
|
|
+const type_c = ref(1)
|
|
|
|
|
+const open = (row?: any,type=1) => {
|
|
|
recordRow.value = row || null
|
|
recordRow.value = row || null
|
|
|
|
|
+ type_c.value = type
|
|
|
|
|
+ isTextMode.value = type_c.value != 1;
|
|
|
formLoading.value = true
|
|
formLoading.value = true
|
|
|
- isTextMode.value = false
|
|
|
|
|
isPrint.value = false
|
|
isPrint.value = false
|
|
|
attachmentList.forEach((it) => {
|
|
attachmentList.forEach((it) => {
|
|
|
// 固定内容附件(3=入住须知)默认展示,不需要从列表选择
|
|
// 固定内容附件(3=入住须知)默认展示,不需要从列表选择
|
|
@@ -408,75 +410,7 @@ const handlePrint = async () => {
|
|
|
}, 500)
|
|
}, 500)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-const handleExport = async () => {
|
|
|
|
|
- isPrint.value = true
|
|
|
|
|
- isTextMode.value = true
|
|
|
|
|
-
|
|
|
|
|
- await nextTick()
|
|
|
|
|
- await new Promise((resolve) => setTimeout(resolve, 2500))
|
|
|
|
|
-
|
|
|
|
|
- const container = document.querySelector('.print-container') as HTMLElement | null
|
|
|
|
|
- if (!container) {
|
|
|
|
|
- message.error('未找到打印内容,请重试')
|
|
|
|
|
- isPrint.value = false
|
|
|
|
|
- isTextMode.value = false
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // html2canvas 无法渲染 display:none 的元素,因此临时显示(移出可视区域,避免闪烁)
|
|
|
|
|
- const originalDisplay = container.style.display
|
|
|
|
|
- const originalPosition = container.style.position
|
|
|
|
|
- const originalLeft = container.style.left
|
|
|
|
|
- const originalTop = container.style.top
|
|
|
|
|
- const originalWidth = container.style.width
|
|
|
|
|
- container.style.display = 'block'
|
|
|
|
|
- container.style.position = 'absolute'
|
|
|
|
|
- container.style.left = '-10000px'
|
|
|
|
|
- container.style.top = '0px'
|
|
|
|
|
- container.style.width = '210mm'
|
|
|
|
|
-
|
|
|
|
|
- const filename = recordRow.value?.elderName
|
|
|
|
|
- ? `${recordRow.value.elderName}-养老服务合同.pdf`
|
|
|
|
|
- : '养老服务合同.pdf'
|
|
|
|
|
|
|
|
|
|
- try {
|
|
|
|
|
- await html2pdf()
|
|
|
|
|
- .set({
|
|
|
|
|
- margin: 0,
|
|
|
|
|
- filename,
|
|
|
|
|
- image: { type: 'jpeg', quality: 0.98 },
|
|
|
|
|
- html2canvas: {
|
|
|
|
|
- scale: 2,
|
|
|
|
|
- useCORS: true,
|
|
|
|
|
- backgroundColor: '#ffffff',
|
|
|
|
|
- logging: false,
|
|
|
|
|
- foreignObjectRendering: false
|
|
|
|
|
- },
|
|
|
|
|
- jsPDF: {
|
|
|
|
|
- unit: 'mm',
|
|
|
|
|
- format: 'a4',
|
|
|
|
|
- orientation: 'portrait'
|
|
|
|
|
- },
|
|
|
|
|
- pagebreak: { mode: ['css'] }
|
|
|
|
|
- })
|
|
|
|
|
- .from(container)
|
|
|
|
|
- .save()
|
|
|
|
|
- message.success('导出成功')
|
|
|
|
|
- } catch (e) {
|
|
|
|
|
- console.error('导出PDF失败', e)
|
|
|
|
|
- message.error('导出失败,请尝试使用打印功能另存为PDF')
|
|
|
|
|
- } finally {
|
|
|
|
|
- container.style.display = originalDisplay
|
|
|
|
|
- container.style.position = originalPosition
|
|
|
|
|
- container.style.left = originalLeft
|
|
|
|
|
- container.style.top = originalTop
|
|
|
|
|
- container.style.width = originalWidth
|
|
|
|
|
- setTimeout(() => {
|
|
|
|
|
- isPrint.value = false
|
|
|
|
|
- isTextMode.value = false
|
|
|
|
|
- }, 500)
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
|
|
const toggleTextMode = () => {
|
|
const toggleTextMode = () => {
|
|
|
isTextMode.value = !isTextMode.value
|
|
isTextMode.value = !isTextMode.value
|
|
@@ -491,6 +425,17 @@ const openAttachmentSelector = (attach: any) => {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+const handleAttachmentDelete = (attach: any) => {
|
|
|
|
|
+ const key = `attach_${attach.no}`
|
|
|
|
|
+ // 固定内容附件(3=入住须知)删除后恢复默认展示
|
|
|
|
|
+ if (attach.no === 3) {
|
|
|
|
|
+ attachments[key] = { title: attach.title }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ attachments[key] = null
|
|
|
|
|
+ }
|
|
|
|
|
+ message.success(`已删除:${attach.title}`)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
const handleAttachmentSelect = (row: any) => {
|
|
const handleAttachmentSelect = (row: any) => {
|
|
|
const key = selectorVisible.value.current
|
|
const key = selectorVisible.value.current
|
|
|
if (key) {
|
|
if (key) {
|
|
@@ -572,11 +517,11 @@ const renderAttachmentContent = (key: string) => {
|
|
|
<el-tag type="info" size="large">颐年集团养老服务合同</el-tag>
|
|
<el-tag type="info" size="large">颐年集团养老服务合同</el-tag>
|
|
|
<div class="toolbar-right">
|
|
<div class="toolbar-right">
|
|
|
<el-tooltip :content="isTextMode ? '切换为编辑模式(输入框)' : '切换为文本模式(打印预览)'" placement="top">
|
|
<el-tooltip :content="isTextMode ? '切换为编辑模式(输入框)' : '切换为文本模式(打印预览)'" placement="top">
|
|
|
- <el-button :type="isTextMode ? 'success' : 'default'" size="small" @click="toggleTextMode">
|
|
|
|
|
|
|
+ <el-button v-show="type_c==1" :type="isTextMode ? 'success' : 'default'" size="small" @click="toggleTextMode">
|
|
|
{{ isTextMode ? '文本模式' : '编辑模式' }}
|
|
{{ isTextMode ? '文本模式' : '编辑模式' }}
|
|
|
</el-button>
|
|
</el-button>
|
|
|
</el-tooltip>
|
|
</el-tooltip>
|
|
|
- <el-button type="primary" :loading="formLoading" size="small" @click="handleSave">保存</el-button>
|
|
|
|
|
|
|
+ <el-button v-show="type_c==1" type="primary" :loading="formLoading" size="small" @click="handleSave">保存</el-button>
|
|
|
<el-button size="small" @click="handleClose">关闭</el-button>
|
|
<el-button size="small" @click="handleClose">关闭</el-button>
|
|
|
<el-tooltip placement="bottom" content="打印时目标打印机选择「Microsoft Print to PDF」;导出时目标打印机选择「另存为 PDF」">
|
|
<el-tooltip placement="bottom" content="打印时目标打印机选择「Microsoft Print to PDF」;导出时目标打印机选择「另存为 PDF」">
|
|
|
<el-button type="success" size="small" @click="handlePrint">打印/导出</el-button>
|
|
<el-button type="success" size="small" @click="handlePrint">打印/导出</el-button>
|
|
@@ -604,6 +549,7 @@ const renderAttachmentContent = (key: string) => {
|
|
|
:selected-data="attachments[`attach_${attach.no}`]"
|
|
:selected-data="attachments[`attach_${attach.no}`]"
|
|
|
:is-text-mode="isTextMode"
|
|
:is-text-mode="isTextMode"
|
|
|
@select="openAttachmentSelector(attach)"
|
|
@select="openAttachmentSelector(attach)"
|
|
|
|
|
+ @delete="handleAttachmentDelete(attach)"
|
|
|
>
|
|
>
|
|
|
<template #default="{ data }">
|
|
<template #default="{ data }">
|
|
|
<div v-if="attach.no === 1" class="attachment-content">
|
|
<div v-if="attach.no === 1" class="attachment-content">
|