home.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <script>
  2. import TopSearchShow from "./components/topSearchShow/index.vue";
  3. import ContentMenu from "./components/contentMenu/index.vue";
  4. import PromiseList from "../components/promiseList/index.vue";
  5. import EnterPriseList from "./components/enterpriseList/index.vue";
  6. import TemplateList from "./components/templateList/index.vue";
  7. import RecentlySearch from "./components/recentlySearch/index.vue";
  8. import {searchCommitment} from "@/api/commitment";
  9. export default {
  10. components: {
  11. TopSearchShow,
  12. ContentMenu,
  13. PromiseList,
  14. EnterPriseList,
  15. TemplateList,
  16. RecentlySearch
  17. },
  18. data() {
  19. return {
  20. activeIndex: 0, // 当前激活的菜单索引
  21. showSearch: false, // 是否显示搜索框
  22. searchValue: "", // 搜索框的值
  23. resultActive: 0, // 搜索结果的tab索引
  24. showSearchResult: false, // 是否显示搜索结果
  25. resultList: [], // 搜索结果列表
  26. activeTemplateId: null // 当前激活的模板的uuid
  27. };
  28. },
  29. methods:{
  30. // 搜索
  31. async onSearch(type=0) {
  32. this.showSearchResult = true;
  33. this.resultActive = type;
  34. try {
  35. const res = await searchCommitment({
  36. searchCriteria: this.searchValue,
  37. createUser: uni.getStorageSync("userInfo").id || '',
  38. type
  39. })
  40. if(type === 0) {
  41. this.resultList = res.data || [];
  42. this.resultList = this.resultList.map(item => {
  43. return {
  44. ...item,
  45. company_name: item.item,
  46. create_time: item.time,
  47. remark: item.name
  48. }
  49. })
  50. }else if(type === 1) {
  51. this.resultList = res.data || [];
  52. this.resultList = this.resultList.map(item => {
  53. return {
  54. ...item,
  55. createTime: item.time,
  56. companyName: item.name
  57. }
  58. })
  59. }
  60. }catch (e) {
  61. console.log(e);
  62. }
  63. },
  64. handleRecentlySearch(searchCriteria) {
  65. this.searchValue = searchCriteria;
  66. this.onSearch();
  67. },
  68. // 取消搜索
  69. onCancel() {
  70. this.showSearch = false;
  71. this.showSearchResult = false;
  72. this.searchValue = "";
  73. },
  74. handleTabsClick(name) {
  75. this.onSearch(name)
  76. },
  77. /* 模板点击搜索承诺 */
  78. handleTemplateClick(item) {
  79. this.activeTemplateId = item.uuid
  80. }
  81. }
  82. };
  83. </script>
  84. <template>
  85. <view>
  86. <transition name="fade" mode="out-in">
  87. <!-- 使用 key 属性区分不同的渲染内容 -->
  88. <view v-if="!showSearch" class="content" key="not-search">
  89. <view class="top-search">
  90. <TopSearchShow :value.sync="showSearch"></TopSearchShow>
  91. <ContentMenu class='menu' :value.sync="activeIndex"></ContentMenu>
  92. </view>
  93. <TemplateList
  94. v-show="activeIndex === 0"
  95. class="template-style"
  96. :activeTemplateId="activeTemplateId"
  97. @click="handleTemplateClick"></TemplateList>
  98. <PromiseList
  99. v-show="activeIndex === 0"
  100. class="promise-style"
  101. :templateId="activeTemplateId"
  102. ></PromiseList>
  103. <view class="enterprise-top-style" v-show="activeIndex === 1">
  104. <span>综合</span>
  105. </view>
  106. <EnterPriseList v-if="activeIndex === 1" class="enter-style"></EnterPriseList>
  107. </view>
  108. <view v-else key="search" class="search-page">
  109. <van-search
  110. v-model="searchValue"
  111. show-action
  112. autofocus
  113. :clearable="false"
  114. placeholder="请输入搜索关键词"
  115. @search="()=>onSearch(0)"
  116. @cancel="onCancel"
  117. />
  118. <RecentlySearch v-if="!showSearchResult" @search="handleRecentlySearch" class="recently-search"></RecentlySearch>
  119. <view v-else>
  120. <van-tabs v-model="resultActive" background='white' color='#1492FF' type='card' @click="handleTabsClick" class="tabs-style">
  121. <van-tab title="承诺信息">
  122. <PromiseList :no-request="true" :prop-data-list="resultList"></PromiseList>
  123. </van-tab>
  124. <van-tab title="企业信息">
  125. <EnterPriseList :no-request="true" :prop-data-list="resultList"></EnterPriseList>
  126. </van-tab>
  127. </van-tabs>
  128. </view>
  129. </view>
  130. </transition>
  131. </view>
  132. </template>
  133. <style scoped>
  134. .top-search {
  135. height: 101px;
  136. position: relative;
  137. background-color: #1492FF;
  138. }
  139. .menu {
  140. position: absolute;
  141. top: 58px;
  142. left: 0;
  143. width: 100%;
  144. z-index: 1;
  145. }
  146. .template-style {
  147. background-color: #fff;
  148. }
  149. .promise-style {
  150. min-height: calc(100vh - 308px);
  151. background-color: transparent;
  152. padding: 0 10px;
  153. }
  154. .enter-style {
  155. margin-top: 10px;
  156. }
  157. .enterprise-top-style {
  158. width: 375px;
  159. height: 51px;
  160. background-image: linear-gradient(180deg, #FFFFFF 35%, #F2F3F5 100%);
  161. border-radius: 0 0 6px 6px;
  162. position: relative;
  163. }
  164. span {
  165. position: absolute;
  166. font-weight: 600;
  167. font-size: 16px;
  168. color: #333333;
  169. left: 20px;
  170. bottom: 15px;
  171. }
  172. .fade-enter-active, .fade-leave-active {
  173. transition: opacity 0.2s;
  174. }
  175. .fade-enter, .fade-leave-to {
  176. opacity: 0;
  177. }
  178. .tabs-style {
  179. .van-tabs__nav--card{
  180. margin: 0;
  181. }
  182. }
  183. </style>