<template>
  <div class="detail">
    <Card dis-hover :padding="30">
      <p slot="title">基础信息</p>
      <Row>
        <Col span="8">活动日期：{{ row.activity_date | format }}</Col>
        <Col span="8">可获得真我币：{{ row.expense_amount }}</Col>
        <Col span="8">签到人数：{{ row.sign_in_num }}</Col>
      </Row>
    </Card>

    <div class="pc-main">
      <Card dis-hover :padding="30">
        <p slot="title">参与用户</p>
        <div class="topSearch">
          <div class="left">
            用户搜索：
            <Input
              v-model="name"
              style="width:200px"
              enter-button
              placeholder="请输入"
            />
            <Button type="primary">查 询</Button>
          </div>
        </div>
        <Table
          :loading="$store.state.app.isLoading"
          border
          ref="selection"
          :columns="columns"
          :data="data"
        >
          <template slot-scope="{ row }" slot="default_avatar">
            <Avatar :src="row.default_avatar" />
          </template>
          <template slot-scope="{ row }" slot="apply_time">
            {{ row.apply_time | format }}
          </template>
          <template slot-scope="{ row }" slot="clock_time">
            {{ row.clock_time | format }}
          </template>
          <template slot-scope="{ row }" slot="action">
            <a @click="edit(row)">编辑</a>
          </template>
        </Table>
        <Pager
          class="margin-top-10"
          :config="config"
          @on-change="handlePager"
        ></Pager>
      </Card>
    </div>
    <div class="btn">
      <Button type="primary" @click="$router.go(-1)">返回</Button>
    </div>
  </div>
</template>

<script>
import { formatDate } from "@/libs/util";
import { activityClockRecords } from "@/api/clock/activityClocks";
import Pager from "@/view/common/Pager.vue";
export default {
  name: "categories",
  components: {
    Pager
  },
  filters: {
    format(value) {
      return formatDate(value);
    }
  },
  data() {
    return {
      config: { total: 0, size: 10, current: 1 },
      name: "",
      tab: "1",
      pageIndex: 1,
      pageSize: 10,
      row: this.$route.query.row,
      data: [],
      columns: [
        {
          title: "用户ID",
          key: "uuid"
        },
        {
          title: "头像",
          slot: "default_avatar"
        },
        {
          title: "姓名",
          key: "nick_name"
        },
        {
          title: "手机号",
          key: "phone"
        },
        {
          title: "报名时间",
          slot: "apply_time"
        },
        {
          title: "打卡时间",
          slot: "clock_time"
        },
        {
          title: "获得真我币",
          key: "expense_amount"
        }
      ]
    };
  },
  methods: {
    handlePager(pager) {
      this.pageIndex = pager.current;
      this.pageSize = pager.size;
      this.search();
    },
    search() {
      let params = {
        name: this.name,
        uuid: this.row.uuid,
        pageIndex: this.pageIndex,
        pageSize: this.pageSize
      };
      activityClockRecords(params).then(res => {
        this.config.total = res.total;
        this.data = res.data;
      });
    }
  },
  mounted() {
    this.search();
  }
};
</script>

<style lang="less" scoped>
.pc-main {
  padding: 20px;
  margin-top: 20px;
  background-color: #fff;
}
.btn {
  text-align: right;
  width: 80%;
  position: fixed;
  background-color: #fff;
  bottom: 10px;
  padding: 10px 30px;
}
</style>
