任务日报工时消耗逻辑整体逻辑改版,整合没有指定的任务日报可新建任务日报功能
1 files modified
112 ■■■■■ changed files
eladmin-web-master/src/views/task/taskDaliy/index.vue 112 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/views/task/taskDaliy/index.vue
@@ -206,15 +206,12 @@
            <el-date-picker v-model="form.fillDate" type="date" style="width: 340px;" :disabled="form.taskUserMongo.id == null" @change="formDateChange" />
          </el-form-item>
          <el-form-item label="消耗工时" prop="consumedHours">
            <el-input v-model="form.consumedHours" style="width: 340px;" :disabled="disabledFlagBySettlement || form.fillDate == null">
            <el-input v-model="form.consumedHours" style="width: 340px;" :disabled="disabledFlagBySettlement || form.fillDate == null" @input="watchFlagChange">
              <template slot="append">小时</template>
            </el-input>
          </el-form-item>
          <el-form-item v-if="form.alreadyConsumedHours === 0 && form.consumedHours === null">
            已消耗工时:{{ 0 }} / 任务工时:{{ form.taskHours }}
          </el-form-item>
          <el-form-item v-else>
            已消耗工时:{{ oldValue == null ? form.alreadyConsumedHours : form.alreadyConsumedHours === 0 ? form.consumedHours = newValue : newValue - 0 + (form.alreadyConsumedHours - 0 - tempValue) > 0 ? newValue - 0 + (form.alreadyConsumedHours - 0 - tempValue ) : 0 }} / 任务工时:{{ form.taskHours }}
          <el-form-item>
            已消耗工时:{{ form.alreadyConsumedHours }} / 任务工时:{{ form.taskHours }}
          </el-form-item>
          <el-form-item label="任务进度" prop="taskProgress">
            <el-input v-model="form.taskProgress" style="width: 340px;" :disabled="disabledFlagBySettlement">
@@ -440,9 +437,10 @@
      confirmProgress: false,
      newValue: '',
      oldValue: '',
      resData: true,
      tempValue: '',
      temp: ''
      resData: true,
      userIds: [],
      watchFlg: false
    }
  },
  computed: {
@@ -452,10 +450,12 @@
  },
  watch: {
    'form.consumedHours': function(newVal, oldVal) {
      this.newValue = newVal
      this.oldValue = oldVal
      if (this.oldValue == null) {
        this.tempValue = this.form.consumedHours
      if (newVal === 0 && this.userIds.includes(this.form.taskUserMongo.id)) {
        this.form.alreadyConsumedHours = this.tempValue
      }
      if (this.watchFlg) {
        this.form.alreadyConsumedHours = (this.form.alreadyConsumedHours) - (oldVal - 0) + (newVal - 0)
        this.watchFlg = false
      }
    },
    'confirmProgress': function(newVal) {
@@ -515,7 +515,6 @@
      this.form.alreadyConsumedHours = 0
      this.confirmHours = false
      this.confirmProgress = false
      this.form.taskHours = 0
    },
    [CRUD.HOOK.afterEditError]() {
      this.form.flag = false
@@ -525,7 +524,6 @@
      this.form.alreadyConsumedHours = 0
      this.confirmHours = false
      this.confirmProgress = false
      this.form.taskHours = 0
    },
    [CRUD.HOOK.afterEditCancel]() {
      this.form.flag = false
@@ -535,7 +533,6 @@
      this.form.alreadyConsumedHours = 0
      this.confirmHours = false
      this.confirmProgress = false
      this.form.taskHours = 0
    },
    [CRUD.HOOK.afterAddCancel]() {
      this.form.flag = false
@@ -545,7 +542,6 @@
      this.form.alreadyConsumedHours = 0
      this.confirmHours = false
      this.confirmProgress = false
      this.form.taskHours = 0
    },
    [CRUD.HOOK.afterAddError]() {
      this.form.flag = false
@@ -555,7 +551,6 @@
      this.form.alreadyConsumedHours = 0
      this.confirmHours = false
      this.confirmProgress = false
      this.form.taskHours = 0
    },
    // 钩子:新建 - 之前
    [CRUD.HOOK.beforeToAdd]() {
@@ -579,6 +574,7 @@
        })
        this.form.taskHours = this.currentTask.performanceHours
        this.form.alreadyConsumedHours = this.currentTask.alreadyConsumedHours
        this.tempValue = this.currentTask.alreadyConsumedHours
        this.form.flag = true
      }
    },
@@ -601,12 +597,8 @@
          // 判断是否为选中任务
          if (this.formTaskUserIds[i].id === this.form.taskUserMongo.id) {
            this.form.taskHours = this.formTaskUserIds[i].performanceHours
            if (this.formTaskUserIds[i].alreadyConsumedHours != null) {
              this.form.alreadyConsumedHours = this.formTaskUserIds[i].alreadyConsumedHours
            } else {
              this.form.alreadyConsumedHours = 0
            }
            this.temp = this.formTaskUserIds[i].alreadyConsumedHours
            this.form.alreadyConsumedHours = this.formTaskUserIds[i].alreadyConsumedHours
            this.tempValue = this.formTaskUserIds[i].alreadyConsumedHours
          }
        }
      })
