<style>
.LianMengManagement ._icon_btn i {
    width: 30px;
    height: 30px;
    display: inline-block;
    color: white !important;
    border-radius: 50%;
    text-align: center;
    line-height: 28px;
    margin-right: 10px;
    cursor: pointer;
    outline: none;
}
.LianMengManagement ._icon_btn i.icon-guanli2{background-color: #E95252;}
</style>
<template>
  <div class="LianMengManagement">
    <table class="singeRowTable" border="0" cellspacing="0" cellpadding="0" v-loading="loading">
      <tr>
        <th>客户名称</th>
        <th>{{$t('hotel.suplier_contact')}}</th>
        <th>{{$t('hotel.table_tel')}}</th>
        <th>是否是会员</th>
        <th>{{$t('system.table_operation')}}</th>
      </tr>
      <tr v-for="item in dataList">
         <td>{{item.CustomerName}} <span v-if="item.IsMain == 1"  style="color: #E95252">(主)</span> </td>
         <td>{{item.Contact}}</td>
         <td>{{item.ContactNumber}}</td>
         <td>{{item.IsMember == 1 ? '是' : '否'}}</td>
         <td class="_icon_btn">
            <el-tooltip class="item" effect="dark" content="设置主门店" placement="top">
              <i class="iconfont icon-guanli2"@click="setAdmin(item)"></i>
            </el-tooltip>
              <el-tooltip class="item" effect="dark" content="移除门店" placement="top">
              <i class="iconfont icon-img_delete_small icon-guanli2" @click="DelAllianceChild(item)"></i>
            </el-tooltip>
          </td>
      </tr>
    </table>
    <div class="noDataNotice" v-if="dataList.length<1">
      <i class="iconfont icon-kong"></i>
      <p>{{$t("active.ld_noData")}}</p>
    </div> 
  </div>
</template>
<script> 
export default { 
  data(){
    return{
      loading: false,
      dataList: [],
      msg: {
        pageIndex: 1,
        pageSize: 10,
        AllianceName: '',
        Contact: '',
      },
    }
  },mounted() {
    let id = this.$route.query.id;
    this.getList(id);
  },methods: {
    setAdmin: function(obj) {
      let ParentId = this.$route.query.id
      this.$confirm('确认设置“'+ obj.CustomerName + '”为主门店？', this.$t('tips.tips'), {
        confirmButtonText: this.$t('pub.sureBtn'),
        cancelButtonText: this.$t('pub.cancelBtn'),
        type: 'warning'
      }).then(() => {
        this.apipost(
          "app_customer_UpdateIsMain",
          {ParentId: ParentId, Id: obj.ID},
          res => {
            if (res.data.resultCode === 1) {
              this.$message.success(res.data.message)
              this.getList(ParentId);
            }
          },
          null
        );
      }).catch(() => {
        this.$message({
          type: 'info',
          message: this.$t('OrderList.orderStatus.cancel'),
        });          
      });
    },
     DelAllianceChild: function(obj) {
      let ParentId = this.$route.query.id
      this.$confirm('确认移除“'+ obj.CustomerName + '”门店？', this.$t('tips.tips'), {
        confirmButtonText: this.$t('pub.sureBtn'),
        cancelButtonText: this.$t('pub.cancelBtn'),
        type: 'warning'
      }).then(() => {
        this.apipost(
          "app_customer_DelAllianceChild",
          { Id: obj.ID},
          res => {
            if (res.data.resultCode === 1) {
              this.$message.success(res.data.message)
              this.getList(ParentId);
            }
          },
          null
        );
      }).catch(() => {
        this.$message({
          type: 'info',
          message: this.$t('OrderList.orderStatus.cancel'),
        });          
      });
    },
    getList: function (id) {
      this.loading = true
      this.apipost('app_customer_GetAlianceCustomerList', {Id: id}, res=>{
        if (res.data.resultCode === 1) {
          this.loading = false;
          this.dataList = res.data.data; 
        }
      }, null)
    },
  }
}
</script>
