<template>
  <div class="divBox">
    <el-card class="box-card">
      <!--顶部搜索栏-->
      <div slot="header" class="clearfix">
        <div class="container">
          <el-form inline size="small" label-width="80px">
            <el-form-item label="搜索：">
              <el-input v-model="tableFrom.mer_id" placeholder="请输入商户ID" class="selWidth" clearable></el-input>
              <el-input v-model="tableFrom.uid" placeholder="请输入用户ID" class="selWidth" clearable>
                <el-button slot="append" icon="el-icon-search" class="el-button-solt" @click="searchData" />
              </el-input>
            </el-form-item>
             <el-form-item class="width100">
                <!--<el-button size="small" type="primary" @click="exports">导出</el-button>-->
             </el-form-item>
          </el-form>
          <cards-data :card-lists="cardLists" />
        </div>
      </div>
      <!--列表内容-->
      <el-table v-loading="listLoading" :data="tableData.data" style="width: 100%" size="mini">
        <el-table-column prop="id" label="ID" min-width="50" align="center"/>
        <el-table-column label="用户信息" prop="nickname" min-width="230" align="center">
          <template slot-scope="scope">
            <div class="user-content">
              <div class="user-avatar" v-if="scope.row.avatar && scope.row.avatar != 1">
                <img :src="scope.row.avatar" />
              </div>
              <div class="user-info">
                <div class="nickname">{{ scope.row.nickname }}</div>
                <div class="user-id">ID：{{ scope.row.uid }}</div>
              </div>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="抽成商户" prop="mer_name" min-width="260" align="center">
          <template slot-scope="scope">
            <div class="user-content">
              <div class="user-avatar" v-if="scope.row.mer_avatar" >
                <img :src="scope.row.mer_avatar" />
              </div>
              <div class="user-info">
                <div class="nickname">{{ scope.row.mer_name || '' }}</div>
                <div class="user-id">ID：{{ scope.row.mer_id || 0 }}</div>
              </div>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="订单商品信息" prop="mer_name" min-width="300" align="center">
          <template slot-scope="scope">
            <div class="user-content" v-if="scope.row.storeOrderProduct">
              <div class="user-avatar" v-if="scope.row.storeOrderProduct.image" >
                <img :src="scope.row.storeOrderProduct.image" />
              </div>
              <div class="user-info">
                <div class="nickname">{{ scope.row.storeOrderProduct.store_name || '' }}</div>
                <div class="user-id">订单号：{{ scope.row.storeOrder.order_sn || 0 }}</div>
                <div class="user-id">商品ID：{{ scope.row.storeOrderProduct.product_id || 0 }}</div>
              </div>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="平台抽成" prop="mer_name" min-width="85" align="center">
          <template slot-scope="scope">
            <el-tag type="success" effect="plain" size="small">{{ scope.row.platform_commission_money || '0.00' }}元</el-tag>
            <br />
            <el-tag effect="plain" class="rate-num" size="small">{{ scope.row.platform_commission_rate || '0' }}%</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="平台分佣" prop="mer_name" min-width="85" align="center">
          <template slot-scope="scope">
            <el-tag type="success" effect="plain" size="small">{{ scope.row.commission_platform_money || '0.00' }}元</el-tag>
            <br />
            <el-tag effect="plain" class="rate-num" size="small">{{ scope.row.commission_platform_rate || '0' }}%</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="合伙人分佣" prop="mer_name" min-width="85" align="center">
          <template slot-scope="scope">
            <el-tag type="success" effect="plain" size="small">{{ scope.row.commission_partner_money || '0.00' }}元</el-tag>
            <br />
            <el-tag effect="plain" class="rate-num" size="small">{{ scope.row.commission_partner_rate || '0' }}%</el-tag>
            <br />
            <el-tag v-if="scope.row.commission_partner_status == 0" type="info" effect="dark" class="rate-num" size="small">待结算</el-tag>
            <el-tag v-else-if="scope.row.commission_partner_status == 1" type="success"  effect="dark" class="rate-num" size="small">已结算</el-tag>
            <el-tag v-else-if="scope.row.commission_partner_status == 2" type="danger"  effect="dark" class="rate-num" size="small">无合伙人</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="招商员分佣" prop="mer_name" min-width="85" align="center">
          <template slot-scope="scope">
            <el-tag type="success" effect="plain" size="small">{{ scope.row.commission_merchants_money || '0.00' }}元</el-tag>
            <br />
            <el-tag effect="plain" class="rate-num" size="small">{{ scope.row.commission_merchants_rate || '0' }}%</el-tag>
            <br />
            <el-tag v-if="scope.row.commission_merchants_status == 0" type="info" effect="dark" class="rate-num" size="small">待结算</el-tag>
            <el-tag v-else-if="scope.row.commission_merchants_status == 1" type="success"  effect="dark" class="rate-num" size="small">已结算</el-tag>
            <el-tag v-else-if="scope.row.commission_merchants_status == 2" type="danger"  effect="dark" class="rate-num" size="small">无招商员</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="推广员分佣" prop="mer_name" min-width="85" align="center">
          <template slot-scope="scope">
            <el-tag type="success" effect="plain" size="small">{{ scope.row.commission_promoter_money || '0.00' }}元</el-tag>
            <br />
            <el-tag effect="plain" class="rate-num" size="small">{{ scope.row.commission_promoter_rate || '0' }}%</el-tag>
            <br />
            <el-tag v-if="scope.row.commission_promoter_status == 0" type="info" effect="dark" class="rate-num" size="small">待结算</el-tag>
            <el-tag v-else-if="scope.row.commission_promoter_status == 1" type="success"  effect="dark" class="rate-num" size="small">已结算</el-tag>
            <el-tag v-else-if="scope.row.commission_promoter_status == 2" type="danger"  effect="dark" class="rate-num" size="small">无推广员</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="积分释放" prop="mer_name" min-width="85" align="center">
          <template slot-scope="scope">
            <el-tag type="success" effect="plain" size="small">{{ scope.row.commission_integral_release_money || '0.00' }}元</el-tag>
            <br />
            <el-tag effect="plain" class="rate-num" size="small">{{ scope.row.commission_integral_release_rate || '0' }}%</el-tag>
          </template>
        </el-table-column>
      </el-table>
      <div class="block">
        <el-pagination
          :page-sizes="[20, 40, 60, 80]"
          :page-size="tableFrom.limit"
          :current-page="tableFrom.page"
          layout="total, sizes, prev, pager, next, jumper"
          :total="tableData.total"
          @size-change="handleSizeChange"
          @current-change="pageChange"
        />
      </div>
    </el-card>
  </div>
