<!-- 收银台订单-->
<template>
  <div>
    <div class="card-change-3-search">
      <div class="wgang">
        <div style="display: flex ">
          <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="60px">

            <el-form-item label="">
              <!--          <el-date-picker-->
              <!--            v-model="dateRange"-->
              <!--            style="width: 400px"-->
              <!--            size="medium"-->
              <!--            value-format="yyyy-MM-dd"-->
              <!--            type="datetimerange"-->
              <!--            range-separator="至"-->
              <!--            start-placeholder="开始日期"-->
              <!--            end-placeholder="结束日期"-->
              <!--          ></el-date-picker>-->
              <el-date-picker
                v-model="beginTime"
                style="width: 140px"
                type="date"
                placeholder="开始日期">
              </el-date-picker>
              至
              <el-date-picker
                v-model="endTime"
                style="width: 140px"
                type="date"
                placeholder="结束日期">
              </el-date-picker>
            </el-form-item>
            <!--            <el-form-item label="机构：" prop="deptId">-->
            <!--              <el-select-->
            <!--                v-model="queryParams.deptId"-->
            <!--                clearable-->
            <!--                placeholder="全部"-->
            <!--              >-->
            <!--                <el-option v-for="item in deptList" :key="item.id" :label="item.deptName" :value="item.deptId">-->
            <!--                </el-option>-->
            <!--              </el-select>-->
            <!--            </el-form-item>-->
            <el-form-item>
              <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
              <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
              <!--              <el-button type="primary" icon="el-icon-plus" @click = "exportExcelCashier()">导出订单</el-button>-->

            </el-form-item>
          </el-form>
        </div>
      </div>


    </div>
    <div class="card-change-1-1">
      <div class="box-gang">
        <div class="box">
          <div class="size-bole">{{ orderStatistics.amount }}</div>
          <div class="size-hui">
            <div class="nei">交易金额</div>
            <div class="icon-img">
              <img src="../../../../assets/images/cut/组 4666@2x.png" alt="">
            </div>
          </div>
        </div>
        <div class="box">
          <div class="size-bole">{{ orderStatistics.strokeCount }}</div>
          <div class="size-hui">
            <div class="nei">交易笔数</div>
            <div class="icon-img">
              <img src="../../../../assets/images/cut/组 4666@2x.png" alt="">
            </div>
          </div>
        </div>
        <div class="box">
          <div class="size-bole">{{ orderStatistics.unitPrice }}</div>
          <div class="size-hui">
            <div class="nei">笔单价</div>
            <div class="icon-img">
              <img src="../../../../assets/images/cut/组 4666@2x.png" alt="">
            </div>
          </div>
        </div>
        <!--        <div class="box">-->
        <!--          <div class="size-hui">日均交易金额</div>-->
        <!--          <div class="size-bole">{{ orderStatistics.dailyAmount }}</div>-->
        <!--        </div>-->
        <!--        <div class="box">-->
        <!--          <div class="size-hui">日均交易笔数</div>-->
        <!--          <div class="size-bole">{{ orderStatistics.strokesPerDay }}</div>-->
        <!--        </div>-->
      </div>
      <div class="table-box">
        <el-table
          :data="orderList"
          border
          style="width: 100%;margin-top: 15px">
          <el-table-column type="index" width="50" align="center" label="序号"/>
          <el-table-column prop="payTime" align="center" label="日期"></el-table-column>
<!--          <el-table-column prop="seekZero" align="center" label="活跃机构数量"> </el-table-column>-->
<!--          <el-table-column prop="storeCount" align="center" label="活跃门店数量"> </el-table-column>-->
          <el-table-column prop="goodsMoney" align="center" label="订单金额"> </el-table-column>
          <el-table-column prop="discountAmount" align="center" label="优惠金额"> </el-table-column>
          <el-table-column prop="refund" align="center" label="退款金额"> </el-table-column>
          <el-table-column prop="amount" align="center" label="实收金额"> </el-table-column>
          <el-table-column prop="vipAmount" align="center" label="充值金额"> </el-table-column>
<!--          <el-table-column prop="amount" align="center" label="充值赠送金额">-->
<!--            <template slot-scope="scope">-->
<!--              -->
<!--            </template>-->
<!--          </el-table-column>-->
          <el-table-column prop="balance" align="center" label="会员消费金额"> </el-table-column>
<!--          <el-table-column prop="strokeCount" align="center" label="交易笔数"> </el-table-column>-->
<!--          <el-table-column prop="unitPrice" align="center" label="笔单价">-->
<!--            <template slot-scope="scope">-->
<!--              <span>{{scope.row.unitPrice}}</span>-->
<!--            </template>-->
<!--          </el-table-column>-->
<!--          <el-table-column prop="dailyAmount" align="center" label="日均交易金额">-->
<!--            <template slot-scope="scope">-->
<!--              <span>{{ (scope.row.amount / scope.row.storeCount).toFixed(2) }}</span>-->
<!--            </template>-->
<!--          </el-table-column>-->
<!--          <el-table-column prop="strokesPerDay" align="center" label="日均交易笔数">-->
<!--            <template slot-scope="scope">-->
<!--              <span>{{ (scope.row.strokeCount / scope.row.storeCount).toFixed(2) }}</span>-->
<!--            </template>-->
<!--          </el-table-column>-->
<!--          <el-table-column prop="seekZero" align="center" label="机构日均交易金额"> </el-table-column>-->
<!--          <el-table-column prop="seekZero" align="center" label="机构日均交易笔数"> </el-table-column>-->
<!--          <el-table-column prop="seekZero" align="center" label="门店日均交易金额"> </el-table-column>-->
        </el-table>
      </div>
      <div class="pagination-box">
        <el-pagination
          background
          v-show="total>0"
          layout="prev, pager, next"
          :total="total"
          :page.sync="queryParams.page"
          :limit.sync="queryParams.pageSize"
          @current-change="getList">
        </el-pagination>
      </div>

    </div>
  </div>
