<template>
  <div>
    <el-table :data="pager.lists" border style="width: 100%;">
      <el-table-column prop="id" label="ID" width="120" />
      <el-table-column label="单据编号" prop="number" show-overflow-tooltip />
      <el-table-column label="单据金额" prop="total" show-overflow-tooltip />
      <el-table-column
        label="抵扣金额"
        prop="deduction_price"
        show-overflow-tooltip
      />
      <el-table-column label="实际金额" prop="actual" show-overflow-tooltip />
      <el-table-column label="实收金额" prop="money" show-overflow-tooltip />
      <el-table-column
        label="单据时间"
        prop="create_time"
        show-overflow-tooltip
      />
      <el-table-column label="操作" fixed="right">
        <template #default="{ row }">
          <el-button type="primary" @click="openDetail(row)" link>详情</el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="flex mt-4 justify-end">
      <pagination v-model="pager" @change="getLists" />
    </div>
    <goodList ref="goodListRef" />
  </div>
</template>

<script lang="ts" setup name="subOrder">
import { usePaging } from "@/hooks/usePaging";
import { apiOpurchaseclassSubOrders } from "@/api/opurchaseclass";
import { useRoute } from "vue-router";
import goodList from "./goodList.vue";

const route = useRoute();

const queryParams = reactive({
  id: route.query.id,
});
// 分页相关
const { pager, getLists, resetParams, resetPage } = usePaging({
  fetchFun: apiOpurchaseclassSubOrders,
  params: queryParams,
});

defineExpose({
    getLists
})

const goodListRef = ref(null);

const openDetail = (row: any) => {
    goodListRef.value?.open(row);
}

</script>
