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
| <template>
| <!-- <el-form-item label="场景类型" :prop="prop"> -->
| <el-select
| :model-value="modelValue"
| @change="handleChange"
| placeholder="场景类型"
| size="small"
| :style="'width: ' + width + 'px'"
| >
| <el-option v-for="s in sceneTypes" :key="s.value" :label="s.label" :value="s" />
| </el-select>
| <!-- </el-form-item> -->
| </template>
|
| <script>
| import { enumScene } from '@/enum/scene'
|
| export default {
| props: {
| // 是否在首选项处添加“全部”选项
| allOption: {
| type: Boolean,
| default: true
| },
| // 1:飞羽环境系统;2:飞羽监管系统;
| type: {
| type: Number,
| default: 1
| },
| // 返回结果
| modelValue: Object,
| // 是否默认返回初始选项
| initValue: {
| type: Boolean,
| default: true
| },
| // form表单绑定属性名
| prop: {
| type: String,
| default: '_scenetype'
| },
| // 切换 type 后,当前选项是否清空
| sourceInit: {
| type: Boolean,
| default: true
| },
| width: {
| type: Number,
| default: 220
| }
| },
| emits: ['update:modelValue'],
| data() {
| return {
| // sceneTypes: enumScene(this.type, this.allOption),
| }
| },
| computed: {
| sceneTypes() {
| if (this.sourceInit) {
| // 当因为type或者allOption参数变化引起选项变更时,清空当前选项
| this.handleChange()
| }
| return enumScene(this.type, this.allOption)
| }
| },
| methods: {
| handleChange(value) {
| this.$emit('update:modelValue', value)
| }
| },
| mounted() {
| if (this.initValue) {
| this.handleChange(this.sceneTypes[0])
| }
| }
| }
| </script>
|
|