7 changed files with 145 additions and 40 deletions
@ -0,0 +1,42 @@ |
|||||
|
<script setup> |
||||
|
import { computed, defineProps, defineEmits, ref, watch } from 'vue'; |
||||
|
import { useStore } from 'vuex'; |
||||
|
|
||||
|
const props = defineProps({ status: Object }); |
||||
|
|
||||
|
defineEmits(['search']); |
||||
|
|
||||
|
const store = useStore(); |
||||
|
const devices = computed(() => store.state.device.devices); // 设备/站点列表 |
||||
|
const deviceId = ref(''); // 选中的设备id |
||||
|
const currentDeviceId = computed(() => store.state.device.currentDeviceId); // 正在操作的设备的id |
||||
|
const get = computed(() => (props.status.get ? '设置生效' : '等待下发')); |
||||
|
const set = computed(() => (props.status.set ? '设置生效' : '等待下发')); |
||||
|
|
||||
|
// 监听currentDeviceId |
||||
|
watch( |
||||
|
() => currentDeviceId.value, |
||||
|
newValue => { |
||||
|
console.log('newValue: ', newValue); |
||||
|
if (newValue && deviceId.value !== newValue) { |
||||
|
deviceId.value = newValue; |
||||
|
} |
||||
|
}, |
||||
|
{ immediate: true }, |
||||
|
); |
||||
|
</script> |
||||
|
|
||||
|
<template> |
||||
|
<div class="mb-3"> |
||||
|
<span class="text-sm text-gray-500">选择站点:</span> |
||||
|
<el-select v-model="deviceId" placeholder="选择站点" @change="$emit('search', deviceId)"> |
||||
|
<el-option v-for="item in devices" :key="item.deviceId" :label="item.address" :value="item.deviceId"></el-option> |
||||
|
</el-select> |
||||
|
|
||||
|
<span class="text-sm text-gray-500 ml-10">获取状态:</span> |
||||
|
<el-tag type="success">{{ get }}</el-tag> |
||||
|
|
||||
|
<span class="text-sm text-gray-500 ml-10">设置状态:</span> |
||||
|
<el-tag type="success">{{ set }}</el-tag> |
||||
|
</div> |
||||
|
</template> |
@ -0,0 +1,19 @@ |
|||||
|
<script setup> |
||||
|
import { defineEmits } from 'vue'; |
||||
|
|
||||
|
defineEmits(['refresh']); |
||||
|
</script> |
||||
|
|
||||
|
<template> |
||||
|
<el-tooltip class="refresh-btn shadow-md" effect="dark" content="刷新" placement="top-start"> |
||||
|
<el-button type="primary" icon="el-icon-refresh" circle @click="$emit('refresh')"></el-button> |
||||
|
</el-tooltip> |
||||
|
</template> |
||||
|
|
||||
|
<style scoped> |
||||
|
.refresh-btn { |
||||
|
position: absolute; |
||||
|
right: 20px; |
||||
|
bottom: 20px; |
||||
|
} |
||||
|
</style> |
Loading…
Reference in new issue