Browse Source

优化,问题出现在返回的值是字符串类型

xiaohaizhao 1 week ago
parent
commit
c9a840fd31
1 changed files with 35 additions and 51 deletions
  1. 35 51
      src/optionSystem/throttleManage/detail/modules/attrite/index.vue

+ 35 - 51
src/optionSystem/throttleManage/detail/modules/attrite/index.vue

@@ -1,26 +1,16 @@
 <template>
   <div class="attrite">
-    <ImportFile
-      ref="importFile"
-      class="inline-16"
-      :bindData="{
-        ownertable: 'plm_item',
-        ownerid: $route.query.id,
-        usetype: 'default',
-      }"
-      :errorUrl="errorUrl"
-      @clearUrl="errorUrl = null"
-      @onSuccess="bindImportOrder"
-      v-if="tool.checkAuth($route.name, 'import')"
-    />
+    <ImportFile ref="importFile" class="inline-16" :bindData="{
+      ownertable: 'plm_item',
+      ownerid: $route.query.id,
+      usetype: 'default',
+    }" :errorUrl="errorUrl" @clearUrl="errorUrl = null" @onSuccess="bindImportOrder"
+      v-if="tool.checkAuth($route.name, 'import')" />
     <div class="line-box">
       <div class="item" v-show="source.dc.length">
         <div class="title">
           {{ $t("Dc值") }}
-          <div
-            v-if="tool.checkAuth($route.name, 'excel')"
-            style="cursor: pointer; margin-left: 20px; margin-top: -3px"
-          >
+          <div v-if="tool.checkAuth($route.name, 'excel')" style="cursor: pointer; margin-left: 20px; margin-top: -3px">
             <el-button type="text" size="small" @click="excel('dc')">{{
               $t("导出")
             }}</el-button>
@@ -31,10 +21,7 @@
       <div class="item" v-show="source.fl.length">
         <div class="title">
           {{ $t("Fl值") }}
-          <div
-            v-if="tool.checkAuth($route.name, 'excel')"
-            style="cursor: pointer; margin-left: 20px; margin-top: -3px"
-          >
+          <div v-if="tool.checkAuth($route.name, 'excel')" style="cursor: pointer; margin-left: 20px; margin-top: -3px">
             <el-button type="text" size="small" @click="excel('fl')">{{
               $t("导出")
             }}</el-button>
@@ -45,10 +32,7 @@
       <div class="item" v-show="source.kv.length">
         <div class="title">
           {{ $t("Kv值") }}
-          <div
-            v-if="tool.checkAuth($route.name, 'excel')"
-            style="cursor: pointer; margin-left: 20px; margin-top: -3px"
-          >
+          <div v-if="tool.checkAuth($route.name, 'excel')" style="cursor: pointer; margin-left: 20px; margin-top: -3px">
             <el-button type="text" size="small" @click="excel('kv')">{{
               $t("导出")
             }}</el-button>
@@ -59,10 +43,7 @@
       <div class="item" v-show="source.xt.length">
         <div class="title">
           {{ $t("Xt值") }}
-          <div
-            v-if="tool.checkAuth($route.name, 'excel')"
-            style="cursor: pointer; margin-left: 20px; margin-top: -3px"
-          >
+          <div v-if="tool.checkAuth($route.name, 'excel')" style="cursor: pointer; margin-left: 20px; margin-top: -3px">
             <el-button type="text" size="small" @click="excel('xt')">{{
               $t("导出")
             }}</el-button>
@@ -73,10 +54,8 @@
       <div class="item" v-show="source.zeta.length">
         <div class="title">
           {{ $t("Zeta值") }}
-          <div
-            v-if="tool.checkAuth($route.name, 'import')"
-            style="cursor: pointer; margin-left: 20px; margin-top: -3px"
-          >
+          <div v-if="tool.checkAuth($route.name, 'import')"
+            style="cursor: pointer; margin-left: 20px; margin-top: -3px">
             <el-button type="text" size="small" @click="excel('zeta')">{{
               $t("导出")
             }}</el-button>
@@ -132,38 +111,42 @@ export default {
     },
     init() {
       let that = this;
-      console.log("this.source", this.source);
       Object.keys(this.items).forEach((v) => _render(v));
+
       function _render(el) {
-        const data = that.source[el];
-        let range = [0, 1];
-        const isDescending = data.every((item, index, arr) => {
-          return index === 0 || item.value <= arr[index - 1].value;
+        const data = that.source[el].map(v => {
+          v.value = v.value - 0
+          return v
         });
-        if (isDescending) {
-          range = [1, 0];
-        } else {
-        }
+        console.log("data", JSON.stringify(data));
+
         that.items[el] = new Line(that.$refs[el], {
-          data: that.source[el],
+          data: data,
           padding: "auto",
           xField: "li",
           yField: "value",
           seriesField: "name",
+          point: {
+            size: 2,
+            style: {
+              fill: 'white',
+              stroke: '#5B8FF9',
+              lineWidth: 2,
+            },
+          },
+          label: {
+            // 在折线的每个点显示数值
+            position: 'top',
+            formatter: (datum) => datum.value // 保留3位小数,可按需调整
+          },
           yAxis: {
-            tickCount: 8,
-            range,
           },
           legend: {
             visible: false,
           },
-          tooltip: {
-            formatter: (datum) => {
-              return { name: datum.name, value: datum.value };
-            },
-          },
-          smooth: true,
+          smooth: false, // 关闭平滑曲线,显示折线
         });
+
         that.items[el].render();
       }
     },
@@ -205,6 +188,7 @@ export default {
   margin-top: 20px;
   position: relative;
 }
+
 .attrite .title {
   font-size: 16px;
   font-weight: bolder;