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.

SearchBar.vue 6.6 kB

2 years ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <template>
  2. <div class="search-bar">
  3. <div class="search-bar-l">
  4. <div class="search-c">
  5. <div class="search-input-c">
  6. <input type="text" :placeholder="serchPlaceHolder" v-model="keyword" @keyup.enter="search">
  7. </div>
  8. <div class="search-btn" @click="search">{{ $t('repos.search') }}</div>
  9. </div>
  10. <el-button class="apply-btn" type="primary" icon="el-icon-plus" size="medium" @click="apply">申请展示成果</el-button>
  11. <div class="openi-link-c">
  12. <a class="openi-link" target="_blank" href="javascript:;">OpenI启智社区开源指南</a>
  13. </div>
  14. </div>
  15. <div class="sort-c">
  16. <el-select class="select" size="medium" v-model="sortType" @change="changeSort" placeholder="排序" clearable>
  17. <el-option v-for="item in sortList" :key="item.k" :label="item.v" :value="item.k" />
  18. </el-select>
  19. </div>
  20. </div>
  21. </template>
  22. <script>
  23. export default {
  24. name: "SearchBar",
  25. props: {
  26. type: { type: Number, default: -1 }, // 0-tech_view, 1-repo_view
  27. condition: { type: Object, default: () => ({}) },
  28. },
  29. components: {},
  30. data() {
  31. return {
  32. keyword: '',
  33. serchPlaceHolder: '',
  34. sortType: '',
  35. techSortList: [{
  36. k: 'time',
  37. v: this.$t('repos.recentlyUpdated'),
  38. }, {
  39. k: 'count',
  40. v: '项目成果数',
  41. }],
  42. repoSortList: [
  43. {
  44. k: 'mostpopular',
  45. v: this.$t('repos.mostPopular'),
  46. }, {
  47. k: 'recentupdate',
  48. v: this.$t('repos.recentlyUpdated'),
  49. }, {
  50. k: 'newest',
  51. v: this.$t('repos.newest'),
  52. }
  53. ],
  54. sortList: [],
  55. isTechAdmin: false,
  56. };
  57. },
  58. methods: {
  59. search() {
  60. this.$emit('changeCondition', {
  61. q: this.keyword.trim()
  62. });
  63. },
  64. apply() {
  65. window.location.href = '/tech/new';
  66. },
  67. manage() {
  68. window.location.href = '/tech/admin_view';
  69. },
  70. changeSort() {
  71. this.$emit('changeCondition', {
  72. sort: this.sortType
  73. });
  74. }
  75. },
  76. watch: {
  77. condition: {
  78. handler(newVal) {
  79. this.keyword = newVal.q;
  80. this.sortType = newVal.sort;
  81. },
  82. immediate: true,
  83. deep: true,
  84. },
  85. },
  86. beforeMount() {
  87. if (this.type == 0) {
  88. this.sortList = this.techSortList;
  89. this.serchPlaceHolder = '搜索科技项目名称';
  90. } else if (this.type == 1) {
  91. this.serchPlaceHolder = '搜索项目';
  92. this.sortList = this.repoSortList;
  93. }
  94. },
  95. mounted() { },
  96. };
  97. </script>
  98. <style scoped lang="less">
  99. .search-bar {
  100. margin: 30px 0;
  101. display: flex;
  102. justify-content: space-between;
  103. .search-bar-l {
  104. display: flex;
  105. .search-c {
  106. display: flex;
  107. align-items: center;
  108. justify-content: center;
  109. margin-right: 20px;
  110. .search-input-c {
  111. width: 268px;
  112. height: 40px;
  113. border-color: rgba(0, 61, 192, 0.73);
  114. border-width: 2px;
  115. border-style: solid;
  116. font-size: 14px;
  117. line-height: 20px;
  118. padding: 8px;
  119. display: flex;
  120. color: rgb(136, 136, 136);
  121. align-items: center;
  122. background: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20version%3D%221.1%22%3E%3Cdefs%3E%3ClinearGradient%20id%3D%221%22%20x1%3D%220%22%20x2%3D%221%22%20y1%3D%220%22%20y2%3D%220%22%20gradientTransform%3D%22matrix(6.123233995736766e-17%2C%201%2C%20-0.014005111865831027%2C%206.123233995736766e-17%2C%200.5%2C%200)%22%3E%3Cstop%20stop-color%3D%22%23e2d1ea%22%20stop-opacity%3D%221%22%20offset%3D%220%22%3E%3C%2Fstop%3E%3Cstop%20stop-color%3D%22%23ffffff%22%20stop-opacity%3D%221%22%20offset%3D%220.3%22%3E%3C%2Fstop%3E%3C%2FlinearGradient%3E%3C%2Fdefs%3E%3Crect%20width%3D%22100%25%22%20height%3D%22100%25%22%20fill%3D%22url(%231)%22%3E%3C%2Frect%3E%3C%2Fsvg%3E");
  123. input {
  124. width: 100%;
  125. border: none;
  126. outline: none;
  127. }
  128. }
  129. .search-btn {
  130. height: 40px;
  131. font-size: 14px;
  132. line-height: 20px;
  133. padding: 0px;
  134. display: flex;
  135. color: rgb(255, 255, 255);
  136. align-items: center;
  137. text-align: center;
  138. justify-content: center;
  139. padding: 0 20px;
  140. cursor: pointer;
  141. background: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20version%3D%221.1%22%3E%3Cdefs%3E%3ClinearGradient%20id%3D%221%22%20x1%3D%220%22%20x2%3D%221%22%20y1%3D%220%22%20y2%3D%220%22%20gradientTransform%3D%22matrix(-1.1800000000000002%2C%200.9499999999999998%2C%20-0.23749999999999996%2C%20-1.1800000000000002%2C%201.024%2C%200.047)%22%3E%3Cstop%20stop-color%3D%22%23bbd2f2%22%20stop-opacity%3D%221%22%20offset%3D%220.02%22%3E%3C%2Fstop%3E%3Cstop%20stop-color%3D%22%23003dc0%22%20stop-opacity%3D%220.73%22%20offset%3D%221%22%3E%3C%2Fstop%3E%3C%2FlinearGradient%3E%3C%2Fdefs%3E%3Crect%20width%3D%22100%25%22%20height%3D%22100%25%22%20fill%3D%22url(%231)%22%3E%3C%2Frect%3E%3C%2Fsvg%3E");
  142. }
  143. }
  144. .apply-btn {
  145. margin-left: 20px;
  146. border-color: rgb(31, 1, 115);
  147. border-width: 1px;
  148. border-style: solid;
  149. border-radius: 6px;
  150. font-size: 14px;
  151. background: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20version%3D%221.1%22%3E%3Cdefs%3E%3ClinearGradient%20id%3D%221%22%20x1%3D%220%22%20x2%3D%221%22%20y1%3D%220%22%20y2%3D%220%22%20gradientTransform%3D%22matrix(6.123233995736766e-17%2C%201%2C%20-0.08281144868278038%2C%206.123233995736766e-17%2C%200.5%2C%200)%22%3E%3Cstop%20stop-color%3D%22%233291f8%22%20stop-opacity%3D%221%22%20offset%3D%220%22%3E%3C%2Fstop%3E%3Cstop%20stop-color%3D%22%23060075%22%20stop-opacity%3D%220.73%22%20offset%3D%221%22%3E%3C%2Fstop%3E%3C%2FlinearGradient%3E%3C%2Fdefs%3E%3Crect%20width%3D%22100%25%22%20height%3D%22100%25%22%20fill%3D%22url(%231)%22%3E%3C%2Frect%3E%3C%2Fsvg%3E");
  152. &:hover {
  153. opacity: 0.9;
  154. }
  155. &:active {
  156. opacity: 0.8;
  157. }
  158. }
  159. .openi-link-c {
  160. margin-left: 20px;
  161. display: flex;
  162. align-items: center;
  163. justify-content: center;
  164. .openi-link {
  165. text-decoration: underline;
  166. color: rgb(50, 145, 248);
  167. }
  168. }
  169. }
  170. .sort-c {
  171. display: flex;
  172. align-items: center;
  173. justify-content: center;
  174. justify-self: flex-end;
  175. }
  176. }
  177. </style>