瀏覽代碼

入院押金打印押金凭证增加公章显示

xiongxing 2 周之前
父節點
當前提交
11d10d594e
共有 1 個文件被更改,包括 51 次插入 和 1 次删除
  1. 51 1
      src/views/elderly/fee/deposit/Print.vue

+ 51 - 1
src/views/elderly/fee/deposit/Print.vue

@@ -64,6 +64,10 @@
         <span>出纳:{{ dataForm.createdBy }}</span>
         <span>操作人:{{ user.nickname }}</span>
       </p>
+      <!-- 机构签章:叠在表格右下角,旋转 -45° -->
+      <div v-if="sealUrl" class="seal-overlay">
+        <img :src="sealUrl" class="seal-img" alt="机构公章" />
+      </div>
     </div>
     <template #footer>
       <el-button @click="handleClosed">取消</el-button>
@@ -80,6 +84,8 @@ import { getDictLabel, DICT_TYPE } from '@/utils/dict'
 import { getDepositDetail } from '@/api/elderly/fee/deposit'
 import { fmtDict } from '@/utils'
 import { getOverheadListByType } from '@/api/elderly/fee/overheadCharge'
+import { getTenant } from '@/api/system/tenant'
+import { getTenantId } from '@/utils/auth'
 defineOptions({ name: 'DepositPrint' })
 
 const tenantName = useUserStore().getTenantName // 当前登录的编号
@@ -119,10 +125,20 @@ const pageTitle = ref('')
 const pageType = ref(0)
 const payText = ref('')
 const singleType = ref(true)
+// 当前机构公章(来自租户接口 expenseCachetUrl);为空字符串时签章区不渲染
+const sealUrl = ref('')
 
 /** 打开弹窗 */
 const open = async (elderId, id, type = 1, single = true) => {
   dialogVisible.value = true
+  // 并行拉取机构公章(容错,租户接口失败不影响打印主流程)
+  getTenant(getTenantId() as number)
+    .then((tenant) => {
+      sealUrl.value = tenant?.expenseCachetUrl || ''
+    })
+    .catch(() => {
+      sealUrl.value = ''
+    })
   pageType.value = type
   singleType.value = single
   /** 押金 */
@@ -209,6 +225,7 @@ const handleClosed = () => {
   dialogVisible.value = false
   total.value = 0
   payText.value = ''
+  sealUrl.value = ''
   dataForm.value = {
     orderNumber: '',
     createdTime: '',
@@ -225,12 +242,21 @@ const getList = async () => {
   list.value = res
 }
 
+// 打印样式:与预览保持一致
+// - #printArea 加 padding-bottom 给签章留出空间,否则签章会贴到纸张边缘或被裁掉
+// - 同步印章定位(打印 iframe 不会继承 scoped 样式,需在此重新声明)
+const printExtraCss = `
+  html, body { height: auto !important; overflow: visible !important; }
+  #printArea { height: auto !important; overflow: visible !important; padding-bottom: 12mm !important; }
+  .seal-overlay { right: 5mm !important; bottom: 0mm !important; }
+`
+
 // 打印
 const print = {
   id: 'printArea',
   extraCss: '',
   popTitle: '', // 打印配置页上方的标题
-  extraHead: '', // 最上方的头部文字,附加在head标签上的额外标签,使用逗号分割
+  extraHead: `<style>${printExtraCss}</style>`, // 最上方的头部文字,附加在head标签上的额外标签,使用逗号分割
   preview: false, // 是否启动预览模式,默认是false
   previewTitle: '对账单预览', // 打印预览的标题
   previewPrintBtnLabel: '预览结束,开始打印', // 打印预览的标题下方的按钮文本,点击可进入打印
@@ -258,6 +284,8 @@ const print = {
 </script>
 <style lang="scss" scoped>
 .deposit-print {
+  position: relative; // 让 .seal-overlay 相对本容器定位
+  padding-bottom: 12mm; // 给印章留出空间,避免被 dialog 滚动容器或打印纸张裁切
   .wrap {
     position: relative;
     .title {
@@ -288,5 +316,27 @@ const print = {
   .fr {
     float: right;
   }
+  // 机构签章:绝对定位叠在表格右下角,旋转 -45°
+  // - right: 5mm / bottom: 0mm,让印章落在容器右下角的留白区域内完整可见
+  // - z-index: 20 保证印章叠在表格之上;pointer-events: none 不挡表格交互
+  // - opacity: 0.85 略透,不完全遮住底部文字
+  .seal-overlay {
+    position: absolute;
+    right: 15mm;
+    bottom: 16mm;
+    width: 30mm;
+    height: 30mm;
+    z-index: 20;
+    pointer-events: none;
+
+    .seal-img {
+      width: 100%;
+      height: 100%;
+      object-fit: contain;
+      // transform: rotate(-45deg);
+      transform-origin: 100% 100%;
+      opacity: 0.85;
+    }
+  }
 }
 </style>