<template>	
  <button class="leads-item" @click="handleDetail">
    <view class="cell">
      <text class="cell-left name">
        {{ itemData.leadsName }}
      </text>
      <text class="cell-right" />
    </view>
		
    <view class="cell">
      <text class="cell-left time">
        最后跟进时间：{{ itemData.lastTime | formatTime }}
      </text>
      <text class="cell-right status">
        {{ itemData.ownerUserName }}
      </text>
    </view>
  </button>
</template>

<script>
  import moment from 'moment'
	
  export default {
    name: 'LeadsItem',
    filters: {
      formatTime(val) {
        if (!val) return '--'
        return moment(val).format('YYYY-MM-DD')
      }
    },
    props: {
      itemData: {
        type: Object,
        required: true
      }
    },
    methods: {
      /**
       * 线索详情跳转
       */
      handleDetail() {
        if (!this.$auth('crm.leads.read')) {
          this.$toast('权限不足')
          return
        }
        this.$Router.navigateTo({
          url: '/pages_crm/leads/detail',
          query: {
            id: this.itemData.leadsId
          }
        })
      }
    }
  }
</script>

<style scoped lang="scss">
  @import "../../style/listItem";

  .leads-item {
    border-bottom: 1rpx solid $border-color;
    background-color: white;
    padding: 20rpx 32rpx;
		
    .cell {
      .name {
        font-size: 32rpx;
				color: #212121;
        @include ellipsis;
      }

      .time, .status {
        font-size: 26rpx;
        color: $gray;
      }
    }
  }
</style>
