From 4b4e1b54cae72088fa60978e0192fe57f986e6f3 Mon Sep 17 00:00:00 2001
From: churf <123456>
Date: Mon, 18 Sep 2023 01:25:13 +0000
Subject: [PATCH] 首页绩效图例距离修正

---
 eladmin-web-master/src/views/task/taskUser/index.vue |  144 +++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 118 insertions(+), 26 deletions(-)

diff --git a/eladmin-web-master/src/views/task/taskUser/index.vue b/eladmin-web-master/src/views/task/taskUser/index.vue
index 0edf03a..a94f1c1 100644
--- a/eladmin-web-master/src/views/task/taskUser/index.vue
+++ b/eladmin-web-master/src/views/task/taskUser/index.vue
@@ -24,11 +24,18 @@
                 @change="getTaskDatas"
               />
             </div>
-            <div v-loading="infinite" class="infinite-list" style="overflow:auto;height:500px">
-              <el-card v-for="task in taskDatas" :key="task.id" class="box-card" :class="{ 'active': task === selectedTask }" style="margin-bottom: 10px;" shadow="hover">
-                <div @click="handleNodeClick(task)">
-                  {{ task.name }}
-                </div>
+            <div v-if="!infinite" class="infinite-list" style="overflow:auto;height:500px">
+              <el-card v-for="task in taskDatas" :key="task.id" class="box-card" :class="{ 'active': task === selectedTask }" style="margin-bottom: 10px;cursor:pointer" shadow="hover">
+                <el-tooltip class="item" effect="dark" placement="top-start" :open-delay="1000" enterable>
+                  <div slot="content" class="slot-style">
+                    <div @click="showTaskDetail(task)">
+                      <h4 style="cursor: pointer;">查看详细</h4>
+                    </div>
+                  </div>
+                  <div @click="handleNodeClick(task)">
+                    {{ task.name }}
+                  </div>
+                </el-tooltip>
               </el-card>
             </div>
           </el-card>
@@ -55,32 +62,65 @@
       <!--任务分配数据-->
       <el-col :span="18">
         <el-dialog
-          title="任务详情"
-          :visible.sync="dialogVisible"
+          title="分配详情"
+          :visible.sync="dialogVisible_taskUser"
           width="600px"
           @closed="setNull"
-          @close="dialogLoading = true"
+          @close="dialogVisible_taskUser = false"
         >
-          <div v-if="!dialogLoading">
-            <el-card>
-              任务名称:{{ TaskName }}
-              <p v-for="(item,index) in taskUserDetail" :key="index">
-                {{ index }} 共消耗 {{ item }}  工时
-              </p>
+
+          <div v-if="steps.length > 0" v-loading="dialogLoading_taskUser">
+            <el-card v-if="steps.length > 0">
+              <div style="width: 35%;float: left">
+                任务名称:{{ TaskName }}
+                <p v-for="(item,index) in taskUserDetail" :key="index">
+                  {{ index }} 共消耗 {{ item }}  工时
+                </p>
+              </div>
+              <div style="width: 65%;float: right">
+                <el-progress :percentage="taskProgress" style="width: 80%;margin-left: 55px" :color="ProgressStatus" :format="formatTaskProgress" />
+                <br>
+                <i>任务预计时长:{{ expectedHours }}小时</i><i style="margin-left: 40px">任务实际用时:{{ actualHours }}小时</i>
+              </div>
             </el-card>
           </div>
           <br>
-          <div v-if="steps !== null " v-loading="dialogLoading" class="block" style="height: 500px; overflow: auto;">
+          <div v-if="steps.length > 0" v-loading="dialogLoading_taskUser" class="block" style="height: 500px; overflow: auto;">
             <el-timeline>
               <el-timeline-item v-for="(item,index) in steps" :key="index" :timestamp="item.fillDate" :color="item.color">
                 <el-card>
-                  <h4>{{ item.title }}</h4>
+                  <h4>
+                    {{ item.title }}
+                    <el-tooltip class="item" effect="dark" :content="item.remarks" placement="top-start">
+                      <i v-if="item.flag" class="el-icon-s-comment" style="float: right" />
+                    </el-tooltip></h4>
                 </el-card>
               </el-timeline-item>
             </el-timeline>
           </div>
-          <div v-else v-loading="dialogLoading" class="block">
+          <div v-else v-loading="dialogLoading_taskUser" class="block">
             <p>暂无信息</p></div>
+        </el-dialog>
+
+        <el-dialog
+          title="任务详情"
+          :visible.sync="dialogVisible_task"
+          width="300px"
+          @closed="setNull"
+          @close="dialogLoading_task = false"
+        >
+          <div v-if="taskDetail" v-loading="dialogLoading_task">
+            <el-card style="padding-top: 10px">
+              <div v-for="(item,index) in taskDetail" :key="index" style="padding-top: 10px">
+                <span>{{ index }} 分配时长: {{ item }} 小时</span><br>
+              </div>
+            </el-card>
+          </div>
+          <div v-else>
+            <el-card style="padding-top: 10px">
+              <span>暂无数据</span><br>
+            </el-card>
+          </div>
         </el-dialog>
         <!--工具栏-->
         <div class="head-container">
