<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
      <el-form-item label="时间1">
        <el-date-picker
          v-model="daterangeTime"
          size="small"
          style="width: 340px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
<!--      <el-form-item label="操作员">-->
<!--        <el-select v-model="queryParams.user" placeholder="请选择操作员">-->
<!--          <el-option-->
<!--            v-for="item in integralUsers"-->
<!--            :key="item.userId"-->
<!--            :label="item.nickName"-->
<!--            :value="item.userId"-->
<!--          ></el-option>-->
<!--        </el-select>-->
<!--      </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">
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-print"
          size="mini"
          :loading="exportLoading"
          @click="handleExport"
          v-hasPermi="['canteen:scck:export']"
        >打印</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <iframe height= "963px" width="1080px" :src="print" id="preview">
    </iframe>
  </div>
</template>

<script>
  import user from "@/store/modules/user";
  import {getIntegralUsers} from "@/api/system/user";
  import {getLodop} from '@/api/js/LodopFuncs';

  export default {
    name: "consumeReport",

    data() {
      return {
        print: '',
        // 显示搜索条件
        showSearch: true,
        // 查询参数
        queryParams: {
        },
        // 时间范围
        daterangeTime: [],
        integralUsers: {},
      };
    },
    created() {
      //this.getUserList();
    },
    mounted() {
    },
    methods: {
      getList() {
        debugger
        this.queryParams['organizationCode'] = user.state.organ;
        this.queryParams['begin'] = this.daterangeTime[0];
        this.queryParams['end'] = this.daterangeTime[1];
        var json = JSON.stringify(this.queryParams);
        this.print= encodeURI('/prod-api/Print/consumeReport?req=' + json);
      },
      // getUserList() {
      //   getIntegralUsers({organizationCode: user.state.organ}).then(response =>{
      //     this.integralUsers = response.data;
      //   })
      // },
      // 表单重置
      reset() {
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
      },
      /** 导出按钮操作 */
      handleExport() {
        var lodop = getLodop();
        lodop.PRINT_INIT("");
        var strHtml = document.getElementById("preview").contentWindow.document.documentElement.innerHTML;
        lodop.ADD_PRINT_HTM(-5,0,"100%","100%",strHtml);
        lodop.SET_PRINT_STYLEA(0,"Offset2Top",-30);
        lodop.PREVIEW();
      }
    }
  };
</script>
