<template>
  <div class="body-wrapper">
    <el-tabs  v-model="activeName">
      <el-tab-pane label="支付订单查询" name="支付订单查询">
        <el-form class="form-wrapper" :inline="true" :model="formInline1" style="margin-bottom: 20px;">
          <el-row>
            <el-col :span="6">
              <el-form-item label="订单号:">
                <el-input v-model="formInline1.orderNo" placeholder="请输入"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="车牌号:">
                <el-input v-model="formInline1.plateNo" placeholder="请输入"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="泊位号:">
                <el-input v-model="formInline1.parkingNo" placeholder="请输入"></el-input>
              </el-form-item>
            </el-col>
<!--            <el-col :span="6">-->
<!--              <el-form-item label="支付日期:">-->
<!--                <el-date-picker-->
<!--                  v-model="formInline1.payTime"-->
<!--                  type="date"-->
<!--                  placeholder="选择日期">-->
<!--                </el-date-picker>-->
<!--              </el-form-item>-->
<!--            </el-col>-->
            <el-col :span="6">
              <el-form-item>
                <el-button type="primary" class="query-btn" @click="onSubmit1" icon="el-icon-search">查询</el-button>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <el-table border :row-class-name="rowClassName" :data="tableData1" v-loading="loading1">
          <el-table-column v-for="(item, index) in columns1" :key="index" :label="item.label" :prop="item.key">
          </el-table-column>
        </el-table>
        <div class="table-pagination">
          <el-pagination layout="total, prev, pager, next, jumper" :total="total1" @current-change="handlePageChange1"
                         :current-page.sync="pageNum1" :page-size.sync="pageSize1">
          </el-pagination>
        </div>
      </el-tab-pane>
      <el-tab-pane label="欠费订单查询" name="欠费订单查询">
        <el-form class="form-wrapper" :inline="true" :model="formInline2" style="margin-bottom: 20px;">
          <el-row>
            <el-col :span="8">
              <el-form-item label="订单号: ">
                <el-input v-model="formInline2.orderNo" placeholder="请输入"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="车牌号: ">
                <el-input v-model="formInline2.plateNo" placeholder="请输入"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item>
                <el-button type="primary" class="query-btn" @click="onSubmit2" icon="el-icon-search">查询</el-button>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <el-table border :row-class-name="rowClassName" :data="tableData2" v-loading="loading2">
          <el-table-column v-for="(item, index) in columns2" :key="index" :label="item.label" :prop="item.key">
          </el-table-column>
        </el-table>
        <div class="table-pagination">
          <el-pagination layout="total, prev, pager, next, jumper" :total="total1" @current-change="handlePageChange2"
                         :current-page.sync="pageNum2" :page-size.sync="pageSize2">
          </el-pagination>
        </div>
      </el-tab-pane>
      <el-tab-pane label="查询预付订单信息" name="查询预付订单信息">
        <el-form class="form-wrapper" :inline="true" :model="formInline4" style="margin-bottom: 20px;">
          <el-row>
            <el-col :span="8">
              <el-form-item label="订单号:">
                <el-input v-model="formInline4.orderNo" placeholder="请输入"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="车牌号:">
                <el-input v-model="formInline4.plateNo" placeholder="请输入"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item>
                <el-button type="primary" class="query-btn" @click="onSubmit4" icon="el-icon-search">查询</el-button>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <el-table border :row-class-name="rowClassName" :data="tableData4" v-loading="loading4">
          <el-table-column v-for="(item, index) in columns4" :key="index" :label="item.label" :prop="item.key">
          </el-table-column>
        </el-table>
        <div class="table-pagination">
          <el-pagination layout="total, prev, pager, next, jumper" :total="total4" @current-change="handlePageChange4"
                         :current-page.sync="pageNum4" :page-size.sync="pageSize4">
          </el-pagination>
        </div>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
<script>
import api from "@/api/audit.js";
import dictionary from "@/util/dictionary";
import api_z from "@/api/article_z.js";

