<!--
 * @Author: ysh
 * @Date: 2024-04-08 13:56:14
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2024-04-10 17:56:58
-->
<template>
  <div class="app-container">
    <h2 style="text-align:center;">分管审核</h2>
    <el-form :model="form" :rules="rules" label-width="100px" :disabled="disabled">
      <el-form-item label="审核意见：" prop="jyComment">
        <el-input type="textarea" :rows="4" placeholder="请输入审核意见" v-model="form.jyComment">
        </el-input>
      </el-form-item>
      <el-form-item label="审核人：">
        <span class="auditor">{{ form.manageApprover }}</span>
      </el-form-item>
      <el-form-item label="审核时间：">
        {{ form.manageApprovalTime }}
      </el-form-item>
      <el-form-item>
        <p style="text-align:center;"><el-button type="primary" @click="confirm">确认审核</el-button></p>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { mapGetters } from 'vuex';
import { parseTime } from "@/utils/ruoyi";
import { complete, rejectTask, returnList, returnTask, getNextFlowNode, delegate, flowTaskForm } from "@/api/flowable/todo";
import { getProjectComment, addProjectComment } from "@/api/oa/project/projectComment"
export default {
  computed: {
    ...mapGetters(['name']),
  },
  props: {
    disabled: {
      type: Boolean,
      require: true,
    },
    taskForm: {
      type: Object,
      required: true,
    },
    taskName: {
      type: String,
      required: true,
    },
  },
  data() {
    return {
      form: {
        manageApprover: '',
        manageApprovalTime: ''
      },
      rules: {
        jyComment: [{ required: true, message: "请输入审核意见", trigger: "blur" }]
      },
      jyComment: "",
      manageApprovalTime: ""
    }
  },
  created() {
    this.initForm();
  },
  methods: {
    initForm() {
      console.log(this.taskForm);
      getProjectComment(this.taskForm.formId).then(res => {
        if (res.data) {
          this.form = res.data
        } else {
          if (this.taskName == '分管审核') {
            this.form.manageApprover = this.name;
            this.form.manageApprovalTime = parseTime(new Date(), '{y}-{m}-{d}')
            console.log(this.form);
          } else {
            this.form.manageApprover = '';
            this.form.manageApprovalTime = '';
          }

        }
      })
    },
    confirm() {
      const params = { taskId: this.taskForm.taskId };
      // 获取下一个流程节点
      getNextFlowNode(params).then(res => {
        // getUsersDeptLeaderByDept({ deptId: 107 }).then(res => {
        //   let userId = res.data.userId;
        //   this.$set(this.taskForm.variables, "approval", userId);
        //   complete(this.taskForm).then(response => {
        //     this.$modal.msgSuccess(response.msg);
        //     this.$emit("goBack");
        //   });
        // });
      });
    },

  },
}
</script>

<style lang="scss" scoped>
.auditor {
  font-family: '华文行楷';
  font-size: 20px;
}
</style>