From 4d730af0447c686133130d0116a0fa3dd82c2dca Mon Sep 17 00:00:00 2001
From: BAOLH <baolh@yhzhg.cn>
Date: Tue, 10 Nov 2026 01:41:03 +0000
Subject: [PATCH] Merge branch 'wcd-2411-update' into wcd

---
 eladmin-web-master/src/views/task/task/index.vue |  808 ++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 734 insertions(+), 74 deletions(-)

diff --git a/eladmin-web-master/src/views/task/task/index.vue b/eladmin-web-master/src/views/task/task/index.vue
index 9aec203..c7c0b4c 100644
--- a/eladmin-web-master/src/views/task/task/index.vue
+++ b/eladmin-web-master/src/views/task/task/index.vue
@@ -4,34 +4,38 @@
     <div class="head-container">
       <div>
         <!-- 搜索 -->
-        <el-select v-model="query.projectId" filterable placeholder="所属项目" style="width: 400px;" class="filter-item" @change="queryByProjectId">
+        <el-select v-model="curProject" value-key="id" clearable filterable placeholder="所属项目" style="width: 400px;" class="filter-item" @change="queryByProjectId">
           <el-option
             v-for="item in projects"
             :key="item.id"
             :label="item.name"
-            :value="item.id"
-          />
+            :value="item"
+          >
+            <span style="float: left">{{ item.name }}</span>
+          </el-option>
         </el-select>
       </div>
       <div style="margin-bottom: 20px;">
         <el-card class="box-card">
-          <el-descriptions title="项目信息">
-            <el-descriptions-item label="用户名">kooriookami</el-descriptions-item>
-            <el-descriptions-item label="手机号">18100000000</el-descriptions-item>
-            <el-descriptions-item label="居住地">苏州市</el-descriptions-item>
-            <el-descriptions-item label="备注">
-              <el-tag size="small">学校</el-tag>
-            </el-descriptions-item>
-            <el-descriptions-item label="联系地址">江苏省苏州市吴中区吴中大道 1188 号</el-descriptions-item>
+          <el-descriptions title="项目信息" :column="3">
+            <el-descriptions-item label="项目开始时间">{{ curProject === null ? '' : curProject.planStartDate }}</el-descriptions-item>
+            <el-descriptions-item label="项目结束时间">{{ curProject === null ? '' : curProject.planEndDate }}</el-descriptions-item>
+            <el-descriptions-item label="剩余天数">{{ curProject === null ? '0' : '0' }}</el-descriptions-item>
+            <el-descriptions-item label="总任务数">{{ curProject === null ? '0' : curProject.totalTask }}</el-descriptions-item>
+            <el-descriptions-item label="完成任务数">{{ curProject === null ? '0' : curProject.completeTask }}</el-descriptions-item>
+            <el-descriptions-item label="任务完成比">{{ isNaN(curProject === null ? '0%' : (parseFloat((curProject.completeTask / curProject.totalTask) * 100)).toFixed(2)) ? 0 : curProject === null ? '0%' : (parseFloat((curProject.completeTask / curProject.totalTask) * 100)).toFixed(2) + '%' }}</el-descriptions-item>
+            <el-descriptions-item label="总工时数">{{ curProject === null ? '0.0' : curProject.totalHours }}</el-descriptions-item>
+            <el-descriptions-item label="完成工时数">{{ curProject === null ? '0.0' : curProject.completeHours }}</el-descriptions-item>
+            <el-descriptions-item label="工时完成比">{{ isNaN(curProject === null ? '0%' : (parseFloat((curProject.completeHours / curProject.totalHours) * 100)).toFixed(2)) ? 0 : curProject === null ? '0%' : (parseFloat((curProject.completeHours / curProject.totalHours) * 100)).toFixed(2) + '%' }}</el-descriptions-item>
           </el-descriptions>
         </el-card>
       </div>
-      <div v-if="crud.props.searchToggle">
+      <div>
         <!-- 搜索 -->
         <el-autocomplete v-model="query.name" class="filter-item" :fetch-suggestions="querySearch" placeholder="名称" style="width: 185px;" />
-        <el-select v-model="query.taskStatus" filterable clearable placeholder="任务状态" style="width: 185px;" class="filter-item">
+        <el-select v-model="query.taskStatuses" multiple collapse-tags filterable clearable placeholder="任务状态" style="width: 185px;" class="filter-item">
           <el-option
-            v-for="item in dict[taskStatus]"
+            v-for="item in filteredDict"
             :key="item.id"
             :label="item.label"
             :value="item.value"
@@ -45,23 +49,67 @@
             :value="item.value"
           />
         </el-select>
-        <el-select v-model="query.userId" filterable clearable placeholder="所属员工" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery">
+        <el-select v-model="query.tagList" multiple collapse-tags filterable clearable placeholder="任务分类" style="width: 185px;" class="filter-item">
           <el-option
-            v-for="item in users"
-            :key="item.id"
-            :label="item.nickName"
-            :value="item.id"
+            v-for="item in tags"
+            :key="item"
+            :label="item"
+            :value="item"
           />
         </el-select>
+        <div class="block">
+          <el-cascader
+            v-model="queryUser"
+            :filterable="true"
+            :options="options"
+            :props="props"
+            clearable
+            placeholder="任务负责人"
+            :show-all-levels="false"
+            style="width: 185px;"
+          />
+        </div>
         <rrOperation :crud="crud" />
       </div>
