<template>
  <el-drawer
    :title="title"
    :modal-append-to-body="false"
    :modal="false"
    size="35%"
    :visible.sync="dialogVisible"
  >
    <div class="content-container">
      <!-- <vuescroll :ops="ops" style="height: calc(100vh - 310px)">
        <el-timeline>
          <el-timeline-item v-for="item in eventList" :key="item.eventId" :hide-timestamp="false">
            <div class="record-item">
              <p class="time">{{ item.eventTime }}</p>
              <p class="title">{{ item.accountNameFr }}</p>
              <p class="desc">
                {{ item.eventDesc }}
              </p>
            </div>
          </el-timeline-item>
        </el-timeline>
      </vuescroll> -->
      <el-timeline>
        <el-timeline-item v-for="item in eventList" :key="item.eventId" :hide-timestamp="false">
          <div class="record-item">
            <p class="time">{{ item.eventTime }}</p>
            <p class="title">{{ item.accountNameFr }}</p>
            <p class="desc">
              {{ item.eventDesc }}
            </p>
          </div>
        </el-timeline-item>
      </el-timeline>
      <div class="btn-group">
        <el-button class="cancel-btn" @click="dialogVisible = false">关闭</el-button>
      </div>
    </div>
  </el-drawer>
</template>

<script>
import { getTaskEventByTaskId } from '@/api/system/taskEventApi'
import vuescroll from 'vuescroll'

export default {
  name: 'AppListComponent',
  components: {
    // eslint-disable-next-line vue/no-unused-components
    vuescroll
  },
  props: {
    title: {
      type: String,
      default: '操作记录'
    }
  },
  data() {
    return {
      ops: {
        bar: {
          keepShow: false,
          background: 'rgba(144, 147, 153, 0.4)',
          onlyShowBarOnScroll: false
        }
      },
      rules: {},
      dialogVisible: false,
      eventList: []
    }
  },
  mounted() {
  },
  methods: {

    // Fetch Event Data
    getEventList(data) {
      getTaskEventByTaskId(data).then((resp) => {
        const { code, data, msg } = resp
        if (code === 0) {
          this.eventList = data
        } else {
          this.$message.error(msg)
        }
      }).catch((error) => {
        console.log(error)
      })
    },

    // Show Event Dialog
    showTaskEvent(taskId) {
      this.eventList = []
      this.dialogVisible = true
      this.getEventList(taskId)
    }
  }
}
</script>

<style lang="scss">
</style>
<style lang="scss" scoped>
.content-container {
  margin: 15px;
  position: relative;
  height: calc(100% - 15px);

  .el-timeline {
    width: 360px;
    margin: 15px auto 0;
    padding: 0 0 0 90px;
  }

  .record-item {
    position: relative;
    top: -44px;

    .time {
      font-size: 12px;
      font-weight: 400;
      color: #A9BDC9;
      position: absolute;
      left: -165px;
      top: 7px;
    }

    .title {
      font-size: 16px;
      font-weight: 400;
      color: #A9BDC9;
      line-height: 54px;
    }

    .desc {
      font-size: 16px;
      font-weight: 400;
      color: #FFFFFF;
      line-height: 2em;
      margin: 0;
    }

  }

  .btn-group {
    margin-left: 30px;

    .el-button {
      margin: 0 0 15px;
    }

    .cancel-btn {
      background: #004F7B;
      border-color: #004F7B;
      color: #FFF;

      &:hover {
        background: #026197;
        border-color: #026197;
      }
    }
  }

}

</style>
