ll
liukangdong
2024-10-18 e6acb39a2475e211f2c1decc45a95c868239c25f
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
<template>
  <el-select
    class="data-perm-type-select"
    :class="{select__block: !inline}"
    :value="value"
    :placeholder="placeholder"
    :clearable="clearable"
    :disabled="disabled"
    @change="$emit('change', $event)"
    @input="$emit('input', $event)"
  >
    <el-option v-for="type in filterTypes" :key="type.code" :value="type.code" :label="type.remark"/>
  </el-select>
</template>
 
<script>
import { fetchTypes } from '@/api/system/dataPermission'
export default {
  name: 'DataPermTypeSelect',
  props: {
    value: {},
    // 模块名称
    module: {},
    placeholder: {
      default: '请选择权限类型'
    },
    inline: {
      default: true
    },
    disabled: {},
    clearable: {
      default: false
    }
  },
  data () {
    return {
      types: []
    }
  },
  computed: {
    filterTypes () {
      if (this.module == null || this.module === '') {
        return []
      }
      const types = []
      for (const type of this.types) {
        if (type.modules.length === 0 || type.modules.indexOf(this.module) !== -1) {
          types.push(type)
        }
      }
      return types
    }
  },
  created () {
    fetchTypes()
      .cache()
      .then(data => {
        this.types = data
      })
  }
}
</script>
<style lang="scss" scoped>
  .select__block {
    display: block;
  }
</style>