<template>
  <div>
    <van-cell-group>
      <van-cell :title="ActivityLogInfo.name" title-class="ml10" :is-link="isEdit" value-class="text-left" @click="toEdit">
        <van-icon slot="icon" :name="ActivityLogInfo.avatarUrl || defaultAcatarUrl" style="line-height: inherit;" size="22" />
        <span class="mr20">{{ ActivityLogInfo.age }}岁</span>
        <span>{{ ActivityLogInfo.type == 0 ? '同业' : '白板' }}</span>
        <van-icon slot="right-icon" name="edit" style="line-height: inherit;" :color="isEdit ? '#ee0a24' : 'transparent'" size="24" />
      </van-cell>
    </van-cell-group>
  </div>
</template>
<script>
import formatDate from '@/assets/js/utils/date-utils'
import { Cell, CellGroup, Image } from 'vant'

export default {
  components: {
    [Cell.name]: Cell,
    [CellGroup.name]: CellGroup,
    [Image.name]: Image
  },
  props: {
    ActivityLogInfo: {
      type: Object,
      required: true,
      default: () => {
        return {
          recordCode: '',
          name: '王辉',
          // avatarUrl: 'https://img.yzcdn.cn/vant/cat.jpeg',
          age: '35岁',
          type: '同业',
          recordDate: ''
        }
      }
    }
  },
  data() {
    return {
      defaultAcatarUrl: 'https://b.yzcdn.cn/vant/icon-demo-1126.png'
    }
  },
  methods: {
    toEdit() {
      this.$jump({
        flag: 'h5',
        extra: {
          url: location.origin + `/#/manpower/ActivityLog/Edit?code=${this.ActivityLogInfo.recordCode}&isEdit=${this.isEdit ? '0' : '1'}`,
          forbidSwipeBack: '1',
          needRefresh: '1'
        },
        routerInfo: { path: `/manpower/ActivityLog/Edit?code=${this.ActivityLogInfo.recordCode}&isEdit=${this.isEdit ? '0' : '1'}` }
      })
    }
  },
  computed: {
    isEdit() {
      if (this.ActivityLogInfo.recordDate === formatDate.formatDate().split(' ')[0]) {
        return true
      } else {
        return false
      }
    }
  }
}
</script>
