<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.staff_uid" placeholder="请输入员工UID" class="selWidth" clearable />
              <el-input v-model="tableFrom.store_uid" placeholder="请输入门店负责人UID" class="selWidth" clearable />
              <el-input v-model="tableFrom.area_uid" placeholder="请输入区县合伙人UID" class="selWidth" clearable />
              <el-input v-model="tableFrom.area_store_uid" placeholder="请输入区县运营商UID" class="selWidth" clearable />
              <el-input v-model="tableFrom.delivery_uid" placeholder="请输入配送商UID" class="selWidth" clearable />
              <el-input v-model="tableFrom.province_uid" placeholder="请输入省发起人UID" class="selWidth" clearable>
                <el-button slot="append" icon="el-icon-search" class="el-button-solt" @click="getList(1)" />
              </el-input>
            </el-form-item>
          </el-form>
        </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="订单信息" min-width="180" align="center">
          <template slot-scope="scope">
            <div class="order-content">
              <template v-if="scope.row.source == 1">
                邀请代理奖励 <br />
                {{ scope.row.storeOrder ? scope.row.storeOrder.order_sn : ''}}
              </template>
              <template v-else>
                {{ scope.row.userOrder ? scope.row.userOrder.title : ''}} <br />
                {{ scope.row.userOrder ? scope.row.userOrder.order_sn : ''}}
              </template>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="员工佣金" min-width="200" align="center">
          <template slot-scope="scope">
            <div class="user-content">
              <div class="user-avatar" v-if="scope.row.staff">
                <img :src="scope.row.staff.avatar || moren" />
              </div>
              <div class="user-info">
                <div class="nickname" v-if="scope.row.staff">
                  {{ scope.row.staff.nickname }}
                  <div class="user-id">{{ scope.row.staff.uid }}</div>
                </div>
                <div class="agent-type-text">
                  <el-tag type="info" effect="dark" size="small">{{ scope.row.staff_brokerage || 0.00 }}</el-tag>
                </div>
              </div>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="门店佣金" min-width="200" align="center">
          <template slot-scope="scope">
            <div class="user-content">
              <div class="user-avatar" v-if="scope.row.store">
                <img :src="scope.row.store.avatar || moren" />
              </div>
              <div class="user-info">
                <div class="nickname" v-if="scope.row.store">
                  {{ scope.row.store.nickname }}
                  <div class="user-id">{{ scope.row.store.uid }}</div>
                </div>
                <div class="agent-type-text">
                  <el-tag type="info" effect="dark" size="small">{{ scope.row.store_brokerage || 0.00 }}</el-tag>
                </div>
              </div>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="区县合伙人佣金" min-width="200" align="center">
          <template slot-scope="scope">
            <div class="user-content">
              <div class="user-avatar" v-if="scope.row.area">
                <img :src="scope.row.area.avatar || moren" />
              </div>
              <div class="user-info">
                <div class="nickname" v-if="scope.row.area">
                  {{ scope.row.area.nickname }}
                  <div class="user-id">{{ scope.row.area.uid }}</div>
                </div>
                <div class="agent-type-text">
                  <el-tag type="info" effect="dark" size="small">{{ scope.row.area_brokerage || 0.00 }}</el-tag>
                </div>
              </div>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="区县运营商佣金" min-width="200" align="center">
          <template slot-scope="scope">
            <div class="user-content">
              <div class="user-avatar" v-if="scope.row.areaStore">
                <img :src="scope.row.areaStore.avatar || moren" />
              </div>
              <div class="user-info">
                <div class="nickname" v-if="scope.row.areaStore">
                  {{ scope.row.areaStore.nickname }}
                  <div class="user-id">{{ scope.row.areaStore.uid }}</div>
                </div>
                <div class="agent-type-text">
                  <el-tag type="info" effect="dark" size="small">{{ scope.row.area_store_brokerage || 0.00 }}</el-tag>
                </div>
              </div>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="配送商佣金" min-width="200" align="center">
          <template slot-scope="scope">
            <div class="user-content">
              <div class="user-avatar" v-if="scope.row.delivery">
                <img :src="scope.row.delivery.avatar || moren" />
              </div>
              <div class="user-info">
                <div class="nickname" v-if="scope.row.delivery">
                  {{ scope.row.delivery.nickname }}
                  <div class="user-id">{{ scope.row.delivery.uid }}</div>
                </div>
                <div class="agent-type-text">
                  <el-tag type="info" effect="dark" size="small">{{ scope.row.delivery_brokerage || 0.00 }}</el-tag>
                </div>
              </div>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="省发起人佣金" min-width="200" align="center">
          <template slot-scope="scope">
            <div class="user-content">
              <div class="user-avatar" v-if="scope.row.province">
                <img :src="scope.row.province.avatar || moren" />
              </div>
              <div class="user-info">
                <div class="nickname" v-if="scope.row.province">
                  {{ scope.row.province.nickname }}
                  <div class="user-id">{{ scope.row.province.uid }}</div>
                </div>
                <div class="agent-type-text">
                  <el-tag type="info" effect="dark" size="small">{{ scope.row.province_brokerage || 0.00 }}</el-tag>
                </div>
              </div>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="总部发起人佣金" min-width="200" align="center">
          <template slot-scope="scope">
            <div class="user-content">
              <div class="user-avatar" v-if="scope.row.initiator">
                <img :src="scope.row.initiator.avatar || moren" />
              </div>
              <div class="user-info">
                <div class="nickname" v-if="scope.row.initiator">
                  {{ scope.row.initiator.nickname }}
                  <div class="user-id">{{ scope.row.initiator.uid }}</div>
                </div>
                <div class="agent-type-text">
                  <el-tag type="info" effect="dark" size="small">{{ scope.row.initiator_brokerage || 0.00 }}</el-tag>
                </div>
              </div>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="省公司外勤佣金" min-width="200" align="center">
          <template slot-scope="scope">
            <div class="user-content">
              <div class="user-avatar" v-if="scope.row.fieldStaff">
                <img :src="scope.row.fieldStaff.avatar || moren" />
              </div>
              <div class="user-info">
                <div class="nickname" v-if="scope.row.fieldStaff">
                  {{ scope.row.fieldStaff.nickname }}
                  <div class="user-id">{{ scope.row.fieldStaff.uid }}</div>
                </div>
                <div class="agent-type-text">
                  <el-tag type="info" effect="dark" size="small">{{ scope.row.field_staff_brokerage || 0.00 }}</el-tag>
                </div>
              </div>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="平台佣金" prop="platform_brokerage" min-width="130" align="center"/>
        <el-table-column label="下单时间" prop="create_time" min-width="150" align="center"/>
      </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 {commissionList } from '@/api/marketing'
