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.6 kB

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