From d0c51ac702c57f2cae84a8d879a5b605f2dab630 Mon Sep 17 00:00:00 2001
From: weicd <weicd@yhzhg.cn>
Date: Thu, 28 Sep 2023 09:50:45 +0000
Subject: [PATCH] 修改

---
 eladmin-web-master/src/views/task/taskUser/index.vue |  195 +++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 182 insertions(+), 13 deletions(-)

diff --git a/eladmin-web-master/src/views/task/taskUser/index.vue b/eladmin-web-master/src/views/task/taskUser/index.vue
index 4fdf1ea..91bc073 100644
--- a/eladmin-web-master/src/views/task/taskUser/index.vue
+++ b/eladmin-web-master/src/views/task/taskUser/index.vue
@@ -24,11 +24,19 @@
                 @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 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 }}
+                  <i class="el-icon-search" style="float: right;" @click="showTaskDetail(task)" />
                 </div>
+                <!-- </el-tooltip> -->
               </el-card>
             </div>
           </el-card>
@@ -54,6 +62,67 @@
       </el-col>
       <!--任务分配数据-->
       <el-col :span="18">
+        <el-dialog
+          title="分配详情"
+          :visible.sync="dialogVisible_taskUser"
+          width="600px"
+          @closed="setNull"
+          @close="dialogVisible_taskUser = false"
+        >
+
+          <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.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 }}
+                    <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_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">
           <div>
@@ -142,7 +211,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"
@@ -170,9 +239,6 @@
                 active-text="已完成"
               />
             </el-form-item>
-            <el-form-item label="备注" style="margin-top: 30px">
-              <el-input v-model="form.remarks" :rows="3" type="textarea" style="width: 340px;" />
-            </el-form-item>
           </el-form>
           <div slot="footer" class="dialog-footer">
             <el-button type="text" @click="crud.cancelCU">取消</el-button>
@@ -190,7 +256,7 @@
           <el-table-column type="selection" width="55" />
           <el-table-column :show-overflow-tooltip="true" prop="name" label="名称" fixed="left" width="270">
             <template slot-scope="scope">
-              <el-tag>{{ scope.row.name }}</el-tag>
+              <el-tag slot="reference">{{ scope.row.name }}</el-tag>
             </template>
           </el-table-column>
           <el-table-column :show-overflow-tooltip="true" prop="taskStartDate" label="任务开始时间" width="140" />
@@ -198,8 +264,15 @@
           <el-table-column :show-overflow-tooltip="true" prop="taskHours" label="任务工时" width="80" />
           <el-table-column :show-overflow-tooltip="true" prop="userNickName" label="所属员工" width="100">
             <template slot-scope="scope">
-              <el-tag v-if="scope.row.userNickName">{{ scope.row.userNickName }}</el-tag>
-              <el-tag v-else>未指定</el-tag>
+              <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 style="cursor: pointer;">查看详情</h4>
+                  </div>
+                </div>
+                <el-tag v-if="scope.row.userNickName" style="cursor: pointer;">{{ scope.row.userNickName }}</el-tag>
+                <el-tag v-else>未指定</el-tag>
+              </el-tooltip>
             </template>
           </el-table-column>
           <el-table-column :show-overflow-tooltip="true" prop="performanceHours" label="绩效工时" width="80" />
@@ -262,7 +335,6 @@
     </el-row>
   </div>
 </template>
-
 <script>
 import crudTaskUser from '@/api/task/taskUser'
 import crudTask from '@/api/task/task'
@@ -363,7 +435,19 @@
       uploading: true,
       flag: false,
       infinite: false,
-      selectedTask: ''
+      selectedTask: '',
+      dialogVisible_taskUser: false,
+      dialogLoading_taskUser: true,
+      dialogVisible_task: false,
+      dialogLoading_task: true,
+      steps: [],
+      TaskName: '',
+      expectedHours: '',
+      actualHours: '',
+      taskUserDetail: {},
+      taskDetail: {},
+      taskProgress: '',
+      ProgressStatus: ''
     }
   },
   computed: {
@@ -387,9 +471,37 @@
       })
       return true
     },
+    [CRUD.HOOK.afterSubmit]() {
+      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.taskId = this.query.taskId
-      // this.form.taskName = this.selectedTaskName
       this.form.task.id = this.query.taskId
       this.form.task.name = this.selectedTaskName
       this.form.projectId = this.projectId
@@ -592,6 +704,62 @@
           title: '确认成功'
         })
       })
+    },
+    showDetail(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
+        }
+        // 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) {
+      console.log(e.id)
+      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}%`
     }
   }
 }
@@ -636,4 +804,5 @@
     /* 添加长亮效果的样式 */
     color: #1890ff;
   }
+
 </style>

--
Gitblit v1.9.3