BasicData.nvue
4.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<template>
<view>
<CardNvue :title="t('asis.BasicAnalysis')" :auto-height="true" card-padding="28rpx 0 0" :titleStyle="{padding:'0 28rpx'}">
<template #filter>
<view class="filter filter-border transparent-bg" @tap="handleTapMore" v-if="showMore">
<text class="filter_text">{{ t('app.common.more') }}</text>
<uv-icon name="arrow-right" color="#90949D" size="24rpx" />
</view>
</template>
<template #content>
<AccountBasicData v-if="!options.storeId" :card-data="accountCardComputedList" />
<StoreBasicData v-else :card-data="getStoreCards" :card-data-map="cardDataMap" />
</template>
</CardNvue>
<uv-popup ref="morePopupRef" class="pop_more" round="16rpx">
<view style="width: 710rpx;">
<view class="pop_header" style="width: 100%;">
<view style="width: 22px;"></view>
<text class="pop_header_text">{{ t('asis.BasicAnalysis') }}</text>
<uv-icon name="close" size="22" class="pop_header_icon" @tap="handleCloseMore"></uv-icon>
</view>
<view>
<scroll-view scroll-y="true" style="height: 640rpx;">
<AccountBasicData v-if="!options.storeId" :card-data="accountCardList" />
<StoreBasicData v-else :card-data="storeCards" :card-data-map="cardDataMap" />
</scroll-view>
</view>
</view>
</uv-popup>
</view>
</template>
<script setup>
import {
ref,
onMounted,
computed,
nextTick
} from 'vue';
import {
getAccountCardListApi,
getStoreBasicDataApi
} from '@/api'
import {
formatSeconds,
getStageObj
} from '@/utils'
import CardNvue from './Card.nvue';
import AccountBasicData from './AccountBasicData.nvue'
import StoreBasicData from './StoreBasicData.nvue'
import {
t
} from '@/plugins/index.js'
const props = defineProps({
// 集团卡片数据
storeCards: {
type: Array,
default: () => []
}
})
/********************* 更多 ************************/
const morePopupRef = ref(null)
const handleTapMore = () => {
morePopupRef.value?.open()
}
const handleCloseMore = ()=>{
morePopupRef.value?.close()
}
const showMore = computed(() => {
const isAccount = !options.value.storeId
return (isAccount && accountCardList.value.length > 6) || (!isAccount && props.storeCards.length > 6)
})
const getStoreCards = computed(() => {
return props.storeCards.slice(0, 6) || []
})
const storeChartIds = ref([])
const initStoreCardData = () => {
nextTick(() => {
storeChartIds.value = props.storeCards.map(el => el.id)
getCardDataMap()
})
}
// 获取门店卡片数据·
const cardDataMap = ref({})
const getCardDataMap = async () => {
try {
const {
data
} = await getStoreBasicDataApi({
orgType: 'mall',
mallIds: options.value.storeId,
dateType: props.unit,
orgIds: options.value.storeId,
startDate: options.value.startDate,
endDate: options.value.endDate,
chartIds: storeChartIds.value.join(',')
})
cardDataMap.value = data || {}
} catch (e) {
console.log(e);
}
}
// 获取集团卡片数据
const options = ref({})
const accountId = ref('')
const initAccountCardData = (params) => {
nextTick(() => {
accountId.value = getStageObj('account').id
options.value = params
getAccountCardList()
})
}
// 获取集团卡片列表
const accountCardList = ref([])
const accountCardComputedList = computed(() => {
return accountCardList.value?.slice(0, 4) || []
})
const getAccountCardList = async () => {
try {
const params = {
accountId: accountId.value,
groupId: options.value.groupId ? options.value.groupId : -1,
endDate: options.value.endDate,
startDate: options.value.startDate
}
// 测试参数
// const params = {
// accountId: 382,
// groupId: -1,
// endDate: '2025-05-21',
// startDate: '2025-05-01'
// }
const {
data
} = await getAccountCardListApi(params)
accountCardList.value = data || []
} catch (e) {
console.log(res)
}
}
defineExpose({
initAccountCardData,
initStoreCardData
})
</script>
<style lang="scss" scoped>
@import '@/styles/normal.scss';
.filter {
flex-direction: row;
align-items: center;
.filter_text {
font-size: 24rpx;
color: #6D778F;
margin-right: 10rpx;
}
}
</style>