<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.object_id" placeholder="请输入运营中心角色ID" class="selWidth" clearable />
              <el-select v-model="tableFrom.pay_status" class="selWidth" clearable>
                <el-option label="未交费" :value="0"></el-option>
                <el-option label="已缴费" :value="1"></el-option>
                <el-option label="已退款" :value="2"></el-option>
              </el-select>
              <el-select v-model="tableFrom.pay_type" class="selWidth" clearable>
                <el-option label="定金" :value="1"></el-option>
                <el-option label="尾款" :value="2"></el-option>
                <el-option label="保证金" :value="3"></el-option>
              </el-select>
            </el-form-item>
          </el-form>
          <el-button size="small" type="primary" @click="getList(1)">搜索</el-button>
        </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="200" align="center">
          <template slot-scope="scope">
            <div class="user-content">
              <div class="user-avatar">
                <img :src="scope.row.user.avatar || moren" />
              </div>
              <div class="user-info">
                <div class="nickname">{{ scope.row.user.nickname }}</div>
                <div class="user-id">ID：{{ scope.row.user.uid }}</div>
              </div>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="运营中心身份" min-width="200" align="center">
          <template slot-scope="scope">
            <div class="user-content" v-if="scope.row.agent">
              {{ scope.row.agent.agent_type_text || '' }}
            </div>
          </template>
        </el-table-column>
        <el-table-column label="缴费类型" min-width="100" align="center">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.pay_type == 1">定金</el-tag>
            <el-tag v-else-if="scope.row.pay_type == 2">尾款</el-tag>
            <el-tag v-else-if="scope.row.pay_type == 3">保证金</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="缴费金额" prop="money" min-width="100" align="center"/>
        <el-table-column label="状态" min-width="100" align="center">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.pay_status == 0" type="info">未缴费</el-tag>
            <el-tag v-else-if="scope.row.pay_status == 1" type="success">已缴费</el-tag>
            <el-tag v-else-if="scope.row.pay_status == 2" type="warning">已退款</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="缴费时间" prop="pay_time" min-width="150" align="center"/>
        <!--<el-table-column label="操作" min-width="150" fixed="right" align="center">-->
        <!--  <template slot-scope="scope">-->
        <!--    <el-button v-if="scope.row.status == 1" type="text" size="small" class="mr10" @click="allocationOrder(scope.row)">分配</el-button>-->
        <!--  </template>-->
        <!--</el-table-column>-->
      </el-table>
      <!--分页-->
      <div class="block">
        <el-pagination :page-size="tableFrom.limit" :current-page="tableFrom.page" :total="tableData.total" @current-change="pageChange" />
      </div>
    </el-card>
  </div>
</template>

<script>
import { agentPayRecord } from '@/api/marketing'
export default {
  name: "preSaleProductList",
  components: { },
  data() {
    return {
      moren: require("@/assets/images/f.png"),
      listLoading: true,
      tableData: {
        data: [],
        total: 0,
      },
      tableFrom: {
        page: 1,
        limit: 20,
        object_id: '',
        pay_status: '',
        pay_type: '',
      },




    };
  },
  watch: {},
  mounted() {
    this.getList('');
  },
  methods: {
    // 获取列表
    getList(num) {
      let _this = this;
      _this.listLoading = true;
      _this.tableFrom.page = num ? num : this.tableFrom.page;
      agentPayRecord(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('');
    },



  },
};
</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{
    height: var(--user-content-height-);
    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%));
    }
    .user-id{
      font-size: 13px;
      line-height: calc(var(--user-content-height- * 35%));
    }
  }
}
</style>
