SelectDevice.vue
1.51 KB
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
<template>
<Select
placeholder="请选择设备"
v-model:value="selectValue"
style="width: 100%"
:options="selectOptions"
v-bind="createPickerSearch()"
@change="handleDeviceChange"
:disabled="disabled"
mode="multiple"
labelInValue
/>
<template v-for="(item, index) in deviceList" :key="index">
<InputChannel
:ref="bindDeviceRef.deviceAttrRef"
:value="item"
:index="index"
:disabled="disabled"
/>
</template>
</template>
<script lang="ts" setup name="SelectDevice">
import { ref, Ref, PropType, unref } from 'vue';
import { Select } from 'ant-design-vue';
import { createPickerSearch } from '/@/utils/pickerSearch';
import { StreamInterface } from '../config.data';
import InputChannel from './InputChannel.vue';
defineProps({
selectOptions: {
type: Array as PropType<StreamInterface[]>,
required: true,
},
disabled: {
type: Boolean,
required: false,
},
});
const selectValue = ref([]);
const bindDeviceRef = {
deviceAttrRef: ref([]),
};
const deviceList: Ref<StreamInterface[]> = ref([]);
const getDeviceChannels = () => {
return unref(bindDeviceRef.deviceAttrRef)?.map((item: any) => item.emitChange());
};
const handleDeviceChange = (_, options) => {
deviceList.value = options;
};
const resetValue = () => {
selectValue.value = [];
deviceList.value = [];
};
defineExpose({
resetValue,
getDeviceChannels,
});
</script>
<style scoped lang="css"></style>