From 86b0362eaf4c320dc6a54fc12ce80b0bf7890a85 Mon Sep 17 00:00:00 2001
From: yaozc <yaozc@yhzhg.cn>
Date: Thu, 30 May 2024 02:06:17 +0000
Subject: [PATCH] 11111

---
 eladmin-web-master/src/views/task/taskDaliy/index.vue |  286 +++++++++++++++++++++++++++++++++++----------------------
 1 files changed, 176 insertions(+), 110 deletions(-)

diff --git a/eladmin-web-master/src/views/task/taskDaliy/index.vue b/eladmin-web-master/src/views/task/taskDaliy/index.vue
index 1824e7b..090255d 100644
--- a/eladmin-web-master/src/views/task/taskDaliy/index.vue
+++ b/eladmin-web-master/src/views/task/taskDaliy/index.vue
@@ -141,7 +141,19 @@
         <rrOperation :crud="crud" />
       </div>
       <!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
-      <crudOperation :permission="permission" />
+      <crudOperation :permission="permission">
+        <el-button
+          slot="right"
+          class="filter-item"
+          size="mini"
+          type="primary"
+          icon="el-icon-view"
+          style="margin-left: 4px !important;"
+          @click="statistics"
+        >
+          统计
+        </el-button>
+      </crudOperation>
       <!--表单组件-->
       <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
         <el-form ref="form" :model="form" :rules="rules" size="small" label-width="110px">
@@ -149,7 +161,8 @@
             <el-input v-model="form.userNickName" style="width: 340px;" :disabled="true" />
           </el-form-item>
           <el-form-item label="所属项目" prop="projectId">
-            <el-select v-if="queryProjects.length > 0" :key="form.projectId" v-model="form.projectId" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="form.flag" @change="formProjectChange">
+            <el-input v-if="crud.status.edit > 0" v-model="form.projectName" style="width: 340px;" :disabled="true" />
+            <el-select v-else-if="queryProjects.length > 0" :key="form.projectId" v-model="form.projectId" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="form.flag" @change="formProjectChange">
               <template v-if="loadingQueryProjectsOne" #prefix>
                 <i class="el-icon-loading" />
               </template>
@@ -177,7 +190,8 @@
             </el-select>
           </el-form-item>
           <el-form-item label="所属任务" prop="taskId">
-            <el-select v-if="formTasks.length > 0" :key="form.taskId" v-model="form.taskId" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="form.flag" @change="formTaskChange">
+            <el-input v-if="form.taskName" v-model="form.taskName" style="width: 340px;" :disabled="true" />
+            <el-select v-else-if="formTasks.length > 0" :key="form.taskId" v-model="form.taskId" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="form.flag" @change="formTaskChange">
               <template v-if="loadingQueryProjects" #prefix>
                 <i class="el-icon-loading" />
               </template>
@@ -205,7 +219,8 @@
             </el-select>
           </el-form-item>
           <el-form-item label="分配任务" prop="taskUserMongo">
-            <el-select v-if="formTaskUserIds.length > 0" :key="form.taskUserMongo.id" v-model="form.taskUserMongo.id" :allow-create="true" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="form.flag" @change="formTaskUserChange">
+            <el-input v-if="form.taskUserMongo && form.taskUserMongo.name" v-model="form.taskUserMongo.name" style="width: 340px;" :disabled="true" />
+            <el-select v-else-if="formTaskUserIds.length > 0" :key="form.taskUserMongo.id" v-model="form.taskUserMongo.id" :allow-create="true" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="form.flag" @change="formTaskUserChange">
               <template v-if="loadingQueryProjectsTwo" #prefix>
                 <i class="el-icon-loading" />
               </template>
@@ -233,7 +248,10 @@
             </el-select>
           </el-form-item>
           <el-form-item label="填写日期" prop="fillDate">
