<template>
  <m-dialog ref="dialog" title="审批明细">
    <el-steps align-center finish-status="success" v-loading="loading" :space="800 / items.length">
      <el-step
        v-for="(item) in items"
        :key="item.id"
        :title="item.title"
        :status="statusMap[item.status]"
      >
        <template #description>
          <div>{{ item.date }}</div>
          <div v-if="item.status === 2">拒绝理由： {{ item.msg }}</div>
        </template>
      </el-step>
    </el-steps>
  </m-dialog>
</template>

<script>
import {
  getApprovalProgress
} from '@/api/approval'
export default {
  name: 'approvalProgress',
  data () {
    return {
      loading: false,
      items: [],
      statusMap: ['wait', 'success', 'error']
    }
  },
  methods: {
    async open (workFlowInstanceId) {
      this.$refs.dialog.open()
      this.items = []
      this.loading = true
      try {
        const { data } = await getApprovalProgress({ workFlowInstanceId })
        this.items = data
      } catch (error) {
        this.$message.error(error)
      } finally {
        this.loading = false
      }
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
