churf
2023-08-23 6b1c6be17e4c0cbb9bf0bc76d2c4c18b996496c7
eladmin-web-master/src/views/task/taskDaliy/index.vue
@@ -180,7 +180,7 @@
                :value="item.id"
              />
            </el-select>
            <el-select v-else filterable clearable placeholder="请选择" style="width: 340px;" :disabled="form.flag" @change="formTaskUserChange">
            <el-select v-else v-model="form" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="form.flag" @change="formTaskUserChange">
              <el-option
                v-for="item in formTaskUserIds"
                :key="item.id"
@@ -218,7 +218,7 @@
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
          <el-button :loading="crud.status.cu === 2" type="primary" @click="checkForm(1)">确认</el-button>
        </div>
      </el-dialog>
      <!--表格渲染-->
@@ -442,6 +442,12 @@
    'form.consumedHours': function(newVal, oldVal) {
      this.newValue = newVal
      this.oldValue = oldVal
    },
    'confirmProgress': function(newVal) {
      this.confirmProgress = newVal
    },
    'confirmHours': function(newVal) {
      this.confirmHours = newVal
    }
  },
  methods: {
@@ -584,33 +590,58 @@
      this.taskLoading = false
    },
    [CRUD.HOOK.beforeSubmit]() {
      // 先check一下
      this.resData = this.getCheckResult(this.form.taskProgress, this.form.taskUserMongo.id)
      console.log(2)
      console.log(this.resData)
      if (this.resData === false && !this.confirmProgress) {
        // 为假
        this.centerDialogVisibleTaskProgress = true
        this.waitForPropertyConfirmProgress()
        return false
      }
      const result = (this.form.alreadyConsumedHours - 0) + (this.newValue - 0) - (this.oldValue - 0)
      if (result > this.form.taskHours && !this.confirmHours) {
        this.centerDialogVisibleTaskHours = true
        this.waitForPropertyConfirmHours()
        return false
      }
      return true
    },
    getCheckResult(taskProgress, taskUserId) {
      return (async function() {
        console.log(1)
        const result = await crudTaskDaliy.checkTaskHours({ 'taskProgress': taskProgress, 'taskUserId': taskUserId })
        console.log(3)
        return result
      })()
    checkForm(flag) {
      crudTaskDaliy.checkTaskHours({ 'taskProgress': this.form.taskProgress, 'taskUserId': this.form.taskUserMongo.id, 'fillDate': this.form.fillDate }).then(res => {
        if (res === false && !this.confirmProgress) {
          flag++
          // 为假
          this.centerDialogVisibleTaskProgress = true
          if (this.confirmProgress) {
            // 如果确定了
            const result = (this.form.alreadyConsumedHours - 0) + (this.newValue - 0) - (this.oldValue - 0)
            if (result > this.form.taskHours && !this.confirmHours) {
              this.centerDialogVisibleTaskHours = true
              if (this.confirmHours) {
                this.crud.submitCU()
              } else {
                if (flag > 1) {
                  return
                } else {
                  this.checkForm()
                }
              }
            } else {
              this.crud.submitCU()
            }
          } else {
            if (flag > 1) {
              return
            } else {
              // 没确定
              this.checkForm()
            }
          }
        } else {
          flag++
          // 判读时间
          const result = (this.form.alreadyConsumedHours - 0) + (this.newValue - 0) - (this.oldValue - 0)
          if (result > this.form.taskHours && !this.confirmHours) {
            this.centerDialogVisibleTaskHours = true
            if (this.confirmHours) {
              this.crud.submitCU()
            } else {
              if (flag > 1) {
                return
              } else {
                this.checkForm()
              }
            }
          } else {
            this.crud.submitCU()
          }
        }
      })
    },
    getAdventTasks() {
      crudTaskUser.getAdventTasks().then(res => {
@@ -755,25 +786,6 @@
    submitDialogTaskProgress() {
      this.centerDialogVisibleTaskProgress = false
      this.confirmProgress = true
    },
    waitForPropertyConfirmHours() {
      new Promise(resolve => {
        this.$watch('confirmHours', (newValue) => {
          if (newValue === true) {
            console.log(newValue)
            resolve(this.crud.submitCU())
          }
        })
      })
    },
    waitForPropertyConfirmProgress() {
      new Promise(resolve => {
        this.$watch('confirmProgress', (newValue) => {
          if (newValue === true) {
            resolve(this.crud.submitCU())
          }
        })
      })
    }
  }
}