<template>
  <div  style="flex: 1;margin-bottom: 10px">
    <Card style="width:100%">
      <div class="config_meta">
        <p class="fl">
          待编证书
        </p>
        <div class="fr">
          <ButtonGroup shape="circle" size="small">
            <Button
              v-for="(item,index) in buttonList"
              :key="index"
              :class="{buttonActive :activityIndex === index}"
              @click.stop="_buttonChange(index)"
              type="primary"
            >
              {{ item }}
            </Button>
          </ButtonGroup>
        </div>
        <div class="clear" />
      </div>
      <div class="config_footer">
        <div>
          <span @click="_toWrite()" style="color: #00b5ec;cursor: pointer;" class="fl">{{ num }}</span>
          <div class="clear" />
        </div>
      </div>
    </Card>
  </div>
</template>

<script>
import Global from '../../../api/config'
import { meterSample } from '../../../api'
export default {
  data() {
    return {
      buttonList: ['本月', '本周', '今天'],
      activityIndex: 2, // 按钮0:本月  1：本周   2：当天
      type: 0,
      num: 0
    }
  },
  mounted() {
    if (Global.getLn()) {
      this._request()
    }
  },
  methods: {
    _toWrite() {
      this.$router.push('/meter/certificate/certificate_make')
    },
    _request: async function() {
      // type  请求 0:当天  1：本周   2：本月
      const result = await meterSample.makingCount({ type: this.type })
      if (result) {
        this.num = result
      }
    },
    _buttonChange(index) {
      this.activityIndex = index
      switch (index) {
        case 0:
          this.type = 2
          break
        case 1:
          this.type = 1
          break
        case 2:
          this.type = 0
          break
      }
      // this._request();
    }
  }
}
</script>
