|
@@ -1,25 +1,37 @@
|
|
|
<template>
|
|
<template>
|
|
|
<div class="presetSetting">
|
|
<div class="presetSetting">
|
|
|
<div style="margin-right: 10px">预置位</div>
|
|
<div style="margin-right: 10px">预置位</div>
|
|
|
- <div
|
|
|
|
|
- ><ElSelect
|
|
|
|
|
- v-model="currentPresetToken"
|
|
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <ElSelect
|
|
|
|
|
+ :model-value="currentPresetToken"
|
|
|
size="small"
|
|
size="small"
|
|
|
- @change="emits('update:modelValue', $event)"
|
|
|
|
|
|
|
+ filterable
|
|
|
|
|
+ @update:model-value="handleChangeValue"
|
|
|
>
|
|
>
|
|
|
<ElOption
|
|
<ElOption
|
|
|
v-for="item in presetOptions"
|
|
v-for="item in presetOptions"
|
|
|
:key="item.token"
|
|
:key="item.token"
|
|
|
:label="item.name"
|
|
:label="item.name"
|
|
|
:value="item.token"
|
|
:value="item.token"
|
|
|
- /> </ElSelect
|
|
|
|
|
- ></div>
|
|
|
|
|
|
|
+ >
|
|
|
|
|
+ <span style="float: left">{{ item.name }}</span>
|
|
|
|
|
+ <span style="float: right; color: var(--el-text-color-secondary); font-size: 13px">
|
|
|
|
|
+ <!-- 点击删除的时候,阻止选中菜单 -->
|
|
|
|
|
+ <el-icon @click.stop="handleDeletePreset(item.token)"><CircleCloseFilled /></el-icon>
|
|
|
|
|
+ </span>
|
|
|
|
|
+ </ElOption>
|
|
|
|
|
+ </ElSelect>
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
|
- import { ElSelect, ElOption } from 'element-plus';
|
|
|
|
|
|
|
+ import { ElSelect, ElOption, ElMessage, ElMessageBox } from 'element-plus';
|
|
|
|
|
+ import { CircleCloseFilled } from '@element-plus/icons-vue';
|
|
|
import usePresetListStore from '../../store/usePresetListStore';
|
|
import usePresetListStore from '../../store/usePresetListStore';
|
|
|
import { storeToRefs } from 'pinia';
|
|
import { storeToRefs } from 'pinia';
|
|
|
|
|
+ import { deletePresetApi } from '@/api/camera/camera-preview';
|
|
|
|
|
+ import useCameraDetailStore from '../../store/useCameraDetailStore';
|
|
|
|
|
+ import { ref } from 'vue';
|
|
|
// const presetOptions = ref([
|
|
// const presetOptions = ref([
|
|
|
// { label: '预置位1', value: 'p1' },
|
|
// { label: '预置位1', value: 'p1' },
|
|
|
// { label: '预置位2', value: 'p2' },
|
|
// { label: '预置位2', value: 'p2' },
|
|
@@ -27,10 +39,41 @@
|
|
|
|
|
|
|
|
const presetListStore = usePresetListStore();
|
|
const presetListStore = usePresetListStore();
|
|
|
|
|
|
|
|
|
|
+ const cameraDetailStore = useCameraDetailStore();
|
|
|
|
|
+
|
|
|
const { data: presetOptions, currentPresetToken } = storeToRefs(presetListStore);
|
|
const { data: presetOptions, currentPresetToken } = storeToRefs(presetListStore);
|
|
|
|
|
|
|
|
- const props = defineProps<{ modelValue: string }>();
|
|
|
|
|
- const emits = defineEmits<{ (e: 'update:modelValue', data: string): unknown }>();
|
|
|
|
|
|
|
+ const handleDeletePreset = (token: string) => {
|
|
|
|
|
+ ElMessageBox({
|
|
|
|
|
+ message:
|
|
|
|
|
+ '该预置位可能存在关联的电子围栏。删除该预置位将会删除对应的电子围栏信息,请确认是否删除',
|
|
|
|
|
+ title: '删除确认',
|
|
|
|
|
+ showCancelButton: true,
|
|
|
|
|
+ confirmButtonText: '确认删除',
|
|
|
|
|
+ beforeClose: (action, instance, done) => {
|
|
|
|
|
+ if (action === 'confirm') {
|
|
|
|
|
+ instance.confirmButtonLoading = true;
|
|
|
|
|
+ deletePresetApi({ presetToken: token, cameraId: cameraDetailStore.cameraId })
|
|
|
|
|
+ .then((res) => {
|
|
|
|
|
+ ElMessage.success('删除成功!');
|
|
|
|
|
+ presetListStore.getPresetList(cameraDetailStore.cameraId);
|
|
|
|
|
+ currentPresetToken.value = presetOptions.value?.[0].token || '';
|
|
|
|
|
+ done();
|
|
|
|
|
+ })
|
|
|
|
|
+ .finally(() => {
|
|
|
|
|
+ instance.confirmButtonLoading = true;
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ done();
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ });
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const handleChangeValue = (val) => {
|
|
|
|
|
+ console.log('changeValue', val);
|
|
|
|
|
+ currentPresetToken.value = val;
|
|
|
|
|
+ };
|
|
|
</script>
|
|
</script>
|
|
|
<style scoped>
|
|
<style scoped>
|
|
|
.presetSetting {
|
|
.presetSetting {
|