Search.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template>
  2. <portal to="notification-search">
  3. <div class="searchWrap">
  4. <div class="searchTop">
  5. <div class="iptWrap">
  6. <img
  7. class="searchImg"
  8. src="../images/search.png"
  9. alt=""
  10. >
  11. <input
  12. type="text"
  13. autofocus
  14. placeholder="请搜索"
  15. v-model="searchVal"
  16. >
  17. </div>
  18. <span @click="search">取消</span>
  19. </div>
  20. <div class="searchList">
  21. <!--<p
  22. class="waring"
  23. v-if="!searchVal&&!hasMore&&searchLis.length==0"
  24. >请输入搜索内容</p>-->
  25. <div
  26. class="waring"
  27. v-if="hasMore&&searchVal"
  28. >
  29. <img src="../images/empty.png" alt=""/>
  30. <p>暂无搜索结果</p>
  31. </div>
  32. <ul>
  33. <li
  34. v-for="(item,idx) in searchLis"
  35. :key="item.conceptId+idx"
  36. @click="showDetil(item)"
  37. :style="{'borderBottom':(idx==searchLis.length-1)?'0':'1px solid #E8E8E8'}"
  38. ><img
  39. class="searchImgLis"
  40. src="../images/search.png"
  41. alt=""
  42. >{{item.description||item.name}}{{(item.tagName&&(item.description||item.name != item.tagName))?' ('+item.tagName+')':''}}</li>
  43. </ul>
  44. </div>
  45. </div>
  46. </portal>
  47. </template>
  48. <script>
  49. import api from '@utils/api.js';
  50. import {mapState} from 'vuex';
  51. export default {
  52. data() {
  53. return {
  54. searchVal: '',
  55. searchLis: [],
  56. tmpItem:{},
  57. hasMore:false
  58. }
  59. },
  60. computed:{
  61. ...mapState({
  62. //chooseSymp: state => state.symptom.choose,//已选症状
  63. pathInfo: state => state.pathInfo
  64. }),
  65. },
  66. watch:{
  67. searchVal(curVal, oldVal) {
  68. if (curVal.trim() == "") {
  69. this.searchVal = "";
  70. this.searchLis = [];
  71. this.hasMore = false
  72. return;
  73. }
  74. if (curVal != "" && curVal != oldVal) {
  75. this.searchList()
  76. }
  77. }
  78. },
  79. methods: {
  80. showDetil(item) {
  81. /*let flg = false;
  82. if(JSON.stringify(this.tmpItem)==JSON.stringify(item)){//eg:重复点击胸痛bug
  83. flg = true
  84. }
  85. this.tmpItem = item
  86. if(this.chooseSymp.length == 0){
  87. item.idx = 1
  88. }*/
  89. let timer = setTimeout(() => {
  90. this.$emit('showDetil',item);
  91. let obj = {
  92. "labelName": item.tagName||item.name,//标签名称
  93. "operationNum": 1,//次数
  94. "operationType": 2,//1常见2搜索
  95. };
  96. this.$store.commit('setText', { type: 1, text: '患者出现'+item.name,textP: '患者出现'+(item.description||item.name), pId: item.questionId,idx:'' });
  97. this.$store.commit('addBuriedSome', obj);
  98. clearTimeout(timer)
  99. }, 250);
  100. // this.$emit('search', false)
  101. },
  102. search() {
  103. this.$emit('search', false)
  104. },
  105. searchList() {
  106. let tmpArr = []/*, chooseSymp = this.chooseSymp*/;
  107. /*for (let i = 0; i < chooseSymp.length; i++) {
  108. if(chooseSymp[i].conceptId){
  109. tmpArr.push(chooseSymp[i].conceptId)
  110. }
  111. }*/
  112. const param = {
  113. "age": this.pathInfo.patientAge,
  114. "inputIds": [],
  115. "inputStr": this.searchVal,
  116. "sexType": this.pathInfo.sexType
  117. }
  118. api.getTagInfos(param).then((res) => {
  119. const result = res.data;
  120. if (result.code == 0) {
  121. this.searchLis = result.data
  122. if(result.data.length>0){
  123. this.hasMore = false
  124. }else{
  125. this.hasMore = true
  126. }
  127. }
  128. })
  129. }
  130. }
  131. }
  132. </script>
  133. <style lang="less" scoped>
  134. .searchWrap {
  135. position: fixed;
  136. height: 100%;
  137. width: 100%;
  138. top: 0;
  139. left: 0;
  140. z-index: 102;
  141. font-size: .3rem;
  142. overflow: hidden;
  143. }
  144. .searchTop {
  145. padding: 0.4rem 0.4rem 0.15rem;
  146. padding-right: 1.2rem;
  147. box-sizing: border-box;
  148. position: absolute;
  149. width: 100%;
  150. top: 0;
  151. z-index: 999;
  152. span {
  153. position: absolute;
  154. right: 0.32rem;
  155. top: 0.54rem;
  156. font-size: 0.24rem;
  157. color: #666666;
  158. }
  159. }
  160. .iptWrap {
  161. height: 0.68rem;
  162. border-radius: 0.37rem;
  163. background-color: #F5F5F5;
  164. overflow: hidden;
  165. padding: 0.16rem 0.3rem 0.16rem 0.75rem;
  166. box-sizing: border-box;
  167. width: 100%;
  168. position: relative;
  169. .searchImg {
  170. width: 0.44rem;
  171. height: 0.44rem;
  172. position: absolute;
  173. left: 0.2rem;
  174. top: 0.14rem;
  175. }
  176. input {
  177. width: 100%;
  178. height: 0.42rem;
  179. font-size: 0.24rem;
  180. line-height: 0.42rem;
  181. background: #F5F5F5;
  182. }
  183. }
  184. .searchList {
  185. overflow: scroll;
  186. position: absolute;
  187. -webkit-overflow-scrolling: touch;
  188. top: 0;
  189. left: 0;
  190. padding-top: 1.04rem;
  191. height: 100%;
  192. width: 100%;
  193. background-color: #fff;
  194. .waring {
  195. width: 100%;
  196. text-align: center;
  197. margin-top: 1.6rem;
  198. p{
  199. color: #aaa;
  200. margin-top: .8rem;
  201. font-size: .24rem;
  202. }
  203. }
  204. ul {
  205. padding: 0.2rem 0.2rem 0;
  206. box-sizing: border-box;
  207. background-color: #fff;
  208. }
  209. li {
  210. height: 1rem;
  211. line-height: 1rem;
  212. padding: 0 0.4rem;
  213. border-bottom: 1px solid #E8E8E8;
  214. box-sizing: border-box;
  215. .searchImgLis {
  216. width: 0.44rem;
  217. height: 0.44rem;
  218. float: left;
  219. margin-top: 0.26rem;
  220. margin-right: 0.15rem;
  221. }
  222. }
  223. }
  224. </style>