-            <el-date-picker v-model="form.fillDate" type="date" style="width: 340px;" :disabled="form.taskUserMongo.id == null" @change="formDateChange" />
+            <el-date-picker :key="form.taskUserMongo.id" v-model="form.fillDate" value-format="yyyy-MM-dd" type="date" style="width: 340px;" :picker-options="{ disabledDate }" :disabled="form.taskUserMongo.id == null || crud.status.edit > 0" @change="formDateChange" />
+          </el-form-item>
+          <el-form-item>
+            本日已填其他任务工时:{{ (1 * form.todayFixedHours).toFixed(2) }} / 本日打卡工时:{{ (1 * form.todayAttendanceHours).toFixed(2) }}
           </el-form-item>
           <el-form-item label="消耗工时" prop="consumedHours">
             <el-input v-model="form.consumedHours" style="width: 340px;" :disabled="disabledFlagBySettlement || form.fillDate == null" @input="watchFlagChange">
@@ -241,11 +259,10 @@
             </el-input>
           </el-form-item>
           <el-form-item>
-            已消耗工时:{{ form.alreadyConsumedHours }} / 任务工时:{{ form.taskHours }}
+            本任务已消耗工时:{{ (1 * form.alreadyConsumedHours).toFixed(2) }} / 本任务总工时:{{ (1 * form.taskHours).toFixed(2) }}
           </el-form-item>
           <el-form-item label="消耗工作量" prop="consumedWorkload">
-            <el-input v-model="form.consumedWorkload" style="width: 340px;">
-            </el-input>
+            <el-input v-model="form.consumedWorkload" style="width: 340px;" />
           </el-form-item>
           <el-form-item label="消耗工作量单位">
             {{ dict.label[standardWorkloadUnit][form.consumedWorkloadUnit] }}
@@ -263,6 +280,30 @@
           <el-button type="text" @click="crud.cancelCU">取消</el-button>
           <el-button :loading="crud.status.cu === 2" type="primary" @click="checkForm(1)">确认</el-button>
         </div>
+      </el-dialog>
+
+      <!--表单组件-->
+      <el-dialog :close-on-click-modal="false" :visible.sync="centerDialogVisibleStatistics" title="统计数据" width="800px">
+        <el-table v-loading="statisticsLoading" :data="statisticsData" size="small" style="width: 100%;">
+          <el-table-column :show-overflow-tooltip="true" prop="projectName" label="项目名称" fixed="left" min-width="100px" />
+          <el-table-column :show-overflow-tooltip="true" prop="taskName" label="任务名称" fixed="left" min-width="100px" />
+          <el-table-column prop="settlementStatus" min-width="80px" label="绩效类型">
+            <template slot-scope="scope">
+              <el-tag>{{ scope.row.taskUserMongo.performanceType === "1" ? "绩效" : "非绩效" }}</el-tag>
+            </template>
+          </el-table-column>
+          <el-table-column :show-overflow-tooltip="true" prop="performanceHours" label="分配工时" min-width="80px">
+            <template slot-scope="scope">
+              {{ scope.row.taskUserMongo.performanceHours }}
+            </template>
+          </el-table-column>
+          <el-table-column :show-overflow-tooltip="true" prop="consumedHours" label="绩效工时" min-width="80px" />
+          <el-table-column :show-overflow-tooltip="true" prop="taskProgress" label="任务进度" min-width="80px">
+            <template slot-scope="scope">
+              {{ scope.row.taskProgress }}%
+            </template>
+          </el-table-column>
+        </el-table>
       </el-dialog>
       <!--表格渲染-->
       <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
@@ -298,9 +339,9 @@
             {{ scope.row.taskProgress }}%
           </template>
         </el-table-column>
-        <el-table-column :show-overflow-tooltip="true" prop="settlementStatus" min-width="80px" label="结算状态">
+        <el-table-column :show-overflow-tooltip="true" prop="settlementStatus" min-width="80px" label="绩效类型">
           <template slot-scope="scope">
-            <el-tag>{{ dict.label[settlementStatus][scope.row.settlementStatus] }}</el-tag>
+            <el-tag>{{ scope.row.taskUserMongo.performanceType === "1" ? "绩效" : "非绩效" }}</el-tag>
           </template>
         </el-table-column>
         <el-table-column prop="remarks" label="备注" min-width="140px" />
