reportSearch.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. <template>
  2. <view class="searchTarget-container container">
  3. <view class="searchTarget-header">
  4. <input type="text"
  5. placeholder="请输入关键字"
  6. placeholder-class="sea_ipt_placeholder"
  7. class="sea_ipt"
  8. v-model="searchTxt"
  9. focus="true"
  10. confirm-type="search"
  11. @confirm="searchHandle"/>
  12. <icon type="search" size="15" class="sea_ico"/>
  13. <view class="ipt-right">
  14. <icon type="clear" size="16" color="#E0E0E0" v-show="searchTxt" @click="clearIpt"/>
  15. <text class="line">|</text>
  16. <text @click="searchHandle" style="color: #3385FF;">搜索</text>
  17. </view>
  18. </view>
  19. <view class="search-cont">
  20. <template v-if="!isResult">
  21. <view class="search-cont-top" v-if="historySearchList.length">
  22. <view class="cont-tit">
  23. <text>搜索历史</text>
  24. <image src="@/static/img/empty_ico.png" class="empty_ico" @click="clearHistory"></image>
  25. </view>
  26. <view class="targetList">
  27. <view class="target-item" v-for="(item,index) in historySearchList" :key="index" @click="chooseTarget(item)">{{item}}</view>
  28. </view>
  29. </view>
  30. <view class="search-cont-top">
  31. <view class="cont-tit">
  32. <text>弘则推荐</text>
  33. </view>
  34. <view class="targetList">
  35. <view class="target-item" v-for="(item,index) in keywordList" :key="index" @click="chooseTarget(item)">{{item}}</view>
  36. </view>
  37. </view>
  38. </template>
  39. <template v-else>
  40. <block v-if="haveResult">
  41. <view class="">
  42. <view class="report-ul">
  43. <view class="report-item" v-for="(item,index) in resultList" :key="index" >
  44. <view class="box-text" @click="goDetail(item)">
  45. <view class="" style="padding-left: 30rpx;">
  46. {{item.IndustryName}}
  47. </view>
  48. <view class="text-time">
  49. <text style="padding-right: 20rpx;">{{item.UpdateTime}}更新</text>
  50. <u-icon name="arrow-right" color="#BDBDBD" size="34"></u-icon>
  51. </view>
  52. </view>
  53. <view class="" v-if="item.IndustrialSubjectList.length>6">
  54. <u-read-more :shadow-style="shadowStyle" close-text="展开" color='#D1D1D1' :show-height="item.IndustrialSubjectList.length>6 ? 170 :200" :toggle="true">
  55. <view class="arrow-box">
  56. <view @click="goDetail(item)" class="box-subject" v-for="key in item.IndustrialSubjectList" :key="key.RecommendedIndex">
  57. {{key.SubjectName}}
  58. </view>
  59. </view>
  60. </u-read-more>
  61. </view>
  62. <view class="" v-else @click="goDetail(item)">
  63. <view class="arrow-box">
  64. <view class="box-subject" v-for="key in item.IndustrialSubjectList" :key="key.RecommendedIndex">
  65. {{key.SubjectName}}
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. <u-loadmore :status="status" icon-type="flower" :load-text="loadText" bg-color="#F7F7F7" padding-bottom="20rpx"/>
  73. <!-- v-if="totalPage>1" -->
  74. </block>
  75. <view class="nodata" v-else>
  76. <image src="@/static/img/nodata.png" mode="" class="nodata_ico"></image>
  77. <text>未找到您想搜索的内容</text>
  78. </view>
  79. </template>
  80. </view>
  81. </view>
  82. </template>
  83. <script>
  84. import { Search ,Reports} from '@/config/api.js';
  85. import { Debounce,Throttle } from '@/config/util.js'
  86. export default {
  87. data() {
  88. return {
  89. searchTxt:'',//搜索关键字
  90. isResult:false,//显示搜索结果
  91. haveResult:true,//是否有搜索数据
  92. // 历史搜索列表
  93. historySearchList:[],
  94. // 关键字列表
  95. keywordList:[],
  96. targetList:[],//所有指标列表
  97. // 搜索结果列表
  98. resultList:[],
  99. page_no: 1,
  100. pageSize: 10,
  101. totalPage: 0,
  102. loadText:{
  103. loadmore: '上拉加载更多',
  104. loading: '加载中',
  105. nomore: ''
  106. },
  107. status:'loadmore',
  108. shadowStyle: {
  109. backgroundImage: "none"
  110. }
  111. };
  112. },
  113. watch:{
  114. searchTxt(newVal) {
  115. if(newVal.length <= 0) {
  116. this.isResult = false;
  117. }
  118. },
  119. },
  120. methods:{
  121. /* 获取关键词 */
  122. getKeyWord() {
  123. Search.getKeys().then(res => {
  124. if(res.Ret === 200) {
  125. this.keywordList = res.Data.Item.ConfigValue ? res.Data.Item.ConfigValue.split(',') : [];
  126. }
  127. })
  128. },
  129. // 选择历史搜索
  130. chooseTarget(item) {
  131. this.searchTxt = item;
  132. this.SecName = item;
  133. this.resultList = [];
  134. this.page_no = 1;
  135. this.getDataList();
  136. },
  137. // 键盘输入过程中
  138. searchDoing() {
  139. this.isResult = false;
  140. //全部指标列表
  141. let arr = JSON.parse(JSON.stringify(this.targetList));
  142. let filterArr = [];
  143. // // 过滤出符合搜索条件的值
  144. arr.forEach((item,index)=>{
  145. if(item.SecName.includes(this.searchTxt)){
  146. item.SecName = this.join(item.SecName,this.searchTxt)
  147. filterArr.unshift(item);
  148. }
  149. });
  150. this.keywordList = filterArr;
  151. },
  152. // 拼接
  153. join(str,key){
  154. return str.replace(new RegExp(`${key}`, 'g'), `%%${key}%%`).split('%%');
  155. },
  156. // 搜索数据
  157. searchHandle: Debounce(function() {
  158. if(this.searchTxt) {
  159. //添加搜索记录
  160. if(!this.historySearchList.includes(this.searchTxt)) {
  161. this.historySearchList.unshift(this.searchTxt);
  162. this.$db.set('historySearchListReport',JSON.stringify(this.historySearchList))
  163. }
  164. this.resultList = [];
  165. this.page_no = 1;
  166. this.getDataList();
  167. }else {
  168. this.$util.toast('请输入关键字')
  169. }
  170. }),
  171. // 查找数据
  172. getDataList() {
  173. this.isResult = true;
  174. Reports.getIndustryList({
  175. KeyWord: this.searchTxt,
  176. PageSize: this.pageSize,
  177. CurrentIndex: this.page_no,
  178. }).then(res => {
  179. if(res.Ret === 200) {
  180. if(this.page_no === 1) {
  181. this.resultList = res.Data.List || [];
  182. this.haveResult = this.resultList.length ? true : false
  183. }else {
  184. this.resultList = this.resultList.concat(res.Data.List)
  185. }
  186. if(!this.haveResult) return
  187. this.status = this.page_no < res.Data.Paging.Pages ? 'loadmore' : 'nomore'
  188. this.totalPage = res.Data.Paging.Pages;//总页数
  189. }
  190. })
  191. },
  192. // 点击数据列表修改数据
  193. itemClick(item) {
  194. let data = encodeURIComponent(JSON.stringify(item));
  195. uni.navigateTo({
  196. url:'/pages/recordData/recordData?data=' + data
  197. })
  198. },
  199. /* 表单清空 */
  200. clearIpt() {
  201. this.searchTxt = '';
  202. this.isTabAct=false
  203. },
  204. /* 历史搜索清空 */
  205. clearHistory() {
  206. this.historySearchList = [];
  207. this.$db.del('historySearchListReport');
  208. },
  209. /* 进入详情 校验是否有该品种权限 */
  210. goDetail(item) {
  211. uni.navigateTo({
  212. url:'/reportPages/IndustryReport/IndustryReport?id=' + item.IndustrialManagementId,
  213. });
  214. },
  215. },
  216. /* 触底 */
  217. onReachBottom: Throttle(function() {
  218. if(this.isResult) {
  219. if(this.status === 'nomore') return ;
  220. this.status = 'loading';
  221. this.page_no++;
  222. this.getDataList();
  223. }
  224. }),
  225. onLoad(options) {
  226. this.$store.dispatch("checkHandle",{type:'load',val:option}).then(res=>{
  227. if(options.text) {
  228. this.searchTxt=options.text
  229. this.getDataList();
  230. }
  231. // 获取历史搜索记录
  232. if(this.$db.get('historySearchListReport')) {
  233. let historyList = JSON.parse(this.$db.get('historySearchListReport'));
  234. this.historySearchList = historyList;
  235. }
  236. })
  237. },
  238. onShow() {
  239. this.$store.dispatch("statistics",{PageType:'ReportSearch'})
  240. this.getKeyWord()
  241. },
  242. /**
  243. * 用户点击分享
  244. */
  245. onShareAppMessage: function(res) {
  246. return {
  247. title: "报告",
  248. path: '/reportPages/reportSearch/reportSearch?text='+this.searchTxt,
  249. success: (res) => {},
  250. fail: (err) => {}
  251. }
  252. },
  253. }
  254. </script>
  255. <style lang="scss">
  256. .searchTarget-container {
  257. background-color: #f6f6f6;
  258. padding-bottom: 30rpx;
  259. .searchTarget-header {
  260. padding: 0 34rpx;
  261. width: 100%;
  262. background-color: #fff;
  263. position: fixed;
  264. top: 0;
  265. left: 0;
  266. z-index: 99;
  267. padding: 30rpx 0;
  268. display: flex;
  269. justify-content: center;
  270. align-items: center;
  271. .sea_ipt_placeholder {
  272. color: #E5E5E5;
  273. }
  274. .sea_ipt {
  275. width: 682rpx;
  276. height: 70rpx;
  277. line-height: 70rpx;
  278. box-sizing: border-box;
  279. border: 1rpx solid #E5E5E5;
  280. background-color: rgba(245, 245, 245, 0.2);
  281. font-size: 26rpx;
  282. color: #4A4A4A;
  283. padding: 0 180rpx 0 78rpx;
  284. border-radius: 70rpx;
  285. }
  286. .sea_ico {
  287. width: 31rpx;
  288. height: 31rpx;
  289. position: absolute;
  290. left: 68rpx;
  291. top: 50%;
  292. transform: translateY(-50%);
  293. }
  294. .ipt-right {
  295. display: flex;
  296. align-items: center;
  297. position: absolute;
  298. right:59rpx;
  299. top: 50%;
  300. transform: translateY(-50%);
  301. color: #3385FF;
  302. .line {
  303. margin: 0 21rpx;
  304. color: #E0E0E0;
  305. }
  306. }
  307. }
  308. .report-item {
  309. margin-top: 10rpx;
  310. width: 100%;
  311. background-color: #fff;
  312. .box-text {
  313. display: flex;
  314. justify-content: space-between;
  315. background-color: #fff;
  316. align-items: center;
  317. padding: 0 30rpx;
  318. height: 91rpx;
  319. color: #333333;
  320. font-size: 30rpx;
  321. .text-time {
  322. display: flex;
  323. color: #999999;
  324. font-size: 26rpx;
  325. }
  326. }
  327. .arrow-box {
  328. display: flex;
  329. flex-wrap: wrap;
  330. border-top:3rpx solid #f6f6f6;
  331. padding: 30rpx 30rpx 0;
  332. .box-subject {
  333. margin-bottom: 30rpx;
  334. margin-left: 40rpx;
  335. background:url(../../static/img/report_bg.png) no-repeat;
  336. background-size: 100% 100%;
  337. width: 170rpx;
  338. height: 46rpx;
  339. color: #408FFF;
  340. text-align: center !important;
  341. font-size: 24rpx;
  342. line-height: 46rpx;
  343. text-indent:0em;
  344. }
  345. }
  346. }
  347. .search-cont {
  348. padding-top: 130rpx;
  349. .search-cont-top {
  350. padding: 0 34rpx 0;
  351. margin-bottom: 10rpx;
  352. padding-top: 20rpx;
  353. &:last-child {
  354. margin-bottom: 0;
  355. }
  356. .cont-tit {
  357. color: #666;
  358. font-size: 28rpx;
  359. margin-bottom: 30rpx;
  360. display: flex;
  361. justify-content: space-between;
  362. .empty_ico {
  363. width: 32rpx;
  364. height: 33rpx;
  365. }
  366. }
  367. .targetList {
  368. display: flex;
  369. flex-wrap: wrap;
  370. // justify-content: space-between;
  371. .target-item {
  372. padding: 4rpx 18rpx;
  373. color: #4A4A4A;
  374. font-size: 26rpx;
  375. // border: 1rpx solid #3385ff;
  376. background-color: #F7F7F7;
  377. margin-bottom: 30rpx;
  378. margin-right: 30rpx;
  379. border-radius: 20rpx;
  380. }
  381. }
  382. }
  383. .result-cont {
  384. padding: 0 34rpx 0;
  385. padding-left: 21rpx;
  386. .result-list {
  387. display: flex;
  388. align-items: center;
  389. color: #333;
  390. padding-bottom: 30rpx;
  391. border-bottom: 1rpx solid #EBEDF0;
  392. margin-bottom: 30rpx;
  393. .result_ico {
  394. width: 28rpx;
  395. height: 28rpx;
  396. margin-right: 20rpx;
  397. }
  398. text {
  399. display: inline;
  400. }
  401. .highlight {
  402. color: #3385FF;
  403. }
  404. }
  405. }
  406. .result-data {
  407. // margin-top: 80rpx;
  408. min-height: calc(100vh - 130rpx);
  409. padding: 20rpx 34rpx 40rpx;
  410. display: flex;
  411. background-color: #F7F7F7;
  412. }
  413. }
  414. .tab-cont {
  415. position: fixed;
  416. top: 128rpx;
  417. width: 100%;
  418. padding: 0 26rpx;
  419. background-color: #fff;
  420. font-size: 32rpx;
  421. z-index: 99;
  422. box-shadow: 0 3rpx 6rpx rgba(187,216,255,0.2);
  423. .scroll-tab {
  424. width: 100%;
  425. white-space: nowrap;
  426. }
  427. .scroll-tab-item {
  428. // flex-grow: 1;
  429. text-align: center;
  430. display: inline-block;
  431. padding: 0 8rpx 30rpx 8rpx;
  432. margin-right: 40rpx;
  433. border-bottom: 8rpx solid transparent;
  434. position: relative;
  435. &:last-child {
  436. margin-right: 0;
  437. }
  438. &.active {
  439. border-bottom: none;
  440. color: #2C83FF;
  441. font-weight: 700;
  442. }
  443. .border_act {
  444. width: 100%;
  445. height: 8rpx;
  446. position: absolute;
  447. bottom: 0;
  448. left: 0;
  449. }
  450. }
  451. }
  452. .u-line {
  453. display: none !important;
  454. }
  455. }
  456. </style>