From df2c4a7a693323a43dc74168a780a52c69e41c1b Mon Sep 17 00:00:00 2001
From: eight <641137800@qq.com>
Date: 星期四, 10 四月 2025 16:11:10 +0800
Subject: [PATCH] update

---
 src/views/ecg/doctor/components/DevReadyPanel.vue |  130 +++++++++++++++++++++++++++---------------
 1 files changed, 83 insertions(+), 47 deletions(-)

diff --git a/src/views/ecg/doctor/components/DevReadyPanel.vue b/src/views/ecg/doctor/components/DevReadyPanel.vue
index 653fa4f..8b3411f 100644
--- a/src/views/ecg/doctor/components/DevReadyPanel.vue
+++ b/src/views/ecg/doctor/components/DevReadyPanel.vue
@@ -11,25 +11,26 @@
       v-loading="formLoading"
     >
       <el-form-item label="妫�鏌ラ」鐩�" prop="">
-        {{formData.checkType && checkTypeStore.getCheckTypeName(formData.checkType)}}
+        {{formData?.checkType && checkTypeStore.getCheckTypeName(formData?.checkType)}}
       </el-form-item>
       <el-form-item label="鎮h�呯紪鍙�" prop="patId">
         <el-input v-model="formData.patId" placeholder="璇疯緭鍏ユ偅鑰呯紪鍙�" @input="getRentInfoByPatId" />
-        <Barcode v-if="getDisplayBarcode()" :value="getDisplayBarcode()" :width=100 />
+        <Barcode v-if="displayBarCode" :value="displayBarCode" :width=100 />
+        <el-button @click="copyBarcode()">澶嶅埗</el-button>
       </el-form-item>
       <el-form-item label="鎮h�呭悕绉�" prop="patName">
         <el-input v-model="formData.patName" placeholder="璇疯緭鍏ユ偅鑰呭悕绉�" />
       </el-form-item>
 
       <el-form-item label="鎮h�呮弿杩�" prop="patDeptDesc">
-        <dict-tag v-if="formData.patSrc" :type="DICT_TYPE.ECG_PAT_SOURCE" :value="formData.patSrc" />
-        {{formData.patDetails?.deptDesc}} {{formData.patDetails?.wardDesc}} {{formData.patDetails?.bedNo}}
+        <dict-tag v-if="formData.patDetails?.source" :type="DICT_TYPE.ECG_PAT_SOURCE" :value="formData.patDetails?.source" />
+        {{formData?.patDetails?.deptDesc}} {{formData?.patDetails?.wardDesc}} {{formData?.patDetails?.bedNo}}
       </el-form-item>
       <el-form-item label="璁惧缂栧彿" prop="devId">
         <el-input v-model="formData.devId" placeholder="璇疯緭鍏ヨ澶囩紪鍙�" @input="getDevInfo"/>
       </el-form-item>
       <el-form-item label="璁惧鎻忚堪" prop="">
-        {{deviceInfo.brand + "&nbsp;&nbsp;" + deviceInfo.model + " " + deviceInfo.state}}
+        {{ devInfo?.brand||'-' }} {{ devInfo?.model||'-' }} {{ tranlateDevState(devInfo?.state) }}
       </el-form-item>
       <el-form-item label="棰嗙敤鏃堕棿" prop="rentTime">
         <el-date-picker
@@ -53,12 +54,12 @@
     </el-form>
     <el-button @click="submitForm" type="primary" :disabled="formLoading">棰嗙敤瀹屾垚</el-button>
     <el-checkbox style="margin-left:10px" label="鑷姩&nbsp;" v-model="autoPrint" />
-    <el-button @click="printBill(formData.patId, formData.checkType)">鎵撳嵃灏忕エ</el-button>
-    <el-button @click="printBill(formData.patId, formData.checkType, 8)">鎵撳嵃灏忕エ2</el-button>
+    <el-button @click="printBill(formData.patId!, formData.checkType!)">鎵撳嵃灏忕エ</el-button>
+    <el-button @click="printBill(formData.patId!, formData.checkType!, 8)">鎵撳嵃灏忕エ2</el-button>
     <el-button @click="cancelReady"  :disabled="formLoading">鏀惧純棰嗙敤</el-button>
     <el-button @click="resetForm()">閲� 缃�</el-button>