export default {
  name: "preSaleProductList",
  components: { },
  data() {
    return {
      listLoading: true,
      tableData: {
        data: [],
        total: 0,
      },
      tableFrom: {
        page: 1,
        limit: 20,
        staff_uid: '',
        store_uid: '',
        area_uid: '',
        area_store_uid: '',
        delivery_uid: '',
        province_uid: '',
      },
    };
  },
  watch: {},
  mounted() {
    this.getList('');
  },
  methods: {
    // 获取列表
    getList(num) {
      let _this = this;
      this.listLoading = true;
      this.tableFrom.page = num ? num : this.tableFrom.page;
      commissionList(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('');
    },

  },
};
</script>

<style scoped lang="scss">
/deep/ .el-table .cell{
  padding: 0!important;
}
.selWidth{
  margin-bottom: 10px!important;
}
.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{
    max-width: calc(100% - var(--user-content-height-));
    height: var(--user-content-height-);
    display: inline-flex;
    flex-direction: column;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: flex-start;
    .nickname{
      width: 100%;
      height: 25px;
      line-height: 25px;
      text-align: left;
      font-size: 15px;
      font-weight: bold;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      display: inline-flex;
      flex-direction: row;
      flex-wrap: nowrap;
      justify-content: flex-start;
      align-items: center;
      .user-id{
        color: #fff;
        background-color: #409eff;
        border-color: #409eff;
        height: 18px;
        line-height: 20px;
        font-size: 13px;
        padding: 0 5px;
        border-radius: 5px;
        margin-left: 10px;
        width: max-content!important;
      }
    }
    .user-id{
      font-size: 13px;
      line-height: calc(var(--user-content-height- * 35%));
    }
  }
}
</style>
