BAOLH
2026-11-10 4d730af0447c686133130d0116a0fa3dd82c2dca
eladmin-web-master/src/views/task/taskUser/index.vue
@@ -248,6 +248,15 @@
                :value="item.id"
              />
            </el-select>
            <el-input
              v-model="query.name"
              clearable
              placeholder="请输入任务名称"
              prefix-icon="el-icon-search"
              style="width: 185px;"
              class="filter-item"
              @keyup.enter.native="crud.toQuery"
            />
            <el-select
              v-model="query.taskStatus"
              filterable
@@ -317,9 +326,19 @@
              size="mini"
              type="primary"
              icon="el-icon-tickets"
              style="margin-right: 60px;"
              style="margin-right: 6px;"
              @click="adventTesk()"
            >临期任务</el-button>
            <el-button
              slot="right"
              class="filter-item"
              size="mini"
              type="primary"
              icon="el-icon-plus"
              :disabled="crud.selections.length !== 1"
              style="margin-right: 6px;"
              @click="toReviewTask()"
            >新建复核</el-button>
          </crudOperation>
          <div>
            <span>
@@ -390,7 +409,10 @@
                style="width: 340px;"
              />
            </el-form-item>
            <el-form-item label="任务名称">
            <el-form-item v-show="form.rid !== null" label="复核对象" prop="rname">
              <el-input v-model="form.rname" disabled style="width: 340px;" />
            </el-form-item>
            <el-form-item label="任务名称" prop="name">
              <el-input v-model="form.name" style="width: 340px;" />
            </el-form-item>
            <el-form-item label="任务开始时间" prop="taskStartDate">
@@ -432,14 +454,19 @@
                >小时</template>
              </el-input>
            </el-form-item>
            <el-form-item label="所属员工" prop="userId">
            <el-form-item v-if="crud.status.add === 1" label="选择类型" prop="selectType">
              <el-radio-group v-model="form.selectType" style="width: 340px;" @change="handleTypeChange">
                <el-radio-button label="single">单选</el-radio-button>
                <el-radio-button label="multiple">多选</el-radio-button>
              </el-radio-group>
            </el-form-item>
            <el-form-item v-show="form.selectType === 'single'" label="所属员工" prop="userId">
              <el-select
                v-model="form.userId"
                filterable
                clearable
                placeholder="请选择"
                style="width: 340px;"
                :disabled="form.start"
                @change="withUser(form)"
              >
                <el-option
@@ -458,6 +485,33 @@
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item v-show="form.selectType === 'multiple'" label="所属员工" prop="userIds">
              <el-select
                v-model="form.userIds"
                filterable
                clearable
                multiple
                placeholder="请选择"
                style="width: 340px;"
                @change="withUser(form)"
              >
                <el-option
                  v-for="item in users"
                  :key="item.id"
                  :label="item.nickName"
                  :value="item.id"
                  :disabled="
                    !item.enabled || form.divideUserIds.includes(item.id)
                  "
                >
                  <span style="float: left">{{ item.nickName }}</span>
                  <span style="float: right; color: #8492a6; font-size: 13px">{{
                    item.levelName
                  }}</span>
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="绩效工时" prop="performanceHours">
              <el-input
                v-model="form.performanceHours"
@@ -467,6 +521,11 @@
                <template
                  slot="append"
                >小时</template>
              </el-input>
            </el-form-item>
            <el-form-item v-show="form.rid !== null" label="驳回数量" prop="rejectCount">
              <el-input v-model="form.rejectCount" style="width: 340px;">
                <template slot="append">个</template>
              </el-input>
            </el-form-item>
            <el-form-item label="UID" prop="uid">
@@ -645,7 +704,7 @@
            <el-button type="primary" @click="doTaskCompleted">确 定</el-button>
          </span>
        </el-dialog>
        <!--表单组件-->
        <!--导入任务分配信息-->
        <el-dialog
          :close-on-click-modal="false"
          :before-close="closeGenerate"
