feat: scope articles by brand
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { ReloadOutlined } from '@ant-design/icons-vue'
|
||||
import type {
|
||||
Brand,
|
||||
DesktopAccountInfo,
|
||||
MonitoringHotQuestion,
|
||||
MonitoringPlatformAuthorizationStatus,
|
||||
@@ -25,10 +24,12 @@ import {
|
||||
normalizeMonitoringPlatformFilter,
|
||||
normalizeMonitoringPlatformId,
|
||||
} from '@/lib/monitoring-platforms'
|
||||
import { useCompanyStore } from '@/stores/company'
|
||||
|
||||
const { t } = useI18n()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const companyStore = useCompanyStore()
|
||||
|
||||
const trackingMaxHistoryDays = 30
|
||||
const trackingBusinessTimeZone = 'Asia/Shanghai'
|
||||
@@ -98,7 +99,6 @@ const trackingPlatformOptions = [
|
||||
] as const
|
||||
const allQuestionOptionValue = 'all'
|
||||
|
||||
const selectedBrandId = useStorage<number | null>('tracking_selected_brand', null)
|
||||
const selectedQuestionId = useStorage<number | null>('tracking_selected_question', null)
|
||||
const selectedPlatformId = useStorage<string>('tracking_selected_ai_platform_id', 'all')
|
||||
const selectedBusinessDate = useStorage<string>('tracking_selected_business_date', trackingToday)
|
||||
@@ -117,32 +117,8 @@ const selectedQuestionSetOptionValue = computed<string | number>({
|
||||
},
|
||||
})
|
||||
|
||||
const brandsQuery = useQuery({
|
||||
queryKey: ['tracking', 'brands'],
|
||||
queryFn: () => brandsApi.list(),
|
||||
})
|
||||
|
||||
watch(
|
||||
() => brandsQuery.data.value,
|
||||
(brands) => {
|
||||
if (!brands?.length) {
|
||||
return
|
||||
}
|
||||
|
||||
const requestedBrandId = parseNumericQuery(route.query.brand_id)
|
||||
if (requestedBrandId && brands.some((item) => item.id === requestedBrandId)) {
|
||||
selectedBrandId.value = requestedBrandId
|
||||
return
|
||||
}
|
||||
|
||||
if (selectedBrandId.value && brands.some((item) => item.id === selectedBrandId.value)) {
|
||||
return
|
||||
}
|
||||
|
||||
selectedBrandId.value = brands[0].id
|
||||
},
|
||||
{ immediate: true },
|
||||
)
|
||||
const selectedBrandId = computed(() => companyStore.currentBrandId)
|
||||
const selectedBrand = computed(() => companyStore.currentBrand)
|
||||
|
||||
const questionsQuery = useQuery({
|
||||
queryKey: computed(() => ['tracking', 'questions', selectedBrandId.value]),
|
||||
@@ -325,10 +301,6 @@ const collectNowMutation = useMutation({
|
||||
},
|
||||
})
|
||||
|
||||
const selectedBrand = computed<Brand | null>(() => {
|
||||
return brandsQuery.data.value?.find((item) => item.id === selectedBrandId.value) ?? null
|
||||
})
|
||||
|
||||
const currentUserClientOnline = computed(() => {
|
||||
return dashboardQuery.data.value?.runtime.current_user_client_online === true
|
||||
})
|
||||
@@ -850,17 +822,6 @@ function disableTrackingDate(current: dayjs.Dayjs): boolean {
|
||||
:options="trackingPlatformOptions"
|
||||
/>
|
||||
</div>
|
||||
<div class="tracking-action-item">
|
||||
<span class="tracking-action-label">品牌</span>
|
||||
<a-select
|
||||
v-model:value="selectedBrandId"
|
||||
class="tracking-select"
|
||||
:placeholder="t('tracking.brandPlaceholder')"
|
||||
:options="
|
||||
(brandsQuery.data.value ?? []).map((item) => ({ label: item.name, value: item.id }))
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
<div class="tracking-action-item">
|
||||
<span class="tracking-action-label">关键词库(搜索词)</span>
|
||||
<a-select
|
||||
|
||||
Reference in New Issue
Block a user