<template>
  <el-dialog
    v-if="visible"
    :visible.sync="visible"
    :v-loading="loading"
    :before-close="handleClose"
    :append-to-body="true"
    :title="title"
    width="60%">
    <el-steps :space="200" :active="step" direction="vertical" finish-status="success">
      <el-step v-for="item in list" :key="item.INDEX" :value="item.INDEX" :title="item.INDEX">
        <template slot="description">
          <el-card class="box-card" style="width: 900px;">
            <div slot="header" class="clearfix">
              <span>审批信息</span>
            </div>
            <div>
              <el-row>
                <el-col>
                  审批人：{{ item.FIRST_AUDIT_USER_NAME }}
                </el-col>
                <el-col>
                  审批人公司：{{ item.FIRST_AUDIT_COMPANY_NAME }}
                </el-col>
                <el-col>
                  审批人部门：{{ item.FIRST_AUDIT_DEPARTMENT_NAME }}
                </el-col>
                <el-col>
                  审批状态：{{ getAuditType(item.AUDIT_TYPE) }}
                </el-col>
                <el-col v-if="item.AUDIT_TYPE === '2'">
                  审批时间：{{ item.FIRST_AUDIT_TIME }}
                </el-col>
                <el-col v-if="item.AUDIT_TYPE === '0'">
                  审批意见：{{ item.REASON }}
                </el-col>
              </el-row>
            </div>
          </el-card>
        </template>
      </el-step>
    </el-steps>
    <div slot="footer" class="dialog-footer">
      <el-button @click="closeWindow">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import { requestFN } from '@/utils/request'

export default {
  props: {
    corpInfo: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      visible: false,
      loading: false,
      list: [],
      title: '审批详情',
      form: {
        TEMPORARY_ID: ''
      },
      step: 0
    }
  },
  methods: {
    init(e) {
      this.form.TEMPORARY_ID = e.TEMPORARY_ID
      this.getInfo()
    },
    getAuditType(AUDIT_TYPE) {
      if (AUDIT_TYPE === '0') {
        return '不通过'
      } else if (AUDIT_TYPE === '1') {
        return '审核中'
      } else if (AUDIT_TYPE === '2') {
        return '通过'
      }
    },
    getInfo() {
      requestFN(
        '/mkmj/management/getAuditInfo', this.form
      ).then((data) => {
        this.list = data.auditIndo
        this.visible = true
        this.loading = false
      }).catch((e) => {
        console.log(e)
      })
    },
    handleClose() {
      this.visible = false
      this.$emit('refresh', '')
    },
    closeWindow() {
      this.handleClose()
    }
  }
}
</script>
