You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.vue 2.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <div>
  3. <TopHeader :menu="'repo_view'"></TopHeader>
  4. <div class="ui container">
  5. <SearchBar :type="1" :condition="condition" @changeCondition="changeCondition"></SearchBar>
  6. <div class="conent-c">
  7. <div class="filter-c">
  8. <Filters :type="1" :condition="condition" @changeCondition="changeCondition"></Filters>
  9. </div>
  10. <div class="result-c">
  11. <PrjResultsList ref="resultListRef" :condition="condition" @changeCondition="changeCondition">
  12. </PrjResultsList>
  13. </div>
  14. </div>
  15. </div>
  16. </div>
  17. </template>
  18. <script>
  19. import TopHeader from '../components/TopHeader.vue';
  20. import SearchBar from '../components/SearchBar.vue';
  21. import Filters from '../components/Filters.vue';
  22. import PrjResultsList from '../components/PrjResultsList.vue';
  23. import { getUrlSearchParams } from '~/utils';
  24. export default {
  25. data() {
  26. return {
  27. condition: {
  28. q: '', // 搜索框
  29. topic: '', // 关键词
  30. project_name: '', // 项目类型
  31. institution_name: '', // 成果贡献单位
  32. page: '',
  33. pageSize: '',
  34. sort: '',
  35. },
  36. pageSizes: [15, 30, 50],
  37. };
  38. },
  39. components: {
  40. TopHeader,
  41. SearchBar,
  42. Filters,
  43. PrjResultsList
  44. },
  45. methods: {
  46. changeCondition(params) {
  47. this.condition = {
  48. ...this.condition,
  49. ...params,
  50. };
  51. if (!params.changePage) {
  52. this.condition.page = 1;
  53. }
  54. window.location.href = `/tech/repo_view?` + `q=${encodeURIComponent(this.condition.q.trim())}` +
  55. `&topic=${encodeURIComponent(this.condition.topic)}` +
  56. `&project_name=${encodeURIComponent(this.condition.project_name)}` +
  57. `&institution_name=${encodeURIComponent(this.condition.institution_name)}` +
  58. `&page=${encodeURIComponent(this.condition.page)}` +
  59. `&pageSize=${encodeURIComponent(this.condition.pageSize)}` +
  60. `&sort=${encodeURIComponent(this.condition.sort)}`;
  61. },
  62. },
  63. beforeMount() {
  64. const urlParams = getUrlSearchParams();
  65. this.condition.q = urlParams.q || '';
  66. this.condition.topic = urlParams.topic || '';
  67. this.condition.project_name = urlParams.project_name || '';
  68. this.condition.institution_name = urlParams.institution_name || '';
  69. this.condition.sort = urlParams.sort || '';
  70. this.condition.page = Number(urlParams.page) || 1;
  71. this.condition.pageSize = this.pageSizes.indexOf(Number(urlParams.pageSize)) >= 0 ? Number(urlParams.pageSize) : 15;
  72. this.$nextTick(() => {
  73. this.$refs.resultListRef.search();
  74. });
  75. },
  76. mounted() { },
  77. beforeDestroy() { },
  78. };
  79. </script>
  80. <style scoped lang="less">
  81. .conent-c {
  82. display: flex;
  83. }
  84. .filter-c {
  85. flex: 1;
  86. padding-left: 12px;
  87. }
  88. .result-c {
  89. margin-left: 10px;
  90. flex: 3;
  91. }
  92. </style>