GuideContent.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <script setup lang="ts">
  2. import { defaultMessageRender } from '@/modules/chat/config';
  3. import { useWatcher } from 'alova/client';
  4. import { guideDepartments, guideDoctors } from '@/request/api';
  5. import { useGuideStore } from '@/stores';
  6. const { content } = defineProps<{ content: string }>();
  7. const markdown = computed(() => defaultMessageRender(content));
  8. const Guide = useGuideStore();
  9. const { session } = storeToRefs(Guide);
  10. const activeKey = ref<Array<'departments' | 'doctors'>>([]);
  11. const { data: departments } = useWatcher(() => guideDepartments(content, { session_id: session.value }), [() => content], {
  12. immediate: true,
  13. initialData: [],
  14. }).onSuccess(({ data }) => {
  15. if (data.length > 0) activeKey.value.push('departments');
  16. });
  17. const { data: doctors } = useWatcher(() => guideDoctors(content, { session_id: session.value }), [() => content], {
  18. immediate: true,
  19. initialData: [],
  20. }).onSuccess(({ data }) => {
  21. if (data.length > 0) activeKey.value.push('doctors');
  22. });
  23. const open = (url: string) => {
  24. if (url) window.open(url);
  25. }
  26. </script>
  27. <template>
  28. <div>
  29. <component :is="markdown"></component>
  30. <a-collapse class="recommended-wrapper" v-model:activeKey="activeKey">
  31. <a-collapse-panel key="doctors" header="中医专家推荐" :collapsible="doctors.length ? 'header' : 'disabled'">
  32. <div v-for="doctor in doctors" :key="doctor.id" class="doctor">
  33. <div class="row">
  34. <a-space>
  35. <a-avatar :src="doctor.avatar" style="color: #f56a00; background-color: #fde3cf">
  36. {{ doctor.name?.slice(0, 1) }}
  37. </a-avatar>
  38. <span>{{ doctor.name }}</span>
  39. <span v-if="doctor?.department?.name">{{ doctor.department.name }}</span>
  40. </a-space>
  41. <div>
  42. <a-button v-if="doctor.registerLink" type="primary" @click="open(doctor.registerLink)">预约</a-button>
  43. </div>
  44. </div>
  45. <div>
  46. <a-tag color="pink" v-if="doctor.titleOfClinical">{{ doctor.titleOfClinical }}</a-tag>
  47. <a-tag color="cyan" v-if="doctor.titleOfTeach">{{ doctor.titleOfTeach }}</a-tag>
  48. <a-tag color="purple" v-if="doctor.titleOf">{{ doctor.titleOf }}</a-tag>
  49. </div>
  50. <div class="van-multi-ellipsis--l3">
  51. <span v-if="doctor.description">{{ doctor.description }}</span>
  52. <span v-if="doctor.adeptAt">{{ doctor.adeptAt }}</span>
  53. </div>
  54. </div>
  55. </a-collapse-panel>
  56. <a-collapse-panel key="departments" header="中医科室推荐" :collapsible="departments.length ? 'header' : 'disabled'">
  57. <div v-for="department in departments" :key="department.id" class="department">
  58. <div class="row">
  59. <a-space>
  60. <a-avatar :src="department.avatar" style="color: #7265e6; background-color: #fde3cf">
  61. {{ department.name?.slice(0, 2) }}
  62. </a-avatar>
  63. <span>{{ department.name }}</span>
  64. </a-space>
  65. <div>
  66. <a-button v-if="department.registerLink" type="primary" @click="open(department.registerLink)">预约</a-button>
  67. </div>
  68. </div>
  69. <div class="van-multi-ellipsis--l3" v-if="department.description">
  70. <span>{{ department.description }}</span>
  71. </div>
  72. </div>
  73. </a-collapse-panel>
  74. </a-collapse>
  75. </div>
  76. </template>
  77. <style scoped lang="scss">
  78. .recommended-wrapper {
  79. margin-top: 12px;
  80. .row {
  81. display: flex;
  82. justify-content: space-between;
  83. }
  84. :deep(.ant-collapse-header-text) {
  85. flex: auto!important;
  86. font-weight: 700;
  87. text-align: center;
  88. transform: translateX(-17px);
  89. }
  90. }
  91. .doctor {
  92. > div + div {
  93. margin-top: 8px;
  94. }
  95. & + .doctor {
  96. border-top: 1px cadetblue dashed;
  97. margin-top: 16px;
  98. padding-top: 16px;
  99. }
  100. }
  101. .department {
  102. > div + div {
  103. margin-top: 8px;
  104. }
  105. & + .department {
  106. border-top: 1px cadetblue dashed;
  107. margin-top: 16px;
  108. padding-top: 16px;
  109. }
  110. }
  111. </style>