BookableExaminations.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <window-size>
  3. <van-field v-model="searchContent" label="检索" placeholder="请输入项目名称" left-icon="search"></van-field>
  4. <van-empty v-if="examItems.length === 0" description="暂时没有可以预约的项目"></van-empty>
  5. <div v-else>
  6. <div :style="scrollStyle">
  7. <van-cell
  8. v-for="item in cptExamItems.slice((currentPage - 1) * pageSize, currentPage * pageSize)"
  9. :key="item.code"
  10. :title="item.name"
  11. is-link
  12. :value="item.execUnitName"
  13. @click="routeToSelectDate(item)"
  14. ></van-cell>
  15. </div>
  16. <van-pagination v-model="currentPage" :total-items="cptExamItems.length" :items-per-page="10" />
  17. </div>
  18. </window-size>
  19. </template>
  20. <script>
  21. import { computed, onMounted, ref } from 'vue'
  22. import { getBookableData } from '../../../api/bookable'
  23. import router from '../../../router'
  24. import { getPatientNameByPatientId } from '../../../utils/check-patient-id'
  25. import store from '../../../store'
  26. export default {
  27. setup() {
  28. const windowSize = store.state.windowSize
  29. const scrollStyle = {
  30. marginTop: '4px',
  31. height: windowSize.h - 140 + 'px',
  32. overflowY: 'auto',
  33. }
  34. const currentPage = ref(1)
  35. const pageSize = 20
  36. const flag = router.currentRoute.value.params.flag
  37. const patientId = router.currentRoute.value.params.patientId
  38. const tableName = flag === 'jc' ? 'jc_zd_item' : 'jy_zd_item'
  39. const searchContent = ref('')
  40. const examItems = ref([])
  41. const cptExamItems = computed(() => {
  42. return examItems.value.filter((item) => {
  43. return item.name.indexOf(searchContent.value) !== -1
  44. })
  45. })
  46. const routeToSelectDate = (item) => {
  47. item.patientId = patientId
  48. item.patientName = getPatientNameByPatientId(patientId)
  49. item.tableName = tableName
  50. store.commit('SET_CURRENTBOOK', item)
  51. router.push('/selectBookDate')
  52. }
  53. onMounted(() => {
  54. getBookableData(tableName).then((res) => {
  55. console.log(res)
  56. examItems.value = res
  57. })
  58. })
  59. return {
  60. scrollStyle,
  61. currentPage,
  62. pageSize,
  63. searchContent,
  64. examItems,
  65. cptExamItems,
  66. routeToSelectDate,
  67. }
  68. },
  69. }
  70. </script>