style: add some comments
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
// 设备参数配置在系统中的key前缀
|
||||
const DeviceConfigParamPrefix = {
|
||||
Switch: 'SWITCH_',
|
||||
Server: 'SERVER_',
|
||||
@@ -10,6 +11,7 @@ const DeviceConfigParamPrefix = {
|
||||
|
||||
type DeviceConfigParamPrefixType = (typeof DeviceConfigParamPrefix)[keyof typeof DeviceConfigParamPrefix];
|
||||
|
||||
// 渲染时的数据结构
|
||||
interface DeviceParamItem {
|
||||
id: string;
|
||||
key: string;
|
||||
@@ -22,6 +24,7 @@ interface DeviceParamItem {
|
||||
max?: number;
|
||||
}
|
||||
|
||||
// 一些参数值是零点几,一些参数值是好几十,需要根据参数名称中的关键词来做预处理
|
||||
const parseNumericValue = (name: string, value: string) => {
|
||||
let val = parseFloat(value);
|
||||
const needMultiply = name.includes('流量') || name.includes('占用率');
|
||||
@@ -29,6 +32,7 @@ const parseNumericValue = (name: string, value: string) => {
|
||||
return val;
|
||||
};
|
||||
|
||||
// 在保存参数时需要反向处理
|
||||
const deparseNumericValue = (name: string, value: number) => {
|
||||
let val = value;
|
||||
const needMultiply = name.includes('流量') || name.includes('占用率');
|
||||
@@ -210,6 +214,7 @@ const { mutate: saveDeviceParams } = useMutation({
|
||||
<NForm>
|
||||
<NGrid :cols="1">
|
||||
<NFormItemGi v-for="item in deviceConfigParams" :key="item.key" label-placement="left" :span="1" :label="item.name">
|
||||
<!-- 监视器计划配置渲染时间选择器,其他配置项渲染数字输入框 -->
|
||||
<template v-if="activeTabName === DeviceConfigParamPrefix.Monitor">
|
||||
<NTimePicker v-model:formatted-value="item.timeValue" />
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user