export default {
  components: {},
  data() {
    return {
      loading1: false,
      loading2: false,
      loading4: false,
      activeName: '支付订单查询',
      columns1: [
        {
          label: '订单号',
          key: 'orderNo'
        },
        {
          label: '支付时间',
          key: 'outTime'
        },
        {
          label: '支付金额',
          key: 'payAmount'
        },
        {
          label: '停车场',
          key: 'parkName'
        },
        {
          label: '泊位号',
          key: 'parkingNo'
        },
        {
          label: '车牌号',
          key: 'plateNo'
        },
        {
          label: '入场日期',
          key: 'inTime'
        },
        {
          label: '出场日期',
          key: 'outTime'
        }
      ],
      tableData1: [],
      total1: 0,
      pageSize1: 10,
      pageNum1: 1,
      formInline1: {
        orderNo: '',
        payTime:''
      },
      columns2: [
        {
          label: '欠费订单号',
          key: 'orderNo'
        },
        {
          label: '车牌号',
          key: 'plateNo'
        },
        {
          label: '修改日期',
          key: 'updateTime'
        },
        {
          label: '欠费金额',
          key: ''
        }
      ],
      tableData2: [],
      total2: 0,
      pageSize2: 10,
      pageNum2: 1,
      formInline2: {
        orderNo: '',
        plateNo:''
      },
      columns4: [
        {
          label: '订单号',
          key: 'orderNo'
        },
        {
          label: '车牌号',
          key: 'plateNo'
        },
        {
          label: '所属停车场',
          key: 'parkName'
        },
        {
          label: '预约时间',
          key: 'appointmentTime'
        },
        {
          label: '金额',
          key: 'payAmount'
        },
        {
          label: '支付方式',
          key: 'payWay'
        },
        {
          label: '支付状态',
          key: 'payStatus'
        },
        {
          label: '支付时间',
          key: 'payTime'
        },
      ],
      tableData4: [],
      total4: 0,
      pageSize4: 10,
      pageNum4: 1,
      formInline4: {
        orderNo:'',
        plateNo: ''
      }
    }
  },
  mounted() {
    this.getTableData1()
    this.getTableData2()
    this.getTableData4()
  },
  watch: {
  },
  methods: {
    rowClassName({ rowIndex }) {
      // 偶数行和奇数行分别返回不同的类名，也可以根据实际需求基于rowData进行条件判断
      return rowIndex % 2 === 0 ? 'even-row' : 'odd-row';
    },
    onSubmit1() {
      this.pageNum1 = 1
      this.getTableData1()
    },
    onSubmit2() {
      this.pageNum2 = 1
      this.getTableData2()
    },
    onSubmit4() {
      this.pageNum4 = 1
      this.getTableData4()
    },
    handlePageChange1() {
      this.getTableData1()
    },
    getTableData1() {
      this.loading1 = true
      const {pageNum1, pageSize1} = this
      api_z.queryParkingOrderByPage({current: pageNum1, size: pageSize1, ...this.formInline1}).then(res => {
        this.tableData1 = (res.data.records || []).map(item => ({...item, carType: dictionary.typeMap[item.carType]}))
        this.total1 = res.data.total
        this.loading1 = false
      })
    },
    handlePageChange2() {
      this.getTableData2()
    },
    getTableData2() {
      this.loading2 = true
      const {pageNum2, pageSize2} = this
      api_z.queryParkingOrderArrearsByPage({current: pageNum2, size: pageSize2, ...this.formInline2}).then(res => {
        this.tableData2 = res.data.records || []
        this.total2 = res.data.total
        this.loading2 = false
      })
    },
    handlePageChange4() {
      this.getTableData4()
    },
    getTableData4() {
      this.loading4= true
      const {pageNum4, pageSize4} = this
      api.orderListByPage({current: pageNum4, size: pageSize4, ...this.formInline4}).then(res => {
        this.tableData4 = res.data.records || []
        this.total4 = res.data.total
        this.loading4 = false
      })
    }
  }
}
</script>
<style  lang="scss" scoped>
.body-wrapper {
  .form-wrapper {
    .el-form-item {
      margin-bottom: 0px;
    }
  }
  .button-block{
    text-align: right;
    margin-bottom: 20px;
  }
  .table-pagination{
    text-align: right;
  }
  .search-card{
    margin-bottom: 20px;
    text-align: center;
    .input-wrapper{
      width: 36%;
    }
  }
}
</style>
