index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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: 2,
  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. company_name: item.item,
  56. create_time: item.time,
  57. remark: item.name
  58. }
  59. })
  60. }
  61. }catch (e) {
  62. console.log(e);
  63. }
  64. },
  65. handleRecentlySearch(searchCriteria) {
  66. this.searchValue = searchCriteria;
  67. this.onSearch();
  68. },
  69. // 取消搜索
  70. onCancel() {
  71. this.showSearch = false;
  72. this.showSearchResult = false;
  73. this.searchValue = "";
  74. },
  75. handleTabsClick(name) {
  76. this.onSearch(name)
  77. },
  78. /* 模板点击搜索承诺 */
  79. handleTemplateClick(item) {
  80. this.activeTemplateId = item.uuid
  81. }
  82. }
  83. };
  84. </script>
  85. <template>
  86. <view>
  87. <transition name="fade" mode="out-in">
  88. <!-- 使用 key 属性区分不同的渲染内容 -->
  89. <view v-if="!showSearch" class="content" key="not-search">
  90. <view class="top-search">
  91. <TopSearchShow :value.sync="showSearch"></TopSearchShow>
  92. <ContentMenu class='menu' :value.sync="activeIndex"></ContentMenu>
  93. </view>
  94. <TemplateList
  95. v-show="activeIndex === 0"
  96. class="template-style"
  97. :activeTemplateId="activeTemplateId"
  98. @click="handleTemplateClick"></TemplateList>
  99. <PromiseList
  100. v-show="activeIndex === 0"
  101. class="promise-style"
  102. :templateId="activeTemplateId"
  103. ></PromiseList>
  104. <view class="enterprise-top-style" v-show="activeIndex === 1">
  105. <span>综合</span>
  106. </view>
  107. <EnterPriseList v-show="activeIndex === 1" class="enter-style"></EnterPriseList>
  108. </view>
  109. <view v-else key="search" class="search-page">
  110. <van-search
  111. v-model="searchValue"
  112. show-action
  113. autofocus
  114. :clearable="false"
  115. placeholder="请输入搜索关键词"
  116. @search="()=>onSearch(0)"
  117. @cancel="onCancel"
  118. />
  119. <RecentlySearch v-if="!showSearchResult" @search="handleRecentlySearch" class="recently-search"></RecentlySearch>
  120. <view v-else>
  121. <van-tabs v-model="resultActive" background='white' color='#1492FF' type='card' @click="handleTabsClick" class="tabs-style">
  122. <van-tab title="承诺信息">
  123. <PromiseList :no-request="true" :prop-data-list="resultList"></PromiseList>
  124. </van-tab>
  125. <van-tab title="企业信息">
  126. <EnterPriseList :no-request="true" ::prop-data-list="resultList"></EnterPriseList>
  127. </van-tab>
  128. </van-tabs>
  129. </view>
  130. </view>
  131. </transition>
  132. </view>
  133. </template>
  134. <style scoped>
  135. .top-search {
  136. height: 101px;
  137. position: relative;
  138. background-color: #1492FF;
  139. }
  140. .menu {
  141. position: absolute;
  142. top: 58px;
  143. left: 0;
  144. width: 100%;
  145. z-index: 1;
  146. }
  147. .template-style {
  148. background-color: #fff;
  149. }
  150. .promise-style {
  151. min-height: calc(100vh - 308px);
  152. background-color: transparent;
  153. padding: 0 10px;
  154. }
  155. .enter-style {
  156. margin-top: 10px;
  157. }
  158. .enterprise-top-style {
  159. width: 375px;
  160. height: 51px;
  161. background-image: linear-gradient(180deg, #FFFFFF 35%, #F2F3F5 100%);
  162. border-radius: 0 0 6px 6px;
  163. position: relative;
  164. }
  165. span {
  166. position: absolute;
  167. font-weight: 600;
  168. font-size: 16px;
  169. color: #333333;
  170. left: 20px;
  171. bottom: 15px;
  172. }
  173. .fade-enter-active, .fade-leave-active {
  174. transition: opacity 0.2s;
  175. }
  176. .fade-enter, .fade-leave-to {
  177. opacity: 0;
  178. }
  179. .tabs-style {
  180. .van-tabs__nav--card{
  181. margin: 0;
  182. }
  183. }
  184. </style>