@@ -170,7 +210,7 @@
               </el-input>
             </el-form-item>
             <el-form-item label="所属员工" prop="userId">
-              <el-select v-model="form.userId" filterable clearable placeholder="请选择" style="width: 340px;">
+              <el-select v-model="form.userId" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="form.start">
                 <el-option
                   v-for="item in users"
                   :key="item.id"
@@ -226,10 +266,10 @@
               <el-tooltip class="item" effect="light" :open-delay="1000" placement="top" :disabled="!flag">
                 <div slot="content" class="slot-style">
                   <div @click="showDetail(scope.row)">
-                    <h4>查看详情</h4>
+                    <h4 style="cursor: pointer;">查看详情</h4>
                   </div>
                 </div>
-                <el-tag v-if="scope.row.userNickName">{{ scope.row.userNickName }}</el-tag>
+                <el-tag v-if="scope.row.userNickName" style="cursor: pointer;">{{ scope.row.userNickName }}</el-tag>
                 <el-tag v-else>未指定</el-tag>
               </el-tooltip>
             </template>
@@ -276,6 +316,7 @@
         </el-table>
         <!--表格渲染-->
         <!--分页组件-->
+        <pagination />
         <!--表单组件-->
         <el-dialog :close-on-click-modal="false" :before-close="closeGenerate" :visible.sync="generateStatus" title="导入任务分配信息" width="720px">
           <el-form ref="generateForm" size="small" label-width="80px">
@@ -394,11 +435,18 @@
       flag: false,
       infinite: false,
       selectedTask: '',
-      dialogVisible: false,
-      dialogLoading: true,
+      dialogVisible_taskUser: false,
+      dialogLoading_taskUser: true,
+      dialogVisible_task: false,
+      dialogLoading_task: true,
       steps: [],
       TaskName: '',
-      taskUserDetail: {}
+      expectedHours: '',
+      actualHours: '',
+      taskUserDetail: {},
+      taskDetail: {},
+      taskProgress: '',
+      ProgressStatus: ''
     }
   },
   computed: {
@@ -426,26 +474,31 @@
       this.formTasks = []
       this.form.name = null
       this.form.performanceHours = null
+      this.form.start = false
     },
     [CRUD.HOOK.afterEditError]() {
       this.formTasks = []
       this.form.name = null
       this.form.performanceHours = null
+      this.form.start = false
     },
     [CRUD.HOOK.afterEditCancel]() {
       this.formTasks = []
       this.form.name = null
       this.form.performanceHours = null
+      this.form.start = false
     },
     [CRUD.HOOK.afterAddCancel]() {
       this.formTasks = []
       this.form.name = null
       this.form.performanceHours = null
+      this.form.start = false
     },
     [CRUD.HOOK.afterAddError]() {
       this.formTasks = []
       this.form.name = null
       this.form.performanceHours = null
+      this.form.start = false
     },
     [CRUD.HOOK.beforeToCU]() {
       this.form.task.id = this.query.taskId
@@ -652,20 +705,59 @@
       })
     },
     showDetail(e) {
-      this.dialogVisible = true
-      console.log(e)
+      this.dialogVisible_taskUser = true
       this.TaskName = e.name
+      this.expectedHours = e.performanceHours
+      this.actualHours = 0
       // 发送taskUser,获取所有的日报信息,并在后台进行处理,将处理后的结果返回给前端的steps中,进行显示
       crudTaskUser.getTaskUserDetail(e.id).then(res => {
         this.steps = res
         for (let i = 0; i < this.steps.length; i++) {
           this.taskUserDetail[this.steps[i].taskUserName] = this.steps[i].alreadyConsumeHours
         }
-        this.dialogLoading = false
+        // console.log(this.taskUserDetail)
+        // this.taskUserDetail.map((key, value) => {
+        //   console.log(key)
+        //   console.log(value)
+        // })
+
+        // var key = this.taskUserDetail.keySet();
+        for (var key in this.taskUserDetail) {
+          this.actualHours += this.taskUserDetail[key]
+        }
+
+        this.taskProgress = Math.round(this.actualHours / this.expectedHours * 100)
+        if (this.taskProgress > 100) {
+          this.taskProgress = 100
+        }
+        if (this.taskProgress === 100) {
+          this.ProgressStatus = '#F56C6C'
+        }
+        if (this.taskProgress < 100) {
+          this.ProgressStatus = '#409EFF'
+        }
+        // this.taskUserDetail.forEach(function(value,key){
+        //   console.log(value,key);
+        // });
+        this.dialogLoading_taskUser = false
       })
     },
     setNull() {
       this.taskUserDetail = {}
+      this.dialogLoading_taskUser = true
+      this.dialogLoading_task = true
+    },
+    showTaskDetail(e) {
+      this.dialogVisible_task = true
+      crudTaskUser.getTaskDetail(e.id).then(res => {
+        for (let i = 0; i < res.length; i++) {
+          this.taskDetail[res[i].nickName] = res[i].assignedWork
+        }
+        this.dialogLoading_task = false
+      })
+    },
+    formatTaskProgress(percentage) {
+      return percentage === 100 ? '实际消耗已超出计划时长' : `${percentage}%`
     }
   }
 }

--
Gitblit v1.9.3