index.vue 4.1 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. class="ml-3 px-2"
  35. style="height: 100%; line-height: 100%;"
  36. @keyup.enter="handleSearch"
  37. ></v-text-field>
  38. <!-- <div class="searchBtn" @click="handleSearch">搜索</div> -->
  39. <v-btn class="searchBtn" @click="handleSearch">搜索</v-btn>
  40. </div>
  41. </div>
  42. </template>
  43. <script setup>
  44. import { useSharedState } from '@/store/sharedState'
  45. import jobTypeCard from '@/components/jobTypeCard'
  46. import { ref, watch } from 'vue'
  47. import { useRoute, useRouter } from 'vue-router'
  48. defineOptions({ name:'common-components-headSearch'})
  49. const route = useRoute(); const router = useRouter()
  50. const emits = defineEmits(['update:modelValue', 'handleSearch', 'handleJobClick'])// 定义一个或多个自定义事件
  51. const defineProps = defineProps({
  52. modelValue: [String, Number],
  53. placeholder: {
  54. type: String,
  55. default: '搜索职位/公司'
  56. },
  57. text: {
  58. type: String,
  59. default: ''
  60. },
  61. tipsText: {
  62. type: String,
  63. default: ''
  64. }
  65. })
  66. // const value = ref('')
  67. const value = ref(defineProps.modelValue)
  68. let drawer = ref(false)
  69. if (route.query && route.query?.content) value.value = route.query.content
  70. // 点击外部关闭职位下拉
  71. const sharedState = useSharedState()
  72. // 监听 layoutClickCount 变化
  73. watch(() => sharedState.layoutClickCount, () => {
  74. if (drawer.value) drawer.value = false
  75. });
  76. const handleSearch = () => {
  77. // // 职位搜索页传参,其它的跳转到职位搜索页
  78. // if (route.path !== '/recruit/personal/position') {
  79. // if (value.value) router.push(`/recruit/personal/position?content=${value.value}`)
  80. // else router.push('/recruit/personal/position')
  81. // } else emits('handleSearch', value.value)
  82. emits('handleSearch', value.value)
  83. }
  84. const handleClickJob = (val) => {
  85. // 职位搜索页点击传参, 其它的跳转到职位搜索页
  86. if (route.path !== '/recruit/personal/position') router.push(`/recruit/personal/position?positionId=${val[0]}`)
  87. else emits('handleJobClick', val)
  88. }
  89. </script>
  90. <style lang="scss" scoped>
  91. .search {
  92. height: 50px;
  93. width: 800px;
  94. border: 2px solid var(--v-primary-base);
  95. border-radius: 5px;
  96. .jobBox {
  97. cursor: pointer;
  98. &:hover {
  99. color: var(--v-primary-base);
  100. }
  101. span {
  102. max-width: 150px;
  103. white-space: nowrap;
  104. overflow: hidden;
  105. text-overflow: ellipsis;
  106. }
  107. }
  108. .drawer {
  109. color: var(--v-primary-base);
  110. }
  111. .searchBtn {
  112. width: 100px;
  113. height: 50px;
  114. line-height: 48px;
  115. text-align: center;
  116. font-size: 18px;
  117. color: #fff;
  118. background-color: var(--v-primary-base);
  119. cursor: pointer;
  120. }
  121. .jobTypeCardBox {
  122. position: absolute;
  123. top: 42px;
  124. left: 0;
  125. }
  126. }
  127. </style>