HeaderOne.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <div class="HeaderOne">
  3. <div>
  4. <span :class="[language_type == 'AR' ? 'albbefor' : 'befor']" @click="backHome">
  5. <img src="../../assets/teacherdev/Frame3.png" alt="" />
  6. </span>
  7. <template v-if="allList">
  8. <span>
  9. <img src="../../assets/teacherdev/Frame2759.png" alt="" />
  10. </span>
  11. <span class="text" @click="back"> <!-- 全部列表 -->{{ this.$t("Key572") }} </span>
  12. </template>
  13. <span>
  14. <img src="../../assets/teacherdev/Frame2759.png" alt="" />
  15. </span>
  16. <span class="text">{{ text }}</span>
  17. </div>
  18. <div>
  19. <div class="seek" @keyup="keyDownSeekData">
  20. <el-input
  21. type="text"
  22. name=""
  23. id=""
  24. :placeholder="$t('Key43')"
  25. v-model="SeekName"
  26. @change="SeekName = SeekName.trim()"
  27. maxlength="50"
  28. />
  29. <img @click="gotoSeekResult" src="../../assets/teacherdev/Group2149.png" alt="" />
  30. </div>
  31. </div>
  32. </div>
  33. </template>
  34. <script>
  35. //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  36. //例如:import 《组件名称》from ‘《组件路径》';
  37. import { mapGetters } from "vuex";
  38. export default {
  39. //import引入的组件需要注入到对象中才能使用
  40. components: {},
  41. props: ["type", "text", "changeKeycode", "keycode", "allList"],
  42. data() {
  43. //这里存放数据
  44. return {
  45. SeekName: "",
  46. AllList: false,
  47. };
  48. },
  49. //计算属性 类似于data概念
  50. computed: {
  51. ...mapGetters(["language_type"]),
  52. },
  53. //监控data中数据变化
  54. watch: {},
  55. //方法集合
  56. methods: {
  57. backHome() {
  58. this.$router.push("/");
  59. },
  60. back() {
  61. this.$router.back();
  62. },
  63. // 前往搜索结果
  64. gotoSeekResult() {
  65. if (this.SeekName != "") {
  66. // 是不是在搜索结果页面不是则跳转
  67. this.SeekName = this.SeekName.trim();
  68. if (this.$route.name == "Viewmore") {
  69. this.changeKeycode(this.SeekName);
  70. } else {
  71. this.$router.push({
  72. path: "/Viewmore",
  73. query: { keyWord: this.SeekName, id: this.$route.query.id },
  74. });
  75. }
  76. } else {
  77. this.$message.warning(this.$t("Key46")); //请输入内容
  78. }
  79. },
  80. // 回车搜索
  81. keyDownSeekData(e) {
  82. if (e.keyCode == 13) {
  83. if (this.SeekName != "") {
  84. this.SeekName = this.SeekName.trim();
  85. if (this.$route.name == "Viewmore") {
  86. this.changeKeycode(this.SeekName);
  87. this.$router.replace({
  88. path: "/Viewmore",
  89. query: {
  90. keycode: this.SeekName,
  91. },
  92. });
  93. } else {
  94. this.$router.push({
  95. path: "/Viewmore",
  96. query: { keyWord: this.SeekName, id: this.$route.query.id },
  97. });
  98. }
  99. } else {
  100. this.$message.warning(this.$t("Key46")); //请输入内容
  101. }
  102. }
  103. },
  104. },
  105. //生命周期 - 创建完成(可以访问当前this实例)
  106. created() {
  107. if (this.keycode) {
  108. this.SeekName = this.keycode;
  109. }
  110. },
  111. //生命周期 - 挂载完成(可以访问DOM元素)
  112. mounted() {},
  113. //生命周期-创建之前
  114. beforeCreated() {},
  115. //生命周期-挂载之前
  116. beforeMount() {},
  117. //生命周期-更新之前
  118. beforUpdate() {},
  119. //生命周期-更新之后
  120. updated() {},
  121. //生命周期-销毁之前
  122. beforeDestory() {},
  123. //生命周期-销毁完成
  124. destoryed() {},
  125. //如果页面有keep-alive缓存功能,这个函数会触发
  126. activated() {},
  127. };
  128. </script>
  129. <style lang="scss" scoped>
  130. /* @import url(); 引入css类 */
  131. .HeaderOne {
  132. display: flex;
  133. justify-content: space-between;
  134. align-items: center;
  135. padding: 0 120px 0 24px;
  136. height: 64px;
  137. background: #fff;
  138. >:first-child {
  139. display: flex;
  140. align-items: center;
  141. > span {
  142. margin-left: 15px;
  143. cursor: pointer;
  144. img {
  145. width: 24px;
  146. }
  147. }
  148. .befor,
  149. .albbefor {
  150. img {
  151. width: 24px;
  152. }
  153. }
  154. .befor::before {
  155. content: "|";
  156. width: 6px;
  157. height: 24px;
  158. color: #ff9900;
  159. background: #ff9900;
  160. position: relative;
  161. right: 10px;
  162. }
  163. .albbefor::before {
  164. content: "|";
  165. width: 6px;
  166. height: 24px;
  167. color: #ff9900;
  168. background: #ff9900;
  169. position: relative;
  170. left: 10px;
  171. }
  172. .text {
  173. font-weight: bold;
  174. font-size: 16px;
  175. color: #2c2c2c;
  176. }
  177. }
  178. .seek {
  179. width: 300px;
  180. height: 40px;
  181. background: #ffffff;
  182. border: 1px solid #d9d9d9;
  183. box-sizing: border-box;
  184. border-radius: 8px;
  185. display: flex;
  186. align-items: center;
  187. justify-content: space-between;
  188. padding: 0 16px;
  189. input {
  190. width: 90%;
  191. border: none;
  192. outline: none;
  193. margin-left: 5px;
  194. }
  195. img {
  196. width: 18px;
  197. height: 18px;
  198. }
  199. }
  200. }
  201. </style>
  202. <style lang="scss">
  203. .seek {
  204. .el-input__inner {
  205. border: none;
  206. height: 38px;
  207. padding: 0;
  208. }
  209. }
  210. </style>