+
+      <el-dialog
+        title="任务详情"
+        :visible.sync="dialogVisible"
+        width="800px"
+        @closed="calendarLoading = true"
+        @opened="monthClick('')"
+      >
+        <FullCalendar ref="fullCalendar" v-loading="calendarLoading" :options="calendarOptions" />
+      </el-dialog>
+
       <!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
-      <crudOperation :permission="permission" />
+      <crudOperation v-if="this.crud.query.flag" :permission="permission">
+        <el-button
+          slot="right"
+          class="filter-item"
+          size="mini"
+          type="primary"
+          :disabled="taskDetailDisabled"
+          @click="draw"
+        >任务详情</el-button>
+        <el-button
+          slot="right"
+          class="filter-item"
+          size="mini"
+          type="primary"
+          :disabled="this.crud.selections.length === 0"
+          @click="doTaskCompleted"
+        >任务完结</el-button>
+        <el-button slot="right" v-permission="permission.migration" icon="el-icon-guide" class="filter-item" size="mini" type="primary" @click="toMigration">
+          任务迁移
+        </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">
           <el-form-item label="所属项目" prop="projectId">
-            <el-select v-model="form.projectId" disabled placeholder="请选择" style="width: 340px;" @change="projectChange">
+            <el-select v-model="form.projectId" :disabled="44 !== $store.state.user.user.id" placeholder="请选择" style="width: 340px;">
               <el-option
                 v-for="item in projects"
                 :key="item.id"
@@ -73,21 +121,9 @@
           <el-form-item label="名称" prop="name">
             <el-input v-model="form.name" style="width: 340px;" />
           </el-form-item>
-          <el-form-item label="父级任务">
-            <el-select v-if="pidTasks" v-model="form.parent.id" filterable clearable placeholder="请选择" style="width: 340px;">
-              <el-option
-                v-for="item in pidTasks"
-                :key="item.id"
-                :label="item.name"
-                :value="item.id"
-                :disabled="item.id == form.id"
-              />
-            </el-select>
-            {{ form.parent.id }}
-          </el-form-item>
-          <el-form-item label="任务分类" prop="taskClassification">
+          <el-form-item label="任务分类" prop="taskClassification" placeholder="请选择">
             <el-tag
-              v-for="(tag, id) in form.tags"
+              v-for="(tag, id) in form.tagList"
               :key="id"
               closable
               :disable-transitions="false"
@@ -105,6 +141,7 @@
               allow-create
               default-first-option
               @keyup.enter.native="handleInputConfirm"
+              @change="handleInputConfirm"
             >
               <el-option
                 v-for="(item, id) in tags"
@@ -113,7 +150,7 @@
                 :value="item"
               />
             </el-select>
-            <el-button v-else class="button-new-tag" size="small" @click="showInput">+ New Tag</el-button>
+            <el-button v-else class="button-new-tag" size="small" @click="showInput">请选择标签</el-button>
           </el-form-item>
           <el-form-item label="绩效类型" prop="performanceType">
             <el-select v-model="form.performanceType" filterable clearable placeholder="请选择" style="width: 340px;">
@@ -125,32 +162,71 @@
               />
             </el-select>
           </el-form-item>
+          <el-form-item v-if="isShow" label="任务状态">
+            <el-select v-model="form.taskStatus" filterable clearable placeholder="请选择" style="width: 340px;">
+              <el-option
+                v-for="item in filteredDict"
+                :key="item.id"
+                :label="item.label"
+                :value="item.value"
+              />
+            </el-select>
+          </el-form-item>
           <el-form-item label="描述">
             <el-input v-model="form.description" :rows="3" type="textarea" style="width: 340px;" />
           </el-form-item>
-          <el-form-item label="计划开始时间">
+          <el-form-item label="计划开始时间" prop="planStartTime">
             <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="planStartTimePickerOptions" style="width: 340px;" />
           </el-form-item>
-          <el-form-item label="计划结束时间">
+          <el-form-item label="计划结束时间" prop="planEndTime">
             <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="planEndTimePickerOptions" style="width: 340px;" />
+          </el-form-item>
+          <el-form-item label="计划工作量" prop="planWorkload">
+            <el-input v-model="form.planWorkload" style="width: 340px;" />
+          </el-form-item>
+          <el-form-item label="计划工作量单位">
+            <el-select v-model="form.planWorkloadUnit" filterable clearable placeholder="请选择" style="width: 340px;">
+              <el-option
+                v-for="item in dict[standardWorkloadUnit]"
+                :key="item.id"
+                :label="item.label"
+                :value="item.value"
+              />
+            </el-select>
           </el-form-item>
           <el-form-item label="计划工时" prop="planHours">
             <el-input v-model="form.planHours" style="width: 340px;">
               <template slot="append">小时</template>
             </el-input>
           </el-form-item>
