You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.4 KiB

1 month ago
  1. <template>
  2. <div class="detail-container">
  3. <div class="search-form-container">
  4. <!-- 搜索表单组件监听search事件 -->
  5. <SearchForm @search="handleSearch" />
  6. </div>
  7. <div class="detail-table-container">
  8. <DetailTable :tableData="tableData" />
  9. </div>
  10. </div>
  11. </template>
  12. <script>
  13. import SearchForm from '../components/SearchForm.vue';
  14. import DetailTable from '../components/DetailTable.vue';
  15. import { getGoldBeanDetail } from '../api/goldBeanDetail';
  16. export default {
  17. components: {
  18. SearchForm,
  19. DetailTable
  20. },
  21. data() {
  22. return {
  23. tableData: []
  24. };
  25. },
  26. // 组件创建时,触发一次无参数的查询
  27. async created() {
  28. await this.handleSearch({});
  29. },
  30. methods: {
  31. // 处理搜索事件,调用API获取金豆明细数据并更新表格数据
  32. async handleSearch(params) {
  33. try {
  34. const data = await getGoldBeanDetail(params);
  35. this.tableData = data;
  36. } catch (error) {
  37. console.error('查询失败', error);
  38. }
  39. }
  40. }
  41. };
  42. </script>
  43. <style scoped>
  44. .detail-container {
  45. display: flex;
  46. flex-direction: column; /* 修改为垂直布局 */
  47. }
  48. .search-form-container {
  49. width: 100%; /* 搜索表单宽度占满父容器 */
  50. }
  51. .detail-table-container {
  52. width: 100%; /* 详情表格宽度占满父容器 */
  53. margin-top: 20px; /* 为表格添加顶部间距 */
  54. }
  55. </style>