|
|
@@ -18,16 +18,25 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
<el-empty v-if="footprintGroups.length === 0" description="暂无浏览足迹" />
|
|
|
+ <TablePagination
|
|
|
+ v-if="footprintGroups.length > 0"
|
|
|
+ v-model:page="queryParams.pageNum"
|
|
|
+ v-model:page-size="queryParams.pageSize"
|
|
|
+ :total="total"
|
|
|
+ @change="handleQuery"
|
|
|
+ />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { ref, onMounted } from 'vue';
|
|
|
+import { ref, reactive, onMounted } from 'vue';
|
|
|
import { Delete } from '@element-plus/icons-vue';
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus';
|
|
|
-import { PageTitle, ProductCard } from '@/components';
|
|
|
+import { PageTitle, ProductCard, TablePagination } from '@/components';
|
|
|
import { browsingHistoryList, deleteProductBrowsingHistory } from '@/api/goods/index';
|
|
|
|
|
|
+const queryParams = reactive({ pageNum: 1, pageSize: 20 });
|
|
|
+const total = ref(0);
|
|
|
const loading = ref(false);
|
|
|
const footprintGroups = ref<any[]>([]);
|
|
|
|
|
|
@@ -59,10 +68,10 @@ const getFootprintList = () => {
|
|
|
// 后端返回的是 Map<String, List<PcProductVo>>,key 是日期字符串(yyyy-MM-dd)
|
|
|
const dataMap = res.data || {};
|
|
|
const groups: any[] = [];
|
|
|
-
|
|
|
+
|
|
|
// 按日期降序排序(最新的在前面)
|
|
|
const sortedDates = Object.keys(dataMap).sort((a, b) => b.localeCompare(a));
|
|
|
-
|
|
|
+
|
|
|
sortedDates.forEach((dateKey: string) => {
|
|
|
const products = (dataMap[dateKey] || []).map((item: any) => ({
|
|
|
...item,
|
|
|
@@ -73,7 +82,7 @@ const getFootprintList = () => {
|
|
|
tag: item.tag || '',
|
|
|
checked: false
|
|
|
}));
|
|
|
-
|
|
|
+
|
|
|
groups.push({
|
|
|
dateKey, // 保留原始日期 key,用于删除操作
|
|
|
date: formatDate(dateKey),
|
|
|
@@ -81,8 +90,9 @@ const getFootprintList = () => {
|
|
|
products
|
|
|
});
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
footprintGroups.value = groups;
|
|
|
+ total.value = groups.reduce((sum, group) => sum + group.products.length, 0);
|
|
|
}
|
|
|
})
|
|
|
.finally(() => {
|
|
|
@@ -90,6 +100,10 @@ const getFootprintList = () => {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
+const handleQuery = () => {
|
|
|
+ getFootprintList();
|
|
|
+};
|
|
|
+
|
|
|
/** 获取所有选中的商品 */
|
|
|
const getSelectedItems = () => {
|
|
|
const selected: any[] = [];
|