wwf
16 小时以前 e1b028d486713eaf55aaf35fbf334aa568059c0d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<template>
  <el-select 
    v-model="occupationJobId" 
    filterable 
    style="flex: 1" 
    class="pr-2" 
    placeholder="全部职业(工种)"
    @change="changeOccupation()"
  >
    <el-option
      v-for="(item,index) in newOccupationItems"
      :key="`occupation${index}`"
      :label="item.occupationJob"
      :value="item.id"
    />
  </el-select>
  <el-select
    v-model="level" 
    :disabled="!occupationJobId" 
    style="flex: 1" class="pr-2" 
    placeholder="全部等级"
    multiple
  >
    <el-option
      v-for="(item,index) in levelItems"
      :key="`level${index}`"
      :label="item.label"
      :value="item.value"
    />
  </el-select>
</template>
 
<script>
import { useOptionItemsStore } from '@/stores/optionItems.js'
 
export default {
  setup() {
    const { occupationItems } = useOptionItemsStore()
    return { occupationItems }
  },
  data() {
    return {
      occupationJobId: '',
      level: [],
      levelItems: []
    }
  },
  props: {
    modelValue: {
      type: Object,
      default: () => {
        return {}
      }
    },
  },
  computed: {
    newOccupationItems() {
      return [{ occupationJob: '全部职业(工种)', id: '' }, ...this.occupationItems]
    }
  },
  watch: {
    occupationJobId: function() {
      this.$emit('update:modelValue', {...this.modelValue, occupationJobId: this.occupationJobId})
    },
    level: function() {
      this.$emit('update:modelValue', {...this.modelValue, level: this.level } )
    }
  },
  methods: {
    changeOccupation() {
      this.level = []
      const id = this.occupationJobId
      if (id) {
        let list = []
        const obj = this.occupationItems.find(ele => ele.id == id)
        let levelStr = obj.levelStr
        levelStr?.split(',').forEach(ele => {
          list.push({
            label: this.$getLevelName(ele),
            value: ele
          })
        })
        this.levelItems = list
      }
    }
  }
}
 
</script>