financingStatus.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <template>
  2. <div class="d-flex">
  3. <div class="label-title">融资阶段</div>
  4. <div class="label-content">
  5. <span
  6. v-for="k in items"
  7. :key="k.value"
  8. :class="['label-color', {'actives': k.active}]"
  9. @click="handleItemClick(k)"
  10. >{{ k.label }}</span>
  11. </div>
  12. </div>
  13. </template>
  14. <script setup>
  15. defineOptions({ name: 'search-financing-status'})
  16. import { ref, watch } from 'vue'
  17. import { useRoute } from 'vue-router'
  18. import { getDict } from '@/hooks/web/useDictionaries'
  19. const emits = defineEmits(['handleClick', 'clear'])
  20. const props = defineProps({
  21. isClear: {
  22. type: Boolean,
  23. default: false
  24. }
  25. })
  26. watch(
  27. () => props.isClear,
  28. (newVal) => {
  29. if (!newVal) return
  30. // 清空筛选条件时默认选中不限
  31. items.value.map(e => {
  32. e.active = false
  33. if (e.value === -1) e.active = true
  34. return e
  35. })
  36. emits('clear')
  37. }
  38. )
  39. const route = useRoute()
  40. const routeQuery = route.query
  41. const items = ref([])
  42. getDict('menduner_financing_status').then(({ data }) => {
  43. data = data?.length && data || []
  44. const list = data.map(e => {
  45. e.active = false
  46. return e
  47. })
  48. items.value = [{ value: -1, label: '不限', active: true }, ...list]
  49. // 刷新回显
  50. if (routeQuery.financingStatus) {
  51. const obj = items.value.find(e => e.value === routeQuery.financingStatus)
  52. items.value.map(e => e.active = false)
  53. if (obj) obj.active = true
  54. }
  55. })
  56. const handleItemClick = (k) => {
  57. items.value.map(e => e.active = false)
  58. k.active = true
  59. emits('handleClick', k.value, 'financingStatus')
  60. }
  61. </script>
  62. <style scoped lang="scss">
  63. @import '@/styles/recruit/company.scss';
  64. </style>