<!--
 * @Description: 
 * @Author: shipeng
 * @Date: 2025-06-10 日收入报表开发
-->
<template>
    <div class="app-container">
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="60px">
        <el-form-item label="日期" required>
          <el-date-picker
            v-model="queryParams.performDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
      <el-row :gutter="10" class="mb8"  style="margin-left: 0; margin-top: 10px">
        <el-button
          type="primary"
          size="mini"
          icon="el-icon-download"
          :disabled="dataList.length === 0"
          v-hasPermi="['daily:income:export']"
          @click="handleExport"
          v-loading.fullscreen.lock="handleExportLoading"
          element-loading-text="正在拼命生成数据中..."
          element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.5)"
        >导出excel</el-button>
        <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
      </el-row>
  
      <el-table ref="tables" v-loading="loading" :data="dataList" max-height="650px" border>
        <el-table-column label="序号" align="center" type="index" width="60"></el-table-column>
        <!-- <el-table-column label="剧目名称" align="center" prop="performName" />
        <el-table-column label="票务名称" align="center" prop="goodsName" /> -->
        <el-table-column label="场次日期" align="center" width="100">
          <template slot-scope="scope">
            <span>{{ scope.row.performDate }}</span>
          </template>
        </el-table-column>
        <el-table-column label="场次" align="center" width="110">
          <template slot-scope="scope">
            <span>{{ scope.row.performTimeStart }} -- {{ scope.row.performTimeEnd }}</span>
          </template>
        </el-table-column>
         <el-table-column label="座位类型" align="center" prop="seatTypeName" width="120" />
         <el-table-column label="窗口" align="center" prop="winTotal" />
         <el-table-column label="小程序" align="center"  prop="microAppTotal" />
         <el-table-column label="分销" align="center"  prop="retailTotal" />
         <el-table-column label="自助机" align="center"  prop="selfTotal" />
         <el-table-column label="直客小计" align="center"  prop="directSaleTotal" />
         <el-table-column label="美团" align="center"  prop="meituanTotal" />
         <el-table-column label="抖音" align="center"  prop="duoyinTotal" />
         <el-table-column label="携程" align="center"  prop="xiechenTotal" />
         <el-table-column label="猫眼" align="center"  prop="maoyanTotal" />
         <el-table-column label="OTA小计" align="center"  prop="otaSaleTotal" />
         <el-table-column label="大客户" align="center"  prop="maxCustomerSaleTotal" />
         <el-table-column label="旅行社&红培" align="center"  prop="travelAgencySaleTotal" />
         <el-table-column label="研学" align="center"  prop="studySaleTotal" />
         <el-table-column label="党校" align="center"  prop="partySchoolSaleTotal" />
         <el-table-column label="团购小计" align="center"  prop="groupBuyTotal" />
         <el-table-column label="合计" align="center"  prop="buySaleTotal" />
         <el-table-column label="推广票" align="center"  prop="promotionTicketSaleTotal" />
         <el-table-column label="总计" align="center"  prop="saleTotal" />

      </el-table>
  
    </div>
  </template>
  
  <script>
  
  import { dayIncomeCount, dayReportExport } from '@/api/statisticalReport/statistics'
  import { exportExcel } from '@/utils/exportexcel'
  // import { seatPricePageList } from '@/api/distribution/ticketMr'
  // import { pagePerformTimeList } from "@/api/schedulingMr/schedulingMr"
  import moment from "moment"
  export default {
    name: "Daily",
    dicts: [],
    data() {
      return {
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 用户表格数据
        dataList: [],
        // 弹出层标题
        title: "",
        responseData: {},
        // 是否显示弹出层
        open: false,
        // 日期范围
        dateRange: [],
        // 查询参数
        queryParams: {
          performDate: "",
        },
        visibleStatus: false,
        newObj: {},
        visibleType: '',
        handleExportLoading: false,
      };
    },
    created() {
      this.$set(this.queryParams,'performDate',moment().format("yyyy-MM-DD"));
      this.getList();
    },
    methods: {
      /** 查询列表 */
      getList() {
        this.loading = true;
        dayIncomeCount(this.queryParams).then(response => {
            this.dataList = response.data.rows||[];
            this.total = response.data.total||0;
            this.loading = false;
          }
        ).catch(()=>{
          this.loading = false;
        });
      },
      // 取消按钮
      cancel() {
        this.open = false;
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.$set(this.queryParams,'performDate',moment().format("yyyy-MM-DD"));
        this.handleQuery();
      },
     
      /**
       * 导出报表
       * @date 2022-10-24
       * @returns {any}
       */
      handleExport() {
        this.$confirm('您确定要导出当前查询的数据吗？', '提示', {
          confirmButtonText: '确定 ',
          cancelButtonText: '取消 ',
          type: 'warning'
        }).then(() => {
            this.handleExportLoading = true;
            dayReportExport(this.queryParams).then((res) => {
                exportExcel(res, '日收入报表', '.xlsx');
                this.handleExportLoading = false;
              })
              .catch(() => {
                this.handleExportLoading = false;
              });
        }).catch(() => {
            this.$message.info('您已取消导出！');
          });
      },
    }
  };
  </script>
  <style lang="scss" scoped>
  </style>