-    <el-button @click="feeConfirm"  :disabled="formLoading">纭垂</el-button>
-    <el-button @click="feeCancel"  :disabled="formLoading">鍙栨秷纭垂</el-button>
+    <el-button v-if="formData.checkType && checkTypeStore.getExpenseRecognition(formData.checkType)" @click="feeConfirm"  :disabled="formLoading">纭垂</el-button>
+    <el-button v-if="formData.checkType && checkTypeStore.getExpenseRecognition(formData.checkType)" @click="feeCancel"  :disabled="formLoading">鍙栨秷纭垂</el-button>
 
   <!-- 鍖荤敓瑁呮満鍒楄〃 -->
   <ContentWrap>
@@ -147,8 +148,8 @@
 import {AppointmentApi, AppointmentVO} from "@/api/ecg/appointment";
 import {useCheckTypeStore} from '@/store/modules/checkType'
 import {calGender, getBookBeginTime} from "@/utils";
-import form from "@/components/Form/src/Form.vue";
 import {DICT_TYPE} from "@/utils/dict";
+import {tranlateDevState} from "@/utils/statusFormatter";
 
 /** 璁惧棰嗙敤 琛ㄥ崟 */
 defineComponent({ name: 'DevReadyPanel' })
@@ -175,6 +176,8 @@
 
 const formData = ref<DevRentVO>({
   id: undefined,
+  applyNo: undefined,
+  episodeId: undefined,
   devId: undefined,
   patId: undefined,
   patName: undefined,
@@ -199,15 +202,14 @@
 })
 const formRef = ref() // 琛ㄥ崟 Ref
 
