reportSearch.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  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:'/pages/reportDetail/reportDetail?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() {
  226. // 获取历史搜索记录
  227. if(this.$db.get('historySearchListReport')) {
  228. let historyList = JSON.parse(this.$db.get('historySearchListReport'));
  229. this.historySearchList = historyList;
  230. }
  231. },
  232. onShow() {
  233. this.getKeyWord()
  234. }
  235. }
  236. </script>
  237. <style lang="scss">
  238. .searchTarget-container {
  239. background-color: #f6f6f6;
  240. padding-bottom: 30rpx;
  241. .searchTarget-header {
  242. padding: 0 34rpx;
  243. width: 100%;
  244. background-color: #fff;
  245. position: fixed;
  246. top: 0;
  247. left: 0;
  248. z-index: 99;
  249. padding: 30rpx 0;
  250. display: flex;
  251. justify-content: center;
  252. align-items: center;
  253. .sea_ipt_placeholder {
  254. color: #E5E5E5;
  255. }
  256. .sea_ipt {
  257. width: 682rpx;
  258. height: 70rpx;
  259. line-height: 70rpx;
  260. box-sizing: border-box;
  261. border: 1rpx solid #E5E5E5;
  262. background-color: rgba(245, 245, 245, 0.2);
  263. font-size: 26rpx;
  264. color: #4A4A4A;
  265. padding: 0 180rpx 0 78rpx;
  266. border-radius: 70rpx;
  267. }
  268. .sea_ico {
  269. width: 31rpx;
  270. height: 31rpx;
  271. position: absolute;
  272. left: 68rpx;
  273. top: 50%;
  274. transform: translateY(-50%);
  275. }
  276. .ipt-right {
  277. display: flex;
  278. align-items: center;
  279. position: absolute;
  280. right:59rpx;
  281. top: 50%;
  282. transform: translateY(-50%);
  283. color: #3385FF;
  284. .line {
  285. margin: 0 21rpx;
  286. color: #E0E0E0;
  287. }
  288. }
  289. }
  290. .report-item {
  291. margin-top: 10rpx;
  292. width: 100%;
  293. background-color: #fff;
  294. .box-text {
  295. display: flex;
  296. justify-content: space-between;
  297. background-color: #fff;
  298. align-items: center;
  299. padding: 0 30rpx;
  300. height: 91rpx;
  301. color: #333333;
  302. font-size: 30rpx;
  303. .text-time {
  304. display: flex;
  305. color: #999999;
  306. font-size: 26rpx;
  307. }
  308. }
  309. .arrow-box {
  310. display: flex;
  311. flex-wrap: wrap;
  312. border-top:3rpx solid #f6f6f6;
  313. padding: 30rpx 30rpx 0;
  314. .box-subject {
  315. margin-bottom: 30rpx;
  316. margin-left: 40rpx;
  317. background:url(../../static/img/report_bg.png) no-repeat;
  318. background-size: 100% 100%;
  319. width: 170rpx;
  320. height: 46rpx;
  321. color: #408FFF;
  322. text-align: center !important;
  323. font-size: 24rpx;
  324. line-height: 46rpx;
  325. text-indent:0em;
  326. }
  327. }
  328. }
  329. .search-cont {
  330. padding-top: 130rpx;
  331. .search-cont-top {
  332. padding: 0 34rpx 0;
  333. margin-bottom: 10rpx;
  334. padding-top: 20rpx;
  335. &:last-child {
  336. margin-bottom: 0;
  337. }
  338. .cont-tit {
  339. color: #666;
  340. font-size: 28rpx;
  341. margin-bottom: 30rpx;
  342. display: flex;
  343. justify-content: space-between;
  344. .empty_ico {
  345. width: 32rpx;
  346. height: 33rpx;
  347. }
  348. }
  349. .targetList {
  350. display: flex;
  351. flex-wrap: wrap;
  352. // justify-content: space-between;
  353. .target-item {
  354. padding: 4rpx 18rpx;
  355. color: #4A4A4A;
  356. font-size: 26rpx;
  357. // border: 1rpx solid #3385ff;
  358. background-color: #F7F7F7;
  359. margin-bottom: 30rpx;
  360. margin-right: 30rpx;
  361. border-radius: 20rpx;
  362. }
  363. }
  364. }
  365. .result-cont {
  366. padding: 0 34rpx 0;
  367. padding-left: 21rpx;
  368. .result-list {
  369. display: flex;
  370. align-items: center;
  371. color: #333;
  372. padding-bottom: 30rpx;
  373. border-bottom: 1rpx solid #EBEDF0;
  374. margin-bottom: 30rpx;
  375. .result_ico {
  376. width: 28rpx;
  377. height: 28rpx;
  378. margin-right: 20rpx;
  379. }
  380. text {
  381. display: inline;
  382. }
  383. .highlight {
  384. color: #3385FF;
  385. }
  386. }
  387. }
  388. .result-data {
  389. // margin-top: 80rpx;
  390. min-height: calc(100vh - 130rpx);
  391. padding: 20rpx 34rpx 40rpx;
  392. display: flex;
  393. background-color: #F7F7F7;
  394. }
  395. }
  396. .tab-cont {
  397. position: fixed;
  398. top: 128rpx;
  399. width: 100%;
  400. padding: 0 26rpx;
  401. background-color: #fff;
  402. font-size: 32rpx;
  403. z-index: 99;
  404. box-shadow: 0 3rpx 6rpx rgba(187,216,255,0.2);
  405. .scroll-tab {
  406. width: 100%;
  407. white-space: nowrap;
  408. }
  409. .scroll-tab-item {
  410. // flex-grow: 1;
  411. text-align: center;
  412. display: inline-block;
  413. padding: 0 8rpx 30rpx 8rpx;
  414. margin-right: 40rpx;
  415. border-bottom: 8rpx solid transparent;
  416. position: relative;
  417. &:last-child {
  418. margin-right: 0;
  419. }
  420. &.active {
  421. border-bottom: none;
  422. color: #2C83FF;
  423. font-weight: 700;
  424. }
  425. .border_act {
  426. width: 100%;
  427. height: 8rpx;
  428. position: absolute;
  429. bottom: 0;
  430. left: 0;
  431. }
  432. }
  433. }
  434. .u-line {
  435. display: none !important;
  436. }
  437. }
  438. </style>