@@ -354,8 +395,9 @@
 import crudProject from '@/api/project/project'
 import crudTask from '@/api/task/task'
 import crudTaskUser from '@/api/task/taskUser'
+import crudAttendance from '@/api/attendance/attendance'
 
-const defaultForm = { id: null, projectId: null, taskId: null, taskMongoId: null, taskUserMongo: {}, userId: null, fillDate: null, consumedHours: null, alreadyConsumedHours: 0, taskHours: 0, consumedWorkload: null, consumedWorkloadUnit: null, taskProgress: null, settlementStatus: constant.SETTLEMENT_STATUS_UNSETTLED, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null }
+const defaultForm = { id: null, projectId: null, taskId: null, taskName: null, taskMongoId: null, taskUserMongo: {}, userId: null, fillDate: null, consumedHours: null, todayFixedHours: 0, todayAttendanceHours: 0, alreadyConsumedHours: 0, taskHours: 0, consumedWorkload: null, consumedWorkloadUnit: null, taskProgress: null, settlementStatus: constant.SETTLEMENT_STATUS_UNSETTLED, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null }
 export default {
   name: 'TaskDaliy',
   components: { pagination, crudOperation, rrOperation, udOperation },
@@ -433,6 +475,8 @@
       standardWorkloadUnit: constant.STANDARD_WORKLOAD_UNIT,
       // 字典:结算状态
       settlementStatus: constant.SETTLEMENT_STATUS,
+      // 字典:绩效对象
+      performanceType: constant.PERFORMANCE_TYPE,
       // 角色级别:超级管理员
       roleLevelSuper: constant.ROLE_LEVEL_SUPER,
       // 角色级别:总经理
@@ -470,6 +514,7 @@
       taskLoading: true,
       centerDialogVisibleTaskHours: false,
       centerDialogVisibleTaskProgress: false,
+      centerDialogVisibleStatistics: false,
       confirmHours: false,
       confirmProgress: false,
       newValue: '',
@@ -483,7 +528,9 @@
       loadingTast: false,
       loadingQueryProjectsOne: false,
       loadingQueryProjects: false,
-      loadingQueryProjectsTwo: false
+      loadingQueryProjectsTwo: false,
+      statisticsLoading: false,
+      statisticsData: []
     }
   },
   computed: {
@@ -497,11 +544,14 @@
         this.form.alreadyConsumedHours = this.tempValue
       }
       if (this.crud.status.edit === 1 && newVal === 0) {
-        this.form.alreadyConsumedHours = this.form.alreadyConsumedHours - (this.editVar - 0)
+        this.form.alreadyConsumedHours = (this.form.alreadyConsumedHours - (this.editVar - 0)).toFixed(2)
       }
       if (this.watchFlg) {
-        this.form.alreadyConsumedHours = (this.form.alreadyConsumedHours) - (oldVal - 0) + (newVal - 0)
+        this.form.alreadyConsumedHours = (this.form.alreadyConsumedHours - (oldVal - 0) + (newVal - 0)).toFixed(2)
         this.watchFlg = false
+      }
+      if (this.form.alreadyConsumedHours < 0) {
+        this.form.alreadyConsumedHours = 0
       }
     },
     'confirmProgress': function(newVal) {
@@ -553,8 +603,6 @@
         // 表单禁用标记(结算状态)
         this.disabledFlagBySettlement = false
       }
