From 3e141a386dad33a7a660dd1b6a02a96df6f8f886 Mon Sep 17 00:00:00 2001
From: WX <1377869194@qq.com>
Date: 星期五, 15 九月 2023 17:08:05 +0800
Subject: [PATCH] 保留三位数

---
 src/views/plotting/plottingInquire.vue |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/src/views/plotting/plottingInquire.vue b/src/views/plotting/plottingInquire.vue
index 52e9012..8a6598f 100644
--- a/src/views/plotting/plottingInquire.vue
+++ b/src/views/plotting/plottingInquire.vue
@@ -426,11 +426,31 @@
     resultList.value.push(e);
   });
 };
+//淇濈暀涓変綅灏忔暟
+const keepThreeNum = (value) => {
+  let resValue = 0;
+  //灏忔暟鐐圭殑浣嶇疆
+  let index = value && value.toString().indexOf(".") + 1;
+  //灏忔暟鐨勪綅鏁�
+  let num = value && Math.abs(Number(value)).toString().length - index;
+  if (index && num > 3) {
+    resValue = value && Number(value).toFixed(3);
+  } else {
+    resValue = value;
+  }
+  return resValue;
+};
+
 //绾挎煡璇㈡帴鍙�
 const selectPolyline = async (res) => {
   layerArr.value = [];
   const dt = await selectByPolyline(res);
   console.log(dt);
+  dt.result.forEach((e) => {
+    e.points.forEach((element) => {
+      element = keepThreeNum(element);
+    });
+  });
   layeroptions.value = dt.result;
   layerArr.value.push(dt.result[0]);
   chartIsshow.value = true;

--
Gitblit v1.9.3