@@ -615,8 +607,7 @@
      this.taskLoading = false
    },
    [CRUD.HOOK.beforeSubmit]() {
      var reg = new RegExp('[\\u4E00-\\u9FFF]+', 'g')
      if (reg.test(this.form.taskUserMongo.id)) {
      if (!this.userIds.includes(this.form.taskUserMongo.id)) {
        // 置换一下
        var taskUserMongoName = this.form.taskUserMongo.id
        this.form.taskUserMongo.name = taskUserMongoName
@@ -624,9 +615,6 @@
      }
    },
    checkForm(flag) {
      if (this.form.taskProgress === undefined) {
        return
      }
      crudTaskDaliy.checkTaskHours({ 'taskProgress': this.form.taskProgress, 'taskUserId': this.form.taskUserMongo.id, 'fillDate': this.form.fillDate }).then(res => {
        if (res === false && !this.confirmProgress) {
          flag++
@@ -634,7 +622,7 @@
          this.centerDialogVisibleTaskProgress = true
          if (this.confirmProgress) {
            // 如果确定了
            const result = this.newValue - 0 + (this.form.alreadyConsumedHours - 0 - this.tempValue)
            const result = this.form.alreadyConsumedHours
            if (result > this.form.taskHours && !this.confirmHours) {
              this.centerDialogVisibleTaskHours = true
              if (this.confirmHours) {
@@ -660,7 +648,7 @@
        } else {
          flag++
          // 判断时间
          const result = this.newValue - 0 + (this.form.alreadyConsumedHours - 0 - this.tempValue)
          const result = this.form.alreadyConsumedHours
          if (result > this.form.taskHours && !this.confirmHours) {
            this.centerDialogVisibleTaskHours = true
            if (this.confirmHours) {
@@ -677,6 +665,9 @@
          }
        }
      })
    },
    watchFlagChange() {
      this.watchFlg = true
    },
    getAdventTasks() {
      crudTaskUser.getAdventTasks().then(res => {
@@ -732,39 +723,20 @@
      }
    },
    formDateChange() {
      var reg = new RegExp('[\\u4E00-\\u9FFF]+', 'g')
      var flag = false
      if (reg.test(this.form.taskUserMongo.id)) {
        // 置换一下
        var taskUserMongoName = this.form.taskUserMongo.id
        this.form.taskUserMongo.name = taskUserMongoName
        this.form.taskUserMongo.id = null
        flag = true
      }
      crudTaskDaliy.getDailyDetail({ taskUserId: this.form.taskUserMongo.id, fillDate: this.form.fillDate }).then(res => {
        if (res !== '') {
          console.log('this.temp:', this.temp)
          console.log('res.consumedHours:', res.consumedHours)
          this.form.alreadyConsumedHours = this.temp
          this.form.taskProgress = res.taskProgress
          this.form.consumedHours = res.consumedHours
          this.form.remarks = res.remarks
        } else {
          if (this.temp) {
            this.form.alreadyConsumedHours = this.temp
          } else {
            this.form.alreadyConsumedHours = 0
          }
        if (res === '') {
          this.form.alreadyConsumedHours = this.tempValue
          this.form.consumedHours = 0
          this.tempValue = 0
          if (flag) {
            this.form.taskUserMongo.id = taskUserMongoName
            this.form.taskHours = 0
            this.form.alreadyConsumedHours = 0
          }
        } else {
          this.form.alreadyConsumedHours = this.tempValue
          this.form.consumedHours = res.consumedHours
          this.form.taskProgress = res.taskProgress
        }
        if (form.flag) {
          this.from.alreadyConsumedHours = this.temp
        if (!this.userIds.includes(this.form.taskUserMongo.id)) {
          console.log('不在')
          this.form.consumedHours = 0
          this.form.taskProgress = 0
          this.form.alreadyConsumedHours = 0
        }
      })
    },
@@ -814,7 +786,6 @@
    },
    // 表单任务变更
    formTaskChange(cb) {
      form.taskUserMongo = {}
      // 循环表单任务列表
      for (let i = 0; i < this.formTasks.length; i++) {
        // 判断是否为选中任务
@@ -823,14 +794,13 @@
            if (res === []) {
              this.formTaskUserIds = []
            }
            for (let i = 0; i < res.length; i++) {
              this.userIds.push(res[i].id)
            }
            this.formTaskUserIds = res
            this.form.taskProgress = res.taskProgress
            this.form.consumedHours = res.consumedHours
            if (this.currentTask.alreadyConsumedHours != null) {
              this.temp = this.currentTask.alreadyConsumedHours
            } else {
              this.temp = 0
            }
            this.tempValue = res.alreadyConsumedHours
            if (cb) {
              cb()
            }
@@ -839,16 +809,18 @@
      }
    },
    formTaskUserChange() {
      var reg = new RegExp('[\\u4E00-\\u9FFF]+', 'g')
      if (reg.test(this.form.taskUserMongo.id)) {
        this.form.fillDate = null
      }
      this.form.consumedHours = 0
      this.form.fillDate = null
      this.form.taskProgress = 0
      this.form.alreadyConsumedHours = 0
      this.form.taskHours = 0
      // 循环表单任务列表
      for (let i = 0; i < this.formTaskUserIds.length; i++) {
        // 判断是否为选中任务
        if (this.formTaskUserIds[i].id === this.form.taskUserMongo.id) {
          this.form.taskHours = this.formTaskUserIds[i].performanceHours
          this.form.alreadyConsumedHours = this.formTaskUserIds[i].alreadyConsumedHours
          this.tempValue = this.formTaskUserIds[i].alreadyConsumedHours
        }
      }
    },