<template>
  <div class="time-axis-box">
    <el-timeline>
      <el-timeline-item
        v-for="(activity, index) in activities"
        :key="index"
      >
        <div class="title"> {{ activity.formBusinessName }} </div>
        <div v-for="(item, index) in activity.logs" :key="index" class="content">
          <span v-if="item.assigneeName">处理人：{{ item.assigneeName }}</span>
          <span v-if="item.status">状态：{{ item.status }}</span>
          <span v-if="item.startTime">开始时间：{{ item.startTime }}</span>
          <span v-if="item.endTime">完成时间：{{ item.endTime }}</span>
          <div>
            <span v-if="item.explanation"> 原因：{{ item.explanation }}</span>
          </div>
        </div>

      </el-timeline-item>
    </el-timeline>
  </div>
</template>

<script>
import { getTimeAxis } from '@/api/dictionary'
export default {
  props: {
    timeAxisParams: {
      type: Object,
      default: () => {
        return {
          businessKey: '',
          businessType: '',
          interfaceUrl: ''
        }
      }
    }
  },
  data() {
    return {
      activities: []
    }
  },
  watch: {
    timeAxisParams: {
      handler(newV) {
        if (newV.businessKey) {
          // this.fetchData()
        }
      },
      immediate: true,
      deep: true
    }
  },
  methods: {
    fetchData() {
      getTimeAxis(this.timeAxisParams).then(({ data }) => {
        this.activities = data
      })
    }
  }
}
</script>

<style scoped>
.time-axis-box {
  padding: 10px;
}

.time-axis-box .title {
  color: #FE7D0B;
}

.time-axis-box .content  {
  margin-bottom: 20px;
}

.time-axis-box .content span {
  margin-right: 20px;
}
</style>
