jiangping
2023-09-13 5c82263c61825c37514b2329ee3ffa425e62a900
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
<template>
  <component :is="component" :value="values" :inline="false" @input="handleInput" multiple/>
</template>
 
<script>
export default {
  name: 'CustomSelect',
  props: {
    value: {},
    businessCode: {
      type: String,
      required: true
    }
  },
  computed: {
    // vuetreeselect值类型匹配(解决编辑时无法删除已有值的BUG)
    values () {
      if (this.businessCode === 'DEPARTMENT' || this.businessCode === 'POSITION') {
        const values = []
        for (const id of this.value) {
          values.push(parseInt(id))
        }
        return values
      }
      return this.value
    },
    component () {
      // 部门选择器
      if (this.businessCode === 'DEPARTMENT') {
        return () => import('@/components/common/DepartmentSelect')
      }
      // 岗位选择器
      if (this.businessCode === 'POSITION') {
        return () => import('@/components/common/PositionSelect')
      }
      return null
    }
  },
  methods: {
    handleInput (value) {
      this.$emit('input', value)
      this.$emit('change', value)
    }
  }
}
</script>
 
<style scoped>
 
</style>