<template>
  <div class="orders-page">
    <h2 class="page-title">开单记录</h2>
    <el-card>
      <el-table :data="list" border size="small" :header-cell-style="{ background:'#f8fafc', color:'#64748b', fontWeight:600 }" v-loading="loading">
        <el-table-column prop="id" label="开单编号" width="180" />
        <el-table-column prop="kdhyc" label="会员" width="120" />
        <el-table-column prop="kdrq" label="开单日期" width="120" />
        <el-table-column prop="zdyj" label="整单业绩" width="120" />
        <el-table-column prop="sfyj" label="实付业绩" width="120" />
        <el-table-column label="操作" width="120" fixed="right">
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="viewDetail(scope.row)">详情</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        background
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
        :page-size="pageSize"
        :current-page="page"
        :page-sizes="[10, 20, 50, 100]"
        @size-change="val => { pageSize = val; handlePageChange(1) }"
        @current-change="handlePageChange"
        style="margin-top: 16px; text-align: right;"
      />
    </el-card>
  </div>
</template>

<script>
export default {
  name: 'Orders',
  data() {
    return {
      list: [],
      loading: false,
      page: 1,
      pageSize: 10,
      total: 0
    }
  },
  created() {
    this.fetchList()
  },
  methods: {
    fetchList() {
      this.loading = true
      // TODO: 对接开单列表接口
      setTimeout(() => {
        this.list = []
        this.total = 0
        this.loading = false
      }, 300)
    },
    handlePageChange(p) {
      this.page = p
      this.fetchList()
    },
    viewDetail(row) {
      this.$message.info('详情功能待对接')
    }
  }
}
</script>

<style lang="scss" scoped>
.page-title {
  margin: 0 0 20px;
  font-size: 20px;
  color: #303133;
}
</style>
