Browse Source

✨ feat(监控链接): 调整字段

dodo hold 7 months ago
parent
commit
7ccde3a121
3 changed files with 92 additions and 143 deletions
  1. 5 0
      src/api/tracks.ts
  2. 56 79
      src/views/site/tracks.vue
  3. 31 64
      src/views/site/tracksReport.vue

+ 5 - 0
src/api/tracks.ts

@@ -5,8 +5,10 @@ export interface TrackLinkRecord {
     id: number;
     event_type: string;
     platform: string;
+    typename: string;
     scene: string;
     unique_id: string;
+    description: string;
     path: string;
     create_time: Date;
     update_time: Date;
@@ -17,8 +19,10 @@ export interface TrackReportRecord {
     track_link_id: number;
     event_type: string;
     platform: string;
+    typename: string;
     scene: string;
     unique_id: string;
+    description: string;
     report_date: string;
     event_count: number;
     create_time: Date;
@@ -40,6 +44,7 @@ export interface TrackReportParams {
     track_link_id?: number;
     event_type?: string;
     platform?: string;
+    typename?: string;
     scene?: string;
     unique_id?: string;
     start?: string;

+ 56 - 79
src/views/site/tracks.vue

@@ -58,10 +58,13 @@
                     </a-tag>
                 </template>
                 <template #platform="{ record }">
-                    {{ getTypeName(record.platform) }}
+                    {{ getPlatformNameById(Number(record.platform)) }}
+                </template>
+                <template #typename="{ record }">
+                    {{ record.typename || '-' }}
                 </template>
                 <template #scene="{ record }">
-                    {{ getSubTypeName(record.scene) }}
+                    {{ record.scene || '-' }}
                 </template>
                 <template #path="{ record }">
                     <a-typography-paragraph copyable :ellipsis="{ rows: 1 }" style="margin-bottom: 0;">
@@ -96,25 +99,21 @@
                         <a-option value="click">点击 (click)</a-option>
                     </a-select>
                 </a-form-item>
-                <a-form-item label="平台 (platform)" required>
-                    <a-select v-model="addForm.platform" placeholder="请选择或搜索平台" allow-search allow-clear
-                        :filter-option="filterOption">
-                        <a-option v-for="item in platformOptions" :key="item.value" :value="item.value">
-                            {{ item.label }}
-                        </a-option>
-                    </a-select>
+                <a-form-item label="平台 (platform)">
+                    <a-input v-model="addForm.platform" placeholder="可选,输入平台ID,如:1(淘宝)、2(抖音)、13(京东)" allow-clear />
                 </a-form-item>
-                <a-form-item label="场景 (scene)" required>
-                    <a-select v-model="addForm.scene" placeholder="请选择或搜索场景" allow-search allow-clear
-                        :filter-option="filterOption">
-                        <a-option v-for="item in sceneOptions" :key="item.value" :value="item.value">
-                            {{ item.label }}
-                        </a-option>
-                    </a-select>
+                <a-form-item label="类型 (typename)">
+                    <a-input v-model="addForm.typename" placeholder="可选,输入类型,如:口令、SDK优惠券" allow-clear />
+                </a-form-item>
+                <a-form-item label="场景 (scene)">
+                    <a-input v-model="addForm.scene" placeholder="可选,输入场景,如:100000、应用建议卡" allow-clear />
                 </a-form-item>
                 <a-form-item label="唯一标识 (unique_id)">
                     <a-input v-model="addForm.unique_id" placeholder="可选,用于区分同一场景下的不同链接" allow-clear />
                 </a-form-item>
+                <a-form-item label="描述 (description)">
+                    <a-input v-model="addForm.description" placeholder="可选,链接描述" allow-clear />
+                </a-form-item>
             </a-form>
         </a-modal>
 
@@ -144,6 +143,12 @@
                         {{ record.event_type === 'expose' ? '曝光' : '点击' }}
                     </a-tag>
                 </template>
+                <template #report_platform="{ record }">
+                    {{ getPlatformNameById(Number(record.platform)) }}
+                </template>
+                <template #report_scene="{ record }">
+                    {{ record.scene || '-' }}
+                </template>
                 <template #event_count="{ record }">
                     <a-tag color="arcoblue">{{ record.event_count }}</a-tag>
                 </template>
@@ -164,6 +169,7 @@ import {
     TrackLinkRecord, TrackReportRecord, TrackListParams, TrackReportParams,
     queryTrackList, createTrack, deleteTrack, queryTrackReport
 } from '@/api/tracks';
+import { getPlatformNameById } from '@/constants/pushPlatform';
 
 const { loading, setLoading } = useLoading(false);
 const renderData = ref<TrackLinkRecord[]>([]);
@@ -180,58 +186,15 @@ const pagination = reactive({
     ...basePagination,
 });
 
-// 平台选项 - 来自 getTypeName
-const platformOptions = [
-    { label: '口令', value: 'kouling' },
-    { label: 'SDK优惠券', value: 'sdk_coupon' },
-    { label: '应用建议卡', value: 'app_suggest' },
-    { label: '购物助手', value: 'shopping_helper' },
-    { label: '侧边栏', value: 'sidebar' },
-    { label: '搜同款', value: 'search_similar' },
-];
-
-// 场景选项 - 来自 getSubTypeName
-const sceneOptions = [
-    { label: '口令', value: 'kouling' },
-    { label: '应用内优惠券', value: 'app_coupon' },
-    { label: '应用建议卡', value: 'app_suggest_card' },
-    { label: '浏览器DP', value: 'browser_dp' },
-    { label: '全搜', value: 'full_search' },
-    { label: '分页符', value: 'page_break' },
-    { label: '侧边栏', value: 'sidebar' },
-    { label: '搜同款拍一拍', value: 'search_similar_tap' },
-    { label: '搜同款相册', value: 'search_similar_album' },
-    { label: '搜同款助力栏', value: 'search_similar_assist' },
-    { label: '搜同款默认', value: 'search_similar_default' },
-    { label: '搜同款识屏', value: 'search_similar_screen' },
-    { label: '搜同款小布CUI拍一拍', value: 'search_similar_cui_tap' },
-    { label: '搜同款小布CUI客户端', value: 'search_similar_cui_client' },
-];
-
-// 获取平台名称
-const getTypeName = (platform: string) => {
-    const item = platformOptions.find(p => p.value === platform);
-    return item ? item.label : platform;
-};
-
-// 获取场景名称
-const getSubTypeName = (scene: string) => {
-    const item = sceneOptions.find(s => s.value === scene);
-    return item ? item.label : scene;
-};
-
-const filterOption = (inputValue: string, option: any) => {
-    return option.label.toLowerCase().includes(inputValue.toLowerCase()) ||
-        option.value.toLowerCase().includes(inputValue.toLowerCase());
-};
-
 const columns = computed<TableColumnData[]>(() => [
     { title: '#', slotName: 'index', width: 60 },
     { title: '事件类型', slotName: 'event_type', width: 100 },
-    { title: '平台', slotName: 'platform', width: 120 },
+    { title: '平台', slotName: 'platform', width: 100 },
+    { title: '类型', slotName: 'typename', width: 120 },
     { title: '场景', slotName: 'scene', width: 150 },
-    { title: 'UniqueId', dataIndex: 'unique_id', width: 120, ellipsis: true },
-    { title: '路径', slotName: 'path', width: 300 },
+    { title: 'UniqueId', dataIndex: 'unique_id', width: 100, ellipsis: true },
+    { title: '描述', dataIndex: 'description', width: 150, ellipsis: true },
+    { title: '路径', slotName: 'path', width: 250 },
     { title: '时间', slotName: 'time', width: 160 },
     { title: '操作', slotName: 'operations', width: 160, fixed: 'right' },
 ]);
@@ -239,11 +202,12 @@ const columns = computed<TableColumnData[]>(() => [
 const fetchData = async (params: TrackListParams) => {
     setLoading(true);
     try {
-        const { data } = await queryTrackList(params);
-        if (!data) return;
-        renderData.value = data.list || [];
-        pagination.current = data.page;
-        pagination.total = data.count;
+        const res: any = await queryTrackList(params);
+        if (res && res.data) {
+            renderData.value = res.data.list || [];
+            pagination.current = res.data.page || 1;
+            pagination.total = res.data.count || 0;
+        }
     } catch (err) {
         console.error(err);
     } finally {
@@ -270,26 +234,37 @@ const onPageChange = (current: number) => {
 
 // 新增链接
 const addModalVisible = ref(false);
-const addForm = ref({
+const addForm = ref<{
+    event_type: string;
+    platform: string;
+    typename: string;
+    scene: string;
+    unique_id: string;
+    description: string;
+}>({
     event_type: 'expose',
     platform: '',
+    typename: '',
     scene: '',
     unique_id: '',
+    description: '',
 });
 
 const onAdd = () => {
     addForm.value = {
         event_type: 'expose',
         platform: '',
+        typename: '',
         scene: '',
         unique_id: '',
+        description: '',
     };
     addModalVisible.value = true;
 };
 
 const handleAddSubmit = async () => {
-    if (!addForm.value.platform || !addForm.value.scene) {
-        Message.warning('请填写平台和场景');
+    if (!addForm.value.event_type) {
+        Message.warning('请选择事件类型');
         return;
     }
     try {
@@ -321,11 +296,11 @@ const onDelete = (record: TrackLinkRecord) => {
         onOk: async () => {
             try {
                 const res: any = await deleteTrack(record.id);
-                if (res.success) {
-                    Message.success(res.msg || '删除成功');
+                if (res.success || res.data?.success) {
+                    Message.success(res.msg || res.data?.msg || '删除成功');
                     search();
                 } else {
-                    Message.error(res.msg || '删除失败');
+                    Message.error(res.msg || res.data?.msg || '删除失败');
                 }
             } catch (error) {
                 Message.error('删除请求失败');
@@ -409,8 +384,8 @@ const reportPagination = reactive({
 const reportColumns = computed<TableColumnData[]>(() => [
     { title: '日期', slotName: 'report_date', width: 120 },
     { title: '事件类型', slotName: 'event_type', width: 100 },
-    { title: '平台', dataIndex: 'platform', width: 100 },
-    { title: '场景', dataIndex: 'scene', width: 120 },
+    { title: '平台', slotName: 'report_platform', width: 100 },
+    { title: '场景', slotName: 'report_scene', width: 120 },
     { title: 'UniqueId', dataIndex: 'unique_id', width: 120 },
     { title: '事件数', slotName: 'event_count', width: 100 },
 ]);
@@ -419,9 +394,11 @@ const currentTrackInfo = computed(() => {
     if (!currentTrack.value) return [];
     return [
         { label: '事件类型', value: currentTrack.value.event_type === 'expose' ? '曝光' : '点击' },
-        { label: '平台', value: getTypeName(currentTrack.value.platform) },
-        { label: '场景', value: getSubTypeName(currentTrack.value.scene) },
+        { label: '平台', value: getPlatformNameById(Number(currentTrack.value.platform)) },
+        { label: '类型', value: currentTrack.value.typename || '-' },
+        { label: '场景', value: currentTrack.value.scene || '-' },
         { label: 'UniqueId', value: currentTrack.value.unique_id || '-' },
+        { label: '描述', value: currentTrack.value.description || '-' },
     ];
 });
 

+ 31 - 64
src/views/site/tracksReport.vue

@@ -3,12 +3,12 @@
         <Breadcrumb :items="['menu.settings', 'menu.tracksReport']" />
         <a-card class="general-card" title="监测链接报表">
             <a-row :gutter="16" style="margin-bottom: 16px;">
-                <a-col :span="6">
+                <a-col :span="5">
                     <a-form-item label="时间范围">
                         <a-range-picker v-model="dateRange" style="width: 100%;" @change="onDateChange" />
                     </a-form-item>
                 </a-col>
-                <a-col :span="4">
+                <a-col :span="3">
                     <a-form-item label="事件类型">
                         <a-select v-model="formModel.event_type" placeholder="全部" allow-clear @change="search">
                             <a-option value="expose">曝光</a-option>
@@ -16,24 +16,19 @@
                         </a-select>
                     </a-form-item>
                 </a-col>
-                <a-col :span="4">
+                <a-col :span="3">
                     <a-form-item label="平台">
-                        <a-select v-model="formModel.platform" placeholder="全部" allow-clear allow-search
-                            :filter-option="filterOption" @change="search">
-                            <a-option v-for="item in platformOptions" :key="item.value" :value="item.value">
-                                {{ item.label }}
-                            </a-option>
-                        </a-select>
+                        <a-input v-model="formModel.platform" placeholder="平台ID" allow-clear @press-enter="search" />
                     </a-form-item>
                 </a-col>
-                <a-col :span="4">
+                <a-col :span="3">
+                    <a-form-item label="类型">
+                        <a-input v-model="formModel.typename" placeholder="类型" allow-clear @press-enter="search" />
+                    </a-form-item>
+                </a-col>
+                <a-col :span="3">
                     <a-form-item label="场景">
-                        <a-select v-model="formModel.scene" placeholder="全部" allow-clear allow-search
-                            :filter-option="filterOption" @change="search">
-                            <a-option v-for="item in sceneOptions" :key="item.value" :value="item.value">
-                                {{ item.label }}
-                            </a-option>
-                        </a-select>
+                        <a-input v-model="formModel.scene" placeholder="场景" allow-clear @press-enter="search" />
                     </a-form-item>
                 </a-col>
                 <a-col :span="3">
@@ -56,10 +51,13 @@
                     </a-tag>
                 </template>
                 <template #platform="{ record }">
-                    {{ getTypeName(record.platform) }}
+                    {{ getPlatformNameById(Number(record.platform)) }}
+                </template>
+                <template #typename="{ record }">
+                    {{ record.typename || '-' }}
                 </template>
                 <template #scene="{ record }">
-                    {{ getSubTypeName(record.scene) }}
+                    {{ record.scene || '-' }}
                 </template>
                 <template #event_count="{ record }">
                     <a-tag color="arcoblue">{{ record.event_count.toLocaleString() }}</a-tag>
@@ -76,6 +74,7 @@ import useLoading from '@/hooks/loading';
 import { Pagination } from '@/types/global';
 import type { TableColumnData } from '@arco-design/web-vue/es/table/interface';
 import { TrackReportRecord, TrackReportParams, queryTrackReport } from '@/api/tracks';
+import { getPlatformNameById } from '@/constants/pushPlatform';
 
 const { loading, setLoading } = useLoading(false);
 const renderData = ref<TrackReportRecord[]>([]);
@@ -85,9 +84,16 @@ const dateRange = ref<string[]>([
     dayjs().format('YYYY-MM-DD')
 ]);
 
-const formModel = ref({
+const formModel = ref<{
+    event_type: string;
+    platform: string;
+    typename: string;
+    scene: string;
+    unique_id: string;
+}>({
     event_type: '',
     platform: '',
+    typename: '',
     scene: '',
     unique_id: '',
 });
@@ -100,55 +106,14 @@ const pagination = reactive({
     ...basePagination,
 });
 
-// 平台选项
-const platformOptions = [
-    { label: '口令', value: 'kouling' },
-    { label: 'SDK优惠券', value: 'sdk_coupon' },
-    { label: '应用建议卡', value: 'app_suggest' },
-    { label: '购物助手', value: 'shopping_helper' },
-    { label: '侧边栏', value: 'sidebar' },
-    { label: '搜同款', value: 'search_similar' },
-];
-
-// 场景选项
-const sceneOptions = [
-    { label: '口令', value: 'kouling' },
-    { label: '应用内优惠券', value: 'app_coupon' },
-    { label: '应用建议卡', value: 'app_suggest_card' },
-    { label: '浏览器DP', value: 'browser_dp' },
-    { label: '全搜', value: 'full_search' },
-    { label: '分页符', value: 'page_break' },
-    { label: '侧边栏', value: 'sidebar' },
-    { label: '搜同款拍一拍', value: 'search_similar_tap' },
-    { label: '搜同款相册', value: 'search_similar_album' },
-    { label: '搜同款助力栏', value: 'search_similar_assist' },
-    { label: '搜同款默认', value: 'search_similar_default' },
-    { label: '搜同款识屏', value: 'search_similar_screen' },
-    { label: '搜同款小布CUI拍一拍', value: 'search_similar_cui_tap' },
-    { label: '搜同款小布CUI客户端', value: 'search_similar_cui_client' },
-];
-
-const getTypeName = (platform: string) => {
-    const item = platformOptions.find(p => p.value === platform);
-    return item ? item.label : platform;
-};
-
-const getSubTypeName = (scene: string) => {
-    const item = sceneOptions.find(s => s.value === scene);
-    return item ? item.label : scene;
-};
-
-const filterOption = (inputValue: string, option: any) => {
-    return option.label.toLowerCase().includes(inputValue.toLowerCase()) ||
-        option.value.toLowerCase().includes(inputValue.toLowerCase());
-};
-
 const columns = computed<TableColumnData[]>(() => [
     { title: '日期', slotName: 'report_date', width: 120 },
     { title: '事件类型', slotName: 'event_type', width: 100 },
-    { title: '平台', slotName: 'platform', width: 120 },
+    { title: '平台', slotName: 'platform', width: 100 },
+    { title: '类型', slotName: 'typename', width: 120 },
     { title: '场景', slotName: 'scene', width: 150 },
-    { title: 'UniqueId', dataIndex: 'unique_id', width: 120, ellipsis: true },
+    { title: 'UniqueId', dataIndex: 'unique_id', width: 100, ellipsis: true },
+    { title: '描述', dataIndex: 'description', width: 150, ellipsis: true },
     { title: '事件数', slotName: 'event_count', width: 120 },
 ]);
 
@@ -173,6 +138,7 @@ const search = () => {
         ...basePagination,
         event_type: formModel.value.event_type || undefined,
         platform: formModel.value.platform || undefined,
+        typename: formModel.value.typename || undefined,
         scene: formModel.value.scene || undefined,
         start: dateRange.value[0],
         end: dateRange.value[1],
@@ -191,6 +157,7 @@ const onPageChange = (current: number) => {
         current,
         event_type: formModel.value.event_type || undefined,
         platform: formModel.value.platform || undefined,
+        typename: formModel.value.typename || undefined,
         scene: formModel.value.scene || undefined,
         start: dateRange.value[0],
         end: dateRange.value[1],