<template>
  <el-dialog :close-on-click-modal="false"
             :title="!this.taskForm.taskId == '' ? $t('处理') : $t('详情')"
             :visible.sync="visible"
             :append-to-body="true"
             width="60%">
    <Subitem :sub-id="Number(subId)" :serial-number="sn" :is-approve="Number((taskForm.taskId == '')?2:1)" />
    <span slot="footer" class="dialog-footer">
      <el-button v-if="!this.taskForm.taskId == ''" type="primary"
                 @click="dataFormSubmit(1)" :disabled="submitDisabled">通过</el-button>
      <el-button v-if="!this.taskForm.taskId == ''" type="danger"
                 @click="dataFormSubmit(0)" :disabled="submitDisabled">驳回</el-button>
      <el-button @click="visible = false">{{ $t('返回') }}</el-button>
    </span>
    <div>
      <span>{{ $t('流转详情') }}</span>
      <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>
    </div>
  </el-dialog>
</template>

<script>
import {getHistorylist} from "@/api/ehs/approvedanger";
import Subitem from "@/views/pssr/subitem/index.vue";
import {getSubcontent} from "@/api/pssr/subcontent";

export default {
  name: "pssrApprove-detail",
  components: {Subitem},
  data() {
    return {
      //label样式
      labelStyle: {'width': '200px'},
      //流转列表
      historyList: [],
      historyLoading: true,
      submitDisabled: false,
      taskName: '',
      visible: false,
      subId: null,
      sn: null,
      taskForm: {
        comment: '',
        taskId: '',
        businessKey: '',
        tPssrApprove: {}
      },
      devList: [],
      dataForm: {},
      form: {},
      rules: {},
      flag: false
    }
  },
  methods: {
    init(id, taskId, processId, taskName) {
      this.subId = id;
      getSubcontent(id).then(res => {
        this.sn = res.data.serialNumber
      })
      this.visible = true;
      getHistorylist({processId: processId}).then(response => {
        this.historyList = response.rows;
        this.historyLoading = false
      });
    },
    dataFormSubmit(val) {

    }
  }

}
</script>

<style scoped>

</style>
