<template>
  <div class="tableTitle">
    <div class="tableTitleBox">
      <span class="tableFloatLine"></span>
      <div>{{name}}</div>
    </div>
    <div class="addContacts">
      <img src="@/assets/chat/addcontacts.png" @click="handleAddUser" v-if="iconStatus==1">
      <i class="el-icon-close" @click="closeAddUser" v-else></i>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    name: {
      type: String,
      required: true,
    },
  },
  data() {
    return {
      someData: '',
      iconStatus: 1,//1=添加好友 2=关闭
    };
  },
  methods: {
    handleAddUser() {
      this.iconStatus = 2;
      this.$emit('addUser'); // Emit an event to notify the parent
    },
    closeAddUser(){
      this.iconStatus = 1;
      this.$emit('closeAddUser');
    }
  }
};
</script>

<style scoped lang="less">
  .tableTitle {
    color:#333333;
    position: relative;
    padding-bottom: 20px;
    padding-top: 37px;
    padding-right: 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    img {
      cursor: pointer;
    }
    .tableFloatLine {
      width: 3px;
      height:16px;
      background:#5570F1;
      display: inline-block;
    }
    .tableTitleBox {
      display: flex;
      align-items: center;
      font-size: 18px;
      font-weight: bold;
      span {
        margin-right: 25px;
      }
    }
    .addContacts {
      width: 28px;
      height: 28px;
      background: #EFEFEF;
      border-radius: 8px;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
    }
  }
</style>
