From 8eebd3b823c2e477f949b7f06b6e972ec09327df Mon Sep 17 00:00:00 2001
From: Mr.Zhang <710666463@qq.com>
Date: 星期二, 22 八月 2023 14:27:22 +0800
Subject: [PATCH] 工序 接口调试

---
 screen_standard/src/components/AppLayout.vue |   46 +++++++++--
 screen_standard/src/utils/apis.js            |   12 ++
 screen_standard/src/App.vue                  |    3 
 screen_standard/src/stores/counter.js        |   17 ++++
 screen_standard/src/views/process.vue        |  145 +++++++++++++++++++++--------------
 5 files changed, 151 insertions(+), 72 deletions(-)

diff --git a/screen_standard/src/App.vue b/screen_standard/src/App.vue
index 2aef7b1..4c3da68 100644
--- a/screen_standard/src/App.vue
+++ b/screen_standard/src/App.vue
@@ -5,7 +5,8 @@
 
 const enterprise = useCounterStore()
 // const route = useRoute()
-let query = window.location.href.split('?')[1].split('&')
+let queryStr = window.location.href.split('?')[1]||''
+let query = queryStr.split('&')||[]
 let data = { companyId: enterprise.companyId }
 query.forEach(item => {
   let subQuery = item.split('=')
diff --git a/screen_standard/src/components/AppLayout.vue b/screen_standard/src/components/AppLayout.vue
index bcf8abb..ad01b2c 100644
--- a/screen_standard/src/components/AppLayout.vue
+++ b/screen_standard/src/components/AppLayout.vue
@@ -2,7 +2,7 @@
   <div class="content">
     <div class="header">
       <div class="header-item" style="font-size: 20px;">
-        <el-dropdown trigger="click">
+        <el-dropdown trigger="click" v-if="route.name=='home'">
           <div class="eare-title">
             {{ tempCom.name}}
             <div class="right-icon">
@@ -15,8 +15,10 @@
             </el-dropdown-menu>
           </template>
         </el-dropdown>
-      
+
+        <img v-else src="@/assets/img/btn_back@2x.png" style="width: 108px;height: 34px; margin-top: 14px;" @click="router.go(-1)">
       </div>
+      
       <div class="title">DM浜戝伐鍘傝溅闂村ぇ灞�</div>
       <div class="header-item right">
 
@@ -30,7 +32,6 @@
         <!-- <img src="@/assets/img/title_line@2x.png" class="right-line" alt=""> -->
       </div>
     </div>
-    <!-- 'background': `url(${getAssets(item.bgImg)})`, -->
     <div class="num-list">
       <div
         v-for="(item, index) in layoutList"
@@ -41,9 +42,8 @@
         <img :src="getAssets(item.logo)" alt="">
         <div class="item-right">
           <div class="item-title">{{ item.name }}</div>
-          <div class="num-value">1</div>
+          <div class="num-value">{{ countList[index] }}</div>
         </div>
-        
       </div>
     </div>
     <RouterView />
@@ -54,10 +54,12 @@
 <script setup>
 import { getAssets } from '@/utils'
 import { getDepartmentList } from '@/utils/apis.js'
-import { reactive, toRefs, ref, onMounted } from 'vue';
+import { reactive, toRefs, onMounted, computed } from 'vue';
 import { useCounterStore } from '@/stores/counter.js'
-import { RouterView } from 'vue-router'
+import { RouterView, useRoute, useRouter } from 'vue-router'
 const enterprise = useCounterStore()
+const route = useRoute()
+const router = useRouter()
 const layoutList = [
   { bgImg: 'bg_zhixingzhong@2x.png', name: '鎵ц涓鍒掓暟(涓�)', logo: 'ic_zhixingzhong@2x.png' },
   { bgImg: 'bg_yanqijihua@2x.png', name: '寤舵湡璁″垝鏁�(涓�)', logo: 'ic_yanqijihua@2x.png' },
@@ -65,6 +67,21 @@
   { bgImg: 'bg_jinrishebei@2x.png', name: '浠婃棩鐢熶骇璁惧(鍙�)', logo: 'ic_jinrishebei@2x.png' },
   { bgImg: 'bg_jinribuliang@2x.png', name: '浠婃棩涓嶈壇鍝佺巼(%)', logo: 'ic_jinribuliang@2x.png' },
 ]
+const ingNum = computed(() => {
+    return enterprise.ingNum
+})
+const delayNum = computed(() => {
+    return enterprise.delayNum
+})
+const prouserNum = computed(() => {
+    return enterprise.prouserNum
+})
+const deviceNum = computed(() => {
+    return enterprise.deviceNum
+})
+const unqualifiedRate = computed(() => {
+    return enterprise.unqualifiedRate
+})
 
 const data = reactive({
   tempCom: { name: '璞嗙背绉戞妧' },
@@ -74,13 +91,21 @@
     date: '',
     day: ''
   },
-  comList: []
+  comList: [],
+  countList: [
+    ingNum||0,
+    delayNum||0,
+    prouserNum||0,
+    deviceNum||0,
+    unqualifiedRate||0
+  ]
 })
 
-let { tempCom, isFull, tempDate, comList } = toRefs(data)
+
+
+let { tempCom, isFull, tempDate, comList, countList } = toRefs(data)
 
 const selectCom = (item, index) => {
-  console.log(item);
   data.tempCom = item
   enterprise.setDepartId(data.tempCom.id)
 }
@@ -114,6 +139,7 @@
 }
 
 onMounted(() => {
+  console.log(route.name);
   getDepartmentList(enterprise.companyId)
     .then(res => {
       data.comList = res
diff --git a/screen_standard/src/stores/counter.js b/screen_standard/src/stores/counter.js
index d4b3256..e3364b2 100644
--- a/screen_standard/src/stores/counter.js
+++ b/screen_standard/src/stores/counter.js
@@ -5,7 +5,15 @@
 
   state: () => {
     // 678
-    return { companyId: '8', departId: '132' };
+    return {
+      companyId: '8',
+      departId: '132',
+      delayNum: 0, // 寤舵湡璁″垝鏁�
+      deviceNum: 0, // 浠婃棩鐢熶骇璁惧鏁�
+      ingNum: 0, // 鎵ц涓鍒掓暟
+      prouserNum: 0, // 浠婃棩鐢熶骇浜烘暟
+      unqualifiedRate: 0 // 浠婃棩涓嶈壇鍝佺巼
+    };
   },
 
   actions: {
@@ -18,6 +26,13 @@
     setDepartId(departId) {
       this.departId = departId;
       window.sessionStorage.setItem('departId', departId);
+    },
+    setNum(num) {
+      this.delayNum = num.delayNum
+      this.deviceNum = num.deviceNum
+      this.ingNum = num.ingNum
+      this.prouserNum = num.prouserNum
+      this.unqualifiedRate = num.unqualifiedRate
     }
   }
 
diff --git a/screen_standard/src/utils/apis.js b/screen_standard/src/utils/apis.js
index ed68a8b..907344a 100644
--- a/screen_standard/src/utils/apis.js
+++ b/screen_standard/src/utils/apis.js
@@ -1,6 +1,16 @@
 import axiosInstance from './request';
 
-// 鍛樺伐浜у搧缁熻TOP10
+// 鏌ヨ浼佷笟鍏ㄩ儴鍏徃閮ㄩ棬
 export function getDepartmentList (companyId) {
   return axiosInstance.get(`statistics/getDepartmentList/${companyId}`)
 }
+
+// 鏁版嵁缁熻-鎴愬搧璁″垝锛屾墽琛屼腑銆佸欢鏈熻鍒掓暟銆佷粖鏃ョ敓浜т汉鏁般�佷粖鏃ョ敓浜ц澶囨暟銆佷粖鏃ヤ笉鑹搧
+export function getProcedurePlanData (companyId, departId, params) {
+  return axiosInstance.get(`statistics/getProcedurePlanData/${companyId}/${departId}`, {params} )
+}
+
+// 鍛樺伐浜у搧缁熻TOP10
+export function getTop (companyId, departId, params) {
+  return axiosInstance.get(`statistics/userProduceTop/${companyId}/${departId}`, {params})
+}
\ No newline at end of file
diff --git a/screen_standard/src/views/process.vue b/screen_standard/src/views/process.vue
index 378946b..ac48cf4 100644
--- a/screen_standard/src/views/process.vue
+++ b/screen_standard/src/views/process.vue
@@ -34,31 +34,31 @@
         <div class="yield-content">
           <div class="yield-content-left">
             <div class="content_left_item1_content">
-              <div class="content_left_item1_content_row" v-for="(item, index) in 5" :key="index">
+              <div class="content_left_item1_content_row" v-for="(item, index) in top1" :key="index">
                 <div class="content_left_item1_content_row_name">
                   <div :class="index > 2 ? 'num bg1' : 'num bg2'">{{ index + 1 }}</div>
-                  <span>璧电珛{{ index }}</span>
+                  <span>{{ item.userName }}</span>
                 </div>
                 <div class="content_left_item1_content_row_line">
-                  <el-progress :show-text="false" :percentage="50">
+                  <el-progress :show-text="false" :percentage="item.doneNum/baseNum">
                   </el-progress>
                 </div>
-                <div class="content_left_item1_content_row_num">342</div>
+                <div class="content_left_item1_content_row_num">{{ item.doneNum }}</div>
               </div>
             </div>
           </div>
           <div class="yield-content-left">
             <div class="content_left_item1_content">
-              <div class="content_left_item1_content_row" v-for="(item, index) in 5" :key="index">
+              <div class="content_left_item1_content_row" v-for="(item, index) in top2" :key="index">
                 <div class="content_left_item1_content_row_name">
                   <div class="num bg1">{{ index + 6 }}</div>
-                  <span>璧电珛{{ index }}</span>
+                  <span>{{ item.userName }}</span>
                 </div>
                 <div class="content_left_item1_content_row_line">
-                  <el-progress :show-text="false" :percentage="50">
+                  <el-progress :show-text="false" :percentage="item.doneNum/baseNum">
                   </el-progress>
                 </div>
-                <div class="content_left_item1_content_row_num">342</div>
+                <div class="content_left_item1_content_row_num">{{ item.doneNum }}</div>
               </div>
             </div>
           </div>
@@ -107,54 +107,60 @@
 </template>
 
 <script setup>
-import { reactive, ref, onMounted, onBeforeUnmount, onUnmounted, nextTick } from 'vue'
+import { reactive, ref, toRefs, onMounted, onBeforeUnmount, onUnmounted, nextTick } from 'vue'
+import { getProcedurePlanData, getTop } from '@/utils/apis.js'
+import { useCounterStore } from '@/stores/counter.js'
+import { useRoute } from 'vue-router'
 import * as echarts from 'echarts'
+const route = useRoute()
+const enterprise = useCounterStore()
 let planTimer = ref(null)
 let reportTimer = ref(null)
 let planContainer = ref(null)
 let reportLogContainer = ref(null)
-let listData = reactive([
-  { name: 'dom绗竴涓�' },
-  { name: 'dom绗簩涓�' },
-  { name: 'dom绗笁涓�' },
-  { name: 'dom绗洓涓�' },
-  { name: 'dom绗簲涓�' },
-  { name: 'dom绗叚涓�' },
-  { name: 'dom绗竷涓�' },
-  { name: 'dom绗叓涓�' },
-  { name: 'dom绗節涓�' },
-  { name: 'dom绗崄涓�' },
-  { name: 'dom绗崄涓�' },
-  { name: 'dom绗崄涓�' },
-  { name: 'dom绗崄涓�' },
-  { name: 'dom绗崄涓�' },
-  { name: 'dom绗崄涓�' },
-  { name: 'dom绗崄涓�' },
-  { name: 'dom绗崄涓�' },
-])
-let dayDistribution = reactive([
-  { date: '8/1', num: '20' },
-  { date: '8/2', num: '10' },
-  { date: '8/3', num: '20' },
-  { date: '8/4', num: '40' },
-  { date: '8/5', num: '30' },
-  { date: '8/6', num: '10' },
-  { date: '8/7', num: '20' },
-])
-let typeDistribution = reactive([
-  { name: '澶栬涓嶈壇', num: 15 },
-  { name: '鏈夋瘺鍒�', num: 12 },
-  { name: '灏哄涓嶈壇', num: 22 },
-  { name: '鏈夊垝鐥�', num: 5 },
-  { name: '鍏朵粬', num: 2 },
+const data = reactive({
+  listData: [
+    { name: 'dom绗竴涓�' },
+    { name: 'dom绗簩涓�' },
+    { name: 'dom绗笁涓�' },
+    { name: 'dom绗洓涓�' },
+    { name: 'dom绗簲涓�' },
+    { name: 'dom绗叚涓�' },
+    { name: 'dom绗竷涓�' },
+    { name: 'dom绗叓涓�' },
+    { name: 'dom绗節涓�' },
+    { name: 'dom绗崄涓�' },
+  ],
+  top1: [],
+  top2: [],
+  baseNum: 0,
+  dayDistribution: [
+    { date: '8/1', num: '20' },
+    { date: '8/2', num: '10' },
+    { date: '8/3', num: '20' },
+    { date: '8/4', num: '40' },
+    { date: '8/5', num: '30' },
+    { date: '8/6', num: '10' },
+    { date: '8/7', num: '20' },
+  ],
+  typeDistribution: [
+    { name: '澶栬涓嶈壇', num: 15 },
+    { name: '鏈夋瘺鍒�', num: 12 },
+    { name: '灏哄涓嶈壇', num: 22 },
+    { name: '鏈夊垝鐥�', num: 5 },
+    { name: '鍏朵粬', num: 2 },
+  ]
+})
 
-])
+let { listData, top1, top2, baseNum } = toRefs(data)
+
 // start()
 onBeforeUnmount(() => {
   clearTimeout(planTimer.value)
   clearTimeout(reportTimer.value)
 })
 onMounted(() => {
+  initData()
   nextTick(() => {
     start()
     reportStart()
@@ -168,6 +174,36 @@
   clearTimeout(planTimer.value)
   clearTimeout(reportTimer.value)
 })
+
+function initData() {
+  // 璁″垝鏁�
+  getProcedurePlanData(enterprise.companyId, enterprise.departId, { procedureId: route.query.procedureId })
+    .then(res => {
+      enterprise.setNum(res)
+    })
+  // top10
+  getTop(enterprise.companyId, enterprise.departId, { procedureId: route.query.procedureId })
+    .then(res => {
+      if (res.length) {
+
+        data.baseNum = res[0].doneNum
+        data.top1 = []
+        data.top2 = []
+        if (res.length <= 5) {
+          data.top1 = res
+        } else {
+          res.forEach((item, index) => {
+            if (index < 5) {
+              data.top1.push(item)
+            } else {
+              data.top2.push(item)
+            }
+          })
+        }
+      }
+    })
+  
+}
 
 function handleMouseEnter() {
   clearTimeout(planTimer.value)
@@ -200,12 +236,12 @@
     scrollDom = planContainer.value
   } else {
     // 濡傛灉鍒楄〃鏁伴噺杩囧皯涓嶈繘琛屾粴鍔�
-    if (scrollDom.children.length < 4) {
+    if (scrollDom.children.length <=10) {
       clearTimeout(planTimer.value)
       return
     }
     // 缁勪欢杩涜婊氬姩
-    scrollDom.scrollTop += 2
+    scrollDom.scrollTop += 1.5
     // 鍒ゆ柇鏄惁婊氬姩鍒板簳閮�
     if (scrollDom.scrollTop >= (scrollDom.scrollHeight - scrollDom.clientHeight)) {
       // 鑾峰彇缁勪欢绗竴涓妭鐐�
@@ -233,12 +269,12 @@
     scrollDom = reportLogContainer.value
   } else {
     // 濡傛灉鍒楄〃鏁伴噺杩囧皯涓嶈繘琛屾粴鍔�
-    if (scrollDom.children.length < 4) {
+    if (scrollDom.children.length <= 10) {
       clearTimeout(reportTimer.value)
       return
     }
     // 缁勪欢杩涜婊氬姩
-    scrollDom.scrollTop += 2
+    scrollDom.scrollTop += 1.5
     // 鍒ゆ柇鏄惁婊氬姩鍒板簳閮�
     if (scrollDom.scrollTop >= (scrollDom.scrollHeight - scrollDom.clientHeight)) {
       // 鑾峰彇缁勪欢绗竴涓妭鐐�
@@ -259,7 +295,7 @@
   let dateList = []
   let numList = []
 
-  dayDistribution.forEach(item => {
+  data.dayDistribution.forEach(item => {
     dateList.push(item.date)
     numList.push(item.num)
   })
@@ -350,20 +386,11 @@
   let myChart = echarts.init(dayChartDom);
   let legendData = []
   let seriesData = []
-  typeDistribution.forEach(item => {
+  data.typeDistribution.forEach(item => {
     legendData.push(item.name)
     seriesData.push({name:item.name, value:item.num})
   })
   let option = {
-    // title: {
-    //   text: '鍚屽悕鏁伴噺缁熻',
-    //   subtext: '绾睘铏氭瀯',
-    //   left: 'center'
-    // },
-    // tooltip: {
-    //   trigger: 'item',
-    //   formatter: '{a} <br/>{b} : {c} ({d}%)'
-    // },
     legend: {
       show: false,
       type: 'scroll',

--
Gitblit v1.9.3