weicd
2023-02-20 6754df3c4faf22d426d45d1c4995c865cab686de
eladmin-web-master/src/views/task/task/index.vue
@@ -29,6 +29,14 @@
            :value="item.value"
          />
        </el-select>
        <el-select v-model="query.taskStatus" filterable clearable placeholder="任务状态" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery">
          <el-option
            v-for="item in dict[taskStatus]"
            :key="item.id"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
        <rrOperation :crud="crud" />
      </div>
      <!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
@@ -45,6 +53,32 @@
        >
          分配
        </el-button>
        <el-button
          slot="right"
          v-permission="permission.seeDivide"
          class="filter-item"
          size="mini"
          type="primary"
          icon="el-icon-share"
          :disabled="crud.selections.length !== 1"
          style="margin-left: 4px !important;"
          @click="toSeeDivide(crud.selections[0])"
        >
          查看分配
        </el-button>
        <el-button
          slot="right"
          v-permission="permission.seeDaliy"
          class="filter-item"
          size="mini"
          type="primary"
          icon="el-icon-share"
          :disabled="crud.selections.length !== 1"
          style="margin-left: 4px !important;"
          @click="toSeeDaliy(crud.selections[0])"
        >
          查看日报
        </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">
@@ -59,6 +93,7 @@
                :key="item.id"
                :label="item.name"
                :value="item.id"
                :disabled="item.approveStatus == approveStatusUnrecognized"
              />
            </el-select>
          </el-form-item>
@@ -97,10 +132,10 @@
            <el-input v-model="form.description" :rows="3" type="textarea" style="width: 340px;" />
          </el-form-item>
          <el-form-item label="计划开始时间">
            <el-date-picker v-model="form.planStartTime" type="datetime" :picker-options="planStartTimePickerOptions" 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="planStartTimePickerOptions" style="width: 340px;" />
          </el-form-item>
          <el-form-item label="计划结束时间">
            <el-date-picker v-model="form.planEndTime" type="datetime" :picker-options="planEndTimePickerOptions" 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="planEndTimePickerOptions" style="width: 340px;" />
          </el-form-item>
          <el-form-item label="计划工时" prop="planHours">
            <el-input v-model="form.planHours" style="width: 340px;">
@@ -114,6 +149,16 @@
            <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="taskStatus">
            <el-select v-model="form.taskStatus" filterable placeholder="请选择" style="width: 340px;">
              <el-option
                v-for="item in dict[taskStatus]"
                :key="item.id"
                :label="item.label"
                :value="item.value"
@@ -151,21 +196,26 @@
        <el-table-column :show-overflow-tooltip="true" prop="description" label="描述" width="140" />
        <el-table-column :show-overflow-tooltip="true" prop="planStartTime" label="计划开始时间" width="140" />
        <el-table-column :show-overflow-tooltip="true" prop="planEndTime" label="计划结束时间" width="140" />
        <el-table-column :show-overflow-tooltip="true" label="已完成 / 已分配 / 计划工时" width="120">
        <el-table-column :show-overflow-tooltip="true" label="已完成 / 已分配 / 计划工时" width="160">
          <template slot-scope="scope">
            {{ scope.row.completedHours }} / {{ scope.row.divideHours }} / {{ scope.row.planHours }}
            {{ crud.toMaxTwoDecimalPlaces(scope.row.completedHours) }} / {{ scope.row.divideHours }} / {{ scope.row.planHours }}
          </template>
        </el-table-column>
        <el-table-column :show-overflow-tooltip="true" label="已完成 / 已分配 / 计划工作量" width="130">
        <el-table-column :show-overflow-tooltip="true" label="已完成 / 已分配 / 计划工作量" width="180">
          <template slot-scope="scope">
            <span>
              {{ scope.row.completedWorkload }} / {{ scope.row.divideWorkload }} / {{ scope.row.planWorkload == null || scope.row.planWorkload == '' ? 0 : scope.row.planWorkload }}
              {{ crud.toMaxTwoDecimalPlaces(scope.row.completedWorkload) }} / {{ scope.row.divideWorkload }} / {{ scope.row.planWorkload == null || scope.row.planWorkload == '' ? 0 : scope.row.planWorkload }}
            </span>
          </template>
        </el-table-column>
        <el-table-column :show-overflow-tooltip="true" prop="planWorkloadUnit" label="计划工作量单位" width="110">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.planWorkloadUnit != null && scope.row.planWorkloadUnit != ''">{{ dict.label[standardWorkloadUnit][scope.row.planWorkloadUnit] }}</el-tag>
          </template>
        </el-table-column>
        <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" prop="remarks" label="备注" width="140" />
