34
chenyc
2025-01-09 070ff71561be29e98bbc90e6d77f43f806f5b50b
src/views/home/components/pingubiao/editDietary5.vue
@@ -1,8 +1,8 @@
<template>
    <div class="dietarySurvey-item">
        <el-dialog v-model="state.dialogTableVisible" title="GNIR营养评估分" :fullscreen="true" width="100%">
        <el-dialog v-model="state.dialogTableVisible" title="GNRI" :fullscreen="true" width="100%">
            <div class="container" style="width: 100%; height: 100%;overflow: auto;">
                <div>
                <div id="pinggu5">
                    <div>
                        <el-form size="small">
                            <div style="width: 100%">
@@ -11,7 +11,7 @@
                                    <tr>
                                        <th colspan="2">
                                            <el-form-item label="调查日期">
                                                <el-date-picker v-model="state.tableData.初次调查日期" type="date"
                                                <el-date-picker v-model="state.tableData.初次调查日期" type="date" readonly
                                                    style="width: 100px;" placeholder="" format="YYYY/MM/DD"
                                                    value-format="YYYY-MM-DD" />
                                            </el-form-item>
@@ -19,16 +19,14 @@
                                        </th>
                                        <th colspan="2">
                                            <el-form-item label="更新日期">
                                                <el-date-picker v-model="state.tableData.更新日期" type="date"
                                                <el-date-picker v-model="state.tableData.更新日期" type="date" readonly
                                                    style="width: 100px;" placeholder="" format="YYYY/MM/DD"
                                                    value-format="YYYY-MM-DD" />
                                            </el-form-item>
                                        </th>
                                        <th colspan="2">
                                            <el-form-item label="记录者">
                                                <el-input v-model="state.tableData.记录者" style="width: 100px;"
                                                <el-input v-model="state.tableData.记录者" style="width: 100px;" readonly
                                                    placeholder="" />
                                            </el-form-item>
                                        </th>
@@ -127,7 +125,7 @@
                                    </tr>
                                    <tr>
                                        <td colspan="6" style="color: #E6A23C;">
                                            GNIR营养评估分为4个等级:<br>
                                            GNRI为4个等级:<br>
                                            高营养风险(GNIR&lt;82<br>
                                            中营养风险(82≤GNIR<92)<br>
                                            低营养风险(92≤GNIR≤98)<br>
@@ -151,6 +149,14 @@
                    <el-button type="primary" @click="onSubmit">
                        保存
                    </el-button>
                    <el-button v-if="state.viewInfo.id" type="primary" v-print="'#pinggu5'">
                        <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>
@@ -161,6 +167,7 @@
</template>
<script setup lang="ts" name="visualizingLinkDemo2">
import html2pdf from 'html2pdf.js';
import { reactive, onMounted, onUnmounted, ref, computed, watch } from 'vue';
import { formatDate } from '/@/utils/formatTime';
import { NextLoading } from '/@/utils/loading';
@@ -182,7 +189,7 @@
    options: [0, 1],
    dialogTableVisible: false,
    tableData: {
        表名: 'GNIR营养评估分',
        表名: 'GNRI',
        初次调查日期: "",
        填表日期: '',
        更新日期: '',
@@ -207,7 +214,7 @@
        surveryTime: formatDate(new Date(), 'YYYY-mm-dd HH:MM:SS'),
        surveryPerson: userInfos.value.code,
        surveryJsonBody: '',
        suveryFormName: 'GNIR营养评估分',
        suveryFormName: 'GNRI',
        surveryFormType: 1,
        updateTime: ''
    }
@@ -263,13 +270,13 @@
            data= Number(((1.498 * Number(state.tableData.血清白蛋白浓度)) + 41.7).toFixed(2))
        }
        if(data<82){
           return `GNIR营养评估分:${data} 高营养风险`
           return `GNRI:${data} 高营养风险`
        }else if(data>=82&&data<92){
           return `GNIR营养评估分:${data} 中营养风险`
           return `GNRI:${data} 中营养风险`
        }else if(data>=92&&data<98){
           return `GNIR营养评估分:${data} 低营养风险`
           return `GNRI:${data} 低营养风险`
        }else if(data>=98){
           return `GNIR营养评估分:${data} 无营养风险`
           return `GNRI:${data} 无营养风险`
        }else{
            return ''
        }
@@ -293,7 +300,7 @@
        surveryTime: formatDate(new Date(), 'YYYY-mm-dd HH:MM:SS'),
        surveryPerson: userInfos.value.code,
        surveryJsonBody: JSON.stringify(state.tableData),
        suveryFormName: 'GNIR营养评估分',
        suveryFormName: 'GNRI',
        updateTime: ''
    }
    console.log(info)
@@ -335,6 +342,8 @@
        console.log(mode)
        state.viewInfo = mode
        state.tableData = JSON.parse(mode.surveryJsonBody)
        state.tableData.初次调查日期=mode.surveryTime
        state.tableData.更新日期=mode.updateTime
        state.dialogTableVisible = true
    }
@@ -343,7 +352,7 @@
    const res = await getPatData({ patCode: patientsInfo.value.code, })
    console.log(res.data, '----')
    state.tableData = {
        表名: 'GNIR营养评估分',
        表名: 'GNRI',
        初次调查日期: formatDate(new Date(), 'YYYY-mm-dd'),
        填表日期: '',
        更新日期: formatDate(new Date(), 'YYYY-mm-dd'),
@@ -365,12 +374,23 @@
        surveryTime: formatDate(new Date(), 'YYYY-mm-dd HH:MM:SS'),
        surveryPerson: userInfos.value.code,
        surveryJsonBody: '',
        suveryFormName:'GNIR营养评估分',
        suveryFormName:'GNRI',
        surveryFormType:1,
        updateTime: ''
    }
}
const generatePDF=()=> {
      const element = document.getElementById('pinggu5');
      const opt = {
        margin: 10,
        filename: `${state.tableData.表名}.pdf`,
        image: { type: 'jpeg', quality: 0.98 },
        html2canvas: { scale: 2 },
        jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrai' }
      };
      html2pdf().set(opt).from(element).save();
}
// 第二步:暴露方法
defineExpose({ getData, openShow })
</script>