<template>
  <!-- 负卡金 -->
  <div>
    <div>
      <el-button size="mini" type="primary" @click="refresh" style="margin-left: 95%;">刷新</el-button>
    </div>
    <br>
    <div class="div_content">
      <!-- 充值表格 -->
      <div>
        <el-table :data="tableDate" 
          :header-cell-style="{ background: 'linear-gradient(#6cb3ff, #1873d4)', color: '#eeeeee' }" style="margin-bottom: 10%;width: 90%;
    margin-left: 5%;">
          <el-table-column align="center" label="充值">
            <el-table-column align="center" prop="openning" label="期初"></el-table-column>
            <el-table-column align="center" label="收入">
              <el-table-column align="center" prop="rechargeMoney" label="充值开卡" min-width="50"></el-table-column>
              <el-table-column align="center" prop="rechargeRepay" label="充值还款" min-width="50"></el-table-column>
              <el-table-column align="center" prop="courseTurnRecharge" label="疗程转充值" min-width="50"></el-table-column>
              <el-table-column align="center" prop="cashRefund" label="消费退" min-width="50"></el-table-column>
              <el-table-column align="center" prop="groupPurchase" label="团购卡" min-width="50"></el-table-column>
              <el-table-column align="center" prop="init" label="初始化" min-width="50"></el-table-column>
            </el-table-column>
            <el-table-column align="center" label="支出">
              <el-table-column align="center" prop="courseMoney" label="疗程开卡" min-width="50"></el-table-column>
              <el-table-column align="center" prop="rechargeRepayMoney" label="充值还款" min-width="50"></el-table-column>
              <el-table-column align="center" prop="cashMoney" label="收银" min-width="50"></el-table-column>
              <el-table-column align="center" prop="coursePromotion" label="疗程促销" min-width="50"></el-table-column>
              <el-table-column align="center" prop="rechargeRefundMoney" label="充值退" min-width="50"></el-table-column>
            </el-table-column>
            <el-table-column align="center" prop="balance" label="结存" min-width="50"></el-table-column>
          </el-table-column>
        </el-table>
      </div>
      <!-- 疗程表格 -->
      <div>
        <el-table :data="tableDate1" 
          :header-cell-style="{ background: 'linear-gradient(#6cb3ff, #1873d4)', color: '#eeeeee' }" style="margin-bottom: 10%; width: 90%;
    margin-left: 5%;">
          <el-table-column align="center" label="疗程">
            <el-table-column align="center" prop="openning" label="期初"></el-table-column>
            <el-table-column align="center" label="收入">
              <el-table-column align="center" prop="courseMoney" label="疗程开卡" min-width="50"></el-table-column>
              <el-table-column align="center" prop="courseRepay" label="还款" min-width="50"></el-table-column>
              <el-table-column align="center" prop="cashRefund" label="消费退" min-width="50"></el-table-column>
              <el-table-column align="center" prop="coursePromotion" label="疗程促销" min-width="50"></el-table-column>
              <el-table-column align="center" prop="init" label="初始化" min-width="50"></el-table-column>
              <el-table-column align="center" prop="courseTurnStore" label="疗程转门店" min-width="50"></el-table-column>
              <el-table-column align="center" prop="cardChange" label="加价转疗程" min-width="50"></el-table-column>
            </el-table-column>
            <el-table-column align="center" label="支出">
              <el-table-column align="center" prop="courseRepayMoney" label="还款" min-width="50"></el-table-column>
              <el-table-column align="center" prop="cashMoney" label="收银" min-width="50"></el-table-column>
              <el-table-column align="center" prop="courseRefundMoney" label="疗程退" min-width="50"></el-table-column>
              <el-table-column align="center" prop="courseTurnCharge" label="疗程转充值" min-width="50"></el-table-column>
              <el-table-column align="center" prop="courseTurnStoreMoney" label="疗程转门店" min-width="50">
              </el-table-column>
            </el-table-column>
            <el-table-column align="center" prop="balance" label="结存" min-width="50"></el-table-column>
          </el-table-column>
        </el-table>
      </div>
      <!-- <div style="width: 48%; margin-left: 2%;">

        <el-table :data="tableDate1" show-summary
          :header-cell-style="{ background: 'linear-gradient(#6cb3ff, #1873d4)', color: '#eeeeee' }"
          style="margin-bottom: 10%;">
          <el-table-column align="center" label="疗程">
            <el-table-column align="center" prop="type" label="类别"></el-table-column>
            <el-table-column align="center" prop="beginning" label="期初" min-width="50"></el-table-column>
            <el-table-column align="center" prop="earnings" label="收入" min-width="50"></el-table-column>
            <el-table-column align="center" prop="expenditure" label="支出" min-width="50"></el-table-column>
            <el-table-column align="center" prop="balance" label="结存" min-width="50"></el-table-column>
          </el-table-column>
        </el-table>
      </div> -->
    </div>

  </div>

</template>

<script>
import { partten } from "../../../../partten/index";
import { dayStatisticRecharge, dayStatisticTreatment } from "../../../api/statistics.js";
export default {
  data() {
    return {
      tableDate: [],
      tableDate1: [],
    };
  },
  methods: {
    dayStatisticRecharge() {
      dayStatisticRecharge({ date: partten.dayStatisticDate }).then((res) => {
        if (res.code == "000000") {
          var arr=[];
          arr.push(res.data)
          this.tableDate = arr;
        } else {
          this.$alert(res.message, "提示", {
            confirmButtonText: "确定",
            confirmButtonClass: "confirmbtnFalses",
            type: "warning",
            center: true,
            callback: (action) => { },
          });
        }
      });
    },
    dayStatisticTreatment() {
      dayStatisticTreatment({ date: partten.dayStatisticDate }).then((res) => {
        if (res.code == "000000") {
          var arr=[];
          arr.push(res.data)
          this.tableDate1 = arr;
        } else {
          this.$alert(res.message, "提示", {
            confirmButtonText: "确定",
            confirmButtonClass: "confirmbtnFalses",
            type: "warning",
            center: true,
            callback: (action) => { },
          });
        }
      });
    },
    refresh() {
      // dayStatistic({ date: partten.dayStatisticDate }).then((res) => {
      //   console.log(res);
      //   if (res.code == "000000") {
      //     this.tableDate = res.rows;
      //     this.$message.success({ message: "已刷新最新数据 !" });
      //   } else {
      //     this.$alert(res.message, "提示", {
      //       confirmButtonText: "确定",
      //       confirmButtonClass: "confirmbtnFalses",
      //       type: "warning",
      //       center: true,
      //       callback: (action) => { },
      //     });
      //   }
      // });
      this.dayStatisticTreatment();
      this.dayStatisticRecharge();
    },
  },
  created() {
    this.dayStatisticTreatment();
    this.dayStatisticRecharge();
  },
  //合计
  // getSummaries(param) {
  //   const { columns, data } = param;
  //   const sums = [];
  //   columns.forEach((column, index) => {
  //     if (index === 0) {
  //       sums[index] = '';
  //       return;
  //     }

  //     const values = data.map(item => Number(item[column.property]));
  //     if (!values.every(value => isNaN(value))) {
  //       sums[index] = values.reduce((prev, curr) => {
  //         const value = Number(curr);
  //         if (!isNaN(value)) {
  //           return prev + curr;
  //         }  else {
  //           return prev;
  //         }

  //       }, 0);
  //       sums[index] += ' 元';
  //     } else {
  //       sums[index] = 'N/A';
  //     }
  //   });


  //   return sums;
  // }

};

</script>

<style>
.div_content {
  /* display: flex; */
  width: 100%;
}
</style>
