| | |
| | | <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%"> |
| | |
| | | <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> |
| | |
| | | |
| | | </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: { |
| | |
| | | } |
| | | // 打印 |
| | | 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'); |
| | |
| | | |
| | | } |
| | | // 打开查看或者编辑明细 |
| | | 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) |
| | |
| | | |
| | | |
| | | <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; |