提交 40ac72f7 authored 作者: 王鹏飞's avatar 王鹏飞

feat: 更新时间区间选择逻辑,优化事件处理与数据获取

上级 c8936985
......@@ -19,7 +19,7 @@ async function fetchInfo() {
onMounted(fetchInfo)
async function handleStart() {
if (!date.value.length) {
if (date.value?.length !== 2) {
ElMessage.error('请选择时间区间')
return
}
......
......@@ -12,10 +12,6 @@ async function fetchInfo() {
}
onMounted(fetchInfo)
watch(userValue, () => {
handleStart()
})
async function handleStart() {
fetchLabelHot()
fetchLabelTop()
......@@ -273,6 +269,7 @@ const groupMemberTopOption = computed(() => {
]
}
})
watch(userValue, handleStart, { immediate: true })
</script>
<template>
......
......@@ -4,7 +4,7 @@ import { ElMessage } from 'element-plus'
import { useEvent } from '../composables/useEvent'
import { getEventFunnel, saveEventFunnel } from '../api'
const emit = defineEmits(['update:modelValue'])
const emit = defineEmits(['update:modelValue', 'saved'])
const { eventList } = useEvent()
const rules = ref([])
......@@ -31,6 +31,7 @@ async function handelSubmit() {
await saveEventFunnel({ rules: paramsRules })
ElMessage.success('保存成功')
emit('update:modelValue', false)
emit('saved')
}
</script>
......
......@@ -35,8 +35,11 @@ const loading1 = ref(false)
const eventAction = ref()
const eventActionDate = ref([])
async function fetchEventAction() {
const [startDate, endDate] = eventActionDate.value
if (!userValue.value || !eventValue.value || !startDate || !endDate) return
const [startDate, endDate] = eventActionDate.value || []
if (!userValue.value || !eventValue.value || !startDate || !endDate) {
eventAction.value = undefined
return
}
loading1.value = true
try {
const res = await api.getEventAction({
......@@ -92,8 +95,11 @@ const loading2 = ref(false)
const marketing = ref([])
const marketingDate = ref([])
async function fetchMarketing() {
const [startDate, endDate] = marketingDate.value
if (!userValue.value || !startDate || !endDate) return
const [startDate, endDate] = marketingDate.value || []
if (!userValue.value || !startDate || !endDate) {
marketing.value = []
return
}
loading2.value = true
try {
const res = await api.getEventMarketing({ sso_id: userValue.value, start_date: startDate, end_date: endDate })
......@@ -125,7 +131,10 @@ const userEndDate = computed(() => {
})
async function fetchUser() {
if (!userValue.value || !userStartDate.value || !userEndDate.value) return
if (!userValue.value || !userStartDate.value || !userEndDate.value) {
user.value = []
return
}
loading3.value = true
try {
const res = await api.getMemberList({
......@@ -142,6 +151,7 @@ async function fetchUser() {
function format(date) {
return dayjs(date).format('MM-DD (dd)')
}
watch(userValue, handleStart)
</script>
<template>
......@@ -245,7 +255,7 @@ function format(date) {
</ChartCard>
</el-col>
</el-row>
<MarketingDialog v-model="dialogVisible" v-if="dialogVisible"></MarketingDialog>
<MarketingDialog v-model="dialogVisible" v-if="dialogVisible" @saved="fetchMarketing"></MarketingDialog>
</AppCard>
</template>
......
......@@ -22,10 +22,6 @@ async function fetchInfo() {
}
onMounted(fetchInfo)
watch(userValue, () => {
handleStart()
})
async function handleStart() {
fetchGender()
fetchConnections()
......@@ -176,6 +172,7 @@ const statusOption = computed(() => {
],
}
})
watch(userValue, handleStart, { immediate: true })
</script>
<template>
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论