homeSearch.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <template>
  2. <view class="container">
  3. <view class="content">
  4. <view class="search">
  5. <view class="search_box">
  6. <input class="search_input" :focus="true" placeholder="请输入医生姓名/科室/服务名称"
  7. placeholder-class="placeholder" v-model="searchValue" />
  8. <image class="search_icon " :src="iconUrl.search"></image>
  9. <image class="remove_icon " v-if="searchValue.length > 0" :src="iconUrl.cha" @click.stop="focusFn">
  10. </image>
  11. <view class="search_confirm backgroundCustom_F08 search_confirm_active" @click="searchClick">搜索</view>
  12. </view>
  13. </view>
  14. <view class="content_inner">
  15. <!-- 医生 -->
  16. <template v-if="doctorList.length > 0">
  17. <view class="floot doctor">
  18. <view class="floot_title">医生</view>
  19. <view class="floot_box doctorBox displayFlexLeft">
  20. <view class="doctorBox_item" v-for="(item, index) in doctorList" :key="index"
  21. @click="clickDoctor" :data-item="item">{{ item.DoctorName + " " + item.DeptName }}
  22. </view>
  23. </view>
  24. </view>
  25. </template>
  26. <!-- 科室 -->
  27. <template v-if="deptList.length > 0">
  28. <view class="floot doctor">
  29. <view class="floot_title">科室</view>
  30. <view class="floot_box doctorBox displayFlexLeft">
  31. <view class="doctorBox_item" v-for="(item, index) in deptList" :key="index"
  32. @click="clickDept" :data-item="item">{{ item.DeptName }}</view>
  33. </view>
  34. </view>
  35. </template>
  36. <!-- 功能 -->
  37. <template v-if="menuList.length > 0">
  38. <view class=" menuServices_box">
  39. <view class="floot_title">就医服务</view>
  40. <view class="floot_box displayFlexLeft">
  41. <view class="menuList displayFlexCol" v-for="(item, index) in menuList" :key="index"
  42. :data-item="item" @click="menuClickFn">
  43. <image class="menuIcon" :src="item.Icon" mode="heightFix"></image>
  44. <text class="menuText">{{ item.MenuName }}</text>
  45. </view>
  46. </view>
  47. </view>
  48. </template>
  49. </view>
  50. <view v-if="doctorList.length == 0 && deptList.length == 0 && menuList.length == 0" class="noData">
  51. <noData :value="'暂无搜索记录'"></noData>
  52. </view>
  53. </view>
  54. </view>
  55. </template>
  56. <script lang="ts" setup>
  57. import { getCurrentInstance, nextTick, ref } from 'vue';
  58. import { useIsToAuthPage, useGetDefaultMember } from '../../../../../hook';
  59. import { onShow, onPullDownRefresh } from '@dcloudio/uni-app';
  60. import { common, menuClick } from '@/utils';
  61. import icon from '@/utils/icon';
  62. import store from '@/store';
  63. import { searchClinicDeptAndDoctor } from '../../../service/base';
  64. import noData from '@/pages/st1/components/noData/noData.vue'
  65. const { proxy } = getCurrentInstance();
  66. const app = getApp();
  67. const iconUrl = ref(icon)
  68. const searchValue = ref("")
  69. const doctorList = ref([])
  70. const deptList = ref([])
  71. const menuList = ref([])
  72. /** 清空查询 */
  73. const focusFn = () => {
  74. searchValue.value = ''
  75. menuList.value = []
  76. doctorList.value = []
  77. deptList.value = []
  78. }
  79. /** 点击搜索 */
  80. const searchClick = async () => {
  81. let pageConfig = common.deepCopy(app.globalData.config.pageConfiguration.yyghDeptList_config)
  82. let searchValueData = searchValue.value;
  83. if (common.isEmpty(searchValueData)) {
  84. common.showToast('请输入医生姓名/科室/服务名称')
  85. return
  86. }
  87. let menuListData = uni.getStorageSync('menuList')
  88. let doctorListData = [], deptListData = [];
  89. // 获取医生或者科室
  90. let queryData = {
  91. HosId: app.globalData.districtId || app.globalData.hosId,
  92. SearchLike: searchValueData,
  93. QueryLocal: "1",
  94. UseBaseInfo: true,
  95. ExcludeOneLv: pageConfig.showDeptSec ? 1 : 0,// 是否过滤一级科室,
  96. }
  97. let { resp } = await searchClinicDeptAndDoctor(queryData)
  98. if (!common.isEmpty(resp)) {
  99. doctorListData = resp.filter(item => item.SearchType != '1') // 过滤医生
  100. deptListData = resp.filter(item => item.SearchType == '1') // 过滤科室
  101. }
  102. // 获取功能菜单
  103. if (common.isNotEmpty(menuListData)) {
  104. //遍历成独立的数组
  105. const childArray = getAllChildren(menuListData.map(item => item.Children));
  106. console.log('childArray================', childArray,searchValueData)
  107. // 过滤搜索条件不满足的
  108. menuListData = childArray.filter(item => item.MenuName && item.MenuName.indexOf(searchValueData) != -1 && item.IsShow == 1 && common.isNotEmpty(item.Url))
  109. // 去重相同条件的
  110. menuListData = common.unique(menuListData, 'MenuName')
  111. }
  112. console.log('menuListData================', menuListData)
  113. menuList.value = menuListData
  114. doctorList.value = doctorListData
  115. deptList.value = deptListData
  116. }
  117. /** 菜单数组处理 */
  118. const getAllChildren = (arr) => {
  119. return arr.flatMap(item => {
  120. if (Array.isArray(item)) {
  121. return getAllChildren(item);
  122. } else if (item.Children) {
  123. return [item, ...getAllChildren(item.Children)];
  124. } else {
  125. return [item];
  126. }
  127. });
  128. }
  129. /** 就医服务点击 */
  130. const menuClickFn = (e) => {
  131. menuClick(e, proxy)
  132. }
  133. /** 医生点击 */
  134. const clickDoctor = async (e) => {
  135. app.globalData.queryBean = e.currentTarget.dataset.item;
  136. let url = `/pagesPatient/st1/business/yygh/yyghClinicMsg/yyghClinicMsg`;
  137. /**跳转到挂号页面 需要判断就诊人 和公众号授权*/
  138. if (useIsToAuthPage()) {
  139. return;
  140. }
  141. // 获取当前设置的患者信息 判断是否可以无卡预约 取不同的值允许无卡预约或者默认就诊人信息 否者获取就诊卡信息,如当前默认就诊人无就诊卡,跳转选卡界面
  142. let lastOperatorResp = await useGetDefaultMember({
  143. cardType: app.globalData.withoutCard ? '' : '1',
  144. url: url,
  145. isKeepPage: true,
  146. })
  147. // 判断返回的操作人为null 代表跳转选择界面了
  148. if (lastOperatorResp === null) return
  149. if (common.isEmpty(lastOperatorResp)) {
  150. app.globalData.toUrl = url; //保存添加成功后跳转地址
  151. app.globalData.cardType = app.globalData.withoutCard ? '' : '1' //保存添加成功,要查询的默认人信息
  152. url = `/pagesPersonal/st1/business/patientManagement/addMember/addMember`
  153. }
  154. common.goToUrl(url)
  155. }
  156. /** 医生科室 */
  157. const clickDept = (e) => {
  158. app.globalData.queryBean = e.currentTarget.dataset.item
  159. common.goToUrl(`/pagesPatient/st1/business/yygh/yyghDoctorList/yyghDoctorList`)
  160. }
  161. </script>
  162. <style lang="scss" scoped>
  163. .container,
  164. .content {
  165. background-color: #fff;
  166. }
  167. /* 搜索框 */
  168. .search {
  169. position: fixed;
  170. z-index: 2;
  171. height: 110upx;
  172. width: 100%;
  173. padding: 0 30upx 20upx;
  174. top: 0;
  175. left: 0;
  176. background-color: #fff;
  177. display: flex;
  178. align-items: center;
  179. justify-content: space-between;
  180. }
  181. .search_box {
  182. width: 100%;
  183. margin-top: 10upx;
  184. display: flex;
  185. flex-direction: row;
  186. justify-content: flex-start;
  187. align-items: center;
  188. position: relative;
  189. z-index: 10;
  190. }
  191. .search_input {
  192. width: 660upx;
  193. height: 72upx;
  194. border-radius: 36px;
  195. font-size: 28upx;
  196. color: #333 !important;
  197. background: #F1F1F6;
  198. margin-right: 24upx;
  199. padding-left: 65upx;
  200. padding-right: 158upx;
  201. }
  202. .search_icon {
  203. width: 26upx;
  204. height: 26upx;
  205. position: absolute;
  206. top: 33%;
  207. left: 20upx;
  208. }
  209. .remove_icon {
  210. width: 36upx;
  211. height: 36upx;
  212. position: absolute;
  213. top: 28%;
  214. right: 128upx;
  215. z-index: 50;
  216. }
  217. .search_confirm {
  218. width: 110upx;
  219. font-size: 28upx;
  220. border-radius: 33px;
  221. line-height: 65upx;
  222. text-align: center;
  223. transition: all 0.3s;
  224. position: absolute;
  225. right: 0;
  226. border: 4upx solid #fff;
  227. }
  228. .content_inner {
  229. margin-top: 110upx;
  230. }
  231. .floot {
  232. margin: 30upx;
  233. }
  234. .floot_title {
  235. font-size: 28upx;
  236. font-family: PingFang SC;
  237. font-weight: bold;
  238. color: #222326;
  239. padding: 20upx 0 30upx;
  240. }
  241. .doctorBox_item {
  242. background: #F7F7FA;
  243. border-radius: 28upx;
  244. font-size: 24upx;
  245. font-family: PingFang SC;
  246. color: #62626D;
  247. padding: 17upx 33upx;
  248. margin: 0 16upx 16upx 0;
  249. }
  250. .menuServices_box .floot_title {
  251. margin: 0 30upx;
  252. }
  253. .menuServices_box .menuList {
  254. width: 25%;
  255. margin-bottom: 36upx;
  256. }
  257. .menuServices_box .menuIcon {
  258. width: 78upx;
  259. height: 84upx;
  260. margin-bottom: 20upx;
  261. }
  262. .menuServices_box .menuText {
  263. font-size: 26upx;
  264. font-family: PingFang SC;
  265. color: #222326;
  266. }
  267. </style>