deptList.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <view class="container">
  3. <view class="content">
  4. <view class="search">
  5. <view class="search_box">
  6. <input :class="[isFocus ? 'search_input' : 'search_input_none']"
  7. placeholder="搜索科室名称"
  8. :placeholder-class="isFocus ? 'placeholder' : 'placeholder_none'"
  9. v-model="searchValue"
  10. @focus="focusFn('focus')" />
  11. <image :class="['search_icon', isFocus ? 'search_icon_none' : '']" :src="iconUrl.search"></image>
  12. <image class="remove_icon" v-if="isFocus" :src="iconUrl.cha" @click.stop="focusFn('blur')"></image>
  13. <view v-if="isFocus" :class="['search_confirm', 'backgroundCustom_F08', isFocus ? 'search_confirm_active' : '']" @click="searchClick">搜索</view>
  14. </view>
  15. </view>
  16. </view>
  17. <view class="dept_list">
  18. <view class="dept_list_inner" v-if="deptList.length > 0">
  19. <view :class="['dept_list_fir', (deptListIndex >= 0 && deptList[deptListIndex]?.Data_1?.length > 0) ? 'dept_list_fir_short' : '']">
  20. <view :class="['dept_item', index == deptListIndex ? 'dept_item_active colorCustom' : '', index == deptListIndex - 1 ? 'toBoderRadio' : '']"
  21. v-for="(item, index) in deptList" :key="index"
  22. @click="deptClick('fir', item, index)">
  23. <view class="dept_item_inner border_bottom">
  24. {{item.DeptName}}
  25. </view>
  26. </view>
  27. </view>
  28. <view class="dept_list_sec" v-if="deptListIndex >= 0 && deptList[deptListIndex]?.Data_1?.length > 0">
  29. <view class="dept_item border_bottom"
  30. v-for="(item, index) in deptList[deptListIndex].Data_1" :key="index"
  31. @click="deptClick('sec', item, index)">
  32. {{item.DeptName}}
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. <view v-if="deptList.length == 0" class="noData">
  38. <noData value="暂无数据"></noData>
  39. </view>
  40. </view>
  41. </template>
  42. <script setup lang="ts">
  43. import { ref } from 'vue';
  44. import { onLoad } from '@dcloudio/uni-app';
  45. import { common } from '@/utils';
  46. import icon from '@/utils/icon';
  47. import { queryBaseDeptTreeV2 } from '@/pagesPatient/service/new/index';
  48. import noData from '@/pages/st1/components/noData/noData.vue';
  49. const iconUrl = icon;
  50. const isFocus = ref(false);
  51. const searchValue = ref('');
  52. const queDeptList = ref<any[]>([]);
  53. const deptList = ref<any[]>([]);
  54. const deptListIndex = ref(-1);
  55. const app = getApp();
  56. onLoad((options) => {
  57. main();
  58. });
  59. const main = async () => {
  60. let queryData = {
  61. HospitalId: app.globalData?.districtId || app.globalData?.hosId,
  62. IsQueryUserSize: true,
  63. StatusList: "0,1"
  64. };
  65. let resp = await queryBaseDeptTreeV2(queryData);
  66. if (!common.isEmpty(resp)) {
  67. queDeptList.value = resp;
  68. deptList.value = resp;
  69. deptListIndex.value = 0;
  70. }
  71. };
  72. const deptClick = (type: string, item: any, index: number) => {
  73. let qb = encodeURIComponent(JSON.stringify(item));
  74. let url = "";
  75. if (type == 'fir') {
  76. deptListIndex.value = index;
  77. if (common.isEmpty(item.Data_1)) {
  78. url = `/pagesPatient/st1/business/news/deptDetails/deptDetails?queryBean=${qb}`;
  79. }
  80. } else if (type == 'sec') {
  81. url = `/pagesPatient/st1/business/news/deptDetails/deptDetails?queryBean=${qb}`;
  82. }
  83. if (!common.isEmpty(url)) {
  84. common.goToUrl(url);
  85. }
  86. };
  87. const searchClick = () => {
  88. if (common.isEmpty(searchValue.value)) {
  89. common.showModal('请输入搜索科室');
  90. return;
  91. }
  92. let tempDeptList: any[] = [];
  93. let tempQueDeptList = common.deepCopy(queDeptList.value, []);
  94. tempQueDeptList.map((item: any) => {
  95. let data_1: any[] = [];
  96. let has = false;
  97. if (common.isNotEmpty(item.Data_1)) {
  98. item.Data_1.map((ele: any) => {
  99. if (ele.DeptName.indexOf(searchValue.value) != -1) {
  100. has = true;
  101. data_1.push(ele);
  102. }
  103. });
  104. }
  105. if (item.DeptName.indexOf(searchValue.value) != -1) {
  106. has = true;
  107. }
  108. if (has) {
  109. item.Data_1 = data_1;
  110. tempDeptList.push(item);
  111. }
  112. });
  113. deptList.value = tempDeptList;
  114. deptListIndex.value = -1;
  115. };
  116. const focusFn = (type: string) => {
  117. if (type === 'focus') {
  118. isFocus.value = true;
  119. } else {
  120. isFocus.value = false;
  121. searchValue.value = '';
  122. deptList.value = queDeptList.value;
  123. deptListIndex.value = -1;
  124. }
  125. };
  126. </script>
  127. <style lang="scss" scoped>
  128. @import '@/pagesPatient/st1/static/css/search.wxss';
  129. .content {
  130. padding-top: 110upx;
  131. position: relative;
  132. z-index: 10;
  133. }
  134. .dept_list {
  135. width: 100%;
  136. position: absolute;
  137. top: 0;
  138. left: 0;
  139. width: 100%;
  140. height: 95%;
  141. padding: 140upx 30upx 0;
  142. }
  143. .dept_list_inner {
  144. display: flex;
  145. align-items: center;
  146. justify-content: space-between;
  147. overflow: hidden;
  148. border-radius: 24upx ;
  149. height: 100%;
  150. }
  151. .dept_list_fir {
  152. height: 100%;
  153. overflow: auto;
  154. width: 100%;
  155. -webkit-overflow-scrolling: touch;
  156. background-color: #fff;
  157. }
  158. .dept_list_fir_short {
  159. max-width: 316upx;
  160. }
  161. .dept_list_fir_short .dept_item {
  162. background: #F7F7FC;
  163. }
  164. .dept_list_sec {
  165. height: 100%;
  166. overflow: auto;
  167. -webkit-overflow-scrolling: touch;
  168. width: 410upx;
  169. background-color: #fff;
  170. }
  171. .dept_list_sec .dept_item {
  172. text-indent: 30upx;
  173. display: flex;
  174. align-items: center;
  175. justify-content: start;
  176. padding: 34upx 0 34upx 30upx;
  177. line-height: 44upx;
  178. }
  179. .dept_item {
  180. font-size: 28upx;
  181. position: relative;
  182. color: #222326;
  183. padding-left: 30upx;
  184. padding-right: 30upx;
  185. }
  186. .dept_item_inner {
  187. padding: 34upx 0;
  188. line-height: 44upx;
  189. }
  190. .dept_item_active {
  191. font-size: 32upx;
  192. font-weight: bold;
  193. }
  194. .dept_list_fir_short .dept_item_active {
  195. background-color: #fff;
  196. }
  197. .dept_list_fir_short .dept_item_active + .dept_item {
  198. border-radius: 0 30upx 0 0 ;
  199. }
  200. .toBoderRadio{
  201. border-radius: 0 0 30upx 0;
  202. }
  203. </style>