|
@@ -11,16 +11,16 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
-import { ref,onMounted, onBeforeUnmount, Ref, onBeforeMount, watch, computed } from 'vue'
|
|
|
|
|
|
+import { ref,onMounted, onBeforeUnmount, Ref, unref, watch, computed } from 'vue'
|
|
import * as echarts from 'echarts'
|
|
import * as echarts from 'echarts'
|
|
-import { useShopInfo } from '/@/stores/shopInfo'
|
|
|
|
import { spCampaignMetricsEnum } from '/@/views/adManage/utils/enum.js'
|
|
import { spCampaignMetricsEnum } from '/@/views/adManage/utils/enum.js'
|
|
import MetricsCards from '/@/components/MetricsCards/index.vue'
|
|
import MetricsCards from '/@/components/MetricsCards/index.vue'
|
|
import XEUtils from 'xe-utils'
|
|
import XEUtils from 'xe-utils'
|
|
-import { buildChartOpt } from '/@/views/adManage/utils/tools.js'
|
|
|
|
-import { usePublicData } from '/@/stores/publicData'
|
|
|
|
-import { storeToRefs } from 'pinia'
|
|
|
|
-import { response } from '/@/utils/tools'
|
|
|
|
|
|
+import { buildChartOpt, parseQueryParams } from '/@/views/adManage/utils/tools.js'
|
|
|
|
+
|
|
|
|
+// import { useShopInfo } from '/@/stores/shopInfo'
|
|
|
|
+// import { usePublicData } from '/@/stores/publicData'
|
|
|
|
+// import { storeToRefs } from 'pinia'
|
|
|
|
|
|
defineOptions({
|
|
defineOptions({
|
|
name: "DataTendencyChart"
|
|
name: "DataTendencyChart"
|
|
@@ -31,7 +31,7 @@ interface Props {
|
|
fetchLine: Function,
|
|
fetchLine: Function,
|
|
fetchLineMonth?: Function,
|
|
fetchLineMonth?: Function,
|
|
fetchLineWeek?: Function,
|
|
fetchLineWeek?: Function,
|
|
- query?: {[key: string]: any},
|
|
|
|
|
|
+ query: {[key: string]: any},
|
|
initMetric?: ShowMetric[],
|
|
initMetric?: ShowMetric[],
|
|
metricEnum?: {[key: string]: string}[]
|
|
metricEnum?: {[key: string]: string}[]
|
|
}
|
|
}
|
|
@@ -44,9 +44,11 @@ const props = withDefaults(defineProps<Props>(), {
|
|
],
|
|
],
|
|
metricEnum: () => spCampaignMetricsEnum
|
|
metricEnum: () => spCampaignMetricsEnum
|
|
})
|
|
})
|
|
-const publicData = usePublicData()
|
|
|
|
|
|
+
|
|
const metrics = ref(props.initMetric)
|
|
const metrics = ref(props.initMetric)
|
|
-const shopInfo = useShopInfo()
|
|
|
|
|
|
+// const shopInfo = useShopInfo()
|
|
|
|
+// const publicData = usePublicData()
|
|
|
|
+// const { dateRange } = storeToRefs(publicData)
|
|
const metricsItems: Ref<MetricData[]> = ref([])
|
|
const metricsItems: Ref<MetricData[]> = ref([])
|
|
let chartObj:any
|
|
let chartObj:any
|
|
const chartRef = ref()
|
|
const chartRef = ref()
|
|
@@ -183,16 +185,8 @@ const option: any = {
|
|
}
|
|
}
|
|
]
|
|
]
|
|
}
|
|
}
|
|
-const { dateRange } = storeToRefs(publicData)
|
|
|
|
const loading = ref(true)
|
|
const loading = ref(true)
|
|
-const queryParams = computed(() => {
|
|
|
|
- return {
|
|
|
|
- profileId: shopInfo.profile.profile_id,
|
|
|
|
- startDate: dateRange.value[0],
|
|
|
|
- endDate: dateRange.value[1],
|
|
|
|
- ...props.query
|
|
|
|
- }
|
|
|
|
-})
|
|
|
|
|
|
+const queryParams = computed(() => parseQueryParams(props.query))
|
|
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
getMetricsItems()
|
|
getMetricsItems()
|
|
@@ -240,7 +234,7 @@ const initLine = async () => {
|
|
for(const info of metrics.value) {
|
|
for(const info of metrics.value) {
|
|
option.legend.selected[info.label] = true
|
|
option.legend.selected[info.label] = true
|
|
}
|
|
}
|
|
- console.log(option)
|
|
|
|
|
|
+ // console.log(option)
|
|
chartObj.setOption(option)
|
|
chartObj.setOption(option)
|
|
loading.value = false
|
|
loading.value = false
|
|
}
|
|
}
|
|
@@ -291,8 +285,9 @@ const changeStatDim = async () => {
|
|
}
|
|
}
|
|
|
|
|
|
watch(
|
|
watch(
|
|
- queryParams,
|
|
|
|
|
|
+ props.query,
|
|
async () => {
|
|
async () => {
|
|
|
|
+ // console.log("------watch-----queryParams", props.query)
|
|
loading.value = true
|
|
loading.value = true
|
|
await getMetricsItems()
|
|
await getMetricsItems()
|
|
const items = await getDataset()
|
|
const items = await getDataset()
|
|
@@ -302,10 +297,6 @@ watch(
|
|
}
|
|
}
|
|
)
|
|
)
|
|
|
|
|
|
-publicData.$subscribe((mutation, state) => {
|
|
|
|
- publicData.setDateRange(state.dateRange)
|
|
|
|
-})
|
|
|
|
-
|
|
|
|
const resizeChart = () => { chartObj.resize() }
|
|
const resizeChart = () => { chartObj.resize() }
|
|
const addResize = () => { window.addEventListener('resize', resizeChart) }
|
|
const addResize = () => { window.addEventListener('resize', resizeChart) }
|
|
const removeResize = () => { window.removeEventListener('resize', resizeChart) }
|
|
const removeResize = () => { window.removeEventListener('resize', resizeChart) }
|