<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="98px">
      <el-form-item label="班次号" prop="classesNo">
        <el-input
          v-model="queryParams.classesNo"
          placeholder="请输入班次号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="开始时间" prop="startDate">
        <el-date-picker clearable size="small" style="width: 200px"
          v-model="queryParams.startDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择开始时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="结束时间" prop="endDate">
        <el-date-picker clearable size="small" style="width: 200px"
          v-model="queryParams.endDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择结束时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="油站名称" prop="stationName">
        <el-input
          v-model="queryParams.stationName"
          placeholder="请输入油站名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="班结人" prop="classesMan">
        <el-input
          v-model="queryParams.classesMan"
          placeholder="请输入班结人"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="cyan" 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-table v-loading="loading" :data="summaryList" >
      <el-table-column label="班结主键id" align="center" prop="id" v-if="false" />
      <el-table-column label="班次号" align="center" prop="classesNo" />
      <el-table-column label="班次开始时间" align="center" prop="startDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.startDate, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="班次结束时间" align="center" prop="endDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.endDate, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="油站id" align="center" prop="stationId" v-if="false" />
      <el-table-column label="油站名称" align="center" prop="stationName" />
      <el-table-column label="订单数" align="center" prop="orderNum" />
      <el-table-column label="小票数量" align="center" prop="printNum" />
      <el-table-column label="销量L" align="center" prop="saleLiters" />
      <el-table-column label="销售额元" align="center" prop="saleAmt" />
      <el-table-column label="微信销售金额" align="center" prop="wxAmt" />
      <el-table-column label="支付宝销售金额" align="center" prop="zfbAmt" />
      <el-table-column label="电子卡销售金额" align="center" prop="dzkAmt" />
      <el-table-column label="班结人" align="center" prop="classesMan" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <router-link :to="{path:'/station/structure',query:{classesNo:scope.row.classesNo,stationId:scope.row.stationId}}" class="link-type">
            <span>查看</span>
          </router-link>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['customer:setting:edit']"
          >查看</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { listSummary } from "@/api/station/summary";

export default {
  name: "Summary",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 【请填写功能名称】表格数据
      summaryList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        classesNo: null,
        startDate: null,
        endDate: null,
        stationId: null,
        stationName: null,
        orderNum: null,
        printNum: null,
        saleLiters: null,
        saleAmt: null,
        wxAmt: null,
        zfbAmt: null,
        dzkAmt: null,
        classesMan: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询【请填写功能名称】列表 */
    getList() {
      this.loading = true;
      listSummary(this.queryParams).then(response => {
        this.summaryList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        classesNo: null,
        startDate: null,
        endDate: null,
        stationId: null,
        stationName: null,
        orderNum: null,
        printNum: null,
        saleLiters: null,
        saleAmt: null,
        wxAmt: null,
        zfbAmt: null,
        dzkAmt: null,
        classesMan: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    }

  }
};
</script>
