|
@@ -2,12 +2,27 @@
|
|
|
import { Delete, Edit } from '@element-plus/icons-vue'
|
|
|
import * as echarts from 'echarts'
|
|
|
import { ElMessage } from 'element-plus'
|
|
|
-import { inject, onBeforeUnmount, onMounted, ref } from 'vue'
|
|
|
+import { inject, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
|
|
import emitter from '/@/utils/emitter'
|
|
|
import { getProductCardData, postDeleteProductLine } from '/@/views/productCenter/productList/api'
|
|
|
|
|
|
-const profile = <any>inject('profile')
|
|
|
+emitter.on('ProductList-updateCardData', (value: any) => {
|
|
|
+ if (value.isUpdate) {
|
|
|
+ cardData.value.splice(0)
|
|
|
+ fetchProductCardData()
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+emitter.on('TopFilters-selectValue', (value: any) => {
|
|
|
+ const newIndex = cardData.value.findIndex((item) => item.productlineId === value.selectValue)
|
|
|
+ if (newIndex !== -1) {
|
|
|
+ selectedCardIndex.value = newIndex
|
|
|
+ }
|
|
|
+})
|
|
|
|
|
|
+const profile = <any>inject('profile')
|
|
|
+const dateRange = <any>inject('dateRange')
|
|
|
+const loading = ref(false)
|
|
|
const cardData = ref([])
|
|
|
const pieChartRefs = ref<HTMLDivElement[]>([])
|
|
|
|
|
@@ -15,7 +30,11 @@ const selectedCardIndex = ref(0)
|
|
|
|
|
|
async function fetchProductCardData() {
|
|
|
try {
|
|
|
- const { data } = await getProductCardData({ profileId: profile.value.profile_id })
|
|
|
+ const { data } = await getProductCardData({
|
|
|
+ profileId: profile.value.profile_id,
|
|
|
+ startDate: dateRange.value[0],
|
|
|
+ endDate: dateRange.value[1]
|
|
|
+ })
|
|
|
cardData.value = data
|
|
|
} catch (error) {
|
|
|
console.log('error:', error)
|
|
@@ -107,18 +126,11 @@ async function deleteProductLine(item) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-emitter.on('ProductList-updateCardData', (value: any) => {
|
|
|
- if (value.isUpdate) {
|
|
|
- cardData.value.splice(0)
|
|
|
- fetchProductCardData()
|
|
|
- }
|
|
|
-})
|
|
|
-
|
|
|
-emitter.on('TopFilters-selectValue', (value: any) => {
|
|
|
- const newIndex = cardData.value.findIndex((item) => item.productlineId === value.selectValue)
|
|
|
- if (newIndex !== -1) {
|
|
|
- selectedCardIndex.value = newIndex
|
|
|
- }
|
|
|
+watch(dateRange, async() => {
|
|
|
+ loading.value = true
|
|
|
+ console.log(123)
|
|
|
+ await fetchProductCardData()
|
|
|
+ loading.value = false
|
|
|
})
|
|
|
|
|
|
onMounted(async () => {
|
|
@@ -132,7 +144,7 @@ onBeforeUnmount(() => {
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
- <div class="out-container">
|
|
|
+ <div class="out-container" v-loading="loading">
|
|
|
<el-scrollbar>
|
|
|
<div class="scrollbar-flex-content">
|
|
|
<el-card
|