|
@@ -6,12 +6,14 @@
|
|
*/
|
|
*/
|
|
import * as api from '/@/views/customers-voice/api';
|
|
import * as api from '/@/views/customers-voice/api';
|
|
import { useResponse } from '/@/utils/useResponse';
|
|
import { useResponse } from '/@/utils/useResponse';
|
|
-import { onMounted, ref } from 'vue';
|
|
|
|
|
|
+import { onMounted, reactive } from 'vue';
|
|
|
|
|
|
|
|
+// 定义 Props
|
|
const props: any = defineProps({
|
|
const props: any = defineProps({
|
|
rowData: Object,
|
|
rowData: Object,
|
|
queryParameter: Object,
|
|
queryParameter: Object,
|
|
});
|
|
});
|
|
|
|
+
|
|
const { rowData, queryParameter } = props;
|
|
const { rowData, queryParameter } = props;
|
|
const start_time = dayjs(queryParameter?.date[0]).format('YYYY-MM-DD');
|
|
const start_time = dayjs(queryParameter?.date[0]).format('YYYY-MM-DD');
|
|
const end_time = dayjs(queryParameter?.date[1]).format('YYYY-MM-DD');
|
|
const end_time = dayjs(queryParameter?.date[1]).format('YYYY-MM-DD');
|
|
@@ -23,128 +25,156 @@ interface Comment {
|
|
date: string;
|
|
date: string;
|
|
}
|
|
}
|
|
|
|
|
|
-const negativeCommentList = ref<Comment[]>([]); // 评论列表
|
|
|
|
-const page = ref(1); // 当前页
|
|
|
|
-const loading = ref(false); // 加载状态
|
|
|
|
-const noMore = ref(false); // 是否没有更多数据
|
|
|
|
-const disabled = computed(() => loading.value || noMore.value);
|
|
|
|
|
|
+function createGridOptions() {
|
|
|
|
+ return reactive({
|
|
|
|
+ size: 'mini',
|
|
|
|
+ border: true,
|
|
|
|
+ // stripe: true,
|
|
|
|
+ showHeader: false,
|
|
|
|
+ height: 500,
|
|
|
|
+ // showOverflow: 'tooltip',
|
|
|
|
+ loading: false,
|
|
|
|
+ rowConfig: {
|
|
|
|
+ isCurrent: true,
|
|
|
|
+ isHover: true,
|
|
|
|
+ height: 50,
|
|
|
|
+ },
|
|
|
|
+ loadingConfig: {
|
|
|
|
+ icon: 'vxe-icon-indicator roll',
|
|
|
|
+ text: '加载中...',
|
|
|
|
+ },
|
|
|
|
+ // tooltipConfig: {
|
|
|
|
+ // zIndex: 9999,
|
|
|
|
+ // },
|
|
|
|
+ pagerConfig: {
|
|
|
|
+ total: 0,
|
|
|
|
+ page: 1,
|
|
|
|
+ limit: 10, // 每页条数
|
|
|
|
+ },
|
|
|
|
+ columns: [{ field: 'comment', title: '评论内容', align: 'center', width: 500 }],
|
|
|
|
+ data: [] as Comment[],
|
|
|
|
+ });
|
|
|
|
+}
|
|
|
|
|
|
-// 获取评论数据
|
|
|
|
-async function fetchList() {
|
|
|
|
- if (loading.value || noMore.value) return; // 防止重复请求或没有更多数据时请求
|
|
|
|
|
|
+// 每个表格的配置
|
|
|
|
+const returnGridOptions = createGridOptions(); // 退货评论
|
|
|
|
+const feedbackGridOptions = createGridOptions(); // 反馈评论
|
|
|
|
+const reviewGridOptions = createGridOptions(); // 评价评论
|
|
|
|
|
|
- loading.value = true;
|
|
|
|
|
|
+// 获取数据
|
|
|
|
+async function handlePageChange(option: string, gridOptions: any) {
|
|
|
|
+ gridOptions.loading = true;
|
|
|
|
|
|
- // 请求参数
|
|
|
|
|
|
+ // 请求参数,动态更新分页信息
|
|
const query = {
|
|
const query = {
|
|
- asin: 'B0D21RMR85', // 请根据实际情况替换
|
|
|
|
|
|
+ asin: rowData.asin,
|
|
start_time: start_time,
|
|
start_time: start_time,
|
|
end_time: end_time,
|
|
end_time: end_time,
|
|
- option: 'return_negative_comment',
|
|
|
|
- page: page.value,
|
|
|
|
- limit: 5,
|
|
|
|
|
|
+ option,
|
|
|
|
+ page: gridOptions.pagerConfig.page,
|
|
|
|
+ limit: gridOptions.pagerConfig.limit,
|
|
};
|
|
};
|
|
|
|
|
|
try {
|
|
try {
|
|
const resp = await useResponse(api.getCommentData, query);
|
|
const resp = await useResponse(api.getCommentData, query);
|
|
- const newData = resp.data;
|
|
|
|
-
|
|
|
|
- // 如果返回数据少于 5 条,说明没有更多数据
|
|
|
|
- if (newData.length < 5) {
|
|
|
|
- noMore.value = true;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 合并数据
|
|
|
|
- negativeCommentList.value = [...negativeCommentList.value, ...newData];
|
|
|
|
- console.log('=>(DataDisplay.vue:58) negativeCommentList.value', negativeCommentList.value);
|
|
|
|
-
|
|
|
|
- // 页数加 1
|
|
|
|
- page.value += 1;
|
|
|
|
|
|
+ gridOptions.data = resp.data;
|
|
|
|
+ gridOptions.pagerConfig.total = resp.total || 0; // 更新总数
|
|
} catch (error) {
|
|
} catch (error) {
|
|
- console.error('加载评论数据失败:', error);
|
|
|
|
|
|
+ console.error(`加载 ${option} 数据失败:`, error);
|
|
} finally {
|
|
} finally {
|
|
- loading.value = false;
|
|
|
|
|
|
+ gridOptions.loading = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-// 在组件加载时获取数据
|
|
|
|
|
|
+function cellStyle(){
|
|
|
|
+ return {
|
|
|
|
+ fontSize: '14px',
|
|
|
|
+ color:'#666',
|
|
|
|
+ fontWeight: 600,
|
|
|
|
+ };
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 组件加载时获取数据
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
- fetchList();
|
|
|
|
|
|
+ handlePageChange('return_negative_comment', returnGridOptions);
|
|
|
|
+ handlePageChange('feedback_negative_comment', feedbackGridOptions);
|
|
|
|
+ handlePageChange('review_negative_comment', reviewGridOptions);
|
|
});
|
|
});
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<template>
|
|
<template>
|
|
- <el-card style="height: 600px">
|
|
|
|
|
|
+ <div class="mt-5" style="height: 600px">
|
|
<el-row>
|
|
<el-row>
|
|
|
|
+ <!-- 退货评论 -->
|
|
<el-col :span="8">
|
|
<el-col :span="8">
|
|
- <div class="infinite-list-wrapper" style="overflow: auto">
|
|
|
|
- <ul v-infinite-scroll="fetchList" :infinite-scroll-disabled="disabled" class="list">
|
|
|
|
- <li v-for="item in negativeCommentList" :key="item.order_id" class="list-item">
|
|
|
|
- <div class="comment-text">{{ item.comment }}</div>
|
|
|
|
- </li>
|
|
|
|
- </ul>
|
|
|
|
- <p v-if="loading">Loading...</p>
|
|
|
|
- <p v-if="noMore">No more</p>
|
|
|
|
|
|
+ <div class="title">
|
|
|
|
+ <div class="font-semibold italic mb-2">退货评论</div>
|
|
|
|
+ <vxe-grid v-bind="returnGridOptions" :cell-style="cellStyle">
|
|
|
|
+ <template #empty>
|
|
|
|
+ <el-empty description="暂无数据" />
|
|
|
|
+ </template>
|
|
|
|
+ <template #pager>
|
|
|
|
+ <vxe-pager
|
|
|
|
+ v-model:currentPage="returnGridOptions.pagerConfig.page"
|
|
|
|
+ v-model:pageSize="returnGridOptions.pagerConfig.limit"
|
|
|
|
+ :total="returnGridOptions.pagerConfig.total"
|
|
|
|
+ class="mt-1.5"
|
|
|
|
+ @page-change="() => handlePageChange('return_negative_comment', returnGridOptions)"
|
|
|
|
+ />
|
|
|
|
+ </template>
|
|
|
|
+ </vxe-grid>
|
|
</div>
|
|
</div>
|
|
</el-col>
|
|
</el-col>
|
|
|
|
+
|
|
|
|
+ <!-- 反馈评论 -->
|
|
<el-col :span="8">
|
|
<el-col :span="8">
|
|
- <div class="infinite-list-wrapper" style="overflow: auto">
|
|
|
|
- <ul v-infinite-scroll="fetchList" :infinite-scroll-disabled="disabled" class="list">
|
|
|
|
- <li v-for="item in negativeCommentList" :key="item.order_id" class="list-item">
|
|
|
|
- <div class="comment-text">{{ item.comment }}</div>
|
|
|
|
- </li>
|
|
|
|
- </ul>
|
|
|
|
- <p v-if="loading">Loading...</p>
|
|
|
|
- <p v-if="noMore">No more</p>
|
|
|
|
|
|
+ <div class="title">
|
|
|
|
+ <div class="font-semibold italic mb-2">反馈评论</div>
|
|
|
|
+ <vxe-grid v-bind="feedbackGridOptions">
|
|
|
|
+ <template #empty>
|
|
|
|
+ <el-empty description="暂无数据" />
|
|
|
|
+ </template>
|
|
|
|
+ <template #pager>
|
|
|
|
+ <vxe-pager
|
|
|
|
+ v-model:currentPage="feedbackGridOptions.pagerConfig.page"
|
|
|
|
+ v-model:pageSize="feedbackGridOptions.pagerConfig.limit"
|
|
|
|
+ :total="feedbackGridOptions.pagerConfig.total"
|
|
|
|
+ class="mt-1.5"
|
|
|
|
+ @page-change="() => handlePageChange('feedback_negative_comment', feedbackGridOptions)"
|
|
|
|
+ />
|
|
|
|
+ </template>
|
|
|
|
+ </vxe-grid>
|
|
</div>
|
|
</div>
|
|
</el-col>
|
|
</el-col>
|
|
|
|
+
|
|
|
|
+ <!-- 评价评论 -->
|
|
<el-col :span="8">
|
|
<el-col :span="8">
|
|
- <div class="infinite-list-wrapper" style="overflow: auto">
|
|
|
|
- <ul v-infinite-scroll="fetchList" :infinite-scroll-disabled="disabled" class="list">
|
|
|
|
- <li v-for="item in negativeCommentList" :key="item.order_id" class="list-item">
|
|
|
|
- <div class="comment-text">{{ item.comment }}</div>
|
|
|
|
- </li>
|
|
|
|
- </ul>
|
|
|
|
- <p v-if="loading">Loading...</p>
|
|
|
|
- <p v-if="noMore">No more</p>
|
|
|
|
|
|
+ <div class="title">
|
|
|
|
+ <div class="font-semibold italic mb-2">评价评论</div>
|
|
|
|
+ <vxe-grid v-bind="reviewGridOptions">
|
|
|
|
+ <template #empty>
|
|
|
|
+ <el-empty description="暂无数据" />
|
|
|
|
+ </template>
|
|
|
|
+ <template #pager>
|
|
|
|
+ <vxe-pager
|
|
|
|
+ v-model:currentPage="reviewGridOptions.pagerConfig.page"
|
|
|
|
+ v-model:pageSize="reviewGridOptions.pagerConfig.limit"
|
|
|
|
+ :total="reviewGridOptions.pagerConfig.total"
|
|
|
|
+ class="mt-1.5"
|
|
|
|
+ @page-change="() => handlePageChange('review_negative_comment', reviewGridOptions)"
|
|
|
|
+ />
|
|
|
|
+ </template>
|
|
|
|
+ </vxe-grid>
|
|
</div>
|
|
</div>
|
|
</el-col>
|
|
</el-col>
|
|
</el-row>
|
|
</el-row>
|
|
- </el-card>
|
|
|
|
|
|
+ </div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<style scoped>
|
|
<style scoped>
|
|
-.infinite-list-wrapper {
|
|
|
|
- height: 300px;
|
|
|
|
- text-align: center;
|
|
|
|
-}
|
|
|
|
-.infinite-list-wrapper .list {
|
|
|
|
- padding: 0;
|
|
|
|
- margin: 0;
|
|
|
|
- list-style: none;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-.infinite-list-wrapper .list-item {
|
|
|
|
|
|
+.title {
|
|
display: flex;
|
|
display: flex;
|
|
|
|
+ flex-direction: column;
|
|
align-items: center;
|
|
align-items: center;
|
|
- justify-content: center;
|
|
|
|
- height: 50px;
|
|
|
|
- background: var(--el-color-primary-light-9);
|
|
|
|
- margin: 10px;
|
|
|
|
- color: var(--el-color-primary);
|
|
|
|
-}
|
|
|
|
-.infinite-list-wrapper .list-item + .list-item {
|
|
|
|
- margin-top: 10px;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-.comment-text {
|
|
|
|
- display: -webkit-box;
|
|
|
|
- -webkit-box-orient: vertical;
|
|
|
|
- -webkit-line-clamp: 1; /* 显示的行数 */
|
|
|
|
- overflow: hidden;
|
|
|
|
- text-overflow: ellipsis;
|
|
|
|
- max-height: 4.5em; /* 根据字号和行高设置最大高度 */
|
|
|
|
- line-height: 1.5em; /* 控制行高,与你的内容相匹配 */
|
|
|
|
- font-size: 14px;
|
|
|
|
}
|
|
}
|
|
</style>
|
|
</style>
|