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