</template>

<script>

import {
  exportExcelDayApi,
  getDayDatyListApi,
  getDayListApi,
  getmyDataApi,
  getRunningWaterByTissueApi
} from "@/api/allOrder";

  export default {
    name: "runningWater-day",
    data(){
      return{
        radio1:"油号选错",
        loading:false,
        deptList:[],

        // 员工列表
        staffList:[],
        // 日期范围
        dateRange: [],
        beginTime:"",
        endTime:"",
        // 是否为当天时间
        isSysDate:false,
        // 收银台订单列表
        orderList:[],
        // 查询参数
        queryParams: {
          page: 1,
          pageSize: 10,
          beginTime:"",
          endTime:"",
          isType:"3",
        },
        orderStatistics:{
          amount:'0',
          strokeCount:'0',
          unitPrice:'0',
          dailyAmount:'0',
          strokesPerDay:'0'
        },
        total:0,
      }
    },
    async created() {
      let start = new Date();
      start.setHours(0)
      start.setMinutes(0)
      start.setSeconds(0)
      start.setMilliseconds(0)
      this.dateRange = [start,new Date()];
      this.beginTime = start
      this.endTime = new Date()
      this.isSysDate = true
      // await this.getDeptList();

      this.getList();



    },
    methods:{
      async getDeptList() {
        await getmyDataApi(this.addDateRange(this.queryParams)).then( response => {
          this.queryParams.deptId = response.data.deptId;
        })
      },
      exportExcelCashier() {
        let dateRange = []
        if (this.beginTime && this.endTime) {
          dateRange.push(this.beginTime.toLocaleDateString())
          dateRange.push(this.endTime.toLocaleDateString())
        }
        exportExcelDayApi(this.addDateRange(this.queryParams, dateRange)).then(res=>{
          const blob = new Blob([res], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
          this.$download.saveAs(blob,'日流水分析.xLsx')
        })
      },
      // getDeptList() {
      //   getRunningWaterByTissueApi(this.addDateRange(this.queryParams)).then( response => {
      //     this.deptList = response.data.records;
      //   })
      // },

      // 获取订单统计信息

      getOrderStatistics() {
        let dateRange = []
        if (this.beginTime && this.endTime) {
          dateRange.push(this.beginTime.toLocaleDateString())
          dateRange.push(this.endTime.toLocaleDateString())
        }
        getDayDatyListApi(this.addDateRange(this.queryParams, dateRange)).then(res=>{
          this.orderStatistics = res.data
        })
      },

      // 获取列表信息
      async getList(val){
        await this.getDeptList()
        let dateRange = []
        if (this.beginTime && this.endTime) {
          dateRange.push(this.beginTime.toLocaleDateString())
          dateRange.push(this.endTime.toLocaleDateString())
        }
        await getDayListApi(this.addDateRange(this.queryParams, dateRange)).then( response => {
          this.orderList = response.data.records;
          this.total = response.data.total;
          this.isSysDate = false
          this.getOrderStatistics()

        })
      },

      // 搜索按钮操作
      handleQuery() {
        this.queryParams.page = 1;
        this.getList();
      },
      // 重置按钮操作
      resetQuery() {
        this.dateRange = [];
        this.queryParams = {
          page: 1,
          pageSize: 10,
          isType:"3",

        }
        this.beginTime = ""
        this.endTime = ""
        this.handleQuery();
      },
    }
  }
</script>

<style scoped lang="scss">
  .app-top{
    width: 100%;

    height: 60px;
    box-sizing: border-box;
    padding: 10px;
  }
  .clearfix{
    width: 100%;

  }
  .box-card{
    width: 100%;
    margin-bottom: 15px;
  }
  .box-gang{
    width: 100%;
    display: flex;
    align-items: center;
  }
  .box{
    //box-sizing: border-box;
    padding: 5px;
    //background: #f9f9f9;
    margin-right: 20px;
    padding-left: 20px;

    width: 211px;
    height: 60px;
    background: rgba(64,158,255,0.05);
    border-radius: 6px 6px 6px 6px;
    border: 1px solid #409EFF;
  }
  .el-form--inline .el-form-item {
    margin-right: 44px;
  }
  .size-hui{
    display: flex;
    align-items: center;
    //width: 200px;
    font-family: Source Han Sans CN, Source Han Sans CN;
    font-weight: 400;
    font-size: 13px;
    color: #888888;
    //line-height: 0px;
    text-align: left;
    font-style: normal;
    text-transform: none;
    .nei {
      width: 150px;
    }
  }

  .icon-img{
    //margin-left: 110px;
    width: 100%;
    height: 20px;
    margin-right: 5px;
    img{
      float: right;
      //width: 100%;
      width: 20px;
      height: 100%;
    }
  }
  .size-bole{
    //font-weight: bold;

    //width: 53px;
    height: 31px;
    font-family: YouSheBiaoTiHei;
    font-weight: 400;
    font-size: 24px;
    color: #555555;
    //line-height: 0px;
    text-align: left;
    font-style: normal;
    text-transform: none;
  }
  .wgang{
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;

  }
  .table-box{
    width: 100%;
  }
  .pagination-box{
    width: 100%;
    margin: 10px auto;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .top-app-sou{
    width: 20%;
  }
  .tk{
    text-align: center;
    color: grey;
    margin: 10px 0;
  }

</style>
