Sfoglia il codice sorgente

优化代码修改字段名称

xiaochan 2 anni fa
parent
commit
d8a4fc0ef8

+ 41 - 12
src/components/zhu-yuan-yi-sheng/shou-shu-shen-qing/DaYingShouShuShengQingDan.vue

@@ -3,8 +3,8 @@
     纸张:
     <el-radio v-model="zhiZhang" :label="1" size="large">A4</el-radio>
     <el-radio v-model="zhiZhang" :label="2" size="large">A5</el-radio>
-    <el-button @click="daYing">打印</el-button>
-    <div id="daYing">
+    <el-button @click="printClick">打印</el-button>
+    <div ref="printRef">
       <div style="width:393pt;height:570pt;background-color: white;font-size: 9.75pt">
         <div style="height: 15pt"></div>
         <table style="width: 100%;table-layout: fixed;">
@@ -103,7 +103,7 @@
   </div>
 </template>
 
-<script setup name="DaYingShouShuShengQingDan">
+<script setup lang="ts">
 import {computed, onMounted, ref} from "vue";
 import {cptSex} from "@/utils/computed";
 import {getLodop, initLodop} from "@/utils/c-lodop";
@@ -123,6 +123,35 @@ const props = defineProps({
   }
 })
 
+interface OpRecord {
+  recordId?: string
+  deptCodeName?: string
+  inpatientNo?: string
+  bedNo?: string
+  patientName?: string
+  sex?: string
+  age?: string
+  diagBeforeOp?: string
+  opName?: string
+  hocusName?: string
+  opScaleName?: string
+  doctorZdName?: string
+  doctor1Name?: string
+  doctor2Name?: string
+  doctor3Name?: string
+  doctorMzName?: string
+  nurseQxName?: string
+  nurseXhName?: string
+  applyDate?: string
+  opDatetime?: string
+  referPhysicianName?: string
+  deptDirectorName?: string
+  urgentClinicFlag?: string
+  remark?: string
+}
+
+const printRef = ref<HTMLDivElement>()
+
 const zuJianDaXiao = computed(() => {
   return {
     width: props.width + 'px',
@@ -131,7 +160,7 @@ const zuJianDaXiao = computed(() => {
   }
 })
 const zhiZhang = ref(2)
-const data = ref({})
+const data = ref<OpRecord>({})
 const css = '*{font-size:12pt}.tanXingHeZiHeng{display:flex;justify-content:space-between;margin-top:3pt;padding:0 3.75pt}.tanXingHeZiHeng2{display:flex;margin-top:3pt;padding:0 3.75pt}.tanXingHeZiShu{display:flex;flex-direction:column}.wen-zi{display:flex;margin-top:3pt;margin-left:3.75pt;height:23.75pt}.wen-zi div:first-child{display:flex;flex-direction:row;justify-content:center;text-align:right}.wen-zi div:nth-child(2){margin-left:3pt;display:table}.ge-zi{display:table-column}'
 
 const situationFunc = () => {
@@ -142,15 +171,13 @@ const situationFunc = () => {
   return findValueByListCode(surgicalSituation, data.value.urgentClinicFlag)
 }
 
-const daYing = () => {
+const printClick = () => {
   if (!data) {
     return ElMessage.error('请先选择患者')
   }
-
-  let LODOP = getLodop()
-  const strFormHtml = '<style>' + css + '</style>' + '<body>' + document.getElementById('daYing').innerHTML + '</body>';
+  let LODOP = getLodop();
+  const strFormHtml = '<style>' + css + '</style>' + '<body>' + printRef.value.innerHTML + '</body>';
   LODOP.PRINT_INIT(0, 0, 522, 333, '检查申请') // 初始化打印机 名字
-  // LODOP.SET_PRINT_MODE("PRINT_PAGE_PERCENT", "Full-Width");
   // 整宽不变形
   if (zhiZhang.value === 1) {
     LODOP.SET_PRINT_PAGESIZE(2, 0, 0, 'A4')   // 设置纸张大小  A
@@ -158,17 +185,19 @@ const daYing = () => {
     LODOP.SET_PRINT_PAGESIZE(1, 0, 0, 'A5')
   }
   LODOP.ADD_PRINT_HTM(0, 0, '100%', '100%', strFormHtml) //  参数分别为顶边距,左边距,宽,高,打印项内容。
-  // LODOP.PRINT_DESIGN()
   LODOP.PREVIEW() // 关闭
 }
 
+const setData = (val) => {
+  data.value = val
+}
+
 onMounted(() => {
   initLodop()
 })
 
 defineExpose({
-  daYing,
-  data
+  setData
 })
 
 </script>

+ 10 - 7
src/utils/findValueByListCode.ts

@@ -1,20 +1,23 @@
 import XEUtils from "xe-utils";
 
-interface listArr {
-    code: string,
-    name: string
+interface Option {
+    listCode: string,
+    listValue: string
 }
 
-const findValueByListCode = (arr: any[] | listArr[],
-                             code: string | number,
-                             listCode: string = 'code',
-                             listValue: string = 'name'): string => {
+const defaultValue: Option = {listCode: 'code', listValue: 'name'}
+
+const findValueByListCode = (arr: any[], code: string | number, option: Option = defaultValue): string => {
+    const {listCode, listValue} = option
     if (XEUtils.isEmpty(arr)) {
         return '';
     }
     if (!XEUtils.isArray(arr)) {
         return '';
     }
+    if (typeof code === 'undefined' || code === null) {
+        return '';
+    }
 
     for (let i = 0, len = arr.length; i < len; i++) {
         if (arr[i][listCode] === code) {

+ 2 - 3
src/views/hospitalization/zhu-yuan-yi-sheng/shou-shu-shen-qing/ShouShuShenQing.vue

@@ -81,7 +81,7 @@ import {
 import {
   huanZheXinXi, jsQueryYzData,
   operationApplication,
-  youWuXuanZheHuanZhe, yzHeaderSize, yzSize
+  youWuXuanZheHuanZhe, yzSize
 } from '@/views/hospitalization/zhu-yuan-yi-sheng/public-js/zhu-yuan-yi-sheng'
 import {shortcuts} from '@/data/shortcuts'
 import store from '@/store'
@@ -92,7 +92,6 @@ import BianJiShouShu from "@/components/zhu-yuan-yi-sheng/shou-shu-shen-qing/Bia
 import {getRenYuan, getServerDateApi, maZuiFangShi} from "@/api/public-api";
 import SurgicalErrorInfo from "@/components/zhu-yuan-yi-sheng/shou-shu-shen-qing/SurgicalErrorInfo";
 import {BizException, ExceptionEnum} from "@/utils/BizException";
-import {isDev} from "@/utils/public";
 
 const windowSize = computed(() => {
   return store.state.app.windowSize
@@ -209,13 +208,13 @@ const removeTab = (targetName) => {
 
 const dianJiChaKanShouShu = (row) => {
   huoQuShouShuShenQingDaYing(huanZheXinXi.value.inpatientNo, huanZheXinXi.value.admissTimes, row.recordId).then((res) => {
-    daYing.value.data = res
     if (stringNotBlank(res.applyDate)) {
       res.applyDate = res.applyDate.split(' ')[0]
     }
     if (stringNotBlank(res.opDatetime)) {
       res.opDatetime = res.opDatetime.split(' ')[0]
     }
+    daYing.value.setData(res)
   })
   tabs.value = 0
 }

+ 14 - 1
src/views/settings/Test.vue

@@ -1,7 +1,20 @@
 <template>
-  <EmrTestV2 pat-no="0420929"/>
+  <!--  <EmrTestV2 pat-no="0420929"/>-->
 </template>
 
 <script setup lang="ts">
 import EmrTestV2 from "@/components/zhu-yuan-yi-sheng/emr/auxiliary-tools/EmrTestV2.vue";
+import {onMounted} from "vue";
+import findValueByListCode from "@/utils/findValueByListCode";
+
+const testData = [
+  {code: 1, name: 'asd'},
+  {code: 2, name: 'asd1'},
+  {code: 3, name: '3'},
+  {code: 4, name: '4'},
+]
+
+onMounted(() => {
+  console.log(findValueByListCode(testData, 1));
+})
 </script>