DoctorArrangement.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. <template>
  2. <window-size>
  3. <van-grid :column-num="1" :center="false">
  4. <van-grid-item>
  5. <div style="display: flex">
  6. <van-image
  7. round
  8. fit="cover"
  9. width="60px"
  10. height="80px"
  11. :src="'data:image/png;base64,' + data.doctorInfo.portrait"
  12. />
  13. <div style="min-width: 60%">
  14. <van-cell center :title="data.doctorInfo.doctorName">
  15. <template #label>
  16. <div>{{ data.doctorInfo.deptName }}</div>
  17. <div>{{ data.doctorInfo.doctorTitle }}</div>
  18. </template>
  19. </van-cell>
  20. </div>
  21. <div>
  22. <div style="height: 5px"></div>
  23. <van-button type="primary" plain size="small" :icon="collected.icon" @click="collectAction">
  24. {{ collected.text }}
  25. </van-button>
  26. <div style="height: 5px"></div>
  27. <van-button type="primary" plain size="small" icon="qr" @click="showDoctorQrCode">二维码</van-button>
  28. </div>
  29. </div>
  30. </van-grid-item>
  31. </van-grid>
  32. <van-collapse v-model="data.activeCollapse">
  33. <van-collapse-item title="介绍" name="1">
  34. <div style="color: #333333; margin-top: 10px">简介</div>
  35. <van-text-ellipsis
  36. rows="3"
  37. :content="data.doctorInfo.introduction"
  38. expand-text="展开"
  39. collapse-text="收起"
  40. />
  41. <div style="color: #333333; margin-top: 10px">擅长</div>
  42. <van-text-ellipsis
  43. rows="3"
  44. :content="data.doctorInfo.specialty"
  45. expand-text="展开"
  46. collapse-text="收起"
  47. />
  48. </van-collapse-item>
  49. <div id="noPadding">
  50. <van-collapse-item title="挂号" name="2">
  51. <van-collapse v-model="data.activeDate" accordion>
  52. <van-collapse-item :title="getSelectDate" name="dateSelection" value="更多日期">
  53. <van-grid direction="horizontal" :column-num="7">
  54. <van-grid-item v-for="item in data.oneWeekText" :key="item" :text="'周' + item" />
  55. </van-grid>
  56. <van-grid direction="horizontal" :column-num="7">
  57. <van-grid-item v-for="(item, index) in data.nextSevenDate" :key="index">
  58. <van-badge :content="hasSource(index)" :color="badgeColor(index)">
  59. <van-button
  60. :type="getType(index)"
  61. size="small"
  62. round
  63. @click="handleClickDate(index)"
  64. :disabled="hasSource(index) === '无'"
  65. >{{ item.date }}</van-button
  66. >
  67. </van-badge>
  68. </van-grid-item>
  69. </van-grid>
  70. </van-collapse-item>
  71. </van-collapse>
  72. <div v-for="item in data.arrangements" :key="item.mzyRequestId" @click="beforeConfirmAppointment(item)">
  73. <van-cell center :title="item.ampm" is-link>
  74. <template #label>
  75. <span v-html="hasLeftNum(item.leftNum)"></span>
  76. </template>
  77. <template #default>
  78. <span style="color: orangered">¥{{ item.fee }}</span>
  79. </template>
  80. </van-cell>
  81. </div>
  82. </van-collapse-item>
  83. </div>
  84. </van-collapse>
  85. <van-popup v-model:show="data.showQr" closeable position="bottom" :style="{ height: '300px' }">
  86. <van-grid :border="false" :column-num="1">
  87. <van-grid-item>
  88. <van-image fit="fill" style="width: 240px; height: 240px" :src="data.qrcode" />
  89. <span style="color: orangered; font-size: 12px; margin-top: 5px">长按二维码识别或保存</span>
  90. </van-grid-item>
  91. </van-grid>
  92. </van-popup>
  93. <van-empty :image="empty" v-show="data.arrangements.length === 0" description="暂未获取到医生排班信息" />
  94. <van-action-sheet v-model:show="showTimeSections" title="请选择">
  95. <div style="padding: 16px 16px 30px">
  96. <van-radio-group v-model="currentAppointmentItem.apTime">
  97. <van-cell-group inset>
  98. <van-cell v-for="obj in timeSections" :title="'时段:' + obj.apValue" :value="'余号:' + obj.apLeftNum" clickable
  99. @click="currentAppointmentItem.apTime = obj.apTime;currentAppointmentItem.apValue = obj.apValue"
  100. value-class="need-padding">
  101. <template #right-icon>
  102. <van-radio :name="obj.apTime" :disabled="obj.apLeftNum === '0'"/>
  103. </template>
  104. </van-cell>
  105. </van-cell-group>
  106. </van-radio-group>
  107. <van-button style="margin-top: 20px" block type="primary" @click="toConfirmAppointment"
  108. :disabled="!currentAppointmentItem.apTime">确认</van-button>
  109. </div>
  110. </van-action-sheet>
  111. <div style="margin-top: 8px; background: white">
  112. <van-cell title="患者评价" value="查看全部" is-link @click="handleClickShowAllComments"></van-cell>
  113. <div style="margin-top: 8px" v-for="item in fewComments">
  114. <div style="position: relative; display: flex; align-items: center; font-size: 12px; padding: 0 16px">
  115. <div style="color: rgb(128,128,128)">{{ item.fuzzyName }}</div>
  116. <div style="margin-left: 8px">
  117. <van-rate
  118. v-model="item.commentLevel"
  119. :size="15"
  120. color="#ffd21e"
  121. void-icon="star"
  122. void-color="#eee"
  123. />
  124. </div>
  125. <div style="color: rgb(128,128,128); position: absolute; right: 20px">
  126. {{ item.commentTime }}
  127. </div>
  128. </div>
  129. <div style="padding: 8px 16px; font-size: 12px; color: black">
  130. {{ item.commentContent }}
  131. </div>
  132. </div>
  133. </div>
  134. <van-action-sheet v-model:show="showAllComments" title="患者评价">
  135. <van-list
  136. v-model:loading="commentLoading"
  137. :finished="allComments.finished"
  138. finished-text="没有更多了"
  139. :offset="100"
  140. @load="onCommentLoad">
  141. <div style="margin-top: 8px; border-bottom: 1px solid lightgray" v-for="item in allComments.list">
  142. <div style="position: relative; display: flex; align-items: center; font-size: 12px; padding: 0 16px">
  143. <div style="color: rgb(128,128,128)">{{ item.fuzzyName }}</div>
  144. <div style="margin-left: 8px">
  145. <van-rate
  146. v-model="item.commentLevel"
  147. :size="15"
  148. color="#ffd21e"
  149. void-icon="star"
  150. void-color="#eee"
  151. />
  152. </div>
  153. <div style="color: rgb(128,128,128); position: absolute; right: 20px">
  154. {{ item.commentTime }}
  155. </div>
  156. </div>
  157. <div style="padding: 8px 16px; font-size: 12px; color: black">
  158. {{ item.commentContent }}
  159. </div>
  160. </div>
  161. </van-list>
  162. </van-action-sheet>
  163. </window-size>
  164. </template>
  165. <script setup>
  166. import empty from '../../../assets/empty.png'
  167. import store from '../../../store'
  168. import { useRouter } from 'vue-router'
  169. import { computed, onMounted, reactive, ref } from 'vue'
  170. import {
  171. getDoctorInfo,
  172. getSourcesByDateAndDoctor,
  173. getDoctorArrangement,
  174. getDoctorQrCode,
  175. } from '../../../api/appointment'
  176. import { collectDoctor, disCollectDoctor } from '../../../api/my-collection'
  177. import { getLocalOpenId } from '../../../utils/check-patient-id'
  178. import { genTextPortrait } from '../../../utils/portrait'
  179. import { getOneWeekText, getNextSevenDate } from '../../../utils/date'
  180. import { showToast } from 'vant'
  181. import {fetchDoctorComments} from "../../../api/comment";
  182. import Cookies from 'js-cookie'
  183. const router = useRouter()
  184. const deptCode = router.currentRoute.value.params.dept
  185. const doctorCode = router.currentRoute.value.params.doctor
  186. const date = router.currentRoute.value.params.date
  187. const data = reactive({
  188. activeCollapse: ['1', '2'],
  189. activeDate: '',
  190. doctorInfo: {},
  191. arrangements: [],
  192. showQr: false,
  193. date: date,
  194. currentIndex: 0,
  195. oneWeekText: getOneWeekText(),
  196. nextSevenDate: getNextSevenDate(),
  197. nextSevenDaySources: new Array(7).fill(4001),
  198. qrcode: '',
  199. })
  200. const currentAppointmentItem = ref({})
  201. const timeSections = ref([])
  202. const showTimeSections = ref(false)
  203. const amSectionLabel = [
  204. {apTime: 'a1', apValue: '08:00-08:30'},
  205. {apTime: 'a2', apValue: '08:30-09:00'},
  206. {apTime: 'a3', apValue: '09:00-09:30'},
  207. {apTime: 'a4', apValue: '09:30-10:00'},
  208. {apTime: 'a5', apValue: '10:00-10:30'},
  209. {apTime: 'a6', apValue: '10:30-11:00'},
  210. {apTime: 'a7', apValue: '11:00-11:30'},
  211. {apTime: 'a8', apValue: '11:30-12:00'}]
  212. const pmSectionLabel = [
  213. {apTime: 'p1', apValue: '14:00-14:30'},
  214. {apTime: 'p2', apValue: '14:30-15:00'},
  215. {apTime: 'p3', apValue: '15:00-15:30'},
  216. {apTime: 'p4', apValue: '15:30-16:00'},
  217. {apTime: 'p5', apValue: '16:00-16:30'},
  218. {apTime: 'p6', apValue: '16:30-17:00'},
  219. {apTime: 'p7', apValue: '17:00-17:30'},
  220. ]
  221. const beforeConfirmAppointment = (item) => {
  222. currentAppointmentItem.value = item
  223. currentAppointmentItem.value.deptCode = Cookies.get('appointmentDeptCode')
  224. currentAppointmentItem.value.deptName = Cookies.get('appointmentDeptName')
  225. currentAppointmentItem.value.date = data.date
  226. currentAppointmentItem.value.week = weekText.value
  227. if (item.ampm !== '上午' && item.ampm !== '下午') {
  228. toConfirmAppointment()
  229. } else {
  230. timeSections.value = []
  231. const sectionLabels = item.ampm === '上午' ? amSectionLabel : pmSectionLabel
  232. sectionLabels.forEach(section => {
  233. let temp = { apTime: section.apTime, apValue: section.apValue, apLeftNum: item[section.apTime]}
  234. if (temp.apLeftNum !== null && temp.apLeftNum !== undefined) {
  235. timeSections.value.push(temp)
  236. }
  237. })
  238. showTimeSections.value = true
  239. }
  240. }
  241. const toConfirmAppointment = () => {
  242. store.commit('SET_APPOINTMENTINFO', currentAppointmentItem.value)
  243. router.push('/appointmentConfirm')
  244. }
  245. const collected = computed(() => {
  246. const icon = data.doctorInfo.collected > 0 ? 'star' : 'star-o'
  247. const text = data.doctorInfo.collected > 0 ? '已收藏' : '未收藏'
  248. return { icon, text }
  249. })
  250. const openId = getLocalOpenId()
  251. const collectAction = () => {
  252. const param = {
  253. openId,
  254. doctorCode,
  255. deptCode,
  256. }
  257. if (data.doctorInfo.collected === 0) {
  258. collectDoctor(param).then(() => {
  259. showToast({
  260. message: '已收藏',
  261. position: 'top'
  262. })
  263. getDoctorInfo(doctorCode, openId).then((res) => {
  264. data.doctorInfo = res
  265. if (!res.portrait) {
  266. data.doctorInfo.portrait = genTextPortrait(res.doctorName)
  267. }
  268. })
  269. })
  270. } else {
  271. disCollectDoctor(param).then(() => {
  272. showToast({
  273. message: '已取消收藏',
  274. position: 'top'
  275. })
  276. getDoctorInfo(doctorCode, openId).then((res) => {
  277. data.doctorInfo = res
  278. if (!res.portrait) {
  279. data.doctorInfo.portrait = genTextPortrait(res.doctorName)
  280. }
  281. })
  282. })
  283. }
  284. }
  285. const getSelectDate = computed(() => {
  286. return data.date
  287. })
  288. const getType = (index) => {
  289. return index === data.currentIndex ? 'primary' : 'default'
  290. }
  291. const hasSource = (index) => {
  292. return data.nextSevenDaySources[index] === 200 ? '有' : '无'
  293. }
  294. const badgeColor = (index) => {
  295. return data.nextSevenDaySources[index] === 200 ? 'green' : 'red'
  296. }
  297. const hasLeftNum = (val) => {
  298. return val > 0
  299. ? '<span style="font-size: 12px;color:green">有号</span>'
  300. : '<span style="font-size: 12px;color:red">无号</span>'
  301. }
  302. const weekText = ref('')
  303. const handleClickDate = (index) => {
  304. if (index > 6) {
  305. return
  306. }
  307. weekText.value = '星期' + data.oneWeekText[index]
  308. data.currentIndex = index
  309. data.date = data.nextSevenDate[index].fullDate
  310. const param = {
  311. date: data.date,
  312. deptCode: deptCode,
  313. doctorCode: doctorCode,
  314. needExcludePassedTime: true,
  315. }
  316. getDoctorArrangement(param).then((res) => {
  317. data.arrangements = res
  318. }).catch(() => {
  319. handleClickDate(++index)
  320. })
  321. }
  322. const showDoctorQrCode = () => {
  323. getDoctorQrCode(doctorCode).then((res) => {
  324. data.qrcode = res
  325. data.showQr = true
  326. })
  327. }
  328. const fewComments = ref([])
  329. const showAllComments = ref(false)
  330. const commentLoading = ref(false);
  331. const allComments = reactive({
  332. finished: false,
  333. minId: null,
  334. list: []
  335. })
  336. const handleClickShowAllComments = () => {
  337. showAllComments.value = true
  338. onCommentLoad()
  339. }
  340. const onCommentLoad = () => {
  341. if (allComments.finished) {
  342. return
  343. }
  344. fetchDoctorComments({doctorCode: doctorCode, pageSize: 20, minId: allComments.minId}).then(res => {
  345. allComments.minId = res.minId
  346. allComments.finished = res.finished
  347. allComments.list = allComments.list.concat(res.list)
  348. commentLoading.value = false;
  349. })
  350. };
  351. onMounted(() => {
  352. getDoctorInfo(doctorCode, openId).then((res) => {
  353. data.doctorInfo = res
  354. if (!res.portrait) {
  355. data.doctorInfo.portrait = genTextPortrait(res.doctorName)
  356. }
  357. })
  358. fetchDoctorComments({doctorCode}).then(res => {
  359. fewComments.value = res.list
  360. })
  361. const param = {
  362. date: data.nextSevenDate[0].fullDate,
  363. deptCode: deptCode,
  364. doctorCode: doctorCode,
  365. }
  366. getSourcesByDateAndDoctor(param).then((res) => {
  367. data.nextSevenDaySources = res
  368. for (let i = 0; i < 7; i++) {
  369. if (data.nextSevenDate[i].fullDate === date) {
  370. handleClickDate(i)
  371. }
  372. }
  373. })
  374. })
  375. </script>
  376. <style>
  377. #noPadding .van-collapse-item__content {
  378. padding: 0;
  379. }
  380. .need-padding {
  381. padding-right: 8px;
  382. }
  383. </style>