<template>
  <div class="content-main">
    <div class="search-bm-boder">
      <el-row>
        <el-form :inline="true" :model="queryform"  label-width="73px" ref="queryform">
          <el-form-item label="上报日期:" prop="data">
            <el-date-picker v-model="queryform.data" class="dateInputCompatible" type="daterange" range-separator="至" start-placeholder="开始日期"
                            end-placeholder="结束日期" value-format="yyyy-MM-dd" format="yyyy-MM-dd">
            </el-date-picker>
          </el-form-item>
          <div class="search-button">
            <span class="search-line"></span>

            <el-button type="primary" @click="getList" size="small" class="iconfont iconchaxun"> 查询</el-button>
            <el-button type="primary" @click="resetInfo('queryform')" size="small" class="iconfont iconzhongzhi"> 重置</el-button>
          </div>
        </el-form>

      </el-row>
    </div>
    <el-row>
      <el-table tooltip-effect="dark" align="center" border
        v-loading:body="isloading" :data="tableData" @row-click="rowFun">
        <el-table-column type="index" :index="typeIndex" label="序号" width="50"></el-table-column>
        <el-table-column align="center" label="上报开始时间" :show-overflow-tooltip="true" prop="startTime"></el-table-column>
        <el-table-column align="center" label="上报结束时间" :show-overflow-tooltip="true" prop="endTime"></el-table-column>
      </el-table>
      <!-- 分页开始 -->
      <div class="pag-right clearFix">
          <el-pagination
            class="right"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="limit.page"
            :page-sizes="[10,20,30,40]"
            :page-size="limit.size"
            layout="total, sizes, prev, pager, next, jumper"
            :total="limit.total"
          ></el-pagination>
        </div>
    </el-row>

  </div>
</template>

<script>
  import { queryReportTime } from '@/api/grainCirculationPrice/grainPriceQuotation/weekQuotation/index'
  export default {
    name: 'Daily',
    data() {
      return {
        queryform: {
          data: ''
        },
        tableData: [],
        limit: {
          page: 1,
          size: 10,
          total: 0
        },
        isloading: false,
      }
    },
    created() {
      this.getList();
    },
    methods: {
      rowFun(row){
        this.$router.push({ name: 'weekQuotationDetail', query: { id: row.id, startTime: row.startTime, endTime: row.endTime} })
      },
      // List init
      resetInfo(formName) {
        this.$refs[formName].resetFields();
        this.getList()
      },
      getList() {
        const data = {
          "startTime": this.queryform.data[0],
          "endTime": this.queryform.data[1]
        }
        const pageData = {
          page: this.limit.page,
          size: this.limit.size
        }
        queryReportTime(data, pageData).then(response => {
          this.tableData = response.data.resultList
          this.limit.total = response.data.total
          this.isloading = false
        }).catch(function (error) {
          console.log(error)
        })
      },
      handleSizeChange(val) {
        this.limit.size = val;
        this.getList();
      },
      handleCurrentChange(val) {
        this.limit.page = val;
        this.getList();
      },
      typeIndex(index) {
        return index + (this.limit.page - 1) * this.limit.size + 1;
      },
    }
  }
</script>

<style lang="scss" scoped>

</style>
<style>
  .weekprice .el-table tr.el-table__row{ cursor: pointer;}
</style>