-const deviceInfo = ref<DeviceVO> ({
-  id: 0,
-  devId: '',
-  category: '',
-  brand: '',
-  model: '',
-  purchaseDate: 0,
-  state: 0,
+const devInfo = ref<Partial<DeviceVO>>({
+  category: undefined,
+  brand: undefined,
+  model: undefined,
+  state: undefined,
 })
+
+const displayBarCode = ref<string> ()
 
 const getRentInfoByPatId = () => {
   const tempPatId = formData.value.patId;
@@ -217,6 +219,7 @@
 
   formData.value.patId = tempPatId;
   getFreeRentInfo(formData.value)
+  copyBarcode()
 }
 
 // 鏍规嵁鎮h�呮垨璁惧, 鑾峰彇 Free鐨勭璧�
@@ -226,9 +229,10 @@
     return
 
   // formDate 瀵瑰簲  DevRent
-  // formData.value = data  //涓嶈兘鏁翠釜璧嬪�硷紝 榛樿棰嗙敤鏃堕棿琚竻绌�
-  formData.value.id = data.id;   //rent id
-  formData.value.patDetails = data.patDetails
+  formData.value = data
+
+  // 棰嗙敤鏃堕棿  閲囩敤褰撳墠鏃堕棿
+  formData.value.rentTime = new Date().getTime()
 }
 
 /** 鎻愪氦琛ㄥ崟 */
@@ -245,7 +249,7 @@
 
     await DevRentApi.devReady(data)
 
-    if (autoPrint.value)
+    if (autoPrint.value && data.patId && data.checkType)
       printBill( data.patId, data.checkType)
 
     dialogVisible.value = false
@@ -279,6 +283,8 @@
 const resetForm = () => {
   formData.value = {
     id: undefined,
+    applyNo: undefined,
+    episodeId: undefined,
     devId: undefined,
     patId: undefined,
     patName: undefined,
@@ -289,11 +295,6 @@
     baseline: undefined,
     detachment: undefined,
     remark: undefined,
-    patDeptCode: undefined,
-    patDeptDesc: undefined,
-    patWardCode: undefined,
-    patWardDesc: undefined,
-    patBedNo: undefined,
     patDetails: undefined,
     paid: undefined,
     roomId: props.room.roomId,
@@ -301,10 +302,12 @@
   }
   formRef.value?.resetFields()
 
-  deviceInfo.value.category = ''
-  deviceInfo.value.brand = ''
-  deviceInfo.value.model = ''
-  deviceInfo.value.state = 0
+  devInfo.value = {
+    category: undefined,
+    brand: undefined,
+    model: undefined,
+    state: undefined,
+  }
 }
 
 const setPatient = (queueVO: QueueVO | undefined) => {
@@ -314,8 +317,8 @@
   formData.value.patId = queueVO?.patId
   formData.value.patName = queueVO?.patName
   formData.value.checkType = queueVO?.bookCheckType
-  formData.value.patSrc = queueVO?.patDetails.source
   getFreeRentInfo(formData.value)
+  copyBarcode()
 }
 defineExpose({ setPatient }) // 鎻愪緵 setPatient 鏂规硶锛岀敤浜庤缃偅鑰�
 
@@ -356,7 +359,14 @@
 }
 
 const getSelectedRent = async (rentId) => {
-  formData.value = await DevRentApi.getDevRent(rentId)
+  const data = await DevRentApi.getDevRent(rentId)
+
+  formData.value = data
+
+  devInfo.value.category = data.category
+  devInfo.value.brand = data.brand
+  devInfo.value.model = data.model
+  devInfo.value.state = data.devState
 }
 
 const printBill = async (patId: string, checkType: number, printMode?: number) => {
@@ -433,47 +443,73 @@
 */
 
 const getDevInfo = async () => {
-  deviceInfo.value.category = ''
-  deviceInfo.value.brand = ''
-  deviceInfo.value.model = ''
-  deviceInfo.value.state = 0
-  if (isStringEmpty(formData.value.devId))
+  if (formData.value?.devId == null) {
+    devInfo.value.brand = undefined
+    devInfo.value.model = undefined
+    devInfo.value.state = undefined
     return
+  }
 
   const data = await DeviceApi.getDeviceByDevId(formData.value.devId!)
-  console.info( data )
   if ( null !== data)
-    deviceInfo.value = data
+    devInfo.value = data
 }
 
 const feeConfirm = async () => {
+  if (formData.value?.id === undefined) {
+    message.error(t('璇峰厛棰嗙敤'))
+    return
+  }
+
   const result = await DevRentApi.feeConfirm(formData.value.id)
   if (0 == result)
-    message.success(t('鎿嶄綔鎴愬姛'))
+    message.success(t('纭垂鎿嶄綔鎴愬姛'))
 }
 
 const feeCancel = async () => {
+  if (formData.value?.id === undefined) {
+    message.error(t('璇峰厛棰嗙敤'))
+    return
+  }
+
   const result = await DevRentApi.feeCancel(formData.value.id)
   if (0 == result)
     message.success(t('鎿嶄綔鎴愬姛'))
 }
 
-const getDisplayBarcode = () => {
+const getDisplayBarcode = (): string => {
   if (!formData.value.checkType)
     return ""
 
   const displayBarcode: number[] = checkTypeStore.getCheckTypeDispBarCode(formData.value.checkType!)
-  if (!displayBarcode.includes( formData.value.patSrc ))
+  if (formData.value.patDetails == null || formData.value.patDetails.source == null ||
+      !displayBarcode.includes( formData.value.patDetails.source ))
     return ""
 
-  if (1 === formData.value.patSrc || 2 === formData.value.patSrc)
-    return formData.value.applyNo
-  else if (3 === formData.value.patSrc || 4 === formData.value.patSrc)
-    return formData.value.episodeId
+  return getBarcode()
+}
+
+const getBarcode = (): string => {
+  if (!formData.value.checkType)
+    return ""
+
+  const patSource = formData.value.patDetails?.source
+  if (patSource == null)
+    return ""
+
+  if (1 === patSource || 2 === patSource)
+    return formData.value.applyNo??""
+  else if (3 === patSource || 4 === patSource)
+    return formData.value.episodeId??""
 
   return ""
 }
 
+const copyBarcode = async () => {
+  displayBarCode.value = getDisplayBarcode()
+  await navigator.clipboard.writeText( getBarcode() );
+}
+
 /** 鍒濆鍖� **/
 onMounted(() => {
   getList()

--
Gitblit v1.9.3