From ddbb2bd2691629336faa4491a59fdc3dc3c5934e Mon Sep 17 00:00:00 2001
From: gaoshp <291585735@qq.com>
Date: 星期一, 17 六月 2024 23:44:23 +0800
Subject: [PATCH] update

---
 src/views/mdc/components/Time.vue |   36 +++++++++++++++++++++++++++++-------
 1 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/src/views/mdc/components/Time.vue b/src/views/mdc/components/Time.vue
index 17d160d..5bb8fcd 100644
--- a/src/views/mdc/components/Time.vue
+++ b/src/views/mdc/components/Time.vue
@@ -1,7 +1,7 @@
 <!--
  * @Date: 2024-04-18 21:52:18
  * @LastEditors: Sneed
- * @LastEditTime: 2024-04-27 23:30:06
+ * @LastEditTime: 2024-06-17 23:37:51
  * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/mdc/components/Time.vue
 -->
 <template>
@@ -16,7 +16,7 @@
         </el-col>
         <el-col style="margin-top: 12px;">
             <el-card shadow="never">
-                <scEcharts height="300px" :option="option2"></scEcharts>
+                <scEcharts height="300px" :option="option2" v-if="option2.title" />
             </el-card>
         </el-col>
         <el-col>
@@ -26,9 +26,9 @@
             <scTable ref="table" row-key="id" border :params="params" :apiObj="apiObj" stripe>
                 <el-table-column prop="workstationCode" label="宸ヤ綅缂栫爜" />
                 <el-table-column prop="workstationName" label="宸ヤ綅鍚嶇О" />
-                <el-table-column prop="" :label="item" v-for="item in cols">
+                <el-table-column prop="" :label="item" v-for="item in cols" :key="item">
                     <template #default="scope">
-                        <span>{{ scope.row.data[item] }}</span>
+                        <span>{{ colnameFn(scope.row.data[item]) }}</span>
                     </template>
                 </el-table-column>
 
@@ -44,6 +44,25 @@
         url: {
             default: '/api/blade-mdc/efficiency-analysis',
             type: String,
+        },
+        options: {
+            default() {
+                return {}
+            },
+        },
+        colnameFn: {
+            type: Function,
+            default: val => {
+                if (isNaN(val)) return '-'
+                return `${(val ? val * 100 : 0).toFixed(2)}%`
+            }
+        },
+        resFn: {
+            type: Function,
+            default: val => {
+                if (isNaN(val)) return 0
+                return (val - 0) * 100
+            }
         }
     },
     components: {
@@ -70,7 +89,7 @@
             ],
             cols: [],
             chartsData: [],
-            option2: null,
+            option2: {},
         }
     },
     watch: {
@@ -121,6 +140,7 @@
                 queryType: 0,
                 statisticalMethod: this.statisticalMethod
             }
+            this.option2 = {}
             return this.$HTTP.post(this.url, dataSend, { params }).then(res => {
                 this.chartsData = res.data.items.records
                 let option2 = {
@@ -157,7 +177,8 @@
                     dataset: {
                         source: []
                     },
-                    series: []
+                    ...this.options,
+                    series: [],
                 }
                 let source1 = ['product']
                 let row = res.data.items.records[0]
@@ -171,7 +192,8 @@
                 res.data.items.records.forEach(v => {
                     let current = [v.id]
                     Object.keys(v.nameData).forEach(key => {
-                        current.push((v.data[key] - 0) * 100)
+                        current.push(this.resFn(v.data[key]))
+                        // current.push((v.data[key] - 0) * 100)
                     })
                     option2.dataset.source.push(current)
                 });

--
Gitblit v1.9.3