emcp/frontend/src/views/ControlView.vue

29 lines
832 B
Vue
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<script setup lang="ts">
import { ref } from "vue"
import { controlSwitch } from "../api/platform"
defineProps<{ store: any; actions: any }>()
const channel = ref(1)
const result = ref("等待下发")
async function sendControl(action: number) {
const response = await controlSwitch(channel.value, action)
result.value = response.data.control_status
}
</script>
<template>
<section class="panel">
<h2>控制指令</h2>
<div class="form-grid">
<label>开关通道<input v-model="channel" type="number" min="1" max="12" /></label>
</div>
<div class="actions">
<button class="primary" @click="sendControl(1)">合闸</button>
<button class="primary" @click="sendControl(0)">分闸</button>
</div>
<p>执行结果{{ result }}</p>
</section>
</template>