chenyc
2025-07-14 05c827fea632f004821cc746ba73880769fab7cd
src/views/home/components/editDietary2.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='printFrom2'>
            <div style="width: 100%; height: 100%;overflow: auto;">
                <div id='printMe'>
                    <div>
                        <el-form size="small">
                            <div style="width: 100%">
@@ -42,9 +42,8 @@
                                            1.常吃的主食
                                        </td>
                                        <td colspan="5">
                                            <el-form :inline="true" size="small" >
                                                <el-form-item>
                                                    <el-radio-group class="elradiozdi"
                                            <el-form-item>
                                                    <el-radio-group
                                                        v-model="state.tableData.常吃的主食.type">
                                                        <el-checkbox value="精米面类">A.精米面类</el-checkbox>
                                                        <el-checkbox value="杂豆类">B.杂豆类</el-checkbox>
@@ -53,20 +52,20 @@
                                                        <el-checkbox value="其它">E.其它</el-checkbox>
                                                    </el-radio-group>
                                                    <span>
                                                        <el-input v-model="state.tableData.常吃的主食.input1"
                                                            style="max-width: 150px" placeholder="">
                                                            <template #append>次/周</template>
                                                        </el-input>
                                                    </span>
                                                    <span>食用份量</span>
                                                    <span>
                                                        <el-input v-model="state.tableData.常吃的主食.input2"
                                                            style="max-width: 150px" placeholder="">
                                                            <template #append>g/天</template>
                                                        </el-input>
                                                    </span>
                                                </el-form-item>
                                                <el-form-item label="食用频率">
                                                    <el-input v-model="state.tableData.常吃的主食.input1"
                                                        style="max-width: 150px" placeholder="">
                                                        <template #append>次/周</template>
                                                    </el-input>
                                                </el-form-item>
                                                <el-form-item label="食用份量">
                                                    <el-input v-model="state.tableData.常吃的主食.input2"
                                                        style="max-width: 150px" placeholder="">
                                                        <template #append>g/天</template>
                                                    </el-input>
                                                </el-form-item>
                                            </el-form>
                                        </td>
                                    </tr>
@@ -75,10 +74,9 @@
                                            2.常吃的蔬菜
                                        </td>
                                        <td colspan="5">
                                            <el-form :inline="true" size="small" >
                                                <el-form-item>
                                                <el-radio-group class="elradiozdi" v-model="state.tableData.常吃的蔬菜.type">
                                                <el-radio-group  v-model="state.tableData.常吃的蔬菜.type">
                                                    <el-checkbox value="叶菜">A.叶菜</el-checkbox>
                                                    <el-checkbox value="根茎类">B.根茎类</el-checkbox>
                                                    <el-checkbox value="瓜茄">C.瓜茄</el-checkbox>
@@ -113,9 +111,9 @@
                                            <el-form-item>
                                                <el-radio-group class="elradiozdi"
                                                    v-model="state.tableData.蔬菜日食用量.type">
                                                    <el-radio value="小于300g">A.小于300g </el-radio>
                                                    <el-radio value="<300g">A.< 300g </el-radio>
                                                    <el-radio value="300g-500g">B.300g-500g</el-radio>
                                                    <el-radio value="于500g">C.大于500g</el-radio>
                                                    <el-radio value=">500g">C.> 500g</el-radio>
                                                </el-radio-group>
                                            </el-form-item>
@@ -682,9 +680,9 @@
                    <el-button type="primary" @click="onSubmit">
                        保存
                    </el-button>
                    <el-button v-if="state.viewInfo.id" type="primary" v-print="'#printFrom2'">
                    <el-button v-if="state.viewInfo.id" type="primary" v-print="'#printMe'">
                        <el-icon><Printer /></el-icon>
                        打印
                        打印ddd
                    </el-button>
                    <el-button type="primary" v-if="state.viewInfo.id" @click="generatePDF">
                        <el-icon><Position /></el-icon>
@@ -882,7 +880,7 @@
        surveryTime: formatDate(new Date(), 'YYYY-mm-dd HH:MM:SS'),
        surveryPerson: userInfos.value.code,
        surveryJsonBody: '',
        suveryFormName: '营养膳食调查表',
        suveryFormName: '膳食调查表',
        updateTime: ''
    }
@@ -892,7 +890,7 @@
    state.dialogTableVisible = false
}
const generatePDF=()=> {
      const element = document.getElementById('printFrom2');
      const element = document.getElementById('printMe');
      const opt = {
        margin: 10,
        filename: `${state.tableData.表名}.pdf`,
@@ -914,9 +912,9 @@
        surveryTime: formatDate(new Date(), 'YYYY-mm-dd HH:MM:SS'),
        surveryPerson: userInfos.value.code,
        surveryJsonBody: JSON.stringify(state.tableData),
        suveryFormName: '营养膳食调查表',
        suveryFormName: '膳食调查表',
        surveryFormType: 0,
        updateTime: ''
        updateTime: formatDate(new Date(), 'YYYY-mm-dd HH:MM:SS'),
    }
    console.log(info)
    if (info.id === 0) {
@@ -952,6 +950,8 @@
        console.log(mode)
        state.viewInfo = mode
        state.tableData = JSON.parse(mode.surveryJsonBody)
        state.tableData.初次调查日期=mode.surveryTime
        state.tableData.更新日期=mode.updateTime
        state.dialogTableVisible = true
@@ -1120,7 +1120,7 @@
        surveryTime: formatDate(new Date(), 'YYYY-mm-dd HH:MM:SS'),
        surveryPerson: userInfos.value.code,
        surveryJsonBody: '',
        suveryFormName: '营养膳食调查表',
        suveryFormName: '膳食调查表',
        updateTime: ''
    }
}
@@ -1131,6 +1131,26 @@
<style scoped lang="scss">
@media print {
  body * {
    visibility: hidden;
  }
  #printMe, #printMe * {
    visibility: visible;
  }
  #printMe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: auto;
  }
  /* 控制分页 */
  .page-break {
    page-break-before: always;
  }
}
.gridtable {
    font-family: verdana, arial, sans-serif;
    font-size: 11px;