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

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

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