-          <el-form-item label="所属员工" prop="userId">
-            <el-select v-model="form.userIdList" multiple filterable clearable placeholder="请选择" style="width: 340px;">
+          <el-form-item label="任务成员" prop="containUserList">
+            <div class="block">
+              <el-cascader
+                v-model="selectedValue"
+                :filterable="true"
+                :options="options"
+                :props="props"
+                clearable
+                placeholder="任务成员"
+                :show-all-levels="false"
+                style="width: 340px;"
+              />
+            </div>
+          </el-form-item>
+          <el-form-item label="任务负责人" prop="userId">
+            <el-select v-if="form.containUserList" v-model="form.userIdList" :no-data-text=" '没有任务成员' " multiple filterable clearable placeholder="请选择" style="width: 340px;">
               <el-option
                 v-for="item in users"
                 :key="item.id"
                 :label="item.nickName"
                 :value="item.id"
+                :show-all-levels="false"
               >
                 <span style="float: left">{{ item.nickName }}</span>
                 <span style="float: right; color: #8492a6; font-size: 13px">{{ item.levelName }}</span>
               </el-option>
             </el-select>
+            <el-select v-else v-model="form.userIdList" :no-data-text=" '没有任务成员' " multiple filterable clearable placeholder="请选择" style="width: 340px;" />
           </el-form-item>
         </el-form>
         <div slot="footer" class="dialog-footer">
@@ -158,8 +234,93 @@
           <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
         </div>
       </el-dialog>
+
+      <!--任务迁移表单-->
+      <el-dialog :close-on-click-modal="false" :before-close="closeMigration" :visible.sync="migrationParams.visible" title="任务迁移" width="960px">
+        <el-form ref="migrationForm" :model="migrationParams.form" :rules="migrationParams.rules" size="small" label-width="80px">
+          <el-row :gutter="0">
+            <el-col :span="11" class="part-form-box">
+              <div class="part-form-title">迁移来源</div>
+              <!-- <el-row :gutter="0"> -->
+              <el-col :span="22">
+                <el-form-item label="迁移层级" prop="sourceLevel" required>
+                  <el-radio-group v-model="migrationParams.form.sourceLevel" @input="sourceLevelChange">
+                    <el-radio label="project" disabled>
+                      <span>项目</span>
+                    </el-radio>
+
+                    <el-radio label="task">
+                      <span>任务</span>
+                    </el-radio>
+
+                    <el-radio label="taskUser">
+                      <span>分配任务</span>
+                    </el-radio>
+                  </el-radio-group>
+                </el-form-item>
+                <el-form-item label="所属项目" prop="sourceProjectId" required>
+                  <el-select v-model="migrationParams.form.sourceProjectId" filterable clearable placeholder="请先选择所属项目" style="width: 300px;" @change="sourceProjectChange">
+                    <el-option v-for="item in projects" :key="item.id" :label="item.name" :value="item.id" />
+                  </el-select>
+                </el-form-item>
+
+                <el-form-item v-show="migrationParams.sourceTaskList.length > 0" label="所属任务" prop="sourceTaskId" :required="migrationParams.form.sourceLevel === 'task' || migrationParams.form.sourceLevel === 'taskUser'">
+                  <el-select v-model="migrationParams.form.sourceTaskId" filterable clearable placeholder="请先选择所属任务" style="width: 300px;" @change="sourceTaskChange">
+                    <el-option v-for="item in migrationParams.sourceTaskList" :key="item.id" :label="item.name" :value="item.id" />
+                  </el-select>
+                </el-form-item>
+
+                <el-form-item v-show="migrationParams.sourceTaskUserList.length > 0" label="分配任务" prop="sourceTaskUserId" :required="migrationParams.form.sourceLevel === 'taskUser'">
+                  <el-select v-model="migrationParams.form.sourceTaskUserId" multiple filterable clearable placeholder="请先选择分配任务" style="width: 300px;">
+                    <el-option v-for="item in migrationParams.sourceTaskUserList" :key="item.id" :label="item.name" :value="item.id" />
+                  </el-select>
+                </el-form-item>
+              </el-col>
+              <!-- </el-row> -->
+            </el-col>
+            <el-col :span="2">
+              <div style="text-align: center; line-height: 70px;">
+                <i class="el-icon-d-arrow-right" style="font-size: 36px;" />
+              </div>
+            </el-col>
+            <el-col :span="11" class="part-form-box">
+              <div class="part-form-title">迁移目标</div>
+              <el-col :span="22">
+                <el-form-item label="迁移层级" prop="targetLevel" required>
+                  <el-radio-group v-model="migrationParams.form.targetLevel" disabled>
+                    <el-radio label="project">
+                      <span>项目</span>
+                    </el-radio>
+
+                    <el-radio label="task">
+                      <span>任务</span>
+                    </el-radio>
+                  </el-radio-group>
+                </el-form-item>
+                <el-form-item label="所属项目" prop="targetProjectId" required>
+                  <el-select v-model="migrationParams.form.targetProjectId" filterable clearable placeholder="请先选择所属项目" style="width: 300px;" @change="targetProjectChange">
+                    <el-option v-for="item in projects" :key="item.id" :label="item.name" :value="item.id" />
+                  </el-select>
+                </el-form-item>
+
+                <el-form-item v-show="migrationParams.targetTaskList.length > 0" label="所属任务" prop="targetTaskId" :required="migrationParams.form.targetLevel === 'task'">
+                  <el-select v-model="migrationParams.form.targetTaskId" filterable clearable placeholder="请先选择所属任务" style="width: 300px;">
+                    <el-option v-for="item in migrationParams.targetTaskList" :key="item.id" :label="item.name" :value="item.id" />
+                  </el-select>
+                </el-form-item>
+              </el-col>
+            </el-col>
+          </el-row>
+        </el-form>
+        <div slot="footer" class="dialog-footer">
+          <el-button type="text" @click="closeMigration">取消</el-button>
+          <el-button :loading="migrationParams.loading" type="primary" @click="doMigration">确认</el-button>
+        </div>
+      </el-dialog>
+
       <!--表格渲染-->
       <el-table
