Commit 2f09a8de1f0e3ceee5142aa2983d82ea747b0bfd

Authored by ww
1 parent 480572d2

fix: 修复modbus命令下发值为负数时,下发值不对

... ... @@ -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 96 number = number.toString();
96 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 104 const { createMessage } = useMessage();
... ...