@@ -199,7 +249,7 @@
          <el-form-item label="任务名称" prop="taskName">
            {{ divideForm.taskName }}
          </el-form-item>
          <el-form-item label="分配用户" prop="userIds">
          <el-form-item label="分配员工" prop="userIds">
            <el-select v-model="divideForm.userIds" filterable clearable multiple placeholder="请选择" style="width: 340px;">
              <el-option
                v-for="item in users"
@@ -207,14 +257,17 @@
                :label="item.nickName"
                :value="item.id"
                :disabled="!item.enabled || divideForm.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="taskStartDate">
            <el-date-picker v-model="divideForm.taskStartDate" type="datetime" :picker-options="taskStartDatePickerOptions" style="width: 340px;" />
            <el-date-picker v-model="divideForm.taskStartDate" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" :default-time="$store.state.user.user.sysRostering.workStartTime + ':00'" :picker-options="taskStartDatePickerOptions" style="width: 340px;" />
          </el-form-item>
          <el-form-item label="任务结束时间" prop="taskEndDate">
            <el-date-picker v-model="divideForm.taskEndDate" type="datetime" :picker-options="taskEndDatePickerOptions" style="width: 340px;" />
            <el-date-picker v-model="divideForm.taskEndDate" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" :default-time="$store.state.user.user.sysRostering.workEndTime + ':00'" :picker-options="taskEndDatePickerOptions" style="width: 340px;" />
          </el-form-item>
          <el-form-item label="任务工时" prop="taskHours">
            <el-input v-model="divideForm.taskHours" style="width: 340px;">