+        ref="table"
         v-loading="crud.loading"
         :data="crud.data"
         size="small"
@@ -167,8 +328,10 @@
         row-key="id"
         :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
         @selection-change="crud.selectionChangeHandler"
+        @row-click="getTaskUser"
       >
         <el-table-column type="selection" width="55" />
+        <el-table-column :show-overflow-tooltip="true" prop="projectName" label="项目" fixed="left" width="180" />
         <el-table-column :show-overflow-tooltip="true" prop="name" label="名称" fixed="left" width="180" />
         <el-table-column :show-overflow-tooltip="true" label="计划工时" width="80">
           <template slot-scope="scope">
@@ -182,18 +345,31 @@
             <el-tag>{{ dict.label[taskStatus][scope.row.taskStatus] }}</el-tag>
           </template>
         </el-table-column>
+        <el-table-column :show-overflow-tooltip="true" label="消耗工时" width="80">
+          <template slot-scope="scope">
+            <el-tag v-if="scope.row.consumedHours > scope.row.sumPlanHours" type="info">{{ scope.row.consumedHours }}</el-tag>
+            <el-tag v-else type="error">{{ scope.row.consumedHours }}</el-tag>
+          </template>
+        </el-table-column>
         <el-table-column :show-overflow-tooltip="true" prop="performanceType" label="绩效类型" width="80">
           <template slot-scope="scope">
             <el-tag>{{ dict.label[performanceType][scope.row.performanceType] }}</el-tag>
           </template>
         </el-table-column>
-        <el-table-column :show-overflow-tooltip="true" prop="taskClassification" label="任务分类" width="160">
+        <el-table-column :show-overflow-tooltip="true" prop="tagList" label="任务分类" width="240">
           <template slot-scope="scope">
-            <el-tag>{{ dict.label[taskClassification][scope.row.taskClassification] }}</el-tag>
+            <template>
+              <el-tag v-for="tag in scope.row.tagList" :key="tag">{{ tag }}</el-tag>
+            </template>
           </template>
         </el-table-column>
-        <el-table-column :show-overflow-tooltip="true" prop="description" label="描述" width="180" />
-        <el-table-column v-if="checkPer(['admin','task:divide','task:edit','task:del'])" label="操作" width="180px" align="center" fixed="right">
+        <el-table-column :show-overflow-tooltip="true" prop="userIdList" label="任务负责人" width="240">
+          <template slot-scope="scope">
+            <el-tag v-for="userId in scope.row.userIdList" :key="userId">{{ getUserNameById(userId) }}</el-tag>
+          </template>
+        </el-table-column>
+        <el-table-column :show-overflow-tooltip="true" prop="description" label="描述" />
+        <el-table-column v-if="checkPer(['admin','task:divide','task:edit','task:del']) && this.crud.query.flag === true" label="操作" width="180px" align="center" fixed="right">
           <template slot-scope="scope">
             <udOperation :data="scope.row" :permission="permission" />
           </template>
@@ -207,6 +383,7 @@
 
 <script>
 import crudTask from '@/api/task/task'
+import crudTaskUser from '@/api/task/taskUser'
 import CRUD, { presenter, header, form, crud } from '@crud/crud'
 import rrOperation from '@crud/RR.operation'
 import crudOperation from '@crud/CRUD.operation'
@@ -215,11 +392,15 @@
 import constant from '@/utils/constant'
 import crudUser from '@/api/system/user'
 import crudProject from '@/api/project/project'
+import '@fullcalendar/core/vdom'
+import FullCalendar from '@fullcalendar/vue'
+import dayGridPlugin from '@fullcalendar/daygrid'
+import moment from 'moment'
 
-const defaultForm = { id: null, name: null, projectId: null, userIdList: [], parent: { id: null }, priority: null, tags: [], performanceType: null, description: null, planStartTime: null, planEndTime: null, planHours: null, pieceRate: 0, planWorkload: 0, planWorkloadUnit: null, taskStatus: null, remarks: null, version: null, createBy: null, createTime: null, updateBy: null, updateTime: null }
+const defaultForm = { id: null, name: null, projectId: null, userIdList: [], parent: { id: null }, priority: null, tagList: [], performanceType: null, description: null, planStartTime: null, planEndTime: null, planHours: null, pieceRate: 0, planWorkload: 0, planWorkloadUnit: null, taskStatus: null, remarks: null, version: null }
 export default {
   name: 'Task',
-  components: { pagination, crudOperation, rrOperation, udOperation },
+  components: { pagination, crudOperation, rrOperation, udOperation, FullCalendar },
   mixins: [presenter(), header(), form(defaultForm), crud()],
   dicts: [constant.PRIORITY, constant.TAST_CLASSIFICATION, constant.PERFORMANCE_TYPE, constant.STANDARD_WORKLOAD_UNIT, constant.TASK_STATUS],
   cruds() {
@@ -237,7 +418,31 @@
         callback()
       }
     }
