From 9bbb2946699515807256dfb30ab57359f4fdf563 Mon Sep 17 00:00:00 2001
From: chenyc <501753378@qq.com>
Date: 星期一, 24 三月 2025 16:09:43 +0800
Subject: [PATCH] gx优化

---
 src/views/home/components/editDietary.vue |   92 +++++++++++++++++++++++++---------------------
 1 files changed, 50 insertions(+), 42 deletions(-)

diff --git a/src/views/home/components/editDietary.vue b/src/views/home/components/editDietary.vue
index 1a0177d..60c4e8c 100644
--- a/src/views/home/components/editDietary.vue
+++ b/src/views/home/components/editDietary.vue
@@ -1,8 +1,8 @@
 <template>
     <div class="dietarySurvey-item">
         <el-dialog  v-model="state.dialogTableVisible" title="膳食生活调查表" :fullscreen="true" width="100%">
-            <div class="container" style="width: 100%; height: 100%;overflow: auto;">
-                <div id="printMe">
+            <div  style="width: 100%; height: 100%;overflow: auto;">
+                <div ref="printRef">
                     <div>
                         <el-form size="small">
                             <div style="width: 100%">
@@ -906,14 +906,14 @@
                     <el-button type="primary" @click="onSubmit">
                         保存
                     </el-button>
-                    <el-button v-if="state.viewInfo.id" type="primary" v-print="'#printMe'">
+                    <el-button v-if="state.viewInfo.id" type="primary" @click="onPrint">
                         <el-icon><Printer /></el-icon>
                         打印
                     </el-button>
-                    <el-button type="primary" v-if="state.viewInfo.id" @click="generatePDF">
+                    <!-- <el-button type="primary" v-if="state.viewInfo.id" @click="generatePDF">
                         <el-icon><Position /></el-icon>
                         导出
-                    </el-button>
+                    </el-button> -->
                     
                 </div>
             </template>
@@ -924,23 +924,26 @@
 
 </template>
 
-<script setup lang="ts" name="visualizingLinkDemo2">
+<script setup lang="ts" >
 import html2pdf from 'html2pdf.js';
+import printJs from 'print-js';
 import { reactive, onMounted, onUnmounted, ref } from 'vue';
 import { formatDate } from '/@/utils/formatTime';
 import { NextLoading } from '/@/utils/loading';
 import { useUserInfo } from '/@/stores/userInfo';
 import { usePatientsInfo } from '/@/stores/patientsInfo';
 const storesPat = usePatientsInfo();
-import {Add,update,deleteId,tiaochabiaoInfo} from '/@/api/tiaochabiao/index'
+import {Add,update,list,tiaochabiaoInfo} from '/@/api/tiaochabiao/index'
 import { storeToRefs } from 'pinia';
 import { useRoute,useRouter } from 'vue-router';
-import { ElMessage } from 'element-plus';
+import { ElLoading, ElMessage } from 'element-plus';
 const stores = useUserInfo();
 const { patientsInfo } = storeToRefs(storesPat);
 const { userInfos } = storeToRefs(stores);
 const router = useRouter()
 const emit = defineEmits([ "shuaxin" ]);
+// 定义变量内容
+const printRef = ref();
 const state = reactive({
     dialogTableVisible:false,
     tableData: {
@@ -1140,7 +1143,13 @@
 }
 // 打印
 const onPrint=()=>{
-    
+    printJs({
+		printable: printRef.value,
+		type: 'html',
+		css: ['@/assets/css/printcss.css','//at.alicdn.com/t/c/font_2298093_rnp72ifj3ba.css', '//unpkg.com/element-plus/dist/index.css'],
+		scanStyles: false,
+		style: `@media print{}}`,
+	});
 }
 const generatePDF=()=> {
       const element = document.getElementById('printMe');
@@ -1384,11 +1393,40 @@
 
 }
 // 打开查看或者编辑明细
-const openShow = (type: string,mode:tiaochabiaoInfo) => {
+const openShow = async (type: string,mode:tiaochabiaoInfo) => {
     console.log(type)
     if(type==='add'){
-        getPageInfo()
-        state.dialogTableVisible = true
+        const pasm={
+            page: 0,
+            size: 1,
+            wherecondition:`survery_form_type=0 and patient_code='${patientsInfo.value.code}' and  suvery_form_name='膳食生活调查表'`,
+            ordercondition: 'survery_time desc'
+        }
+        const re= await list(pasm);
+        console.log('店家--------',re.data)
+        if(re.data.list.length){
+            const model=re.data.list[0]
+            state.tableData=JSON.parse(model.surveryJsonBody)
+    
+            state.dialogTableVisible = true
+            state.viewInfo={
+                id: 0,
+                code: '',
+                clientCode: userInfos.value.clientCode,
+                patientCode: patientsInfo.value.code,
+                surveryTime: formatDate(new Date(), 'YYYY-mm-dd HH:MM:SS'),
+                surveryPerson: userInfos.value.code,
+                surveryJsonBody: '',
+                suveryFormName:'膳食生活调查表',
+                surveryFormType:0,
+                updateTime: ''
+            }
+
+        }else{
+            getPageInfo()
+            state.dialogTableVisible = true
+        }
+       
     }
     else if(type==='update'){
         console.log(mode)
@@ -1410,36 +1448,6 @@
 
 
 <style scoped lang="scss">
-@media print {
-  body * {
-    visibility: hidden;
-  }
-  #printMe, #printMe * {
-    visibility: visible;
-  }
-  #printMe {
-    position: absolute;
-    top: 0;
-    left: 0;
-    width: 100%;
-  }
-
-  /* 防止内容在页面边界处被截断 */
-  p, h1, div {
-    page-break-inside: avoid;
-  }
-
-  /* 确保表格行不会被截断(如果有表格的话) */
-  table tr {
-    page-break-inside: avoid;
-  }
-
-  /* 设置页面大小和边距 */
-  @page {
-    size: A4;
-    margin: 0mm;
-  }
-}
 .gridtable {
     font-family: verdana, arial, sans-serif;
     font-size: 11px;

--
Gitblit v1.8.0