From b01a02e25f2964cd98f4f34dd9539c8b2d883cc5 Mon Sep 17 00:00:00 2001
From: haoxuan <haoxuan>
Date: 星期四, 18 四月 2024 17:05:03 +0800
Subject: [PATCH] 看板 完成进度低于100%,和等于100,2种提示区别开

---
 src/views/dashboard/components/TaskControl.vue |   42 ++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/src/views/dashboard/components/TaskControl.vue b/src/views/dashboard/components/TaskControl.vue
index 6967381..817fed0 100644
--- a/src/views/dashboard/components/TaskControl.vue
+++ b/src/views/dashboard/components/TaskControl.vue
@@ -46,7 +46,7 @@
           icon-color="red"
           :hide-after="0"
           :teleported="false"
-          title="璇风‘璁ゆ槸鍚﹀凡瀹屾垚姝ょ敓浜т换鍔�?"
+          :title="processingPercent == 0 ? '杩涘害鏈畬鎴愶紝鏄惁鎻愬墠瀹屾垚浠诲姟锛�' : '璇风‘璁ゆ槸鍚﹀凡瀹屾垚姝ょ敓浜т换鍔�?'"
           placement="top"
           @confirm="finishTaskProduce"
         >
@@ -78,7 +78,7 @@
 </template>
 <script setup lang="ts">
 import type { Task, Worker } from '@/api/task'
-import { ref, toRefs } from 'vue'
+import { ref, toRefs, computed } from 'vue'
 import BigButton from '@/views/dashboard/components/BigButton.vue'
 import { useDateFormat } from '@vueuse/core'
 import TaskControlModal from '@/views/dashboard/components/TaskControlModal.vue'
@@ -326,6 +326,44 @@
       })
   }
 }
+export interface Statistics {
+  totalNumber: number
+  finishNumber: number
+}
+/**
+ * 璁$畻鐢熶骇杩涘害
+ * @param statistics
+ * @return 杩涘害,0~100
+ */
+function calculateProgress(statistics: Statistics): number {
+  if (!statistics) {
+    return 0
+  }
+
+  if (statistics.finishNumber === 0) {
+    return 0
+  }
+  if (statistics.finishNumber === statistics.totalNumber) {
+    return 100
+  }
+
+  const result = Math.floor((statistics.finishNumber / statistics.totalNumber) * 100)
+  return result > 100 ? 100 : result
+}
+const processingPercent = computed(() => {
+  // if (task?.value?.Procedure?.Status === 1) {
+  //   return 0
+  // }
+
+  if (task?.value?.Procedure?.Status === 3) {
+    return 100
+  }
+  // if (task?.value?.Procedure?.Status === 2 || task?.value?.Procedure?.Status === 1) {
+  //   return calculateProgress(plcStore.plcInfo as Statistics)
+  // }
+
+  return calculateProgress(plcStore.plcInfo as Statistics)
+})
 </script>
 <style scoped lang="scss">
 $title-text-color: #9599af;

--
Gitblit v1.8.0