index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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
  73. // 点击外部关闭职位下拉
  74. const sharedState = useSharedState()
  75. // 监听 layoutClickCount 变化
  76. watch(() => sharedState.layoutClickCount, () => {
  77. if (drawer.value) drawer.value = false
  78. });
  79. const handleSearch = () => {
  80. // // 职位搜索页传参,其它的跳转到职位搜索页
  81. // if (route.path !== '/recruit/personal/position') {
  82. // if (value.value) router.push(`/recruit/personal/position?content=${value.value}`)
  83. // else router.push('/recruit/personal/position')
  84. // } else emits('handleSearch', value.value)
  85. emits('handleSearch', value.value)
  86. }
  87. const handleClickJob = (val) => {
  88. // 职位搜索页点击传参, 其它的跳转到职位搜索页
  89. if (route.path !== '/recruit/personal/position') router.push(`/recruit/personal/position?positionId=${val[0]}`)
  90. else emits('handleJobClick', val)
  91. }
  92. </script>
  93. <style lang="scss" scoped>
  94. .search {
  95. height: 50px;
  96. width: 800px;
  97. border: 2px solid var(--v-primary-base);
  98. border-radius: 5px;
  99. .jobBox {
  100. cursor: pointer;
  101. &:hover {
  102. color: var(--v-primary-base);
  103. }
  104. span {
  105. max-width: 150px;
  106. white-space: nowrap;
  107. overflow: hidden;
  108. text-overflow: ellipsis;
  109. }
  110. }
  111. .drawer {
  112. color: var(--v-primary-base);
  113. }
  114. .searchBtn {
  115. width: 180px;
  116. height: 50px;
  117. line-height: 48px;
  118. text-align: center;
  119. font-size: 18px;
  120. color: #fff;
  121. background-color: var(--v-primary-base);
  122. cursor: pointer;
  123. }
  124. .jobTypeCardBox {
  125. position: absolute;
  126. top: 42px;
  127. left: 0;
  128. }
  129. }
  130. </style>