index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <ele-page flex-table>
  3. <page-search @search="handleSearch" />
  4. <ele-card :body-style="{ padding: '10px' }">
  5. <!-- Tabs -->
  6. <el-tabs v-model="activeTab" @tab-click="handleTabClick">
  7. <el-tab-pane label="全部订单状态" name="all" />
  8. <el-tab-pane v-for="item in shop_order_status" :key="item.dictValue" :label="item.dictLabel" :name="item.dictValue" />
  9. </el-tabs>
  10. <!-- Custom Table Header -->
  11. <order-table-header />
  12. <!-- Order List -->
  13. <div class="order-list" v-loading="loading">
  14. <div v-if="list.length === 0" class="empty-text">暂无数据</div>
  15. <order-item v-for="order in list" :key="order.orderId" :order="order" @view-detail="openDetail"
  16. @push-sms="openSms" @refund="openRefund" />
  17. </div>
  18. <!-- Pagination -->
  19. <div class="pagination-wrapper">
  20. <el-pagination v-model:current-page="pageParams.page" v-model:page-size="pageParams.limit"
  21. :total="total" layout="total, sizes, prev, pager, next, jumper" @size-change="handleSizeChange"
  22. @current-change="handlePageChange" />
  23. </div>
  24. </ele-card>
  25. <!-- Dialogs -->
  26. <order-detail ref="detailRef" />
  27. <push-sms-dialog ref="smsRef" />
  28. <refund-dialog ref="refundRef" />
  29. <add-package-dialog ref="packageRef" />
  30. </ele-page>
  31. </template>
  32. <script setup>
  33. import { ref, reactive, onMounted } from 'vue';
  34. import PageSearch from './components/page-search.vue';
  35. import OrderDetail from './components/order-detail.vue';
  36. import PushSmsDialog from './components/push-sms-dialog.vue';
  37. import RefundDialog from './components/refund-dialog.vue';
  38. import AddPackageDialog from './components/add-package-dialog.vue';
  39. import OrderTableHeader from './components/order-table-header.vue';
  40. import OrderItem from './components/order-item.vue';
  41. import request from '@/utils/request';
  42. import { useDictData } from '@/utils/use-dict-data';
  43. defineOptions({ name: 'MallOrderAll' });
  44. const activeTab = ref('all');
  45. const loading = ref(false);
  46. const total = ref(0);
  47. const pageParams = reactive({
  48. page: 1,
  49. limit: 10
  50. });
  51. const searchParams = ref({});
  52. const [shop_order_status] = useDictData(['shop_order_status']);
  53. const list = ref([]);
  54. const detailRef = ref(null);
  55. const smsRef = ref(null);
  56. const refundRef = ref(null);
  57. const fetchData = () => {
  58. loading.value = true;
  59. const params = {
  60. ...pageParams,
  61. ...searchParams.value
  62. };
  63. // Handle Tab Filter
  64. if (activeTab.value !== 'all') {
  65. params.status = activeTab.value;
  66. }
  67. request.get('/shop/shopOrder/pagelist', { params })
  68. .then(res => {
  69. const data = res.data; // Adjust based on response structure
  70. total.value = data.total || 0;
  71. list.value = data.rows || [];
  72. })
  73. .finally(() => {
  74. loading.value = false;
  75. });
  76. };
  77. const handleSearch = (data) => {
  78. pageParams.page = 1;
  79. searchParams.value = data;
  80. fetchData();
  81. };
  82. const handleTabClick = (tab) => {
  83. activeTab.value = tab.props.name;
  84. pageParams.page = 1;
  85. fetchData();
  86. };
  87. const handleSizeChange = (val) => {
  88. pageParams.limit = val;
  89. fetchData();
  90. };
  91. const handlePageChange = (val) => {
  92. pageParams.page = val;
  93. fetchData();
  94. };
  95. const openDetail = (row) => {
  96. detailRef.value?.handleOpen(row);
  97. };
  98. const openSms = (row) => {
  99. smsRef.value?.open(row);
  100. };
  101. const openRefund = (row) => {
  102. refundRef.value?.open(row);
  103. };
  104. onMounted(() => {
  105. fetchData();
  106. });
  107. </script>
  108. <style scoped>
  109. .order-list {
  110. min-height: 200px;
  111. }
  112. .empty-text {
  113. text-align: center;
  114. padding: 40px;
  115. color: #909399;
  116. }
  117. .pagination-wrapper {
  118. margin-top: 16px;
  119. display: flex;
  120. justify-content: flex-end;
  121. }
  122. </style>