34
chenyc
2025-01-09 070ff71561be29e98bbc90e6d77f43f806f5b50b
src/views/home/components/pingubiao/editDietary3.vue
@@ -1,8 +1,8 @@
<template>
   <div class="dietarySurvey-item">
      <el-dialog v-model="state.dialogTableVisible" title="营养不良炎症评分表(MIS)" :fullscreen="true" width="100%">
      <el-dialog v-model="state.dialogTableVisible" title="MIS" :fullscreen="true" width="100%">
         <div class="container" style="width: 100%; height: 100%; overflow: auto">
            <div>
            <div id="pinggu3">
               <div>
                  <el-form size="small">
                     <div style="width: 100%">
@@ -10,7 +10,7 @@
                           <tr>
                              <th colspan="2">
                                 <el-form-item label="初次调查日期">
                                    <el-date-picker
                                    <el-date-picker readonly
                                       v-model="state.tableData.初次调查日期"
                                       type="date"
                                       style="width: 100px"
@@ -22,7 +22,7 @@
                              </th>
                              <th colspan="2">
                                 <el-form-item label="更新日期">
                                    <el-date-picker
                                    <el-date-picker readonly
                                       v-model="state.tableData.更新日期"
                                       type="date"
                                       style="width: 100px"
@@ -34,7 +34,7 @@
                              </th>
                              <th colspan="2">
                                 <el-form-item label="记录者">
                                    <el-input v-model="state.tableData.记录者" style="width: 100px" placeholder="" />
                                    <el-input v-model="state.tableData.记录者" style="width: 100px" readonly placeholder="" />
                                 </el-form-item>
                              </th>
                           </tr>
@@ -194,6 +194,14 @@
            <div class="dialog-footer" style="text-align: center">
               <el-button @click="funhui">取消</el-button>
               <el-button type="primary" @click="onSubmit"> 保存 </el-button>
               <el-button v-if="state.viewInfo.id" type="primary" v-print="'#pinggu3'">
                        <el-icon><Printer /></el-icon>
                        打印
                    </el-button>
                    <el-button type="primary" v-if="state.viewInfo.id" @click="generatePDF">
                        <el-icon><Position /></el-icon>
                        导出
                    </el-button>
            </div>
         </template>
      </el-dialog>
@@ -201,6 +209,7 @@
</template>
<script setup lang="ts" name="visualizingLinkDemo2">
import html2pdf from 'html2pdf.js';
import { reactive, onMounted, onUnmounted, ref, computed } from 'vue';
import { formatDate } from '/@/utils/formatTime';
import { NextLoading } from '/@/utils/loading';
@@ -219,7 +228,7 @@
const state = reactive({
   dialogTableVisible: false,
   tableData: {
      表名: '营养不良炎症评分表(MIS)',
      表名: 'MIS',
      初次调查日期: '',
      填表日期: '',
      更新日期: '',
@@ -304,7 +313,7 @@
      surveryTime: formatDate(new Date(), 'YYYY-mm-dd HH:MM:SS'),
      surveryPerson: userInfos.value.code,
      surveryJsonBody: JSON.stringify(state.tableData),
      suveryFormName: '营养不良炎症评分表(MIS)',
      suveryFormName: 'MIS',
      updateTime: '',
   };
   console.log(info);
@@ -343,12 +352,14 @@
      console.log(mode);
      state.viewInfo = mode;
      state.tableData = JSON.parse(mode.surveryJsonBody);
      state.tableData.初次调查日期=mode.surveryTime
        state.tableData.更新日期=mode.updateTime
      state.dialogTableVisible = true;
   }
};
const getPageInfo = () => {
   state.tableData = {
      表名: '营养不良炎症评分表(MIS)',
      表名: 'MIS',
      初次调查日期: formatDate(new Date(), 'YYYY-mm-dd'),
      填表日期: '',
      更新日期: formatDate(new Date(), 'YYYY-mm-dd'),
@@ -407,7 +418,18 @@
      updateTime: '',
   };
};
const generatePDF=()=> {
      const element = document.getElementById('pinggu3');
      const opt = {
        margin: 10,
        filename: `${state.tableData.表名}.pdf`,
        image: { type: 'jpeg', quality: 0.98 },
        html2canvas: { scale: 2 },
        jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' }
      };
      html2pdf().set(opt).from(element).save();
}
// 第二步:暴露方法
defineExpose({ getData, openShow });
</script>