-      // 随机数
-      this.random = Math.random()
     },
     [CRUD.HOOK.afterSubmit]() {
       this.form.flag = false
@@ -603,82 +651,61 @@
     },
     // 钩子:新建 - 之前
     [CRUD.HOOK.beforeToAdd]() {
-      this.formTasks = []
-      this.formTaskUserIds = []
-      this.form.taskId = null
-      this.form.taskUserMongo.id = null
-      this.form.userId = this.user.id
-      this.form.userNickName = this.user.nickName
-      // 判断用户最大角色级别是否是角色级别:超级管理员或角色级别:总经理
-      if (this.userRolesLevelMin !== this.roleLevelSuper && this.userRolesLevelMin !== this.roleLevelGeneral) {
-        // 表单赋值
-        this.form.userId = this.user.id
-        this.form.userNickName = this.user.nickName
-
-        // 表单用户变更
-        this.formUserChange()
-        this.formTaskChange()
-      }
       if (this.currentTask) {
         this.form.projectId = this.currentTask.projectId
-        this.formProjectChange(() => {
-          this.form.taskId = this.currentTask.taskId
-          this.formTaskChange(() => { this.form.taskUserMongo.id = this.currentTask.id })
-        })
-        this.form.taskHours = this.currentTask.performanceHours
-        this.form.alreadyConsumedHours = this.currentTask.alreadyConsumedHours
-        this.tempValue = this.currentTask.alreadyConsumedHours
+        this.form.taskId = this.currentTask.taskId
+        this.form.taskName = this.currentTask.taskName
+        this.form.taskUserMongo.id = this.currentTask.id
+        this.form.taskUserMongo.name = this.currentTask.name
+        this.form.taskUserMongo.taskStartDate = this.currentTask.taskStartDate
+        this.form.taskUserMongo.taskEndDate = this.currentTask.taskEndDate
+
+        this.fetchAlreadyConsumedHours()
+
+        // this.form.taskHours = this.currentTask.performanceHours
+        // this.form.alreadyConsumedHours = this.currentTask.alreadyConsumedHours
+        // this.tempValue = this.currentTask.alreadyConsumedHours
         this.form.flag = true
+
+        this.form.userId = this.user.id
+        this.form.userNickName = this.user.nickName
+      } else {
+        this.formTasks = []
+        this.formTaskUserIds = []
+        this.form.taskId = null
+        this.form.taskUserMongo.id = null
+        this.form.taskUserMongo.name = null
+        this.form.taskUserMongo.taskStartDate = null
+        this.form.taskUserMongo.taskEndDate = null
+        this.form.userId = this.user.id
+        this.form.userNickName = this.user.nickName
       }
     },
     // 钩子:编辑 - 之前
     [CRUD.HOOK.beforeToEdit]() {
       this.form.userId = this.user.id
       this.form.userNickName = this.user.nickName
-      this.loadingQueryProjects = true
-      this.loadingQueryProjectsTwo = true
-      crudTask.getAllOfDaily({ projectId: this.form.projectId }).then(res => {
-        // 检索任务列表
+      this.tempValue = this.form.taskHours
 
-        this.formTasks = res
-        this.$nextTick().then(() => {
-          this.loadingQueryProjects = false
-        })
-      })
-      crudTaskUser.getAllTaskUser(this.form.taskUserMongo.id).then(res => {
-        if (res === []) {
-          this.formTaskUserIds = []
-        }
-        this.formTaskUserIds = res
-        this.$nextTick().then(() => {
-          this.loadingQueryProjectsTwo = false
-        })
-
-        for (let i = 0; i < this.formTaskUserIds.length; i++) {
-          this.userIds.push(this.formTaskUserIds[i].id)
-        }
-
-        // 循环表单任务列表
-        for (let i = 0; i < this.formTaskUserIds.length; i++) {
-          // 判断是否为选中任务
-          if (this.formTaskUserIds[i].id === this.form.taskUserMongo.id) {
-            this.form.taskHours = this.formTaskUserIds[i].performanceHours
-            this.form.alreadyConsumedHours = this.formTaskUserIds[i].alreadyConsumedHours
-            this.tempValue = this.formTaskUserIds[i].alreadyConsumedHours
-          }
-        }
-      })
+      this.formDateChange()
+      this.fetchAlreadyConsumedHours()
     },
     [CRUD.HOOK.afterRefresh]() {
       this.taskLoading = false
     },
