<template>
  <div>
    <subcontent :aboveall-id="Number(aboveallId)" :is-approve="Number(2)" :client-height="Number(350)" :task-type="Number(taskType)"/>
    <div  style="text-align: center">
      <el-button v-if="!this.taskForm.taskId == ''" type="primary"
                 @click="dataFormSubmit(0)">通过</el-button>
    </div>
    <el-card shadow="always" class="mb20 mt20 mr20 m20">
      <div slot="header" class="clearfix">
        <span>流转详情</span>
      </div>
      <el-table :data="historyList" border v-loading="historyLoading" style="width: 100%;">
        <el-table-column prop="taskName" header-align="center" align="center"
                         :label="$t('流程进度')"></el-table-column>
        <el-table-column prop="userName" header-align="center" align="center" :label="$t('姓名')"></el-table-column>
        <el-table-column prop="taskCreateTime" header-align="center" align="center"
                         :label="$t('开始时间')"></el-table-column>
        <el-table-column prop="taskEndTime" header-align="center" align="center"
                         :label="$t('结束时间')"></el-table-column>
        <el-table-column prop="comment" header-align="center" align="center"
                         :label="$t('审批意见')"></el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
import {getHistorylist} from "@/api/ehs/approvedanger";
import {handleMgrApprove, listApprove} from "@/api/pssr/approve";
import Subcontent from "@/views/pssr/subcontent/index.vue";

export default {
  name: "pssrMgrApprove-detail",
  components: {Subcontent},
  data() {
    return {
      //label样式
      labelStyle: {'width': '200px'},
      isApprove: 1,//0-显示新增等按钮；1-确认人查询（我的待办）；2-28项负责人查询（我的待办）；3-无按钮；4-确认人1；5-确认人2；6-确认人3；
      taskType: 0,//0-查询所有sub数据；1-只查询当前用户对应的输得
      //流转列表
      historyList: [],
      historyLoading: true,
      submitDisabled: false,
      taskName: '',
      visible: false,
      aboveallId: null,
      sn: '',
      taskForm: {
        comment: '',
        taskId: '',
        processId: '',
        condition: '',
        taskName: '',
        processName: '',
        businessKey: '',
        tPssrApprove: {}
      },
      devList: [],
      dataForm: {},
      form: {},
      rules: {},
      flag: false
    }
  },
  created() {
    console.log(this.$route)
    this.init(this.$route.query.aboveallId, this.$route.query.taskId, this.$route.query.processId, this.$route.query.taskName)
  },
  methods: {
    init(id, taskId, processId, taskName) {
      this.aboveallId = id;
      this.taskForm.taskId = taskId
      this.taskForm.processId = processId
      this.taskForm.taskName = taskName
      console.log(this.sn)
      this.visible = true;
      this.getHistorylist();
      listApprove({aboveallId: id}).then(res => {
        this.taskForm.tPssrApprove = res.rows[0];
        console.log(this.taskForm)
      })
      console.log(taskName)
      if (taskName=='部门经理'){
        this.taskType=1
      }
    },
    getHistorylist() {
      getHistorylist({processId: this.taskForm.processId}).then(response => {
        this.historyLoading = false
        this.historyList = response.rows;
      });
    },
    afterConfirm() {
      this.visible = false;
      this.$emit('refreshDataList')
    },
    dataFormSubmit(val) {
      this.taskForm.condition = val;
      handleMgrApprove(this.taskForm).then(res => {
        this.msgSuccess("审核成功");
        this.visible = false;
        this.$emit('refreshDataList')
      })
    },
  }

}
</script>

<style scoped>

</style>
