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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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.native="search">
  7. </div>
  8. <div class="search-btn" @click="search">搜索</div>
  9. </div>
  10. <el-button class="apply-btn" type="primary" icon="el-icon-plus" size="medium" @click="apply">申请展示项目</el-button>
  11. <el-button class="apply-btn" type="primary" icon="el-icon-s-management" size="medium" v-if="isTechAdmin"
  12. @click="manage">管理展示项目</el-button>
  13. <div class="openi-link-c">
  14. <a class="openi-link" href="">OpenI启智社区开源指南</a>
  15. </div>
  16. </div>
  17. <div class="sort-c">
  18. <el-select class="select" size="medium" v-model="sortType" @change="changeSort" placeholder="排序" clearable>
  19. <el-option v-for="item in sortList" :key="item.k" :label="item.v" :value="item.k" />
  20. </el-select>
  21. </div>
  22. </div>
  23. </template>
  24. <script>
  25. import { getIsTechAdmin } from '~/apis/modules/tech';
  26. export default {
  27. name: "SearchBar",
  28. props: {
  29. condition: { type: Object, default: () => ({}) },
  30. },
  31. components: {},
  32. data() {
  33. return {
  34. keyword: '',
  35. serchPlaceHolder: '搜索项目名称/简介',
  36. sortType: '',
  37. sortList: [{
  38. k: '1',
  39. v: '最近更新',
  40. }, {
  41. k: '2',
  42. v: '项目成果数',
  43. }],
  44. isTechAdmin: true,
  45. };
  46. },
  47. methods: {
  48. search() {
  49. this.$emit('changeCondition', {
  50. q: this.keyword.trim()
  51. });
  52. },
  53. apply() {
  54. window.location.href = '/tech/new';
  55. },
  56. manage() {
  57. window.location.href = '/tech/admin_view';
  58. },
  59. changeSort() {
  60. this.$emit('changeCondition', {
  61. sort: this.sortType
  62. });
  63. }
  64. },
  65. watch: {
  66. condition: {
  67. handler(newVal) {
  68. console.log('searchBar:watch:condition', newVal);
  69. this.keyword = newVal.q;
  70. this.sortType = newVal.sort;
  71. },
  72. immediate: true,
  73. deep: true,
  74. },
  75. },
  76. beforeMount() {
  77. getIsTechAdmin().then(res => {
  78. console.log(res);
  79. }).catch(err => {
  80. console.log(err);
  81. });
  82. },
  83. mounted() { },
  84. };
  85. </script>
  86. <style scoped lang="less">
  87. .search-bar {
  88. margin: 30px 0;
  89. display: flex;
  90. justify-content: space-between;
  91. .search-bar-l {
  92. display: flex;
  93. .search-c {
  94. display: flex;
  95. align-items: center;
  96. justify-content: center;
  97. margin-right: 20px;
  98. .search-input-c {
  99. width: 268px;
  100. height: 40px;
  101. border-color: rgba(0, 61, 192, 0.73);
  102. border-width: 2px;
  103. border-style: solid;
  104. font-size: 14px;
  105. line-height: 20px;
  106. padding: 8px;
  107. display: flex;
  108. color: rgb(136, 136, 136);
  109. align-items: center;
  110. 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");
  111. input {
  112. width: 100%;
  113. border: none;
  114. outline: none;
  115. }
  116. }
  117. .search-btn {
  118. height: 40px;
  119. font-size: 14px;
  120. line-height: 20px;
  121. padding: 0px;
  122. display: flex;
  123. color: rgb(255, 255, 255);
  124. align-items: center;
  125. text-align: center;
  126. justify-content: center;
  127. padding: 0 20px;
  128. cursor: pointer;
  129. 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");
  130. }
  131. }
  132. .apply-btn {
  133. margin-left: 20px;
  134. border-color: rgb(31, 1, 115);
  135. border-width: 1px;
  136. border-style: solid;
  137. border-radius: 6px;
  138. font-size: 14px;
  139. 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");
  140. &:hover {
  141. opacity: 0.9;
  142. }
  143. &:active {
  144. opacity: 0.8;
  145. }
  146. }
  147. .openi-link-c {
  148. margin-left: 20px;
  149. display: flex;
  150. align-items: center;
  151. justify-content: center;
  152. .openi-link {
  153. text-decoration: underline;
  154. color: rgb(50, 145, 248);
  155. }
  156. }
  157. }
  158. .sort-c {
  159. display: flex;
  160. align-items: center;
  161. justify-content: center;
  162. justify-self: flex-end;
  163. }
  164. }
  165. </style>