-    [CRUD.HOOK.beforeSubmit]() {
-      if (!this.userIds.includes(this.form.taskUserMongo.id)) {
-        // 置换一下
-        var taskUserMongoName = this.form.taskUserMongo.id
-        this.form.taskUserMongo.name = taskUserMongoName
-        this.form.taskUserMongo.id = null
-      }
+    // [CRUD.HOOK.beforeSubmit]() {
+    //   if (!this.userIds.includes(this.form.taskUserMongo.id)) {
+    //     // 置换一下
+    //     var taskUserMongoName = this.form.taskUserMongo.id
+    //     this.form.taskUserMongo.name = taskUserMongoName
+    //     this.form.taskUserMongo.id = null
+    //   }
+    // },
+    disabledDate(time) {
+      return (
+        time.getTime() < new Date(this.form.taskUserMongo.taskStartDate) - 8.64e7 ||
+        time.getTime() > new Date(this.form.taskUserMongo.taskEndDate).getTime()
+      )
     },
     checkForm(flag) {
       if (this.form.taskUserMongo.id === undefined) {
@@ -698,7 +725,14 @@
       } else if (this.form.consumedHours === undefined || this.form.consumedHours === 0) {
         this.$message({
           showClose: true,
-          message: '请填写任务时长',
+          message: '请填写消耗工时',
+          type: 'error'
+        })
+        return
+      } else if (parseInt(this.form.consumedHours) + parseInt(this.form.todayFixedHours) > parseInt(this.form.todayAttendanceHours)) {
+        this.$message({
+          showClose: true,
+          message: '当日消耗工时总和超过打卡时间,请修改消耗工时',
           type: 'error'
         })
         return
@@ -718,20 +752,20 @@
           if (this.confirmProgress) {
             // 如果确定了
             const result = this.form.alreadyConsumedHours
-            if (result > this.form.taskHours && !this.confirmHours) {
-              this.centerDialogVisibleTaskHours = true
-              if (this.confirmHours) {
-                this.crud.submitCU()
-              } else {
-                if (flag > 1) {
-                  return
-                } else {
-                  this.checkForm()
-                }
-              }
-            } else {
-              this.crud.submitCU()
-            }
+            // if (result > this.form.taskHours && !this.confirmHours) {
+            //   this.centerDialogVisibleTaskHours = true
+            //   if (this.confirmHours) {
+            //     this.crud.submitCU()
+            //   } else {
+            //     if (flag > 1) {
+            //       return
+            //     } else {
+            //       this.checkForm()
+            //     }
+            //   }
+            // } else {
+            this.crud.submitCU()
+            // }
           } else {
             if (flag > 1) {
               return
@@ -764,6 +798,17 @@
     watchFlagChange() {
       this.watchFlg = true
     },
+    statistics() {
+      this.centerDialogVisibleStatistics = true
+      this.statisticsLoading = true
+      crudTaskDaliy.getStatistics(this.crud.query).then(res => {
+        this.statisticsData = res
+        console.log('this.statisticsData : ', this.statisticsData)
+      }).finally(() => {
+        // 同意按钮加载状态
+        this.statisticsLoading = false
+      })
+    },
     getAdventTasks() {
       crudTaskUser.getAdventTasks().then(res => {
         this.adventTasks = res
@@ -780,10 +825,8 @@
       })
     },
     handleClick(tab, event) {
-      console.log(tab, event)
     },
     handleClickTobeTasked(tab, event) {
-      console.log(tab, event)
     },
     // 获取检索项目
     getQueryProject() {
@@ -799,12 +842,6 @@
         this.$nextTick().then(() => {
           this.loadingQueryProjectsOne = false
         })
-      })
-
-      // 获取任务列表
-      crudTask.getAllOfDaily({ projectId: this.query.projectId }).then(res => {
-        // 检索任务列表
-        this.queryTasks = res
       })
     },
     // 检索项目变更
@@ -830,6 +867,12 @@
       this.loadingTast = false
     },
     formDateChange() {
+      crudAttendance.queryAttendanceHours({ userId: this.$store.state.user.user.id, date: this.form.fillDate }).then(res => {
+        this.form.todayAttendanceHours = res
+      })
+      crudTaskDaliy.taskConsumedHours({ userId: this.$store.state.user.user.id, fillDate: this.form.fillDate, id: this.form.id }).then(res => {
+        this.form.todayFixedHours = res
+      })
       crudTaskDaliy.getDailyDetail({ taskUserId: this.form.taskUserMongo.id, fillDate: this.form.fillDate }).then(res => {
         if (res === '') {
           this.form.alreadyConsumedHours = this.tempValue
@@ -839,11 +882,11 @@
           this.form.consumedHours = res.consumedHours
           this.form.taskProgress = res.taskProgress
         }
-        if (!this.userIds.includes(this.form.taskUserMongo.id)) {
-          this.form.consumedHours = 0
-          this.form.taskProgress = 0
-          this.form.alreadyConsumedHours = 0
-        }
+        // if (!this.userIds.includes(this.form.taskUserMongo.id)) {
+        //   this.form.consumedHours = 0
+        //   this.form.taskProgress = 0
+        //   this.form.alreadyConsumedHours = 0
+        // }
       })
     },
     // 表单用户变更
@@ -899,6 +942,23 @@
         })
       }
     },