@@ -690,20 +749,16 @@
import crudTaskUser from '@/api/task/taskUser'
import crudTask from '@/api/task/task'
import crudUser from '@/api/system/user'
import crudUserInsurance from '@/api/treatment/userInsurance'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import DateRangePicker from '@/components/DateRangePicker'
import Treeselect from '@riophae/vue-treeselect'
import { mapGetters } from 'vuex'
import constant from '@/utils/constant'
import UploadExcelComponent from '@/components/UploadExcel/index.vue'
import UploadExcelComponentTwo from '@/components/UploadExcel/excelIndex.vue'
import { transformData, formatExcelDate } from '@/utils/trans'
import { parseTime, downloadFile } from '@/utils/index'
import { downloadFile } from '@/utils/index'
const defaultForm = {
  id: null,
  name: null,
@@ -719,19 +774,22 @@
  remarks: null,
  divideUserIds: [],
  is_ok: null,
  uid: null
  uid: null,
  rid: null,
  rname: null,
  rejectCount: null,
  // 多选用户id
  userIds: [],
  // 用于新增用户时单选或多选
  selectType: 'single'
}
export default {
  name: 'TaskUser',
  // eslint-disable-next-line vue/no-unused-components
  components: {
    Treeselect,
    crudOperation,
    rrOperation,
    udOperation,
    pagination,
    DateRangePicker,
    UploadExcelComponent,
    UploadExcelComponentTwo
  },
  cruds() {
@@ -780,6 +838,9 @@
        generate: ['admin', 'taskUser:add']
      },
      rules: {
        name: [
          { required: true, message: '任务名称不能为空', trigger: 'change' }
        ],
        taskStartDate: [
          { required: true, message: '任务开始时间不能为空', trigger: 'change' }
        ],
@@ -793,7 +854,8 @@
      queryTypeOptions: [
        { key: 'userId', display_name: '所属员工' },
        { key: 'taskStatus', display_name: '任务状态' },
        { key: 'createTime', display_name: '创建时间' }
        { key: 'createTime', display_name: '创建时间' },
        { key: 'name', display_name: '名称' }
      ],
      // 字典:任务状态
      taskStatus: constant.TASK_STATUS,
@@ -852,7 +914,12 @@
      slong: false,
      taskSo: constant.TASK_STATUS_UNRECOGNIZED,
      taskSt: constant.TASK_STATUS_COMPLETED,
      taskStatusOne: ''
      taskStatusOne: '',
      // 复核任务参数
      reviewTaskParams: {
        rid: null,
        rname: null
      }
    }
  },
  computed: {
@@ -878,15 +945,24 @@
      this.formTasks = []
      this.form.name = null
      this.form.performanceHours = null
      this.form.start = false
    },
    // 新建之前
    [CRUD.HOOK.beforeToAdd]() {
      const that = this
      if (that.reviewTaskParams.rid !== null) {
        that.$set(that.form, 'rid', that.reviewTaskParams.rid)
        that.$set(that.form, 'rname', that.reviewTaskParams.rname)
        that.$set(that.form, 'name', that.reviewTaskParams.rname + '(复核)')
      }
      return true
    },
    // 编辑之前
    [CRUD.HOOK.beforeToEdit]() {
      if (this.form.taskStatus == this.taskSo) {
      if (this.form.taskStatus === this.taskSo) {
        this.form.is_ok = false
        this.taskStatusOne = '未承认'
      }
      if (this.form.taskStatus == this.taskSt) {
      if (this.form.taskStatus === this.taskSt) {
        this.form.is_ok = true
        this.taskStatusOne = '已完成'
      }
@@ -895,25 +971,35 @@
      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.beforeAddCancel]() {
      const that = this
      that.$set(that.reviewTaskParams, 'rid', null)
      that.$set(that.reviewTaskParams, 'rname', null)
      return true
    },
    [CRUD.HOOK.afterAddCancel]() {
      this.formTasks = []
      this.form.name = null
      this.form.performanceHours = null
      this.form.start = false
    },
    // 提交之后
    [CRUD.HOOK.afterSubmit]() {
      const that = this
      that.$set(that.reviewTaskParams, 'rid', null)
      that.$set(that.reviewTaskParams, 'rname', null)
      return true
    },
    [CRUD.HOOK.afterAddError]() {
      this.formTasks = []
      this.form.name = null
      this.form.performanceHours = null
      this.form.start = false
    },
    [CRUD.HOOK.beforeToCU]() {
      this.form.task.id = this.query.taskId
@@ -949,10 +1035,10 @@
    handleChange(value) {
      if (value) {
        this.taskStatusOne = '已完成'
        this.form.taskStatus == this.taskSt
        this.form.taskStatus === this.taskSt
      } else {
        this.taskStatusOne = '未承认'
        this.form.taskStatus == this.taskSo
        this.form.taskStatus === this.taskSo
      }
    },
    checkStartTime(time) {
@@ -1052,7 +1138,7 @@
          this.slong = false
          this.crud.notify('生成成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
        })
        .catch(error => {
        .catch(() => {
          this.slong = false
          this.crud.notify('生成失败', CRUD.NOTIFICATION_TYPE.ERROR)
        })
@@ -1118,83 +1204,131 @@
      this.generateForm = results
      this.generateForm = results.map(item => {
        const {
          所属员工ID: _,
          任务状态ID: ___,
          优先度ID: __,
          隔绝列1: ____,
          隔绝列2: _____,
          隔绝列3: ______,
          隔绝列4: _______,
          隔绝列5: ________,
          隔绝列6: _________,
          隔绝列7: __________,
          隔绝列8: ____________,
          // eslint-disable-next-line no-unused-vars
          所属员工ID,
          // eslint-disable-next-line no-unused-vars
          任务状态ID,
          // eslint-disable-next-line no-unused-vars
          优先度ID,
          // eslint-disable-next-line no-unused-vars
          隔绝列1,
          // eslint-disable-next-line no-unused-vars
          隔绝列2,
          // eslint-disable-next-line no-unused-vars
          隔绝列3,
          // eslint-disable-next-line no-unused-vars
          隔绝列4,
          // eslint-disable-next-line no-unused-vars
          隔绝列5,
          // eslint-disable-next-line no-unused-vars
          隔绝列6,
          // eslint-disable-next-line no-unused-vars
          隔绝列7,
          // eslint-disable-next-line no-unused-vars
          隔绝列8,
          ...newItem
        } = item
        if ('任务开始时间' in newItem) {
        // 判断日期格式是否正确,如果不正确,则提示错误信息,并覆盖数据为false
        if ('任务开始时间' in newItem && Number.isFinite(newItem['任务开始时间'])) {
          newItem['任务开始时间'] = formatExcelDate(newItem['任务开始时间'])
        } else {
          this.$message.warning('第' + (this.generateForm.indexOf(item) + 1) + '项的任务开始时间格式不正确')
          return false
        }
        if ('任务结束时间' in newItem) {
        if ('任务结束时间' in newItem && Number.isFinite(newItem['任务结束时间'])) {
          newItem['任务结束时间'] = formatExcelDate(newItem['任务结束时间'])
        } else {
          this.$message.warning('第' + (this.generateForm.indexOf(item) + 1) + '项的任务结束时间格式不正确')
          return false
        }
        return newItem
      })
      // 表头数据转换
      this.generateFormTwo = transformData(results)
      for (let i = 0; i < this.generateFormTwo.length; i++) {
        const item = this.generateFormTwo[i]
        if (!item.name) {
          this.$message({
            message: `第${i + 1}项的名称为空`,
            type: 'warning'
          })
          this.generateFormTwo = []
          this.generateForm = []
          return false
      if (this.generateForm.includes(false)) {
        // 存在异常数据,清空表单数据
        this.generateForm = []
        return false
      } else {
        // 表头数据转换
        this.generateFormTwo = transformData(results)
        for (let i = 0; i < this.generateFormTwo.length; i++) {
          const item = this.generateFormTwo[i]
          if (!item.name) {
            this.$message({
              message: `第${i + 1}项的名称为空`,
              type: 'warning'
            })
            this.generateFormTwo = []
            this.generateForm = []
            return false
          }
          if (!item.taskStartDate) {
            this.$message({
              message: `第${i + 1}项的任务开始时间为空`,
              type: 'warning'
            })
            this.generateFormTwo = []
            this.generateForm = []
            return false
          }
          if (!item.taskEndDate) {
            this.$message({
              message: `第${i + 1}项的任务结束时间为空`,
              type: 'warning'
            })
            this.generateFormTwo = []
            this.generateForm = []
            return false
          }
          if (!item.taskHours) {
            this.$message({
              message: `第${i + 1}项的任务工时为空`,
              type: 'warning'
            })
            this.generateFormTwo = []
            this.generateForm = []
            return false
          }
          if (!item.taskStatus) {
            this.$message({
              message: `第${i + 1}项的任务状态为空`,
              type: 'warning'
            })
            this.generateFormTwo = []
            this.generateForm = []
            return false
          }
          // 状态转换
          if (item.taskStatus === '未开始') {
            item.taskStatus = constant.TASK_STATUS_NOT_STARTED
          } else if (item.taskStatus === '进行中') {
            item.taskStatus = constant.TASK_STATUS_IN_HAND
          } else if (item.taskStatus === '待测试') {
            item.taskStatus = constant.TASK_STATUS_TEST
          } else if (item.taskStatus === '已暂停') {
            item.taskStatus = constant.TASK_STATUS_STOP
          } else if (item.taskStatus === '未承认') {
            item.taskStatus = constant.TASK_STATUS_UNRECOGNIZED
          } else if (item.taskStatus === '已完成') {
            item.taskStatus = constant.TASK_STATUS_COMPLETED
          }
          if (item.taskStartDate > item.taskEndDate) {
            this.$message({
              message: `第${i + 1}项的任务开始时间大于任务结束时间`,
              type: 'warning'
            })
            this.generateFormTwo = []
            this.generateForm = []
            return false
          }
        }
        if (!item.taskStartDate) {
          this.$message({
            message: `第${i + 1}项的任务开始时间为空`,
            type: 'warning'
          })
          this.generateFormTwo = []
          this.generateForm = []
          return false
        }
        if (!item.taskEndDate) {
          this.$message({
            message: `第${i + 1}项的任务结束时间为空`,
            type: 'warning'
          })
          this.generateFormTwo = []
          this.generateForm = []
          return false
        }
        if (!item.taskHours) {
          this.$message({
            message: `第${i + 1}项的任务工时为空`,
            type: 'warning'
          })
          this.generateFormTwo = []
          this.generateForm = []
          return false
        }
        if (!item.taskStatus) {
          this.$message({
            message: `第${i + 1}项的任务状态为空`,
            type: 'warning'
          })
          this.generateFormTwo = []
          this.generateForm = []
          return false
        }
        this.tableHeader = header.filter(
          item =>
            item !== '所属员工ID' && item !== '任务状态ID' && item !== '优先度ID' && item !== '隔绝列1' &&
            item !== '隔绝列2' && item !== '隔绝列3' && item !== '隔绝列4' && item !== '隔绝列5' && item !== '隔绝列6' &&
            item !== '隔绝列7' && item !== '隔绝列8'
        )
      }
      this.tableHeader = header.filter(
        item =>
          item !== '所属员工ID' && item !== '任务状态ID' && item !== '优先度ID' && item !== '隔绝列1' &&
          item !== '隔绝列2' && item !== '隔绝列3' && item !== '隔绝列4' && item !== '隔绝列5' && item !== '隔绝列6' &&
          item !== '隔绝列7' && item !== '隔绝列8'
      )
    },
    // 生成表单打开
    openGenerate() {
@@ -1231,7 +1365,7 @@
          this.crud.toQuery()
          this.crud.notify('导入成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
        })
        .catch(err => {
        .catch(() => {
          this.uploading = false
          // 生成表单加载
          this.generateLoading = false
@@ -1360,6 +1494,23 @@
    },
    formatTaskProgress(percentage) {
      return percentage === 100 ? '实际消耗已超出计划时长' : `${percentage}%`
    },
    // 开启新建复核
    toReviewTask() {
      const that = this
      if (that.crud.selections[0].rid === undefined || that.crud.selections[0].rid === null) {
        that.$set(that.reviewTaskParams, 'rid', that.crud.selections[0].id)
        that.$set(that.reviewTaskParams, 'rname', that.crud.selections[0].name)
        that.crud.toAdd()
      } else {
        that.$message.warning('复核任务下不可创建复核任务')
      }
    },
    // 切换类型时清空之前的选择
    handleTypeChange() {
      const that = this
      that.$set(that.form, 'userId', null)
      that.$set(that.form, 'userIds', [])
    }
  }
}