Files
lingji-work-fe/src/views/components/dataEngine/hotTranslation.vue

415 lines
12 KiB
Vue
Raw Normal View History

2025-06-16 14:42:26 +08:00
<template>
<view>
2025-06-17 11:18:39 +08:00
<topHeader ref="topHeaderRef" @search="search"></topHeader>
2025-06-16 14:42:26 +08:00
<!-- tabel -->
2025-09-04 16:50:20 +08:00
<div class="bg-#fff rounded-8px w-100% py-0 px-20px mb-24px">
2025-06-30 18:37:27 +08:00
<div class="title-row">
<span class="title mr-4px">行业热门话题洞察</span>
<Tooltip>
<template #title>基于社交内容平台的行业数据分析用户关注的热门话题与趋势</template>
2025-07-01 14:34:16 +08:00
<icon-question-circle size="16" class="!color-#737478" />
</Tooltip>
2025-06-30 18:37:27 +08:00
</div>
2025-09-04 18:05:16 +08:00
<Table
:dataSource="dataList"
2025-06-22 16:01:48 +08:00
:pagination="false"
2025-09-04 18:05:16 +08:00
:showSorterTooltip="false"
2025-06-30 18:37:27 +08:00
@change="handleChange"
2025-06-22 16:01:48 +08:00
>
2025-09-04 18:05:16 +08:00
<Table.Column
v-for="column in columns"
:key="column.dataIndex"
:title="column.title"
:dataIndex="column.dataIndex"
:width="column.width"
:minWidth="column.minWidth"
:sortable="column.sortable"
>
<template v-if="column.slotName === 'rank'" #customRender="{ record }">
<img v-if="record.rank == 1" :src="topImages[0]" style="width: 25px; height: 17px" />
<img v-else-if="record.rank == 2" :src="topImages[1]" style="width: 25px; height: 17px" />
<img v-else-if="record.rank == 3" :src="topImages[2]" style="width: 25px; height: 17px" />
<span v-else>{{ record.rank }}</span>
</template>
<template v-else-if="column.slotName === 'keywords'" #customRender="{ record }">
2025-09-05 13:51:33 +08:00
<Tag
2025-09-04 18:05:16 +08:00
v-for="item in record.keywords"
:key="item"
class="!rounded-2px !px-8px !py-1px !bg-#F2F3F5 !h-22px !color-#3C4043 mb-5px mr-5px"
2025-09-05 13:51:33 +08:00
>{{ item }}</Tag
2025-09-04 18:05:16 +08:00
>
</template>
<template v-else-if="column.slotName === 'hot'" #customRender="{ record }">
<img
v-for="i in record.hot"
:key="i"
:src="starImages[i - 1]"
style="width: 16px; height: 16px"
class="mr-2px"
/>
</template>
<template v-else-if="column.slotName === 'sentiment'" #customRender="{ record }">
<img v-if="record.felling == '2'" src="@/assets/img/hottranslation/good.png" class="w-24px h-24px" />
<img v-else-if="record.felling == '1'" src="@/assets/img/hottranslation/normal.png" class="w-24px h-24px" />
<img v-else-if="record.felling == '0'" src="@/assets/img/hottranslation/poor.png" class="w-24px h-24px" />
</template>
<template v-else-if="column.slotName === 'optional'" #customRender="{ record }">
<Button type="primary" ghost @click="gotoDetail(record)">详情</Button>
</template>
<template v-else-if="column.titleSlotName === 'hotTitle'" #title>
<div class="flex items-center">
<span class="mr-8px">热度指数</span>
<Tooltip>
<template #title>综合话题出现频次互动数据如点赞收藏评论加权计算的热度得分</template>
<icon-question-circle size="14" class="!color-#737478" />
</Tooltip>
</div>
</template>
<template v-else-if="column.titleSlotName === 'sentimentTitle'" #title>
<div class="flex items-center">
<span class="mr-8px">情感倾向</span>
<Tooltip>
<template #title
>统计该行业下全部内容的情绪分布选取占比最高的情绪类型作为该话题的整体情感倾向</template
>
<icon-question-circle size="14" class="!color-#737478" />
</Tooltip>
</div>
</template>
</Table.Column>
<template #emptyText>
2025-07-01 16:39:47 +08:00
<NoData />
</template>
2025-09-04 18:05:16 +08:00
</Table>
2025-09-04 16:50:20 +08:00
</div>
2025-09-03 12:04:15 +08:00
<Modal
v-model:open="visible"
unmountOnClose
centered
wrapClassName="hot-translation-modal"
width="640px"
@cancel="handleCancel"
>
2025-06-16 14:42:26 +08:00
<template #title>
<span style="text-align: left; width: 100%">行业热门话题洞察</span>
</template>
<div>
2025-09-04 16:50:20 +08:00
<Space direction="vertical">
2025-06-30 18:37:27 +08:00
<div class="mb-4px flex items-center">
<p class="cts !mr-16px flex-shrink-0 w-48px">话题名称</p>
<span class="cts">{{ topicInfo.name }}</span>
</div>
<div class="mb-10px flex items-start">
<p class="cts !mr-16px flex-shrink-0 w-48px">话题简介</p>
<span class="cts">{{ topicInfo.intro }}</span>
</div>
<div class="mb-4px flex items-center">
<p class="cts !mr-16px flex-shrink-0 w-48px">关键词</p>
2025-09-05 13:51:33 +08:00
<Tag
2025-06-30 18:37:27 +08:00
v-for="item in topicInfo.keywords"
:key="item"
class="mr-8px py-10px px-8px rounded-4px bg-#F2F3F5 cts !h-24px"
2025-09-05 13:51:33 +08:00
>{{ item }}</Tag
2025-06-30 18:37:27 +08:00
>
</div>
<div class="mb-4px flex items-center">
<p class="cts !mr-16px flex-shrink-0 w-48px">热度指数</p>
2025-06-16 14:42:26 +08:00
<img v-for="i in topicInfo.hot" :key="i" :src="starImages[i - 1]" style="width: 16px; height: 16px" />
2025-06-30 18:37:27 +08:00
</div>
<div class="mb-4px flex items-center">
<p class="cts !mr-16px flex-shrink-0 w-48px">情感指数</p>
<img v-if="topicInfo.felling == '2'" src="@/assets/img/hottranslation/good.png" class="w-20px h-20px" />
2025-06-16 14:42:26 +08:00
<img
v-else-if="topicInfo.felling == '1'"
src="@/assets/img/hottranslation/normal.png"
2025-06-30 18:37:27 +08:00
class="w-20px h-20px"
2025-06-16 14:42:26 +08:00
/>
<img
v-else-if="topicInfo.felling == '0'"
src="@/assets/img/hottranslation/poor.png"
2025-06-30 18:37:27 +08:00
class="w-20px h-20px"
2025-06-16 14:42:26 +08:00
/>
2025-06-30 18:37:27 +08:00
</div>
<div class="flex items-start">
<p class="!mr-16px w-48px cts relative top-2px">原始来源</p>
<div class="flex flex-col">
2025-07-01 14:34:16 +08:00
<div v-for="item in topicInfo.industry_topic_sources" :key="item" class="mb-18px flex items-center">
2025-06-30 18:37:27 +08:00
<a-link style="background-color: initial" :href="item.link" target="_blank" class="!text-12px">{{
item.title
}}</a-link>
2025-07-01 14:34:16 +08:00
<img src="@/assets/img/hottranslation/xhs.png" width="16" height="16" />
2025-06-30 18:37:27 +08:00
</div>
</div>
</div>
2025-09-04 16:50:20 +08:00
</Space>
2025-06-16 14:42:26 +08:00
</div>
2025-06-30 18:37:27 +08:00
<template #footer>
2025-09-03 11:15:37 +08:00
<Button size="large" @click="handleCancel">取消</Button>
<Button type="primary" size="large" @click="handleOk"> 确定 </Button>
2025-06-30 18:37:27 +08:00
</template>
2025-09-03 11:15:37 +08:00
</Modal>
2025-06-16 14:42:26 +08:00
</view>
</template>
<script setup>
import topHeader from './topHeader.vue';
2025-09-05 13:51:33 +08:00
import { Modal, Button, Tooltip, Space, Table, Tag } from 'ant-design-vue';
2025-06-16 14:42:26 +08:00
import { ref, computed } from 'vue';
import { fetchIndustriesTree, fetchIndustryTopics, fetchIndustryTopicDetail } from '@/api/all/index';
import star1 from '@/assets/img/hottranslation/star-fill1.png';
import star2 from '@/assets/img/hottranslation/star-fill2.png';
import star3 from '@/assets/img/hottranslation/star-fill3.png';
import star4 from '@/assets/img/hottranslation/star-fill4.png';
import star5 from '@/assets/img/hottranslation/star-fill5.png';
import top1 from '@/assets/img/captcha/top1.svg';
import top2 from '@/assets/img/captcha/top2.svg';
import top3 from '@/assets/img/captcha/top3.svg';
2025-06-21 11:39:35 +08:00
import { IconQuestionCircle, IconArrowUp, IconArrowDown } from '@arco-design/web-vue/es/icon';
// 新增排序状态和函数
const heatSortDirection = ref('desc'); // 默认降序排列
const columns = [
{
title: '排名',
dataIndex: 'rank',
slotName: 'rank',
2025-06-22 16:01:48 +08:00
width: 60,
minWidth: 60,
},
{
title: '话题名称',
dataIndex: 'name',
2025-06-22 16:01:48 +08:00
width: 300,
minWidth: 300,
},
{
title: '关键词',
dataIndex: 'keywords',
slotName: 'keywords',
2025-06-22 16:01:48 +08:00
width: 250,
minWidth: 250,
},
{
2025-06-22 16:01:48 +08:00
titleSlotName: 'hotTitle',
width: 180,
minWidth: 180,
title: '热度指数',
dataIndex: 'hot',
2025-06-30 18:37:27 +08:00
slotName: 'hot',
sortable: {
sortDirections: ['ascend', 'descend'],
},
},
{
2025-06-22 16:01:48 +08:00
titleSlotName: 'sentimentTitle',
title: '情感倾向',
dataIndex: 'sentiment',
slotName: 'sentiment',
2025-06-22 16:01:48 +08:00
width: 120,
minWidth: 120,
},
{
title: '操作',
slotName: 'optional',
2025-06-30 18:37:27 +08:00
width: 80,
},
];
2025-06-21 11:39:35 +08:00
// 切换排序方向
const toggleHeatSort = () => {
heatSortDirection.value = heatSortDirection.value === 'asc' ? 'desc' : 'asc';
sortDataByHeat();
};
// 实际排序逻辑
const sortDataByHeat = () => {
dataList.value.sort((a, b) => {
return heatSortDirection.value === 'asc' ? a.hot - b.hot : b.hot - a.hot;
});
// 排序后更新排名
dataList.value.forEach((item, index) => {
item.rank = index + 1;
});
};
2025-06-16 14:42:26 +08:00
const starImages = [star1, star2, star3, star4, star5];
const topImages = [top1, top2, top3];
// 行业大类
const industriesTree = ref([]);
// 行业热门话题洞察
const dataList = ref([]);
// 显示详情
const visible = ref(false);
const topicInfo = ref({});
const topHeaderRef = ref();
// 从topHeader获取统一的状态
const selectedIndustry = computed(() => topHeaderRef.value?.selectedIndustry);
const selectedSubCategory = computed(() => topHeaderRef.value?.selectedSubCategory);
const selectedTimePeriod = computed(() => topHeaderRef.value?.selectedTimePeriod);
2025-06-17 11:18:39 +08:00
const search = () => {
getIndustryTopics();
};
2025-06-16 14:42:26 +08:00
// 监听筛选条件变化
2025-06-17 11:18:39 +08:00
watch([selectedIndustry, selectedTimePeriod, selectedSubCategory], () => {
2025-06-16 14:42:26 +08:00
getIndustryTopics();
});
2025-06-17 11:18:39 +08:00
watch(selectedIndustry, () => {
selectedSubCategory.value = 0;
getIndustryTopics();
});
2025-06-16 14:42:26 +08:00
onMounted(() => {
getIndustriesTree();
});
// 获取行业大类数据
const getIndustriesTree = async () => {
const res = await fetchIndustriesTree();
industriesTree.value = res;
2025-09-04 18:05:16 +08:00
selectedIndustry.value = res[0]?.id;
2025-06-16 14:42:26 +08:00
getIndustryTopics();
};
2025-06-21 11:39:35 +08:00
const handleSort = () => {
console.log('table change');
};
2025-06-16 14:42:26 +08:00
// 行业热门话题
const getIndustryTopics = async () => {
let parms = {
industry_id: selectedIndustry.value,
time_dimension: selectedTimePeriod.value,
};
if (selectedIndustry.value == undefined) {
return;
}
if (selectedSubCategory.value != undefined && selectedSubCategory.value != 0) {
2025-06-17 11:18:39 +08:00
parms['industry_id'] = selectedSubCategory.value;
}
2025-06-16 14:42:26 +08:00
const res = await fetchIndustryTopics(parms);
if (res.code == 200) {
dataList.value = res.data;
}
2025-06-16 14:42:26 +08:00
};
// 详情
const gotoDetail = async (record) => {
console.log(record);
const res = await fetchIndustryTopicDetail(record.id);
if (res.code == 200) {
visible.value = true;
topicInfo.value = res.data;
}
2025-06-16 14:42:26 +08:00
};
// 弹窗的取消
const handleCancel = () => {
visible.value = false;
};
// 弹窗的确定
const handleOk = () => {
visible.value = false;
};
</script>
2025-06-30 18:37:27 +08:00
<style scoped lang="scss">
:deep(.arco-table) {
tbody {
.arco-table-cell {
.arco-table-cell-content {
color: var(--Text-2, #3c4043);
}
}
}
}
2025-06-16 14:42:26 +08:00
/* 自定义样式 */
:deep(.arco-table-th) {
background-color: var(--color-fill-2);
}
:deep(.arco-table-tr):hover {
background-color: var(--color-fill-1);
}
:deep(.arco-btn-outline) {
color: #6d4cfe !important;
border-color: #6d4cfe !important;
}
2025-09-03 16:42:05 +08:00
:deep(.ant-modal-body) {
2025-06-16 14:42:26 +08:00
padding: 0px;
}
.pop-btn {
background: #fff !important;
border-color: #fff !important;
color: #737478 !important;
2025-06-22 16:01:48 +08:00
margin-left: -10px;
}
.pop-btn2 {
background: transparent !important;
border-color: transparent !important;
color: #737478 !important;
margin-left: -10px;
2025-06-16 14:42:26 +08:00
}
2025-06-21 11:39:35 +08:00
:deep(.arco-icon) {
display: inline-block;
vertical-align: middle;
}
/* 按钮悬停效果 */
:deep(.arco-btn-text:not(.arco-btn-disabled):hover) {
background-color: transparent;
}
2025-06-30 18:37:27 +08:00
.title-row {
display: flex;
height: 64px;
padding: 10px 0 2px 0;
align-items: center;
.title {
color: var(--Text-1, #211f24);
font-family: $font-family-medium;
2025-06-30 18:37:27 +08:00
font-size: 16px;
font-style: normal;
font-weight: 400;
line-height: 24px; /* 150% */
}
}
</style>
<style lang="scss">
.hot-translation-modal {
.arco-modal-header {
border-bottom: none;
height: 56px;
padding: 0 20px;
.arco-modal-title {
justify-content: flex-start;
}
}
2025-09-03 16:42:05 +08:00
.ant-modal-body {
2025-06-30 18:37:27 +08:00
padding: 12px 20px 0;
.cts {
color: var(--Text-2, #3c4043);
font-family: $font-family-regular;
2025-06-30 18:37:27 +08:00
font-size: 12px;
font-style: normal;
font-weight: 400;
line-height: 20px; /* 166.667% */
}
p {
margin: 0;
padding: 0;
}
}
.arco-modal-footer {
display: flex;
height: 64px;
padding: 0px 20px;
justify-content: flex-end;
align-items: center;
border-top: 1px solid var(--Border-1, #d7d7d9);
}
}
2025-06-16 14:42:26 +08:00
</style>