config.vue
5.25 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<template>
<CollapseItem :name="t('information.playerConfig')" :expanded="true">
<setting-item-box :name="t('information.uploadImage')" :alone="true">
<setting-item>
<TKUpload :uploadImageUrl="optionData.poster" @sendFile="handleSendFile" @removeFile="handleRemoveFile" />
</setting-item>
</setting-item-box>
<setting-item-box :name="t('information.sourceType')" :alone="true">
<setting-item>
<n-radio-group @update:value="handleChecked" v-model:value="optionData.sourceType" name="radiogroup">
<n-space>
<n-radio v-for="(item, index) in sourceTypes" :key="item.value + index" :value="item.value">
{{ item.label }}
</n-radio>
</n-space>
</n-radio-group>
</setting-item>
</setting-item-box>
<setting-item-box v-if="optionData.sourceType === sourceTypeEnum.CUSTOM" :name="t('common.sourceAddress')" :alone="true">
<setting-item>
<n-input-group>
<n-input v-model:value="optionData.customVideoUrl" size="small" :placeholder="t('common.pleaseEnterTheSourceAddress')"></n-input>
</n-input-group>
</setting-item>
</setting-item-box>
<setting-item-box v-if="optionData.sourceType === sourceTypeEnum.PLATFORM" :name="t('common.organizationText')" :alone="true">
<setting-item>
<n-tree-select
placement="top-start"
label-field="name"
v-model:value="optionData.organization"
key-field="id"
children-field="children"
:options="originationOption"
@update:value="handleUpdateTreeValue"
/>
</setting-item>
</setting-item-box>
<setting-item-box v-if="optionData.sourceType === sourceTypeEnum.PLATFORM" :name="t('common.videoText')" :alone="true">
<setting-item>
<n-select
@update:value="handleSelect"
v-model:value="optionData.videoId"
:options="videoOptions"
:placeholder="t('information.placeVideUrl')"
/>
</setting-item>
</setting-item-box>
<setting-item-box :name="t('information.autoplay')">
<setting-item>
<n-switch v-model:value="optionData.autoplay" size="small" />
</setting-item>
</setting-item-box>
</CollapseItem>
</template>
<script setup lang="ts">
import { PropType, ref, onMounted, watch } from 'vue'
import { AccessMode, option, sourceTypeEnum, videoListInterface, sourceTypeNameEnum, Dataset } from './config'
import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
import { NTreeSelect } from 'naive-ui'
import { getOrganizationList, getVideoList } from '@/api/external/common/index'
import { TKUpload } from '@/components/external/Common/TKUpload'
const props = defineProps({
optionData: {
type: Object as PropType<typeof option>,
required: true
}
})
const t = window['$t']
const sourceTypes = [
{
value: sourceTypeEnum.CUSTOM,
label: t('information.custom')
},
{
value: sourceTypeEnum.PLATFORM,
label: t('information.platform')
}
]
const originationOption = ref<Recordable[]>([])
const videoOptions = ref<videoListInterface[]>([])
const getOriginationList = async () => {
const res = await getOrganizationList()
originationOption.value = res
}
const handleUpdateTreeValue = (value: string) => {
props.optionData.dataset = {} as Dataset
getVideoLists(value)
}
const getVideoLists = async (organizationId: string) => {
const res = await getVideoList({ organizationId })
if (!res) return
videoOptions.value = res?.data?.map((item) => {
return {
label: item.name,
value: item.id,
customUrl: item.accessMode === AccessMode.ManuallyEnter ? item.videoUrl : '', //参数只给自定义视频流使用
id: item.id,
accessMode: item.accessMode,
channelId: item.accessMode === AccessMode.GBT28181 ? item?.params?.channelNo : '', //参数只给gbt28181使用
deviceId: item.accessMode === AccessMode.GBT28181 ? item?.params?.deviceId : '', //参数只给gbt28181使用
playProtocol: item?.playProtocol
} as any
})
}
const handleChecked = (value: string) => {
props.optionData.dataset = {} as Dataset
props.optionData.organization = ''
props.optionData.videoId = null
props.optionData.customVideoUrl = ''
if (value === sourceTypeEnum.PLATFORM) {
getOriginationList()
}
}
const handleSelect = (_: string, e: videoListInterface) => {
const { accessMode, id, customUrl, channelId, deviceId, value } = e
props.optionData.videoId = value as any
props.optionData.dataset = {
accessMode,
id,
customUrl,
channelId,
deviceId,
value
}
}
watch(()=>props.optionData, (newData)=>{
if (newData.sourceType === sourceTypeEnum.PLATFORM) {
getOriginationList()
if (newData.organization) {
getVideoLists(newData.organization)
}
}
},
{
immediate: true,
deep: true
})
onMounted(() => {
if (props.optionData.sourceType === sourceTypeEnum.PLATFORM) {
getOriginationList()
if (props.optionData.organization) {
getVideoLists(props.optionData.organization)
}
}
})
const handleSendFile = (file: string) => {
if (!file) return
props.optionData.poster = file
}
const handleRemoveFile = (status: boolean) => (status ? (props.optionData.poster = '') : null)
</script>