BookExam.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <div v-show="showTips" class="tip-wrapper">
  3. <div class="tip-box">
  4. <div class="tip-title">请仔细阅读以下内容:</div>
  5. <div class="tip-body">
  6. <div v-for="(tip, index) in bookTips" :key="index">
  7. <p>
  8. {{ tip }}
  9. </p>
  10. <div class="tip-divide"></div>
  11. </div>
  12. </div>
  13. <div class="tip-footer">
  14. <div style="height: 8px"></div>
  15. <van-button block type="primary" size="small" :disabled="disableFinish" @click="executeBook">
  16. 确认预约<span v-show="disableFinish">({{ countdown }})</span>
  17. </van-button>
  18. <div style="height: 8px"></div>
  19. <van-button block type="primary" plain size="small" @click="cancelBook"> 取消预约 </van-button>
  20. </div>
  21. </div>
  22. </div>
  23. <window-size>
  24. <van-cell title="项目名称" :value="bookItem.name"></van-cell>
  25. <van-cell title="执行科室" :value="bookItem.execUnitName"></van-cell>
  26. <van-cell title="预约人" :value="bookItem.patientName"></van-cell>
  27. <van-cell title="预约日期" :value="bookItem.recordDate"></van-cell>
  28. <van-cell title="预约时间段" :value="bookItem.beginTime + ' - ' + bookItem.endTime"></van-cell>
  29. <div style="height: 8px"></div>
  30. <van-button block type="primary" icon="passed" @click="beforeExecuteBook">执行预约</van-button>
  31. </window-size>
  32. </template>
  33. <script setup>
  34. import { showToast } from 'vant'
  35. import { getBookTip, saveBookPrescription } from '../../../api/bookable'
  36. import router from '../../../router'
  37. import store from '../../../store'
  38. import { computed, ref } from 'vue'
  39. const bookItem = store.state.currentBook
  40. const bookTips = ref([])
  41. const showTips = ref(false)
  42. const countdown = ref(0)
  43. const disableFinish = computed(() => {
  44. return countdown.value > 0
  45. })
  46. const executeCountdown = () => {
  47. setTimeout(() => {
  48. countdown.value--
  49. if (countdown.value > 0) {
  50. executeCountdown()
  51. }
  52. }, 1000)
  53. }
  54. const beforeExecuteBook = () => {
  55. getBookTip(bookItem.tableName, bookItem.code).then((res) => {
  56. if (res) {
  57. bookTips.value = res
  58. countdown.value = 15
  59. showTips.value = true
  60. executeCountdown()
  61. } else {
  62. executeBook()
  63. }
  64. })
  65. }
  66. const executeBook = () => {
  67. showTips.value = false
  68. saveBookPrescription(bookItem).then((res) => {
  69. store.commit('SET_YJREQNO', res)
  70. showToast({
  71. message: '自助开单成功。',
  72. position: 'top',
  73. });
  74. router.push('/unPaidList/' + bookItem.patientId)
  75. })
  76. }
  77. const cancelBook = () => {
  78. showTips.value = false
  79. countdown.value = 0
  80. router.go(-2)
  81. }
  82. </script>
  83. <style scoped>
  84. .tip-wrapper {
  85. z-index: 3000;
  86. position: fixed;
  87. left: 0;
  88. right: 0;
  89. top: 0;
  90. bottom: 0;
  91. background: rgba(0, 0, 0, 0.5);
  92. }
  93. .tip-box {
  94. position: fixed;
  95. width: calc(80% - 30px);
  96. height: calc(80% - 20px);
  97. left: 10%;
  98. top: 10%;
  99. background: white;
  100. border-radius: 10px;
  101. padding: 10px 10px 10px 20px;
  102. }
  103. .tip-title {
  104. font-size: 20px;
  105. font-weight: bold;
  106. height: 32px;
  107. line-height: 32px;
  108. }
  109. .tip-body {
  110. margin-top: 10px;
  111. height: calc(100% - 150px);
  112. overflow-y: auto;
  113. }
  114. .tip-body p {
  115. padding-right: 10px;
  116. }
  117. .tip-divide {
  118. width: calc(100% - 10px);
  119. height: 1px;
  120. margin: 5px 0;
  121. border-bottom: 1px dashed rgb(128, 128, 128);
  122. }
  123. .tip-footer {
  124. margin-top: 10px;
  125. }
  126. </style>