index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <div class="d-flex align-center" :style="{'margin': '0 auto', 'width': tipsText ? '963px': '800px'}">
  3. <span v-if="tipsText" class="color-666 mr-3">{{ tipsText }}</span>
  4. <div class="search d-flex align-center">
  5. <v-menu v-if="defineProps.text" :close-delay="1" :open-delay="0" v-bind="$attrs">
  6. <template v-slot:activator="{ isActive, props }">
  7. <v-btn
  8. style="height: 100%; font-size: 16px;"
  9. variant="text"
  10. density="comfortable"
  11. :append-icon="isActive ? 'mdi mdi-menu-up' : 'mdi mdi-menu-down'"
  12. color="primary"
  13. v-bind="props"
  14. >
  15. {{ defineProps.text }}
  16. </v-btn>
  17. </template>
  18. <jobTypeCard v-if="defineProps.text === '职位类型'" isBuryingPoint class="jobTypeCardBox" @handleJobClick="handleClickJob"></jobTypeCard>
  19. </v-menu>
  20. <!-- <div style="position: relative;">
  21. <div class="jobBox d-flex pl-5" :class="{'drawer': drawer}" @click.stop="drawer = !drawer">
  22. <span>{{ text }}</span>
  23. <span class="mdi mdi-chevron-down px-2" style="font-size: 18px;"></span>
  24. </div>
  25. <jobTypeCard class="jobTypeCardBox" v-if="drawer" @click.stop=""></jobTypeCard>
  26. </div> -->
  27. <v-text-field
  28. v-model="value"
  29. :placeholder="defineProps.placeholder"
  30. color="primary"
  31. variant="plain"
  32. density="compact"
  33. :hide-details="true"
  34. clearable
  35. class="ml-3 px-2"
  36. style="height: 100%; line-height: 100%;"
  37. @click:clear="handleSearch"
  38. @keyup.enter="handleSearch"
  39. ></v-text-field>
  40. <v-hover v-slot="{ isHovering, props }">
  41. <v-btn v-bind="props" v-ripple.center class="searchBtn" @click="handleSearch" :class="isHovering ? 'elevation-10' : 'elevation-5'">搜索</v-btn>
  42. </v-hover>
  43. </div>
  44. </div>
  45. </template>
  46. <script setup>
  47. import { useSharedState } from '@/store/sharedState'
  48. import jobTypeCard from '@/components/jobTypeCard'
  49. import { ref, watch } from 'vue'
  50. import { useRoute, useRouter } from 'vue-router'
  51. defineOptions({ name:'common-components-headSearch'})
  52. const route = useRoute(); const router = useRouter()
  53. const emits = defineEmits(['update:modelValue', 'handleSearch', 'handleJobClick'])// 定义一个或多个自定义事件
  54. const defineProps = defineProps({
  55. modelValue: [String, Number],
  56. placeholder: {
  57. type: String,
  58. default: '搜索职位/公司关键字'
  59. },
  60. text: {
  61. type: String,
  62. default: ''
  63. },
  64. tipsText: {
  65. type: String,
  66. default: ''
  67. }
  68. })
  69. // const value = ref('')
  70. const value = ref(defineProps.modelValue)
  71. let drawer = ref(false)
  72. if (route.query && route.query?.content) value.value = route.query.content.includes('%') ? decodeURIComponent(route.query.content) : route.query.content
  73. // 点击外部关闭职位下拉
  74. const sharedState = useSharedState()
  75. // 监听 layoutClickCount 变化
  76. watch(() => sharedState.layoutClickCount, () => {
  77. if (drawer.value) drawer.value = false
  78. });
  79. const handleSearch = () => {
  80. const name = value.value ? value.value.includes('&') ? encodeURIComponent(value.value) : value.value : ''
  81. emits('handleSearch', name)
  82. }
  83. const handleClickJob = (val) => {
  84. // 职位搜索页点击传参, 其它的跳转到职位搜索页
  85. if (route.path !== '/recruit/personal/position') router.push(`/recruit/personal/position?positionId=${val[0]}`)
  86. else emits('handleJobClick', val)
  87. }
  88. </script>
  89. <style lang="scss" scoped>
  90. .search {
  91. height: 50px;
  92. width: 800px;
  93. border-top: 2px solid var(--v-primary-base);
  94. border-left: 2px solid var(--v-primary-base);
  95. border-bottom: 2px solid var(--v-primary-base);
  96. border-radius: 5px;
  97. .jobBox {
  98. cursor: pointer;
  99. &:hover {
  100. color: var(--v-primary-base);
  101. }
  102. span {
  103. max-width: 150px;
  104. white-space: nowrap;
  105. overflow: hidden;
  106. text-overflow: ellipsis;
  107. }
  108. }
  109. .drawer {
  110. color: var(--v-primary-base);
  111. }
  112. .searchBtn {
  113. width: 180px;
  114. height: 50px;
  115. line-height: 48px;
  116. text-align: center;
  117. font-size: 18px;
  118. color: #fff;
  119. background-color: var(--v-primary-base);
  120. cursor: pointer;
  121. }
  122. .jobTypeCardBox {
  123. position: absolute;
  124. top: 42px;
  125. left: 0;
  126. }
  127. }
  128. </style>