@@ -250,23 +303,23 @@
import crudProject from '@/api/project/project'
import crudUser from '@/api/system/user'
const defaultForm = { id: null, name: null, projectId: null, pid: null, priority: 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, name: null, projectId: null, pid: null, priority: null, taskClassification: null, description: null, planStartTime: null, planEndTime: null, planHours: null, planWorkload: null, planWorkloadUnit: null, taskStatus: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null }
export default {
  name: 'Task',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  dicts: [constant.PRIORITY, constant.TAST_CLASSIFICATION, constant.STANDARD_WORKLOAD_UNIT],
  dicts: [constant.PRIORITY, constant.TAST_CLASSIFICATION, constant.STANDARD_WORKLOAD_UNIT, constant.TASK_STATUS],
  cruds() {
    return CRUD({ title: '任务', url: 'api/task', idField: 'id', sort: 'id,desc', crudMethod: { ...crudTask }})
  },
  data() {
    // 指针重指向
    const _this = this
    // 时长(千内)验证
    // 时长(万内)验证
    var durationValidate = (rule, value, callback) => {
      const reg = /^([0-9]|[1-9]\d{1,2})(\.\d{1,2})?$|1000$/
      const reg = /^([0-9]|[1-9]\d{1,3})(\.\d{1,2})?$/
      if (value != null && value !== '' && !reg.test(value)) {
        callback(new Error('请输入 一千 以内的正整数或两位小数'))
        callback(new Error('请输入 一万 以内的正整数或两位小数'))
      } else {
        callback()
      }
@@ -277,7 +330,9 @@
        edit: ['admin', 'task:edit'],
        del: ['admin', 'task:del'],
        download: ['admin', 'task:download'],
        divide: ['admin', 'task:divide']
        divide: ['admin', 'task:divide'],
        seeDivide: ['admin', 'task:seeDivide'],
        seeDaliy: ['admin', 'task:seeDaliy']
      },
      rules: {
        name: [
@@ -299,13 +354,17 @@
        ],
        planWorkload: [
          { validator: durationValidate, trigger: 'blur' }
        ],
        taskStatus: [
          { required: true, message: '任务状态不能为空', trigger: 'change' }
        ]
      },
      queryTypeOptions: [
        { key: 'name', display_name: '名称' },
        { key: 'projectId', display_name: '所属项目' },
        { key: 'priority', display_name: '优先度' },
        { key: 'taskClassification', display_name: '任务分类' }
        { key: 'taskClassification', display_name: '任务分类' },
        { key: 'taskStatus', display_name: '任务状态' }
      ],
      // 计划开始时间选项
      planStartTimePickerOptions: {
@@ -327,6 +386,10 @@
      taskClassification: constant.TAST_CLASSIFICATION,
      // 字典:标准工作量单位
      standardWorkloadUnit: constant.STANDARD_WORKLOAD_UNIT,
      // 字典:任务状态
      taskStatus: constant.TASK_STATUS,
      // 字典:批准状态-未承认
      approveStatusUnrecognized: constant.APPROVE_STATUS_UNRECOGNIZED,
      // CRUD状态
      crudStatusPrepared: CRUD.STATUS.PREPARED,
      // 项目列表
@@ -338,11 +401,11 @@
      // 分配表单加载
      divideLoading: false,
      // 分配表单数据
      divideForm: { projectId: null, projectName: null, taskId: null, taskname: null, userIds: [], divideUserIds: [], taskStartDate: null, taskEndDate: null, taskHours: null, taskWorkload: null, taskStatus: null },
      divideForm: { projectId: null, projectName: null, taskId: null, taskName: null, userIds: [], divideUserIds: [], taskStartDate: null, taskEndDate: null, taskHours: null, taskWorkload: null, taskStatus: null },
      // 分配表单验证
      divideRules: {
        userIds: [
          { required: true, message: '分配用户不能为空', trigger: 'change' }
          { required: true, message: '分配员工不能为空', trigger: 'change' }
        ],
        taskStartDate: [
          { required: true, message: '任务开始时间不能为空', trigger: 'change' }
@@ -388,7 +451,7 @@
    // 获取项目
    getProject() {
      // 获取项目
      crudProject.getAll({ approveStatus: constant.APPROVE_STATUS_ACKNOWLEDGED }).then(res => {
      crudProject.getRelevant().then(res => {
        // 项目列表
        this.projects = res
      })
@@ -448,8 +511,37 @@
      this.divideForm.divideUserIds = data.divideUserIds
      this.divideForm.taskWorkloadUnit = data.planWorkloadUnit
      this.divideForm.taskStatus = constant.TASK_STATUS_NOT_STARTED
      // 获取任务的计划开始时间结束时间
      if (data.planStartTime) {
        this.divideForm.taskStartDate = data.planStartTime
      }
      if (data.planEndTime) {
        this.divideForm.taskEndDate = data.planEndTime
      }
      // 分配表单状态
      this.divideStatus = true
    },
    // 查看任务分配
    toSeeDivide(data) {
      // 跳转页面
      this.$router.push({
        name: 'TaskUser',
        params: {
          projectId: data.projectId,
          taskId: data.id
        }
      })
    },
    // 查看任务日报
    toSeeDaliy(data) {
      // 跳转页面
      this.$router.push({
        name: 'TaskDaliy',
        params: {
          projectId: data.projectId,
          taskId: data.id
        }
      })
    },
    // 分配表单关闭
    divideClose() {
@@ -458,7 +550,7 @@
      // 分配表单加载
      this.divideLoading = false
      // 分配表单数据
      this.divideForm = { projectId: null, projectName: null, taskId: null, taskname: null, userIds: [], divideUserIds: [], taskStartDate: null, taskEndDate: null, taskHours: null, taskWorkload: null, taskStatus: null }
      this.divideForm = { projectId: null, projectName: null, taskId: null, taskName: null, userIds: [], divideUserIds: [], taskStartDate: null, taskEndDate: null, taskHours: null, taskWorkload: null, taskStatus: null }
      // 清除表单验证
      this.$nextTick(() => {
        this.$refs['divideForm'].clearValidate()