yaozc
2023-08-04 5f225dec59213c7a91ef1ee83d76d5a279284085
eladmin-web-master/src/views/task/taskUser/index.vue
@@ -114,21 +114,11 @@
        <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="taskId">
              <el-input v-show="false" v-model="form.taskId" style="width: 340px;"></el-input>
              <el-input v-model="form.taskName" :disabled="true" style="width: 340px;"></el-input>
              <el-input v-show="false" v-model="form.task.id" style="width: 340px;"></el-input>
              <el-input v-model="form.task.name" :disabled="true" style="width: 340px;"></el-input>
            </el-form-item>
            <el-form-item label="任务名称">
              <el-input v-model="form.name" style="width: 340px;" />
            </el-form-item>
            <el-form-item label="任务分类" prop="taskClassification">
              <el-select v-model="form.taskClassification" filterable clearable placeholder="请选择" style="width: 340px;">
                <el-option
                  v-for="item in dict[taskClassification]"
                  :key="item.id"
                  :label="item.label"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="所属员工" prop="userId">
              <el-select v-model="form.userId" filterable clearable placeholder="请选择" style="width: 340px;">
@@ -145,11 +135,9 @@
              </el-select>
            </el-form-item>
            <el-form-item label="任务开始时间" prop="taskStartDate">
              <el-input v-model="planStartTime" />
              <el-date-picker v-model="form.taskStartDate" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" :default-time="$store.state.user.user.sysRostering.workStartTime + ':00'" :picker-options="{ disabledDate }" style="width: 340px;" />
            </el-form-item>
            <el-form-item label="任务结束时间" prop="taskEndDate">
              <el-input v-model="planEndTime" />
              <el-date-picker v-model="form.taskEndDate" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" :default-time="$store.state.user.user.sysRostering.workEndTime + ':00'" :picker-options="{ disabledDate }" style="width: 340px;" />
            </el-form-item>
            <el-form-item label="任务工时" prop="taskHours">
@@ -176,35 +164,51 @@
          @selection-change="crud.selectionChangeHandler"
        >
          <el-table-column type="selection" width="55" />
          <el-table-column :show-overflow-tooltip="true" prop="name" label="名称" fixed="left" width="180">
          <el-table-column :show-overflow-tooltip="true" prop="name" label="名称" fixed="left" width="370">
            <template slot-scope="scope">
              <el-tag>{{ scope.row.name }}</el-tag>
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="userNickName" label="所属员工" width="100">
            <template slot-scope="scope">
              <el-tag>{{ scope.row.userNickName }}</el-tag>
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" 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 :show-overflow-tooltip="true" prop="taskStartDate" label="任务开始时间" width="140" />
          <el-table-column :show-overflow-tooltip="true" prop="taskEndDate" label="任务结束时间" width="140" />
          <el-table-column :show-overflow-tooltip="true" prop="taskHours" label="任务工时" width="110" />
          <el-table-column :show-overflow-tooltip="true" prop="taskHours" label="任务工时" width="80" />
          <el-table-column :show-overflow-tooltip="true" prop="userNickName" label="所属员工" width="100">
            <template slot-scope="scope">
              <el-tag v-if="scope.row.userNickName">{{ scope.row.userNickName }}</el-tag>
              <el-tag v-else>未指定</el-tag>
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="taskHours" label="绩效工时" width="80" />
          <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 v-if="checkPer(['admin','taskUser:edit','taskUser:del'])" label="操作" width="150px" align="center" fixed="right">
          <el-table-column v-if="checkPer(['admin','taskUser:edit','taskUser:del'])" label="操作" width="180" align="center" fixed="right">
            <template slot-scope="scope">
              <udOperation
                :data="scope.row"
                :permission="permission"
              />
              >
                <el-button
                  slot="left"
                  v-if="scope.row.userNickName"
                  v-permission="permission.list"
                  size="mini"
                  type="primary"
                  icon="el-icon-check"
                  @click="toPick(scope.row)"
                />
                <el-button
                  slot="left"
                  v-else
                  v-permission="permission.list"
                  size="mini"
                  type="primary"
                  icon="el-icon-share"
                  @click="unPick(scope.row)"
                />
              </udOperation>
            </template>
          </el-table-column>
        </el-table>
@@ -242,7 +246,7 @@
import { mapGetters } from 'vuex'
import constant from '@/utils/constant'
import UploadExcelComponent from '@/components/UploadExcel/index.vue'
const defaultForm = { id: null, userId: null, projectId: null, taskId: null, taskStartDate: null, taskEndDate: null, taskHours: null, taskStatus: null, enable1: false, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null, divideUserIds: [] }
const defaultForm = { id: null, userId: null, projectId: null, task: { id: null }, taskStartDate: null, taskEndDate: null, taskHours: null, taskStatus: null, remarks: null, divideUserIds: [] }
export default {
  name: 'TaskUser',
  components: { Treeselect, crudOperation, rrOperation, udOperation, pagination, DateRangePicker, UploadExcelComponent },
@@ -274,6 +278,7 @@
      taskLoading: false,
      defaultProps: { children: 'nodes', label: 'name', isLeaf: 'leaf' },
      permission: {
        list: ['admin', 'taskUser:list'],
        add: ['admin', 'taskUser:add'],
        edit: ['admin', 'taskUser:edit'],
        del: ['admin', 'taskUser:del'],
@@ -340,8 +345,19 @@
      return true
    },
    [CRUD.HOOK.beforeToCU]() {
      this.form.taskId = this.query.taskId
      this.form.taskName = this.selectedTaskName
      // this.form.taskId = this.query.taskId
      // this.form.taskName = this.selectedTaskName
      this.form.task.id = this.query.taskId
      this.form.task.name = this.selectedTaskName
    },
    [CRUD.HOOK.beforeSubmit]() {
      if (!this.form.taskStatus) {
        this.form.taskStatus = 'task_status_not_started'
      }
      // if (this.form.task.id === undefined || this.form.task.id === null || this.form.task.id === '') {
      //   this.form.task = null
      // }
      return true
    },
    disabledDate(time) {
      return time.getTime() < new Date(this.planStartTime) -8.64e7 || time.getTime() > new Date(this.planEndTime).getTime()
@@ -462,15 +478,7 @@
      //     // 生成表单加载
      //     this.generateLoading = false
      // })
    },
    // 自动计算工时
    calcHour() {
      if (this.form.taskEndDate && this.form.taskStartDate && this.form.userId && !this.form.taskHours) {
        crudTaskUser.calcHours({ userId: this.form.userId, taskStartDate: this.form.taskStartDate, taskEndDate: this.form.taskEndDate }).then(res => {
          this.form.taskHours = res
        })
      }
    },
    }
  }
}
</script>