<template>
  <div class="fl-c">
    <flexbox class="fl-h">
      <div v-photo="data.create_user_info"
           v-lazy:background-image="$options.filters.filterUserLazyImg(data.create_user_info.thumb_img)"
           :key="data.create_user_info.thumb_img"
           class="div-photo fl-h-img"></div>
      <div class="fl-h-b">
        <div class="fl-h-name">{{data.create_user_info.realname}}</div>
        <div class="fl-h-time">{{data.create_time|filterTimestampToFormatTime}}</div>
      </div>
      <el-dropdown @command="handleCommand"
                   trigger="click">
        <i style="color:#CDCDCD;"
           class="el-icon-arrow-down el-icon-more"></i>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item command="edit">编辑</el-dropdown-item>
          <el-dropdown-item command="delete">删除</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </flexbox>
    <div class="fl-b">
      <div>
        <div class="state-color"
             :style="{'background-color': data.color ? data.color : '#fff'}"></div>{{data.title}}
      </div>
      <div class="fl-b-des">
        <flexbox class="fl-b-des-item">
          <div class="fl-b-des-item-name">参与人：</div>
          <div class="owner-list">
            <span v-for="(k, j) in data.ownerList"
                  :key="j">
              <el-tooltip placement="bottom"
                          effect="light"
                          popper-class="tooltip-change-border">
                <div slot="content">
                  <span>{{k.realname}}</span>
                </div>
                <div v-photo="k"
                     :key="k.thumb_img"
                     v-lazy:background-image="$options.filters.filterUserLazyImg(k.thumb_img)"
                     class="div-photo header-circle"></div>
              </el-tooltip>
            </span>
          </div>
        </flexbox>
        <flexbox class="fl-b-des-item">
          <div class="fl-b-des-item-name">开始时间：</div>
          <div>{{data.start_time | moment("YYYY-MM-DD HH:mm:ss")}}</div>
        </flexbox>
        <flexbox class="fl-b-des-item">
          <div class="fl-b-des-item-name">结束时间：</div>
          <div>{{data.end_time | moment("YYYY-MM-DD HH:mm:ss")}}</div>
        </flexbox>
        <flexbox class="fl-b-des-item">
          <div class="fl-b-des-item-name">备注：</div>
          <div>{{data.remark}}</div>
        </flexbox>
      </div>
      <!-- 关联业务 -->
      <div class="related-business"
           v-if="data.contactsList.length > 0 || data.customerList.length > 0 || data.businessList.length > 0 || data.contractList.length > 0">
        <div class="label">关联业务</div>
        <p v-for="(contacts, i) in data.contactsList"
           :key="'contacts' + i"
           @click="checkRelatedDetail('contacts',contacts)">
          <img src="@/assets/img/relevance_business.png"
               alt="">
          联系人-{{contacts.name}}
        </p>
        <p v-for="(customer, i) in data.customerList"
           :key="'customer' + i"
           @click="checkRelatedDetail('customer',customer)">
          <img src="@/assets/img/relevance_business.png"
               alt="">
          客户-{{customer.name}}
        </p>
        <p v-for="(business, i) in data.businessList"
           :key="'business' + i"
           @click="checkRelatedDetail('business',business)">
          <img src="@/assets/img/relevance_business.png"
               alt="">
          商机-{{business.name}}
        </p>
        <p v-for="(contract, i) in data.contractList"
           :key="'contract' + i"
           @click="checkRelatedDetail('contract',contract)">
          <img src="@/assets/img/relevance_business.png"
               alt="">
          合同-{{contract.name}}
        </p>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  /** 客户管理 的 客户详情 的 任务cell */
  name: 'follow-schedule-cell',
  components: {},
  props: {
    data: Object
  },
  data() {
    return {}
  },
  filters: {
    getRemindtypeText: function(remindtype) {
      switch (remindtype) {
        case 0:
          return '无'
          break
        case 1:
          return '准时提醒'
          break
        case 2:
          return '5分钟前'
          break
        case 3:
          return '15分钟前'
          break
        case 4:
          return '30分钟前'
          break
        case 5:
          return '一个小时前'
          break
        case 6:
          return '二个小时前'
          break
        case 7:
          return '一天前'
          break
        case 8:
          return '二天前'
          break
        case 9:
          return '一周前'
          break
      }
      return ''
    }
  },
  computed: {},
  mounted() {},
  methods: {
    // 关联详情
    checkRelatedDetail(type, data) {
      this.$emit('on-handle', {
        type: 'related-detail',
        data: { type: type, item: data }
      })
    },
    handleCommand(command) {
      this.$emit('on-handle', {
        type: command,
        data: { item: this.data }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
@import '../styles/followcell.scss';
.fl-h-state {
  width: auto;
  .fl-h-state-mark {
    margin-right: 8px;
    width: 10px;
    height: 10px;
    border-radius: 5px;
  }
  .fl-h-state-name {
    font-size: 13px;
    color: #333;
  }
}

.el-checkbox /deep/ .el-checkbox__label {
  font-size: 13px;
}

.fl-b-des {
  margin: 15px 0;
  .fl-b-des-item {
    font-size: 12px;
    color: #777;
    margin: 8px 0;
    .fl-b-des-item-name {
      width: 60px;
      margin-right: 10px;
    }
  }
}

.state-color {
  width: 15px;
  height: 15px;
  display: inline-block;
  border-radius: 7.5px;
  margin-right: 2px;
}

// 关联业务
.related-business {
  margin: 15px 0;
  .label {
    font-size: 13px;
    margin-bottom: 7px;
  }
  p {
    cursor: pointer;
    color: #3e84e9;
    background: #f5f7fa;
    line-height: 30px;
    margin-bottom: 5px;
    font-size: 13px;
    padding-left: 7px;
    border-radius: 2px;
    img {
      width: 16px;
      vertical-align: middle;
    }
  }
}

// 参与人
.owner-list {
  display: inline-block;
  vertical-align: middle;
  span {
    display: inline-block;
  }
  .div-photo {
    width: 25px;
    height: 25px;
    margin-right: 10px;
  }
}
</style>
