SearchList.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. <template>
  2. <div>
  3. <el-container>
  4. <el-main style="padding: 0">
  5. <!-- 导航头部-->
  6. <!-- 主题导航-->
  7. <el-row >
  8. <el-col :span="18" offset="3">
  9. <el-row class="nav_tap" :gutter="34" style="padding: 10px;margin-left: 0;margin-right:0;margin-top: 25px " >
  10. <p v-show="search_key!=null&&search_key!=''" style="text-align: left">以下是关键词: <span v-html="search_key" class="nav_title"></span> 的检索内容:</p>
  11. <el-col :span="18" style="margin-bottom: 15px">
  12. <span class="nav_title">按关键词:</span>
  13. <el-input
  14. type="textarea"
  15. :autosize="{ minRows: 1, maxRows: 2}"
  16. placeholder="请输入内容"
  17. v-model="s_key">
  18. </el-input>
  19. </el-col>
  20. <el-col :span="8" ><span class="nav_title">按照类型:</span>
  21. <el-select v-model="s_type" clearable placeholder="请选择">
  22. <el-option
  23. v-for="item in wordType"
  24. :key="item.dictCode"
  25. :label="item.dictLabel"
  26. :value="item.dictValue">
  27. </el-option>
  28. </el-select>
  29. </el-col>
  30. <el-col :span="11">
  31. <div class="block">
  32. <span class="nav_title">按照时段:</span>
  33. <el-date-picker
  34. v-model="timer_picker"
  35. type="daterange"
  36. align="right"
  37. unlink-panels
  38. format="yyyy-MM-dd"
  39. value-format="yyyy-MM-dd"
  40. range-separator="至"
  41. start-placeholder="开始日期"
  42. end-placeholder="结束日期"
  43. :picker-options="pickerOptions">
  44. </el-date-picker>
  45. </div>
  46. </el-col>
  47. <el-col :span="5"><span @click="getSearchList()" class="nav_title">&nbsp;&nbsp;&nbsp;搜索&nbsp;&nbsp;&nbsp;</span></el-col>
  48. </el-row>
  49. </el-col>
  50. </el-row>
  51. <!-- 主要列表-->
  52. <el-row>
  53. <el-col :span="18" offset="3">
  54. <el-row>
  55. <el-col v-for="item in news_list" :key="item" >
  56. <el-row class="word_item" style="margin-bottom: 20px">
  57. <el-col :span="8">
  58. <div>
  59. <span class="type_flag" v-for="type in wordType" v-if="type.dictValue==item.newsInfoType">
  60. {{type.dictLabel}}
  61. </span>
  62. </div>
  63. <el-image
  64. style="width: 100%; height: 300px"
  65. lazy
  66. v-if="item.newsInfoUrl "
  67. :src="item.newsInfoUrl "
  68. ></el-image>
  69. </el-col>
  70. <el-col class="word_info" :span="16">
  71. <div >
  72. <h4>
  73. <nuxt-link :to="{name:'info-id',params:{id:item.newsInfoId,title:item.newsInfoTitle}}">
  74. {{item.newsInfoTitle.length>25?item.newsInfoTitle.substr(1,25)+"...":item.newsInfoTitle}}
  75. </nuxt-link>
  76. <!-- <n-link style="text-decoration: none; font-size: 1.3rem;font-weight: 400;color: black" :to="{name:'info-id'}"> {{item.newsInfoTitle}}</n-link>-->
  77. </h4>
  78. <div v-html="item.newsInfoContent.replace(/<[^>]+>/g,'').length>100?item.newsInfoContent.replace(/<[^>]+>/g,'').substr(1,
  79. 100)+'...':item.newsInfoContent.replace(/<[^>]+>/g,'')">
  80. </div>
  81. <span class="info_span"><i class="el-icon-s-custom"></i>{{item.newsInfoAuthor}} 时间:{{item.newsInfoTime}}</span>
  82. </div>
  83. <div></div>
  84. </el-col>
  85. </el-row>
  86. </el-col>
  87. </el-row>
  88. </el-col>
  89. </el-row>
  90. <!-- 分页-->
  91. <el-row>
  92. <el-col :span="18" offset="3">
  93. <el-row>
  94. <el-col :span="18" offset="7">
  95. <pagination
  96. v-show="total>0"
  97. :total="total"
  98. :page.sync="queryParams.pageNum"
  99. :limit.sync="queryParams.pageSize"
  100. @pagination="getSearchList"
  101. />
  102. </el-col>
  103. </el-row>
  104. </el-col>
  105. </el-row>
  106. </el-main>
  107. </el-container>
  108. </div>
  109. </template>
  110. <script>
  111. import {navList,newsList,dictList,listWordPost} from "../static/js/index"
  112. import axios from "axios";
  113. export default {
  114. name: "SearchList",
  115. head(){
  116. return{
  117. title:"中关村公共资源论坛|文章检索"
  118. }
  119. },
  120. data(){
  121. return{
  122. pickerOptions: {
  123. shortcuts: [{
  124. text: '最近一周',
  125. onClick(picker) {
  126. const end = new Date();
  127. const start = new Date();
  128. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
  129. picker.$emit('pick', [start, end]);
  130. }
  131. }, {
  132. text: '最近一个月',
  133. onClick(picker) {
  134. const end = new Date();
  135. const start = new Date();
  136. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
  137. picker.$emit('pick', [start, end]);
  138. }
  139. }, {
  140. text: '最近三个月',
  141. onClick(picker) {
  142. const end = new Date();
  143. const start = new Date();
  144. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
  145. picker.$emit('pick', [start, end]);
  146. }
  147. }]
  148. },
  149. value1: '',
  150. value2: '',
  151. search_key:null,
  152. queryParams: {
  153. pageNum: 1,
  154. pageSize: 10,
  155. title: null,
  156. type: null,
  157. author: null,
  158. releaseTime: null,
  159. word: null,
  160. coverUrl: null
  161. },
  162. news_list:null,
  163. total:0,
  164. wordType:null,
  165. timer_picker:[],
  166. s_type:null,
  167. s_key:null
  168. }
  169. },
  170. created() {
  171. this.getSearchList()
  172. this.getDictType()
  173. },
  174. methods:{
  175. getDictType(){
  176. dictList({"dictType":"sys_info_word_type"}).then(response=>{
  177. this.wordType=response.rows;
  178. })
  179. },
  180. s_click(){
  181. console.log(this.timer_picker)
  182. // axios({
  183. // method: 'post',
  184. // url: 'http://localhost:7070/website/news/listPost',
  185. // data: {
  186. // newsInfoTitle: this.s_key,
  187. // pageNum: 1,
  188. // newsInfoType: this.s_type,
  189. // 'params[beginNewsInfoTime]': this.timer_picker[0],
  190. // 'params[endNewsInfoTime]': this.timer_picker[1],
  191. // pageSize: 5,
  192. //
  193. // },
  194. // headers: {
  195. // 'Content-Type': 'application/x-www-form-urlencoded'
  196. // }
  197. // }).then(response=>{
  198. // this.queryParams.pageNum=1
  199. // this.news_list=response.rows;
  200. // this.total=response.total;
  201. // })
  202. listWordPost({"newsInfoTitle": this.s_key,"pageNum":1,"newsInfoType":this.s_type,
  203. "beginNewsInfoTime":this.timer_picker[0],
  204. "endNewsInfoTime":this.timer_picker[1],
  205. "pageSize":this.queryParams.pageSize}).then(response=>{
  206. this.queryParams.pageNum=1
  207. this.news_list=response.rows;
  208. this.total=response.total;
  209. })
  210. },
  211. getSearchList(){
  212. if(this.timer_picker.length>0){
  213. listWordPost({"newsInfoTitle": this.s_key,"pageNum":this.queryParams.pageNum,"newsInfoType":this.s_type,
  214. "beginNewsInfoTime":this.timer_picker[0],
  215. "endNewsInfoTime":this.timer_picker[1],
  216. "pageSize":this.queryParams.pageSize}).then(response=>{
  217. this.news_list=response.rows;
  218. this.total=response.total;
  219. this.search_key=this.s_key;
  220. })
  221. }else {
  222. newsList({"newsInfoTitle": this.s_key,"pageNum":this.queryParams.pageNum,"newsInfoType":this.s_type,
  223. // "beginNewsInfoTime":this.timer_picker[0],
  224. // "endNewsInfoTime":this.timer_picker[1],
  225. "pageSize":this.queryParams.pageSize}).then(response=>{
  226. this.news_list=response.rows;
  227. this.total=response.total;
  228. this.search_key=this.s_key;
  229. })
  230. }
  231. if (this.$route.params.key!=null){
  232. this.search_key=this.$route.params.key;
  233. this.$route.params.key=null;
  234. }
  235. }
  236. }
  237. }
  238. </script>
  239. <style scoped>
  240. .nav_tap{
  241. background-color: #f0f0f0;
  242. text-align: left;
  243. margin-bottom: 30px;
  244. }
  245. .nav_tap span{
  246. background-color: #b11116;
  247. -webkit-text-size-adjust: 100%;
  248. letter-spacing: 1px;
  249. text-rendering: optimizeLegibility;
  250. font-family: "PingFang SC", "Microsoft YaHei", "STHeiti", "sans-serif";
  251. line-height: 38px;
  252. font-size: 22px;
  253. box-sizing: border-box;
  254. background-size: contain;
  255. background-position: center;
  256. background-repeat: no-repeat;
  257. vertical-align: middle;
  258. text-align: center;
  259. cursor: pointer;
  260. border-radius: 6px;
  261. padding: 0 20px;
  262. color: white;
  263. }
  264. .type_flag{
  265. position: absolute;
  266. z-index: 2;
  267. padding: 7px;
  268. margin: 10px;
  269. color: white;
  270. background-color: rgba(0,0,0,0.5);
  271. border-radius: 20px;
  272. }
  273. .word_item{
  274. background-color: #f0f0f0;
  275. }
  276. .word_info{
  277. padding: 0 20px;
  278. }
  279. .info_span{
  280. position: absolute;
  281. bottom: 10px;
  282. }
  283. </style>
  284. <style>
  285. /*带背景的分页按钮背景色begin*/
  286. .el-pagination.is-background .el-pager li:not(.disabled).active {
  287. background-color: #b11116;
  288. color: #FFF;
  289. }
  290. .el-pagination.is-background .el-pager li.active {
  291. color: #fff;
  292. cursor: default;
  293. }
  294. .el-pagination.is-background .el-pager li:hover {
  295. color: #b11116;
  296. }
  297. .el-pagination.is-background .el-pager li:not(.disabled):hover {
  298. color: #b11116;
  299. }
  300. .el-pagination.is-background .el-pager li:not(.disabled).active:hover {
  301. background-color: #b11116;
  302. color: #FFF;
  303. }
  304. /*带背景的分页按钮背景色end*/
  305. /*不带背景的分页按钮背景色begin*/
  306. .el-pager li.active {
  307. color: #b11116;
  308. cursor: default;
  309. }
  310. .el-pagination .el-pager li:hover {
  311. color: #b11116;
  312. }
  313. .el-pagination .el-pager li:not(.disabled):hover {
  314. color: #b11116;
  315. }
  316. /*不带背景的分页按钮背景色end*/
  317. </style>