|
@@ -91,11 +91,14 @@ |
|
@@ -91,11 +91,14 @@ |
91
|
};
|
91
|
};
|
92
|
|
92
|
|
93
|
// 获取小数
|
93
|
// 获取小数
|
94
|
- const getFloatPart = (number): any => {
|
94
|
+ const getFloatPart = (number: string | number) => {
|
|
|
95
|
+ const isLessZero = Number(number) < 0;
|
95
|
number = number.toString();
|
96
|
number = number.toString();
|
96
|
const floatPartStartIndex = number.indexOf('.');
|
97
|
const floatPartStartIndex = number.indexOf('.');
|
97
|
- const value = ~floatPartStartIndex ? `0.${number.substring(floatPartStartIndex + 1)}` : '0';
|
|
|
98
|
- return value;
|
98
|
+ const value = ~floatPartStartIndex
|
|
|
99
|
+ ? `${isLessZero ? '-' : ''}0.${number.substring(floatPartStartIndex + 1)}`
|
|
|
100
|
+ : '0';
|
|
|
101
|
+ return Number(value);
|
99
|
};
|
102
|
};
|
100
|
|
103
|
|
101
|
const { createMessage } = useMessage();
|
104
|
const { createMessage } = useMessage();
|
|
@@ -139,13 +142,16 @@ |
|
@@ -139,13 +142,16 @@ |
139
|
if (unref(modBUSForm).method == '16' || unref(modBUSForm).method == '10') {
|
142
|
if (unref(modBUSForm).method == '16' || unref(modBUSForm).method == '10') {
|
140
|
const regex = /^-?\d+(\.\d{0,2})?$/;
|
143
|
const regex = /^-?\d+(\.\d{0,2})?$/;
|
141
|
const values =
|
144
|
const values =
|
142
|
- Math.floor(oldValue) * unref(zoomFactorValue) +
|
145
|
+ Math.trunc(oldValue) * unref(zoomFactorValue) +
|
143
|
getFloatPart(oldValue) * unref(zoomFactorValue);
|
146
|
getFloatPart(oldValue) * unref(zoomFactorValue);
|
|
|
147
|
+
|
144
|
if (!regex.test(values as any)) {
|
148
|
if (!regex.test(values as any)) {
|
145
|
createMessage.warning(`属性下发值精确到两位小数,缩放因子是${unref(zoomFactorValue)}`);
|
149
|
createMessage.warning(`属性下发值精确到两位小数,缩放因子是${unref(zoomFactorValue)}`);
|
146
|
return;
|
150
|
return;
|
147
|
}
|
151
|
}
|
148
|
- const newValue = getArray(SingleToHex(unref(isShowMultiply) ? values : oldValue));
|
152
|
+
|
|
|
153
|
+ const newValue =
|
|
|
154
|
+ values == 0 ? [0, 0] : getArray(SingleToHex(unref(isShowMultiply) ? values : oldValue));
|
149
|
modBUSForm.value.registerValues = newValue;
|
155
|
modBUSForm.value.registerValues = newValue;
|
150
|
modBUSForm.value.registerNumber = 2;
|
156
|
modBUSForm.value.registerNumber = 2;
|
151
|
modBUSForm.value.method = '10';
|
157
|
modBUSForm.value.method = '10';
|