+    fetchAlreadyConsumedHours() {
+      crudTask.getRelevantTaskUser({ 'taskId': this.form.taskId }).then(res => {
+        for (let i = 0; i < res.length; i++) {
+          this.userIds.push(res[i].id)
+        }
+        this.formTaskUserIds = res
+        // 循环表单任务列表
+        for (let i = 0; i < this.formTaskUserIds.length; i++) {
+          // 判断是否为选中任务
+          if (this.formTaskUserIds[i].id === this.form.taskUserMongo.id) {
+            this.form.taskHours = this.formTaskUserIds[i].performanceHours
+            this.form.alreadyConsumedHours = this.formTaskUserIds[i].alreadyConsumedHours
+            this.tempValue = this.formTaskUserIds[i].alreadyConsumedHours
+          }
+        }
+      })
+    },
     // 表单任务变更
     formTaskChange(cb) {
       this.formTaskUserIds = []
@@ -909,8 +969,9 @@
         // 判断是否为选中任务
         if (this.formTasks[i].id === this.form.taskId) {
           crudTask.getRelevantTaskUser({ 'taskId': this.form.taskId }).then(res => {
-            if (res === []) {
+            if (res == []) {
               this.formTaskUserIds = []
+              return
             }
             for (let i = 0; i < res.length; i++) {
               this.userIds.push(res[i].id)
@@ -919,8 +980,8 @@
             this.$nextTick().then(() => {
               this.loadingQueryProjectsTwo = false
             })
-            this.form.taskProgress = res.taskProgress
-            this.form.consumedHours = res.consumedHours
+            // this.form.taskProgress = res.taskProgress
+            // this.form.consumedHours = res.consumedHours
             if (cb) {
               cb()
             }
@@ -934,7 +995,6 @@
       // this.form.taskProgress = 0
       this.form.alreadyConsumedHours = 0
       this.form.taskHours = 0
-      console.log('ddd:' + this.form.taskUserMongo.id)
       // 循环表单任务列表
       for (let i = 0; i < this.formTaskUserIds.length; i++) {
         // 判断是否为选中任务
@@ -960,6 +1020,12 @@
         } else {
           this.form.taskProgress = 0
         }
+        if (res.taskUserMongo) {
+          this.form.taskUserMongo.id = res.taskUserMongo.id
+          this.form.taskUserMongo.taskStartDate = res.taskUserMongo.taskStartDate
+          this.form.taskUserMongo.taskEndDate = res.taskUserMongo.taskEndDate
+          this.form.taskUserMongo.performanceType = res.taskUserMongo.performanceType
+        }
       })
     },
     submitDialogTaskHours() {

--
Gitblit v1.9.3