index.vue 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <div class="page_search">
  3. <van-sticky>
  4. <div class="header">
  5. <i class="iconfont icon-zuojiantou" @click="toHomeIndex"></i>
  6. <van-search
  7. v-model="value"
  8. placeholder=" 姓名 / 透析号"
  9. @search="toSearchPatient"
  10. />
  11. </div>
  12. </van-sticky>
  13. <div class="searchList">
  14. <div
  15. class="patientOne"
  16. v-for="(item, index) in patientList"
  17. :key="index"
  18. @click="toPatient(item.id)"
  19. >
  20. <img :src="item.avatar" alt />
  21. <p>{{ item.name }}</p>
  22. </div>
  23. </div>
  24. <div class="history">
  25. <div class="historyTitle">
  26. <span>历史搜索</span>
  27. <i class="iconfont icon-lajixiang" @click="deteleHistory"></i>
  28. </div>
  29. <div class="record">
  30. <ul class="recordList">
  31. <li
  32. class="recordOne"
  33. v-for="(item, index) in historyWord"
  34. :key="index"
  35. @click="toSearchPatient(item)"
  36. >
  37. {{ item }}
  38. </li>
  39. </ul>
  40. </div>
  41. </div>
  42. </div>
  43. </template>
  44. <script>
  45. import { toSearchPatient } from "@/api/patient/patient";
  46. import { setRem } from "@/libs/functionRem";
  47. export default {
  48. data() {
  49. return {
  50. searchVal: "",
  51. active: 0,
  52. keyword: "",
  53. value: "",
  54. patientList: [],
  55. historyWord: []
  56. };
  57. },
  58. methods: {
  59. toHomeIndex() {
  60. this.$router.push({ path: "/homeIndex" });
  61. },
  62. toSearchPatient(val) {
  63. let searchWord = localStorage.getItem("searchWord");
  64. if (searchWord == null) {
  65. localStorage.setItem("searchWord", val);
  66. } else {
  67. let arr = localStorage.getItem("searchWord");
  68. arr = arr.split(",");
  69. if (arr.indexOf(val) != -1) {
  70. arr = arr;
  71. } else {
  72. arr.unshift(val);
  73. }
  74. self.historyWord = arr;
  75. localStorage.setItem("searchWord", self.historyWord);
  76. }
  77. toSearchPatient(val).then(response => {
  78. if (response.data.state === 1) {
  79. var patient = response.data.data.patient;
  80. console.log("patient", patient);
  81. this.patientList = patient;
  82. this.historyWord = localStorage.getItem("searchWord");
  83. this.historyWord = this.historyWord.split(",");
  84. }
  85. });
  86. },
  87. toPatient(id) {
  88. this.$router.push({ path: "/patientdetail?patientid=" + id });
  89. },
  90. deteleHistory() {
  91. this.historyWord = [];
  92. localStorage.removeItem("searchWord");
  93. }
  94. },
  95. created() {
  96. setRem()
  97. this.historyWord = localStorage.getItem("searchWord");
  98. this.historyWord = this.historyWord.split(","); // 将字符串转成数组
  99. }
  100. };
  101. </script>
  102. <style lang="scss" scoped>
  103. .page_search {
  104. overflow: hidden;
  105. overflow-y: auto;
  106. height: 100%;
  107. .header {
  108. height: 2.5rem;
  109. width: 100%;
  110. line-height: 2.5rem;
  111. border-bottom: 1px solid #f4f4f4;
  112. display: flex;
  113. align-items: center;
  114. background: #fff;
  115. .icon-zuojiantou {
  116. float: left;
  117. width: 2.5rem;
  118. height: 2.5rem;
  119. text-align: center;
  120. font-size: 1rem;
  121. }
  122. .van-search {
  123. padding: 0;
  124. width: 80%;
  125. }
  126. .van-search__content {
  127. border-radius: 0.9375rem;
  128. }
  129. .van-search .van-cell {
  130. display: flex;
  131. align-items: center;
  132. }
  133. }
  134. .history {
  135. padding: 1.25rem 0.75rem 0 0.875rem;
  136. .historyTitle {
  137. height: 1.25rem;
  138. line-height: 1.25rem;
  139. i {
  140. float: right;
  141. font-size: 1.625rem;
  142. color: #9b9b9b;
  143. }
  144. span {
  145. float: left;
  146. font-size: 0.9375rem;
  147. color: rgba(60, 60, 60, 1);
  148. }
  149. }
  150. }
  151. .record {
  152. margin-top: 1.25rem;
  153. .recordList {
  154. display: flex;
  155. flex-wrap: wrap;
  156. }
  157. .recordOne {
  158. min-width: 0.0625rem;
  159. background: rgba(244, 244, 244, 1);
  160. border-radius: 14px;
  161. color: rgba(155, 155, 155, 1);
  162. font-size: 0.875rem;
  163. padding: 0.4375rem 0.875rem;
  164. margin-right: 0.625rem;
  165. box-sizing: border-box;
  166. margin-bottom: 0.625rem;
  167. }
  168. }
  169. .searchList {
  170. padding: 0 0.875rem;
  171. .patientOne {
  172. display: flex;
  173. align-items: center;
  174. height: 3.75rem;
  175. img {
  176. width: 2.5rem;
  177. height: 2.5rem;
  178. margin-right: 0.875rem;
  179. }
  180. p {
  181. flex: 1;
  182. height: 100%;
  183. line-height: 3.75rem;
  184. box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.1);
  185. }
  186. }
  187. }
  188. }
  189. ::-webkit-scrollbar {
  190. width: 0;
  191. }
  192. </style>