+    var migrationValidate = (rule, value, callback) => {
+      const that = this
+      if (rule.field === 'sourceTaskId' && (that.migrationParams.form.sourceLevel === 'task' || that.migrationParams.form.sourceLevel === 'taskUser')) {
+        if (value == null || value === '' || value === undefined) {
+          callback(new Error('所属任务不能为空'))
+        } else if (that.migrationParams.form.sourceLevel === 'task' && that.migrationParams.form.sourceProjectId === that.migrationParams.form.targetProjectId) {
+          callback(new Error('所属任务已属于迁移目标所属项目'))
+        }
+      }
+      if (rule.field === 'sourceTaskUserId' && that.migrationParams.form.sourceLevel === 'taskUser') {
+        if (value == null || value === undefined || (value.length !== undefined && value.length === 0)) {
+          callback(new Error('分配任务不能为空'))
+        } else if (that.migrationParams.form.sourceTaskId === that.migrationParams.form.targetTaskId) {
+          callback(new Error('分配任务已属于迁移目标所属任务'))
+        }
+      }
+      if (rule.field === 'targetTaskId' && that.migrationParams.form.targetLevel === 'task') {
+        if (value == null || value === '' || value === undefined) {
+          callback(new Error('所属任务不能为空'))
+        }
+      }
+      callback()
+    }
     return {
+      props: { multiple: true },
       permission: {
         add: ['admin', 'task:add'],
         edit: ['admin', 'task:edit'],
@@ -245,7 +450,8 @@
         download: ['admin', 'task:download'],
         divide: ['admin', 'task:divide'],
         seeDivide: ['admin', 'task:seeDivide'],
-        seeDaliy: ['admin', 'task:seeDaliy']
+        seeDaliy: ['admin', 'task:seeDaliy'],
+        migration: ['admin', 'task:migration']
       },
       rules: {
         name: [
@@ -261,6 +467,12 @@
         pieceRate: [
           { validator: durationValidate, trigger: 'blur' }
         ],
+        planStartTime: [
+          { required: true, message: '计划开始时间不能为空', trigger: 'change' }
+        ],
+        planEndTime: [
+          { required: true, message: '计划结束时间不能为空', trigger: 'change' }
+        ],
         planHours: [
           { required: true, message: '计划工时不能为空', trigger: 'blur' },
           { validator: durationValidate, trigger: 'blur' }
@@ -271,6 +483,89 @@
         taskStatus: [
           { required: true, message: '任务状态不能为空', trigger: 'change' }
         ]
+      },
+      calendarOptions: {
+        // 引入的插件
+        plugins: [dayGridPlugin],
+        // 日历头部按钮位置
+        headerToolbar: {
+          left: '',
+          center: 'title',
+          right: 'prev,today,next'
+        },
+        // 日历头部按钮中文转换
+        buttonText: {
+          today: '今天',
+          month: '月',
+          week: '周',
+          day: '天'
+        },
+        initialView: 'dayGridMonth',
+        locale: 'zh-ch',
+        firstDay: '1',
+        weekNumberCalculation: 'ISO',
+        eventColor: '#3d8eec',
+        timeGridEventMinHeight: '20',
+        aspectRatio: '1.5',
+        displayEventTime: false,
+        validRange: {},
+        allDaySlot: false,
+        eventLimit: true,
+        fixedWeekCount: false,
+        // eslint-disable-next-line no-dupe-keys
+        eventTimeFormat: {
+          hour: 'numeric',
+          minute: '2-digit',
+          hour12: false
+        },
+        slotLabelFormat: {
+          hour: '2-digit',
+          minute: '2-digit',
+          meridiem: false,
+          hour12: false
+        },
+        businessHours: {
+          dow: [1, 2, 3, 4, 5],
+          start: '0:00',
+          end: '24:00'
+        },
+        events: [],
+        // 事件
+        editable: false,
+        eventStartEditable: false,
+        eventDurationEditable: false,
+        selectable: false,
+        selectMirror: true,
+        selectMinDistance: 0,
+        weekends: true,
+        navLinks: true,
+        selectHelper: false,
+        selectEventOverlap: false,
+        dayMaxEvents: true,
+        // dateClick: this.handleDateClick, // 点击日期触发
+        // eventsSet: this.handleEvents,
+        // eventClick: this.handleEventClick, // 点击日程触发
+        // eventDrop: this.handleEventDrop,
+        eventResize: this.eventResize,
+        height: 'auto',
+        customButtons: {
+          prev: {
+            click: () => {
+              this.monthClick('prev')
+            }
+          },
+          today: {
+            text: '今天',
+            click: () => {
+              this.monthClick('')
+            }
+          },
+          next: {
+            click: () => {
+              this.monthClick('next')
+            }
+          }
+        }
       },
       queryTypeOptions: [
         { key: 'name', display_name: '名称' },
@@ -314,6 +609,8 @@
       userRolesLevelMin: null,
       // 项目列表
       projects: [],
+      // 当前项目
+      curProject: null,
       // 父级任务列表
       pidTasks: [],
       // 员工列表
@@ -322,7 +619,83 @@
       tags: [],
       // tag标签
       inputVisible: false,
-      inputValue: ''
+      inputValue: null,
+      containUserList: [],
+      userList: [],
+      options: [],
+      selectedValue: [],
+      queryUser: [],
+      dialogVisible: false,
+      taskDetailDisabled: true,
+      calendarLoading: true,
+      isShow: false,
+      // 任务迁移参数
+      migrationParams: {
+        visible: false,
+        loading: false,
+        form: {
+          sourceProjectId: null,
+          sourceTaskId: null,
+          sourceTaskUserId: [],
+          sourceLevel: 'taskUser',
+          targetProjectId: null,
+          targetTaskId: null,
+          targetLevel: 'task'
+        },
+        sourceTaskList: [],
+        targetTaskList: [],
+        sourceTaskUserList: [],
+        rules: {
+          sourceProjectId: [{ required: true, message: '所属项目不能为空', trigger: 'change' }],
+          sourceTaskId: [{ validator: migrationValidate, trigger: 'change' }],
+          sourceTaskUserId: [{ validator: migrationValidate, trigger: 'change' }],
+          sourceLevel: [{ required: true, message: '迁移来源类别不能为空', trigger: 'change' }],
+          targetProjectId: [{ required: true, message: '所属项目不能为空', trigger: 'change' }],
+          targetTaskId: [{ validator: migrationValidate, trigger: 'change' }],
+          targetLevel: [{ required: true, message: '迁移目标类别不能为空', trigger: 'change' }]
+        }
+      }
+    }
+  },
+  computed: {
+    filteredDict() {
+      return this.dict[this.taskStatus]
+    }
+  },
+  watch: {
+    'selectedValue': function(newVal) {
+      this.form.containUserList = []
+      for (let i = 0; i < newVal.length; i++) {
+        var temp = []
+        temp = newVal[i]
+        if (!this.form.containUserList.includes(temp[newVal[i].length - 1])) {
+          // 如果不在
+          this.form.containUserList.push(temp[newVal[i].length - 1])
+        }
+      }
+    },
+    'crud.selections': function(newVal) {
+      this.taskDetailDisabled = true
+      if (newVal.length === undefined) {
+        this.taskDetailDisabled = false
+      }
+      if (newVal.length > 1) {
+        this.taskDetailDisabled = true
+      }
+      if (newVal.length === 1) {
+        this.taskDetailDisabled = false
+      }
+    },
+    'queryUser': function(newVal) {
+      this.query.userIds = []
+      for (let i = 0; i < newVal.length; i++) {
+        var temp = []
+        temp = newVal[i]
+        if (!this.query.userIds.includes(temp[newVal[i].length - 1])) {
+          // 如果不在
+          this.query.userIds.push(temp[newVal[i].length - 1])
+        }
+      }
     }
   },
   created() {
@@ -336,36 +709,162 @@
     this.getTags()
   },
   methods: {
+    [CRUD.HOOK.afterSubmit]() {
+      this.form.containUserList = []
+      this.selectedValue = null
+    },
+    [CRUD.HOOK.afterEditError]() {
+      this.form.containUserList = []
+      this.selectedValue = null
+    },
+    [CRUD.HOOK.afterEditCancel]() {
+      this.form.containUserList = []
+      this.selectedValue = null
+    },
+    [CRUD.HOOK.afterAddCancel]() {
+      this.form.containUserList = []
+      this.selectedValue = null
+    },
+    [CRUD.HOOK.afterAddError]() {
+      this.form.containUserList = []
+      this.selectedValue = null
+    },
+    getContainUserList(e) {
+      this.form.containUserList = e
+    },
+    getTags() {
+      crudTask.getTags().then(res => {
+        this.tags = res
+      })
+    },
     // 钩子:在获取表格数据之前执行,false 则代表不获取数据
     [CRUD.HOOK.beforeRefresh]() {
-      if (!this.crud.query.projectId) {
-        return false
-      }
+      // if (!this.crud.query.projectId) {
+      //   return false
+      // }
       // 用户角色级别数组
       const userRolesLevel = this.$store.state.user.user.roles.map(({ level }) => level)
       // 用户最大角色级别
       this.userRolesLevelMin = Math.min(...userRolesLevel)
+
       return true
     },
     [CRUD.HOOK.beforeSubmit]() {
-      if (this.form.parent.id === null || this.form.parent.id === '') {
-        this.form.parent = null
+      if (!this.form.taskStatus) {
+        this.form.taskStatus = 'task_status_not_started'
+      }
+      if (this.inputValue !== null) {
+        this.form.tagList.push(this.inputValue)
       }
       return true
     },
-    queryByProjectId(projectId) {
-      this.crud.resetQuery(false)
-      this.crud.query.projectId = projectId
-      this.crud.toQuery()
+    [CRUD.HOOK.afterSubmit]() {
+      this.inputValue = null
+      this.getTags()
     },
-    getTags() {
-      crudTask.getTags().then(res => {
-        // 项目列表
-        this.tags = res
+    // 新增之前
+    [CRUD.HOOK.beforeToAdd]() {
+      this.form.taskStatus = null
+      this.isShow = false
+    },
+    // 钩子:新建 - 之前
+    [CRUD.HOOK.beforeToCU]() {
+      this.form.projectId = this.crud.query.projectId
+      // 父级任务列表
+      this.pidTasks = []
+      crudTask.getAll({ projectId: this.form.projectId }).then(res => {
+        // 父级任务列表
+        this.pidTasks = res
       })
     },
+    // 编辑之前
+    [CRUD.HOOK.beforeToEdit]() {
+      this.isShow = true
+      crudUser.getUserPidDept(this.form.containUserList).then(res => {
+        this.selectedValue = res
+      })
+    },
+    doTaskCompleted() {
+      const selectData = this.$refs.table.selection
+      var changesId = []
+      for (var i = 0; i < selectData.length; i++) {
+        changesId.push(selectData[i].id)
+      }
+      crudTask.changeStatus(changesId).then(res => {
+        this.crud.toQuery()
+        this.$notify.success({
+          title: '任务关闭成功'
+        })
+      })
+    },
+    // 日期点击
+    handleDateClick(selectInfo) {
+    },
+    handleEventClick(info) {
+      if (info.event._def.extendedProps.type === 1) {
+        this.$router.push({
+          path: '/attendance/attendance',
+          query: { date: info.event._def.extendedProps.date1 }
+        })
+      } else {
+        this.$router.push({ path: '/task/taskDaliy', query: { date: info.event._def.extendedProps.date1 }})
+      }
+    },
+    // 箭头点击事件
+    monthClick(type) {
+      if (this.crud.selections[0].id !== null) {
+        crudTask.getTaskValidRange(this.crud.selections[0].id).then(res => {
+          this.calendarOptions.validRange = res
+
+          const calendarApi = this.$refs['fullCalendar'].getApi()
+          if (type === 'prev') {
+            calendarApi.prev()
+          } else if (type === 'next') {
+            calendarApi.next()
+          } else {
+            calendarApi.gotoDate(res.start)
+          }
+          this.getTaskCalendarInfo(moment(calendarApi.view.currentStart).format('YYYY-MM-DD').toString())
+          this.calendarLoading = false
+        })
+      }
+    },
+    // 获取任务信息
+    getTaskCalendarInfo(month) {
+      crudTask.getTaskCalendarInfo(month, this.crud.selections[0].id).then(res => {
+        this.calendarOptions.events = res.map(function(obj) {
+          return obj
+        })
+        setTimeout(() => {
+        }, 1000)
+      })
+    },
+    queryByProjectId(project) {
+      // this.crud.resetQuery(false)
+      if (project) {
+        this.crud.query.projectId = project.id
+        this.crud.query.flag = project.flag
+      } else {
+        this.crud.query.projectId = undefined
+        this.crud.query.flag = undefined
+      }
+      this.query.taskStatuses = ['task_status_not_started', 'task_status_in_hand', 'task_status_test', 'task_status_stop', 'task_status_unrecognized']
+      this.crud.toQuery()
+      this.getProjectTotal()
+    },
+    getTaskUser(even) {
+      this.containUserList = []
+      var containList = even.containUserList
+      for (var i = 0; i < this.users.length; i++) {
+        for (var j = 0; j < containList.length; j++) {
+          if (containList[j] === this.users[i].id) {
+            this.containUserList.push(this.users[i])
+          }
+        }
+      }
+    },
     handleClose(id) {
-      this.form.tags.splice(id, 1)
+      this.form.tagList.splice(id, 1)
     },
     showInput() {
       this.inputVisible = true
@@ -375,11 +874,11 @@
     },
     handleInputConfirm() {
       const inputValue = this.inputValue
-      if (inputValue) {
-        this.form.tags.push(inputValue)
+      if (inputValue !== '' && inputValue !== null && inputValue !== ' ') {
+        this.form.tagList.push(inputValue)
       }
       this.inputVisible = false
-      this.inputValue = ''
+      this.inputValue = null
     },
     handleSelect(item) {
       this.inputValue = item.value
@@ -401,11 +900,22 @@
         // 用户列表
         this.users = res
       })
+
+      crudUser.getUserDept().then(res => {
+        this.options = res
+      })
+    },
+    getUserNameById(userId) {
+      const userList = this.users.filter(user => user.id === userId)
+      return userList.length === 0 ? '' : userList[0].nickName
     },
     // 获取项目
     getProject() {
       // 获取项目
-      crudProject.getRelevant().then(res => {
+      crudProject.getRelevant({
+        'projectStatusIn': ['project_status_not_started', 'project_status_under_way'],
+        'approve_status': 'approve_status_acknowledged'
+      }).then(res => {
         // 项目列表
         this.projects = res
       })
@@ -414,14 +924,28 @@
     load(tree, treeNode, resolve) {
       resolve(tree.children)
     },
-    // 钩子:新建 - 之前
-    [CRUD.HOOK.beforeToCU]() {
-      this.form.projectId = this.crud.query.projectId
-      // 父级任务列表
-      this.pidTasks = []
-      crudTask.getAll({ projectId: this.form.projectId }).then(res => {
-        // 父级任务列表
-        this.pidTasks = res
+    getProjectTotal() {
+      this.curProject.totalTask = 0
+      this.curProject.totalHours = 0.0
+      this.curProject.completeTask = 0
+      this.curProject.completeHours = 0.0
+      crudTask.getProjectTotal({ 'projectId': this.crud.query.projectId }).then(res => {
+        let totalTask = 0
+        let totalHours = 0.0
+        let completeTask = 0
+        let completeHours = 0.0
+        res.forEach(item => {
+          totalTask += item.count
+          totalHours += item.planHours
+          if (item._id === 'task_status_completed') {
+            completeTask += item.count
+            completeHours += item.planHours
+          }
+        })
+        this.curProject.totalTask = totalTask
+        this.curProject.totalHours = totalHours
+        this.curProject.completeTask = completeTask
+        this.curProject.completeHours = completeHours
       })
     },
     // 项目变更
@@ -449,6 +973,119 @@
         results = await crudTask.getNames({ projectId: this.crud.query.projectId, name: queryString })
         cb(results)
       }
+    },
+    draw() {
+      this.dialogVisible = true
+    },
+
+    // 开启任务迁移
+    toMigration() {
+      const that = this
+      that.$set(that.migrationParams, 'visible', true)
+    },
+
+    // 关闭任务迁移
+    closeMigration() {
+      const that = this
+
+      that.$refs.migrationForm.clearValidate()
+      that.$set(that.migrationParams, 'loading', false)
+      that.$set(that.migrationParams, 'visible', false)
+      that.$set(that.migrationParams, 'form', {
+        sourceProjectId: null,
+        sourceTaskId: null,
+        sourceTaskUserId: [],
+        sourceLevel: 'taskUser',
+        targetProjectId: null,
+        targetTaskId: null,
+        targetLevel: 'task'
+      })
+      that.$set(that.migrationParams, 'sourceTaskList', [])
+      that.$set(that.migrationParams, 'targetTaskList', [])
+      that.$set(that.migrationParams, 'sourceTaskUserList', [])
+    },
+
+    // 执行任务迁移
+    doMigration() {
+      const that = this
+      that.$refs.migrationForm.validate((valid) => {
+        if (!valid) {
+          return
+        }
+
+        // 构建访问参数
+        that.$set(that.migrationParams, 'loading', true)
+        const data = {}
+        if (that.migrationParams.form.sourceLevel === 'task' && that.migrationParams.form.targetLevel === 'project') {
+          that.$set(data, 'sourceTaskId', that.migrationParams.form.sourceTaskId)
+          that.$set(data, 'targetProjectId', that.migrationParams.form.targetProjectId)
+        }
+        if (that.migrationParams.form.sourceLevel === 'taskUser' && that.migrationParams.form.targetLevel === 'task') {
+          that.$set(data, 'sourceTaskUserId', that.migrationParams.form.sourceTaskUserId)
+          that.$set(data, 'targetTaskId', that.migrationParams.form.targetTaskId)
+        }
+
+        // 执行迁移API
+        that.crud.crudMethod.migration(data).then(() => {
+          that.$message({ type: 'success', message: '迁移成功' })
+          that.closeMigration()
+        }).catch(() => {
+          that.$set(that.migrationParams, 'loading', false)
+        })
+      })
+    },
+
+    // 获取来源任务
+    sourceProjectChange(projectId) {
+      const that = this
+      that.$set(that.migrationParams, 'sourceTaskList', [])
+      that.$set(that.migrationParams.form, 'sourceTaskId', null)
+      that.getSecondTask(that.migrationParams, 'sourceTaskList', projectId)
+    },
+
+    // 获取目标任务
+    targetProjectChange(projectId) {
+      const that = this
+      that.$set(that.migrationParams, 'targetTaskList', [])
+      that.$set(that.migrationParams.form, 'targetTaskId', null)
+      that.getSecondTask(that.migrationParams, 'targetTaskList', projectId)
+    },
+
+    // 获取二级任务
+    getSecondTask(target, key, projectId) {
+      const that = this
+      if (projectId) {
+        const params = { isTop: true, projectId: projectId, sort: 'id,desc' }
+        crudTask.ChildrenTaskAnyParent(params).then(res => {
+          that.$set(target, key, res)
+        }).catch(() => {
+          that.$set(target, key, [])
+        })
+      } else {
+        that.$set(target, key, [])
+      }
+    },
+
+    // 获取来源任务分配
+    sourceTaskChange(taskId) {
+      const that = this
+      that.$set(that.migrationParams, 'sourceTaskUserList', [])
+      that.$set(that.migrationParams.form, 'sourceTaskUserId', [])
+      crudTaskUser.getAllSimple({ taskId }).then(res => {
+        that.$set(that.migrationParams, 'sourceTaskUserList', res)
+      }).catch(() => {
+        that.$set(that.migrationParams, 'sourceTaskUserList', [])
+      })
+    },
+
+    // 迁移层级变更
+    sourceLevelChange(level) {
+      const that = this
+      if (level === 'task') {
+        that.$set(that.migrationParams.form, 'targetLevel', 'project')
+      } else if (level === 'taskUser') {
+        that.$set(that.migrationParams.form, 'targetLevel', 'task')
+      }
     }
   }
 }
@@ -470,4 +1107,27 @@
     margin-left: 10px;
     vertical-align: bottom;
   }
+
+  .block{
+    display: inline-block;
+    vertical-align: middle;
+    margin: 0 3px 10px 0;
+  }
+  .block input {
+    height: 30.5px;
+    line-height: 30.5px;
+  }
+
+  .part-form-box {
+    border: 1px solid #dcdfe6;
+    border-radius: 10px;
+  }
+
+  .part-form-title {
+    font-size: 16px;
+    font-weight: 700;
+    color: #606266;
+    line-height: 52px;
+    text-align: center;
+  }
 </style>

--
Gitblit v1.9.3