index.vue 5.3 KB

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