<template>
  <div class="app-container">
    <!-- 查询及操作区域 -->
    <div class="head-container">
      <div class="filter-container">
        <el-input
          v-model="query.batchNo"
          placeholder="请输入结算单批次号"
          class="filter-item"
          style="width: 200px;"
          clearable
        />
        <el-button type="primary" class="filter-item" @click="handleSearch">
          <i class="el-icon-search" style="color: white;" />
          查询
        </el-button>
        <el-button type="primary" class="filter-item" @click="handleGenerate">
          生成结算单
        </el-button>
      </div>
    </div>

    <!-- 表格 -->
    <el-table
      ref="table"
      v-loading="loading"
      :data="tableData"
      style="width: 100%"
      @selection-change="handleSelectionChange"
    >
      <el-table-column prop="batchNo" label="订单批次号" align="left" />
      <el-table-column prop="status" label="结算状态" align="left">
        <template slot-scope="scope">
          <span>{{ scope.row.status }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="settlementTime" label="结算时间" width="180" align="left" />
      <el-table-column prop="operator" label="制单人" align="left" />
      <el-table-column prop="exportTime" label="导出时间" width="180" align="left" />
      <el-table-column prop="settlementStatus" label="结算状态" align="left">
        <template slot-scope="scope">
          <span>{{ scope.row.settlementStatus }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" width="200" align="center">
        <template slot-scope="scope">
          <el-button
            type="text"
            size="small"
            @click="handleDetail(scope.row)"
          >
            查看详情
          </el-button>
          <el-button
            type="text"
            size="small"
            @click="handlePrint(scope.row)"
          >
            打印结算单
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <!-- 分页 -->
    <div class="pagination-container">
      <el-pagination
        :current-page.sync="page.current"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="page.size"
        :total="page.total"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </div>
  </div>
</template>

<script>
export default {
  name: 'settlementOrder',
  data() {
    return {
      loading: false,
      query: {
        batchNo: ''
      },
      page: {
        current: 1,
        size: 10,
        total: 2
      },
      tableData: [
        {
          batchNo: 'JS123456789',
          status: '结算中',
          settlementTime: '2025-01-01 00:00:00',
          operator: '小明',
          exportTime: '2025-01-01 00:00:00',
          settlementStatus: '结算中'
        },
        {
          batchNo: 'JS123456789',
          status: '待付款',
          settlementTime: '2025-01-01 00:00:00',
          operator: '小明',
          exportTime: '2025-01-01 00:00:00',
          settlementStatus: '已确认'
        }
      ],
      selection: []
    }
  },
  methods: {
    handleSearch() {
      // 实现搜索逻辑
      console.log('搜索条件:', this.query)
    },
    handleSelectionChange(val) {
      this.selection = val
    },
    handleSizeChange(val) {
      this.page.size = val
      // 重新加载数据
    },
    handleCurrentChange(val) {
      this.page.current = val
      // 重新加载数据
    },
    handleDetail(row) {
      // 查看详情
      console.log('查看详情:', row)
    },
    handlePrint(row) {
      // 打印结算单
      console.log('打印结算单:', row)
    },
    handleGenerate() {
      this.$router.push('/order/generateOrder')
    }
  }
}
</script>

<style lang="scss" scoped>
.app-container {
  padding: 20px;
}

.filter-container {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
  gap: 10px;

  .filter-item {
    margin-right: 10px;
  }
}

.pagination-container {
  position: fixed;
  bottom: 0;
  right: 0;
  left: 200px;
  height: 150px;
  background: white;
  padding: 10px;
  text-align: left;
  box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.08);
}
.el-pagination {
  padding: 2px 25px;
}


.el-table {
  margin-bottom: 70px;
}


.el-button--text {
  color: #409EFF;
  &:hover {
    color: #66b1ff;
  }
}

.el-table {
  margin-top: 20px;
  ::v-deep .el-table__body-wrapper {
    overflow-x: auto;
  }
}
</style>
