yaozc
2024-05-30 86b0362eaf4c320dc6a54fc12ce80b0bf7890a85
eladmin-web-master/src/views/task/task/index.vue
@@ -4,7 +4,7 @@
    <div class="head-container">
      <div>
        <!-- 搜索 -->
        <el-select v-model="curProject" value-key="id" 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"
@@ -59,8 +59,10 @@
        </el-select>
        <div class="block">
          <el-cascader
            v-model="query.userIds"
            v-model="queryUser"
            :filterable="true"
            :options="options"
            :props="props"
            clearable
            placeholder="任务负责人"
            :show-all-levels="false"
@@ -90,6 +92,14 @@
          :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>
      </crudOperation>
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
@@ -148,7 +158,7 @@
              />
            </el-select>
          </el-form-item>
          <el-form-item label="任务状态" v-if="isShow">
          <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"
@@ -168,8 +178,7 @@
            <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-input>
            <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;">
@@ -204,7 +213,6 @@
            <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"
                v-show="form.containUserList != undefined && form.containUserList.some(animal => animal === item.id)"
                :key="item.id"
                :label="item.nickName"
                :value="item.id"
@@ -224,6 +232,7 @@
      </el-dialog>
      <!--表格渲染-->
      <el-table
        ref="table"
        v-loading="crud.loading"
        :data="crud.data"
        size="small"
@@ -234,6 +243,7 @@
        @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">
@@ -245,6 +255,12 @@
        <el-table-column :show-overflow-tooltip="true" prop="taskStatus" label="任务状态" width="80">
          <template slot-scope="scope">
            <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">
@@ -259,7 +275,7 @@
            </template>
          </template>
        </el-table-column>
        <el-table-column :show-overflow-tooltip="true" prop="tagList" label="任务负责人" width="240">
        <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>
@@ -502,6 +518,11 @@
      isShow: false
    }
  },
  computed: {
    filteredDict() {
      return this.dict[this.taskStatus]
    }
  },
  watch: {
    'selectedValue': function(newVal) {
      this.form.containUserList = []
@@ -527,16 +548,19 @@
      }
    },
    'queryUser': function(newVal) {
      // this.query.userId = newVal[newVal.length - 1]
      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() {
    this.crud.optShow.reset = false
  },
  computed: {
    filteredDict() {
      return this.dict[this.taskStatus].filter(item => item.value !== 'task_status_unrecognized');
    }
  },
  mounted() {
    // 获取项目
@@ -576,20 +600,15 @@
    },
    // 钩子:在获取表格数据之前执行,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.beforeToEdit]() {
      crudUser.getUserPidDept(this.form.containUserList).then(res => {
        this.selectedValue = res
      })
    },
    [CRUD.HOOK.beforeSubmit]() {
      if (!this.form.taskStatus) {
@@ -622,10 +641,25 @@
    // 编辑之前
    [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) {
      console.log('handleDateClick.info:', selectInfo)
    },
    handleEventClick(info) {
      if (info.event._def.extendedProps.type === 1) {
@@ -663,14 +697,19 @@
          return obj
        })
        setTimeout(() => {
          console.log(this.calendarOptions.events)
        }, 1000)
      })
    },
    queryByProjectId(project) {
      this.crud.resetQuery(false)
      this.crud.query.projectId = project.id
      this.crud.query.flag = project.flag
      // 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()
    },
@@ -696,7 +735,6 @@
    },
    handleInputConfirm() {
      const inputValue = this.inputValue
      console.log(inputValue)
      if (inputValue !== '' && inputValue !== null && inputValue !== ' ') {
        this.form.tagList.push(inputValue)
      }