</template>

<script>
import cardsData from '@/components/cards/index'
import { platformCommissionRecordList, platformCommissionRecordTitle } from '@/api/platformCommission'
export default {
  name: "platformCommissionRecord",
  components: { cardsData },
  data() {
    return {
      listLoading: true,
      tableData: {
        data: [],
        total: 0,
      },
      tableFrom: {
        page: 1,
        limit: 20,
        uid: '',
        mer_id: ''
      },
      loading: false,
      cardLists: [],
    };
  },
  watch: {},
  mounted() {
    this.getIntegralTitle();
    this.getList('');
  },
  methods: {
    // 获取统计数据
    getIntegralTitle() {
      platformCommissionRecordTitle(this.tableFrom).then((res) => {
        this.cardLists = res.data
      }).catch((res) => {
        this.$message.error(res.message)
      })
    },
    // 获取列表 列表分页
    getList(num) {
      this.listLoading = true;
      this.tableFrom.page = num ? num : this.tableFrom.page;
      platformCommissionRecordList(this.tableFrom)
        .then((res) => {
          this.tableData.data = res.data.list;
          this.tableData.total = res.data.count;
          this.listLoading = false;
        })
        .catch((res) => {
          this.listLoading = false;
          this.$message.error(res.message);
        });
    },
    pageChange(page) {
      this.tableFrom.page = page;
      this.getList('');
    },
    handleSizeChange(val) {
      this.tableFrom.limit = val;
      this.getList('');
    },
    // 点击搜索
    searchData(){
      this.getIntegralTitle();
      this.getList(1);
    },
  },
};
</script>

<style scoped lang="scss">
.selWidth {
  width: 350px !important;
}
.seachTiele {
  line-height: 35px;
}
.title{
  margin-bottom: 16px;
  color: #17233d;
  font-size: 14px;
  font-weight: bold;
}
.scollhide::-webkit-scrollbar {
  display: none; /* Chrome Safari */
}
.user-content{
  --user-content-height-: 80px;

  height: var(--user-content-height-);
  width: 100%;
  display: inline-flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  .user-avatar{
    height: var(--user-content-height-);
    width: var(--user-content-height-);
    display: inline-flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: center;
    img{
      height: 80%!important;
      width: 80%!important;
      border-radius: 50% !important;
    }
  }
  .user-info{
    height: var(--user-content-height-);
    width: calc(100% - var(--user-content-height-)) !important;
    display: inline-flex;
    flex-direction: column;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: flex-start;
    .nickname{
      font-size: 15px;
      font-weight: bold;
      line-height: calc(var(--user-content-height- * 65%)) !important;
      width: 100%;
      text-align: left;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .user-id{
      font-size: 13px;
      line-height: calc(var(--user-content-height- * 35%));
    }
  }
}
.rate-num{
  margin-top: 10px!important;
}
/deep/ .cell{
  padding: 0!important;
}
</style>
