Browse Source

混检开放时间动态获取。

lighter 3 years ago
parent
commit
e8e5fabffc

+ 3 - 4
src/api/order-covid-exam.js

@@ -16,10 +16,9 @@ export function savePrescription(patientId, type) {
   })
 }
 
-export function updateIdCard(patientId, socialNo) {
+export function getMultipleExamTimeLimit() {
   return request({
-    url: '/orderCovid/updateIdCard',
+    url: '/orderCovid/getMultipleExamTimeLimit',
     method: 'get',
-    params: { patientId, socialNo },
   })
-}
+}

+ 8 - 1
src/utils/date.js

@@ -53,6 +53,13 @@ export function getOneWeekOffset(start) {
   return { start, end }
 }
 
+export function getHourMinute() {
+  const date = new Date()
+  const hour = date.getHours()
+  const min = date.getMinutes()
+  return Number(hour + '' + ('0' + min).slice(-2))
+}
+
 export function getTomorrow() {
   const tomorrow = new Date().getTime() + 24 * 3600 * 1000
   return new Date(tomorrow)
@@ -65,7 +72,7 @@ export function getAWeekFromNow() {
 
 export function getOneWeekText() {
   const day = new Date().getDay()
-  const weeks = new Array('日', '一', '二', '三', '四', '五', '六')
+  const weeks = ['日', '一', '二', '三', '四', '五', '六']
   const arr = new Array(7)
   for (let index = 0; index < 7; index++) {
     let tempDay = (day + index) % 7

+ 71 - 47
src/views/hospital-service/covid-exam/SelectCovidBranch.vue

@@ -1,44 +1,65 @@
 <template>
   <window-size>
-    <van-cell title="核酸检测自助开单(单人单管)" is-link @click="showDiaglog(1)"></van-cell>
-    <van-cell title="核酸检测自助开单(混检)" center is-link @click="showDiaglog(2)">
+    <van-cell title="核酸检测自助开单(单人单管)" is-link @click="handleClickExamOption(1)"></van-cell>
+    <van-cell title="核酸检测自助开单(混检)" :value="timeLimit.limitValueForDisplay" center is-link @click="handleClickExamOption(2)">
       <template #label>
         <span style="color: green; font-weight: bold">仅限绿码,</span><span style="color: orange">黄码请选择单人单管。</span>
       </template>
     </van-cell>
     <van-cell title="查询检测结果" is-link :to="'/checkCovidExamResult/' + patientId"></van-cell>
-    <van-dialog v-model:show="showInputIdCard" title="填写身份证" show-cancel-button @confirm="confirmChangeIdCard">
-      <div style="font-size: 12px; color: red; padding: 5px 10px 10px 15px">
-        您在我院绑定的身份证号不是有效的身份证号,请重新填写:
+    <van-dialog v-model:show="showTips" title="核酸检测须知">
+      <div style="padding: 12px">
+        <div>1、接种新冠疫苗后72小时方可进行核酸采样。</div>
+        <div>2、混检仅在8:00 - 24:00对绿码人员开放。</div>
+        <div>3、黄码人员请进行单人单管采样。</div>
       </div>
-      <van-field v-model="socialNo" label="身份证号"></van-field>
     </van-dialog>
   </window-size>
 </template>
 
 <script>
-import {Dialog, Toast} from 'vant'
+import {Dialog} from 'vant'
 import {useRouter} from 'vue-router'
-import {hasDoneCovidAssessment, savePrescription, updateIdCard} from '../../../api/order-covid-exam'
-import {ref} from 'vue'
-import {isValidIdcard} from '../../../utils/validate'
+import {hasDoneCovidAssessment, getMultipleExamTimeLimit, savePrescription} from '../../../api/order-covid-exam'
+import {onMounted, ref} from 'vue'
+import {getHourMinute} from '../../../utils/date'
 
 export default {
   setup() {
+    const showTips = ref(false)
     const router = useRouter()
     const patientId = router.currentRoute.value.params.patientId
-    const showInputIdCard = ref(false)
-    const socialNo = ref(null)
-    const confirmChangeIdCard = () => {
-      if (!isValidIdcard(socialNo.value)) {
-        Toast.fail('您输入的身份证不合法!')
-      } else {
-        updateIdCard(patientId, socialNo.value).then(() => {
-          Toast.success('更新身份证成功,您可以继续核酸检测自助开单了。')
-        })
-      }
+    const timeLimit = ref({})
+
+    const validateMultipleExamTime = (flag) => {
+      return new Promise((resolve, reject) => {
+        if (flag === 1) {
+          resolve()
+        } else {
+          const nowtime = getHourMinute();
+          if (nowtime < timeLimit.value.beginLimit || nowtime > timeLimit.value.endLimit) {
+            const message = '混检仅在 ' + timeLimit.value.limitValueForDisplay + ' 开放。'
+            Dialog.alert({
+              title: '提示',
+              message,
+            });
+            reject(message);
+          } else {
+            resolve();
+          }
+        }
+      })
+    }
+
+    const handleClickExamOption = (flag) => {
+      validateMultipleExamTime(flag).then(() => {
+        confirmSaveCovidExam(flag)
+      }).catch((message) => {
+        console.error(message)
+      })
     }
-    const showDiaglog = (flag) => {
+
+    const confirmSaveCovidExam = (flag) => {
       const type = flag === 1 ? '(单人单管)?' : '(混检)?'
       Dialog.confirm({
         message: '是否确认预定新冠核酸检测' + type,
@@ -47,36 +68,39 @@ export default {
         cancelButtonText: '取消',
       })
           .then(() => {
-            savePrescription(patientId, flag)
-                .then(() => {
-                  router.push(`/unPaidList/${patientId}`)
-                })
-                .catch(() => {
-                  showInputIdCard.value = true
-                })
-            // hasDoneCovidAssessment(patientId).then((res) => {
-            //   if (res === 'no') {
-            //     router.push(`/assessments/covid/${patientId}/covidExam_${flag}`)
-            //   } else {
-            //     savePrescription(patientId, flag)
-            //       .then(() => {
-            //         router.push(`/unPaidList/${patientId}`)
-            //       })
-            //       .catch(() => {
-            //         showInputIdCard.value = true
-            //       })
-            //   }
-            // })
-          })
-          .catch(() => {
+            // checkCovidAssessment(flag)
+            executeSavePrescription(flag)
+          });
+    }
+
+    const checkCovidAssessment = (flag) => {
+      hasDoneCovidAssessment(patientId).then((res) => {
+        if (res === 'no') {
+          router.push(`/assessments/covid/${patientId}/covidExam_${flag}`)
+        } else {
+          executeSavePrescription(flag)
+        }
+      })
+    }
+
+    const executeSavePrescription = (flag) => {
+      savePrescription(patientId, flag)
+          .then(() => {
+            router.push(`/unPaidList/${patientId}`)
           })
     }
+
+    onMounted(() => {
+      getMultipleExamTimeLimit().then(res => {
+        timeLimit.value = res
+      })
+    })
+
     return {
       patientId,
-      showDiaglog,
-      showInputIdCard,
-      socialNo,
-      confirmChangeIdCard,
+      showTips,
+      timeLimit,
+      handleClickExamOption,
     }
   },
 }