Commit fecd5f00 by 周田

docs:添加注释

parent dd092395
...@@ -24,6 +24,7 @@ onMounted(() => { ...@@ -24,6 +24,7 @@ onMounted(() => {
table_websocket.onmessage = (e) => { table_websocket.onmessage = (e) => {
// console.log(e.data); // console.log(e.data);
// TODO: 通过获取需要监控的变量将 key 写死
let data = JSON.parse(e.data).message let data = JSON.parse(e.data).message
for (const [key, value] of Object.entries(data[0] as Record<string, string>)) { for (const [key, value] of Object.entries(data[0] as Record<string, string>)) {
tableData.value[0][key] = value tableData.value[0][key] = value
......
...@@ -81,23 +81,33 @@ import axios from 'axios'; ...@@ -81,23 +81,33 @@ import axios from 'axios';
import { DeviceInfo } from "./types"; import { DeviceInfo } from "./types";
import { useProtocolNamesStore } from '@/stores/protocolNames'; import { useProtocolNamesStore } from '@/stores/protocolNames';
// protocol name 存储
const store = useProtocolNamesStore() const store = useProtocolNamesStore()
// form 表单对象
const formRef = ref<typeof ElForm>() const formRef = ref<typeof ElForm>()
// 弹出框是否可见,默认不可见
// 弹出框表单 label 的宽度
const dialogFormVisible = ref(false) const dialogFormVisible = ref(false)
const formLabelWidth = "120px" const formLabelWidth = "120px"
// 父组件往这里传的类型
type porpsType = { type porpsType = {
isShow: boolean, isShow: boolean,
deviceInfo?: DeviceInfo, deviceInfo?: DeviceInfo,
type: string, type: string,
} }
const props = defineProps<porpsType>() const props = defineProps<porpsType>()
// 返回父组件的方法
const emit = defineEmits(['close', 'changeDeviceInfo']) const emit = defineEmits(['close', 'changeDeviceInfo'])
// 关闭弹出框的执行的操作
const handleClose = () => { const handleClose = () => {
// 向父组件发射关闭弹出框的事件
emit('close') emit('close')
// 表单所有的校验和数据重置
formRef.value!.resetFields() formRef.value!.resetFields()
} }
// 默认表单数据
const form = ref<DeviceInfo>({ const form = ref<DeviceInfo>({
station_id: "", station_id: "",
device_id: 0, device_id: 0,
...@@ -113,8 +123,11 @@ const form = ref<DeviceInfo>({ ...@@ -113,8 +123,11 @@ const form = ref<DeviceInfo>({
udp_port_dst: 0 udp_port_dst: 0
}) })
// 检测弹出框是否弹出,如果弹出赋值
watch(() => props.isShow, () => { watch(() => props.isShow, () => {
dialogFormVisible.value = props.isShow dialogFormVisible.value = props.isShow
// 判断传下来的类型是不是 edit,如果是,需要将展示的数据放到表单上
if (props.isShow && props.type === "edit") { if (props.isShow && props.type === "edit") {
form.value = { form.value = {
id: props.deviceInfo!.id, id: props.deviceInfo!.id,
...@@ -137,6 +150,7 @@ watch(() => props.isShow, () => { ...@@ -137,6 +150,7 @@ watch(() => props.isShow, () => {
} }
}) })
// 校验 ip 是否正确
const validateIP = (_: any, value: any, callback: any) => { const validateIP = (_: any, value: any, callback: any) => {
if (value === '') { if (value === '') {
callback(new Error('Please input the IP again')) callback(new Error('Please input the IP again'))
...@@ -149,6 +163,7 @@ const validateIP = (_: any, value: any, callback: any) => { ...@@ -149,6 +163,7 @@ const validateIP = (_: any, value: any, callback: any) => {
} }
} }
// 校验 port 是否正确
const validatePort = (_: any, value: any, callback: any) => { const validatePort = (_: any, value: any, callback: any) => {
if (value === '') { if (value === '') {
callback(new Error('Please input the port again')) callback(new Error('Please input the port again'))
...@@ -161,6 +176,7 @@ const validatePort = (_: any, value: any, callback: any) => { ...@@ -161,6 +176,7 @@ const validatePort = (_: any, value: any, callback: any) => {
} }
} }
// 表单校验规则
const rules = reactive<FormRules<typeof form>>({ const rules = reactive<FormRules<typeof form>>({
station_id: [{ required: true, message: 'Please input station id', trigger: 'blur' }], station_id: [{ required: true, message: 'Please input station id', trigger: 'blur' }],
device_id: [{ required: true, message: 'Please input device id', trigger: 'blur' }], device_id: [{ required: true, message: 'Please input device id', trigger: 'blur' }],
...@@ -192,6 +208,7 @@ const rules = reactive<FormRules<typeof form>>({ ...@@ -192,6 +208,7 @@ const rules = reactive<FormRules<typeof form>>({
}) })
// 下拉框选择触发的事件
const handleProtocolChange = (protocol_name: string) => { const handleProtocolChange = (protocol_name: string) => {
axios.get('/api/device_communication/protocol_performance/' + protocol_name + '/') axios.get('/api/device_communication/protocol_performance/' + protocol_name + '/')
.then((res) => { .then((res) => {
...@@ -202,7 +219,9 @@ const handleProtocolChange = (protocol_name: string) => { ...@@ -202,7 +219,9 @@ const handleProtocolChange = (protocol_name: string) => {
}) })
} }
// 性能参数相关
const checkAll = ref(false) const checkAll = ref(false)
// 设置不确定状态,仅负责样式控制
const isIndeterminate = ref(true) const isIndeterminate = ref(true)
const performance_fields = ref<string[]>([]) const performance_fields = ref<string[]>([])
const checked_performance_fields = ref<string[]>([]) const checked_performance_fields = ref<string[]>([])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment