From c752e33fe402e2179e7e6795f567d41c044ca3c6 Mon Sep 17 00:00:00 2001
From: yaozc <yaozc@yhzhg.cn>
Date: Fri, 07 Jul 2023 08:39:58 +0000
Subject: [PATCH] Merge branch 'yaozc_new' of http://192.168.1.110:5678/r/pms-upgrade

---
 eladmin-web-master/src/views/project/projectTask/index.vue |  156 +++++++++++++++++++++++++++++-----------------------
 1 files changed, 87 insertions(+), 69 deletions(-)

diff --git a/eladmin-web-master/src/views/project/projectTask/index.vue b/eladmin-web-master/src/views/project/projectTask/index.vue
index 33345c7..76133aa 100644
--- a/eladmin-web-master/src/views/project/projectTask/index.vue
+++ b/eladmin-web-master/src/views/project/projectTask/index.vue
@@ -4,9 +4,8 @@
     <div class="head-container">
       <div v-if="crud.props.searchToggle">
         <!-- 搜索 -->
-        <!-- <el-input v-model="query.projectId" clearable placeholder="项目ID" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" /> -->
         <el-input v-model="query.name" clearable placeholder="名称" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
-        <el-select v-model="query.projectId" filterable placeholder="项目名称" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery">
+        <el-select v-model="query.projectId" clearable filterable placeholder="所属项目" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery">
           <el-option
             v-for="item in projectList"
             :key="item.id"
@@ -22,8 +21,6 @@
             :value="item.value"
           />
         </el-select>
-        <!--<el-date-picker v-model="query.planStartTime" type="datetime" clearable placeholder="计划开始时间" style="width: 185px;" value-format="yyyy-MM-dd HH:mm:ss" class="filter-item" @keyup.enter.native="crud.toQuery" />
-        <el-date-picker v-model="query.planEndTime" type="datetime" clearable placeholder="计划结束时间" style="width: 185px;" value-format="yyyy-MM-dd HH:mm:ss" class="filter-item" @keyup.enter.native="crud.toQuery" /> -->
         <rrOperation :crud="crud" />
       </div>
       <!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
@@ -32,10 +29,10 @@
       <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">
           <el-form-item label="名称" prop="name">
-            <el-input v-model="form.name" maxlength="100" style="width: 340px;" />
+            <el-input v-model="form.name" style="width: 340px;" :disabled="disabledFlagByApprove" />
           </el-form-item>
-          <el-form-item label="项目名称" prop="projectId">
-            <el-select v-model="form.projectId" filterable placeholder="请选择" style="width: 340px;">
+          <el-form-item label="所属项目" prop="projectId">
+            <el-select v-model="form.projectId" clearable filterable placeholder="请选择" style="width: 340px;" :disabled="disabledFlagByApprove">
               <el-option
                 v-for="item in projectList"
                 :key="item.id"
@@ -46,7 +43,7 @@
             </el-select>
           </el-form-item>
           <el-form-item label="任务分类" prop="taskClassification">
-            <el-select v-model="form.taskClassification" filterable placeholder="请选择" style="width: 340px;">
+            <el-select v-model="form.taskClassification" clearable filterable placeholder="请选择" style="width: 340px;" :disabled="disabledFlagByApprove">
               <el-option
                 v-for="item in dict[taskClassification]"
                 :key="item.id"
@@ -56,22 +53,22 @@
             </el-select>
           </el-form-item>
           <el-form-item label="描述">
-            <el-input v-model="form.description" :rows="3" type="textarea" style="width: 340px;" />
+            <el-input v-model="form.description" :rows="3" type="textarea" style="width: 340px;" :disabled="disabledFlagByApprove" />
           </el-form-item>
           <el-form-item label="计划开始时间">
-            <el-date-picker v-model="form.planStartTime" type="datetime" :picker-options="pickerOptionsStart" style="width: 340px;" />
+            <el-date-picker v-model="form.planStartTime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" :default-time="$store.state.user.user.sysRostering.workStartTime + ':00'" :picker-options="pickerOptionsStart" style="width: 340px;" :disabled="disabledFlagByApprove" />
           </el-form-item>
           <el-form-item label="计划结束时间">
-            <el-date-picker v-model="form.planEndTime" type="datetime" :picker-options="pickerOptionsEnd" style="width: 340px;" />
+            <el-date-picker v-model="form.planEndTime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" :default-time="$store.state.user.user.sysRostering.workEndTime + ':00'" :picker-options="pickerOptionsEnd" style="width: 340px;" :disabled="disabledFlagByApprove" />
           </el-form-item>
           <el-form-item label="计划工时" prop="planHours">
-            <el-input v-model="form.planHours" style="width: 340px;" />
+            <el-input v-model="form.planHours" style="width: 340px;" :disabled="disabledFlagByApprove" />
           </el-form-item>
           <el-form-item label="计划工作量" prop="planWorkload">
-            <el-input v-model="form.planWorkload" style="width: 340px;" />
+            <el-input v-model="form.planWorkload" style="width: 340px;" :disabled="disabledFlagByApprove" />
           </el-form-item>
           <el-form-item label="计划工作量单位">
-            <el-select v-model="form.planWorkloadUnit" filterable placeholder="请选择" style="width: 340px;">
+            <el-select v-model="form.planWorkloadUnit" filterable placeholder="请选择" style="width: 340px;" :disabled="disabledFlagByApprove">
               <el-option
                 v-for="item in dict[standardWorkloadUnit]"
                 :key="item.id"
@@ -81,7 +78,7 @@
             </el-select>
           </el-form-item>
           <el-form-item label="备注">
-            <el-input v-model="form.remarks" :rows="3" type="textarea" style="width: 340px;" />
+            <el-input v-model="form.remarks" :rows="3" type="textarea" style="width: 340px;" :disabled="disabledFlagByApprove" />
           </el-form-item>
         </el-form>
         <div slot="footer" class="dialog-footer">
@@ -90,30 +87,31 @@
         </div>
       </el-dialog>
       <!--表格渲染-->
-      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
+      <el-table ref="table" v-loading="crud.loading" :summary-method="getSummaries" show-summary :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
         <el-table-column type="selection" width="55" />
-        <el-table-column prop="name" label="名称" />
-        <el-table-column prop="projectName" label="项目名称" show-overflow-tooltip>
+        <el-table-column show-overflow-tooltip prop="name" label="名称" width="180" />
+        <el-table-column show-overflow-tooltip prop="projectName" label="所属项目" width="180">
           <template slot-scope="scope">
             <el-tag>{{ scope.row.projectName }}</el-tag>
           </template>
         </el-table-column>
-        <el-table-column prop="taskClassification" label="任务分类" width="80">
+        <el-table-column show-overflow-tooltip prop="taskClassification" label="任务分类" width="80">
           <template slot-scope="scope">
             <el-tag>{{ dict.label[taskClassification][scope.row.taskClassification] }}</el-tag>
           </template>
         </el-table-column>
-        <el-table-column prop="description" label="描述" show-overflow-tooltip />
-        <el-table-column prop="planStartTime" label="计划开始时间" show-overflow-tooltip width="150" />
-        <el-table-column prop="planEndTime" label="计划结束时间" show-overflow-tooltip width="150" />
-        <el-table-column prop="planHours" label="计划工时" width="80" />
-        <el-table-column prop="planWorkload" label="计划工作量" width="100" />
-        <el-table-column prop="planWorkloadUnit" label="计划工作量单位" width="120">
+        <el-table-column show-overflow-tooltip prop="description" label="描述" width="140" />
+        <el-table-column show-overflow-tooltip prop="planStartTime" label="计划开始时间" />
+        <el-table-column show-overflow-tooltip prop="planEndTime" label="计划结束时间" />
+        <el-table-column show-overflow-tooltip prop="planHours" label="计划工时" width="100" />
+        <el-table-column show-overflow-tooltip prop="planWorkload" label="计划工作量" width="100" />
+        <el-table-column show-overflow-tooltip prop="planWorkloadUnit" label="计划工作量单位" width="120">
           <template slot-scope="scope">
             <el-tag v-if="dict.label[standardWorkloadUnit][scope.row.planWorkloadUnit]!=null">{{ dict.label[standardWorkloadUnit][scope.row.planWorkloadUnit] }}</el-tag>
           </template>
         </el-table-column>
-        <el-table-column prop="remarks" label="备注" show-overflow-tooltip />
+        <el-table-column show-overflow-tooltip prop="remarks" label="备注" width="140" />
+        <el-table-column show-overflow-tooltip prop="createTime" label="创建时间" width="140" />
         <el-table-column v-if="checkPer(['admin','projectTask:edit','projectTask:del'])" label="操作" width="150px" align="center">
           <template slot-scope="scope">
             <udOperation
@@ -139,7 +137,7 @@
 import pagination from '@crud/Pagination'
 import constant from '../../../utils/constant'
 
-const defaultForm = { id: null, projectId: null, name: null, taskClassification: null, description: null, planStartTime: null, planEndTime: null, planHours: null, planWorkload: null, planWorkloadUnit: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null }
+const defaultForm = { id: null, projectId: null, name: null, taskClassification: null, performanceType: '1', description: null, planStartTime: null, planEndTime: null, planHours: null, planWorkload: null, planWorkloadUnit: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null }
 export default {
   name: 'ProjectTask',
   components: { pagination, crudOperation, rrOperation, udOperation },
@@ -149,36 +147,13 @@
     return CRUD({ title: '项目任务', url: 'api/projectTask', idField: 'id', sort: 'id,desc', crudMethod: { ...crudProjectTask }})
   },
   data() {
-    var planTime = (rule, value, callback) => {
-      if (value !== null) {
-        if (isNaN(Number(value))) {
-          callback(new Error('计划工时必须是数字'))
-        } else {
-          if (value <= 0) {
-            callback(new Error('计划工时必须大于0'))
-          } else if (!/^\d{0,4}(\.\d{1,2})?$/.test(value)) {
-            callback(new Error('计划工时最多位四位整数,两位小数'))
-          } else {
-            callback()
-          }
-        }
-      } else {
-        callback(new Error('计划工时不能为空'))
-      }
-    }
-    var planWorkload = (rule, value, callback) => {
-      if (value !== null) {
-        if (isNaN(Number(value))) {
-          callback(new Error('计划工作量必须是数字'))
-        } else {
-          if (value <= 0) {
-            callback(new Error('计划工作量必须大于0'))
-          } else if (!/^\d{0,4}(\.\d{1,2})?$/.test(value)) {
-            callback(new Error('计划工作量最多位四位整数,两位小数'))
-          } else {
-            callback()
-          }
-        }
+    // 指针重指向
+    const _this = this
+    // 时长(万内)验证
+    var durationValidate = (rule, value, callback) => {
+      const reg = /^([0-9]|[1-9]\d{1,3})(\.\d{1,2})?$/
+      if (value != null && value !== '' && !reg.test(value)) {
+        callback(new Error('请输入 一万 以内的正整数或两位小数'))
       } else {
         callback()
       }
@@ -193,27 +168,26 @@
       rules: {
         name: [
           { required: true, message: '名称不能为空', trigger: 'blur' },
-          { min: 1, max: 100, message: '最大长度 100 个字符', trigger: 'blur' }
+          { max: 100, message: '最大长度 100 个字符', trigger: 'blur' }
         ],
         projectId: [
-          { required: true, message: '项目名称不能为空', trigger: 'blur' }
+          { required: true, message: '所属项目不能为空', trigger: 'change' }
         ],
         taskClassification: [
-          { required: true, message: '任务分类不能为空', trigger: 'blur' }
+          { required: true, message: '任务分类不能为空', trigger: 'change' }
         ],
         planHours: [
-          { required: true, validator: planTime, trigger: 'blur' }
+          { required: true, message: '计划工时不能为空', trigger: 'blur' },
+          { validator: durationValidate, trigger: 'blur' }
         ],
         planWorkload: [
-          { validator: planWorkload, trigger: 'blur' }
+          { validator: durationValidate, trigger: 'blur' }
         ]
       },
       queryTypeOptions: [
-        { key: 'projectId', display_name: '项目名称' },
         { key: 'name', display_name: '名称' },
-        { key: 'taskClassification', display_name: '任务分类' },
-        { key: 'planStartTime', display_name: '计划开始时间' },
-        { key: 'planEndTime', display_name: '计划结束时间' }
+        { key: 'projectId', display_name: '所属项目' },
+        { key: 'taskClassification', display_name: '任务分类' }
       ],
       // 字典:任务分类
       taskClassification: constant.TAST_CLASSIFICATION,
@@ -223,36 +197,80 @@
       approveStatusAcknowledged: constant.APPROVE_STATUS_ACKNOWLEDGED,
       // 项目列表
       projectList: [],
+      // 计划开始时间选项
       pickerOptionsStart: {
         disabledDate: (time) => {
           if (this.form.planEndTime) {
-            return time.getTime() > Date.now() || time.getTime() > this.form.planEndTime
+            return _this.form.planEndTime != null && _this.form.planEndTime !== '' ? time.getTime() > new Date(_this.form.planEndTime).getTime() : false
           }
         }
       },
+      // 计划结束时间选项
       pickerOptionsEnd: {
         disabledDate: (time) => {
-          return time.getTime() < this.form.planStartTime
+          return _this.form.planStartTime != null && _this.form.planStartTime !== '' ? time.getTime() < new Date(_this.form.planStartTime).getTime() - (86400000 - 1) : false
         }
-      }
+      },
+      // 表单禁用标记(承认状态)
+      disabledFlagByApprove: false
     }
   },
   methods: {
     // 钩子:在获取表格数据之前执行,false 则代表不获取数据
     [CRUD.HOOK.beforeRefresh]() {
+      // 判断传参是否为空
+      if (this.$route.params.projectId != null && this.$route.params.projectId !== '' && this.crud.query.projectId === undefined) {
+        // 检索条件赋值
+        this.$set(this.crud.query, 'projectId', Number(this.$route.params.projectId))
+      }
+      // 获取信息项目列表
       this.getprojectAll()
       return true
     },
     // 新增与编辑前做的操作
     [CRUD.HOOK.afterToCU](crud, form) {
+      // 表单禁用标记(承认状态)
+      this.disabledFlagByApprove = false
+      // 循环项目列表
+      for (let i = 0; i < this.projectList.length; i++) {
+        // 判断是否为同一项目
+        if (this.form.projectId === this.projectList[i].id && this.projectList[i].approveStatus === constant.APPROVE_STATUS_ACKNOWLEDGED) {
+          // 表单禁用标记(承认状态)
+          this.disabledFlagByApprove = true
+        }
+      }
       // 随机数
       this.random = Math.random()
     },
     // 获取信息项目列表
     getprojectAll() {
+      // 获取信息项目列表
       crudProject.getAll().then(res => {
+        // 项目列表
         this.projectList = res
       })
+    },
+    // 表格统计
+    getSummaries(param) {
+      const { columns, data } = param
+      const sums = []
+      columns.forEach((column, index) => {
+        // 7/8号单元格
+        if (index === 7 || index === 8) {
+          const values = data.map(item => Number(item[column.property]))
+          if (!values.every(value => isNaN(value))) {
+            sums[index] = values.reduce((prev, curr) => {
+              const value = Number(curr)
+              if (!isNaN(value)) {
+                return prev + curr
+              } else {
+                return prev
+              }
+            }, 0)
+          }
+        }
+      })
+      return sums
     }
   }
 }

--
Gitblit v1.9.3