cache for store chard
This commit is contained in:
@@ -9,7 +9,6 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Time } from "timi-web";
|
||||
import EventAPI from "@/api/EventAPI";
|
||||
import StoreChartAPI from "@/api/StoreChartAPI";
|
||||
import type { CustomerDailyStatView } from "@/types/Customer";
|
||||
import type { EventItem } from "@/types/EventItem";
|
||||
@@ -63,7 +62,7 @@ async function loadSummaryData(): Promise<void> {
|
||||
}
|
||||
|
||||
const requestId = ++summaryRequestId;
|
||||
eventList.value = await EventAPI.listValid();
|
||||
eventList.value = await StoreChartAPI.listValidEvents();
|
||||
const eventIdList = getEventIdList();
|
||||
const [customerStatList, recordDailyStatList] = await Promise.all([
|
||||
StoreChartAPI.customerDailyStat({
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import EventAPI from "@/api/EventAPI";
|
||||
import StoreChartAPI from "@/api/StoreChartAPI";
|
||||
import EventRecordCalendar, { type EventRecordCalendarListPayload } from "@/components/EventRecordCalendar.vue";
|
||||
import type { EventItem } from "@/types/EventItem";
|
||||
@@ -44,7 +43,7 @@ onMounted(async () => {
|
||||
});
|
||||
|
||||
async function loadEvents(): Promise<void> {
|
||||
eventList.value = await EventAPI.listValid();
|
||||
eventList.value = await StoreChartAPI.listValidEvents();
|
||||
const eventIdList = getEventIdList();
|
||||
selectedEventIdList.value = selectedEventIdList.value.length ? selectedEventIdList.value.filter(item => eventIdList.includes(item)) : eventIdList;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,6 @@
|
||||
<script setup lang="ts">
|
||||
import { Time } from "timi-web";
|
||||
import type { EChartsOption } from "echarts";
|
||||
import EventAPI from "@/api/EventAPI";
|
||||
import StoreChartAPI from "@/api/StoreChartAPI";
|
||||
import ChartRangeSlider from "@/components/ChartRangeSlider.vue";
|
||||
import type { EventItem } from "@/types/EventItem";
|
||||
@@ -107,7 +106,7 @@ onMounted(async () => {
|
||||
});
|
||||
|
||||
async function loadEvents(): Promise<void> {
|
||||
numberEventList.value = (await EventAPI.listValid()).filter(item => item.valueType === "NUMBER");
|
||||
numberEventList.value = (await StoreChartAPI.listValidEvents()).filter(item => item.valueType === "NUMBER");
|
||||
if (!selectedEventId.value) {
|
||||
selectedEventId.value = numberEventList.value[0]?.id;
|
||||
}
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
<script setup lang="ts">
|
||||
import { Time } from "timi-web";
|
||||
import type { EChartsOption, MarkAreaComponentOption } from "echarts";
|
||||
import EventAPI from "@/api/EventAPI";
|
||||
import StoreAPI from "@/api/StoreAPI";
|
||||
import StoreChartAPI from "@/api/StoreChartAPI";
|
||||
import ChartRangeSlider from "@/components/ChartRangeSlider.vue";
|
||||
import type { EventItem } from "@/types/EventItem";
|
||||
@@ -131,7 +129,7 @@ onBeforeUnmount(() => {
|
||||
});
|
||||
|
||||
async function loadEvents(): Promise<void> {
|
||||
eventList.value = await EventAPI.listValid();
|
||||
eventList.value = await StoreChartAPI.listValidEvents();
|
||||
}
|
||||
|
||||
async function loadDailyStat(): Promise<void> {
|
||||
@@ -203,7 +201,7 @@ async function loadRestDays(): Promise<void> {
|
||||
}
|
||||
|
||||
try {
|
||||
const list = await StoreAPI.businessDayCalendar(storeId, getDateValue(dateList[0]), getDateValue(dateList[dateList.length - 1]));
|
||||
const list = await StoreChartAPI.businessDayCalendar(storeId, getDateValue(dateList[0]), getDateValue(dateList[dateList.length - 1]));
|
||||
if (requestId === restDayRequestId) {
|
||||
restDaySet.value = new Set(getRestDayList(list));
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
<script setup lang="ts">
|
||||
import { Time } from "timi-web";
|
||||
import type { EChartsOption } from "echarts";
|
||||
import EventAPI from "@/api/EventAPI";
|
||||
import StoreChartAPI from "@/api/StoreChartAPI";
|
||||
import type { EventItem } from "@/types/EventItem";
|
||||
import type { StoreEventRecordDailyStatView } from "@/types/Store";
|
||||
@@ -111,7 +110,7 @@ onBeforeUnmount(() => {
|
||||
});
|
||||
|
||||
async function loadEvents(): Promise<void> {
|
||||
eventList.value = await EventAPI.listValid();
|
||||
eventList.value = await StoreChartAPI.listValidEvents();
|
||||
}
|
||||
|
||||
async function loadDailyStat(): Promise<void> {
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
</template>
|
||||
</t-cell>
|
||||
</t-cell-group>
|
||||
</section>
|
||||
<store-data-charts :key="currentStoreStore.currentStoreId" />
|
||||
</section>
|
||||
<store-data-charts :key="`${currentStoreStore.currentStoreId}-${chartRefreshKey}`" />
|
||||
<t-popup v-model="storePickerVisible" placement="bottom">
|
||||
<t-picker
|
||||
v-model="storePickerDraft"
|
||||
@@ -53,7 +53,9 @@
|
||||
import { Message } from "@/utils/message";
|
||||
import { useUserStore } from "timi-web";
|
||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||
import { useNavBarStore } from "@/store/navBarStore";
|
||||
import { gaoRoleCodes, gaoStoreScopePermissionCodes, permissionCodes } from "@/utils/permission";
|
||||
import { clearStoreChartCache } from "@/utils/storeChartCache";
|
||||
|
||||
type PickerValue = string | number;
|
||||
|
||||
@@ -66,6 +68,8 @@ defineOptions({
|
||||
const router = useRouter();
|
||||
const userStore = useUserStore();
|
||||
const currentStoreStore = useCurrentStoreStore();
|
||||
const navBarStore = useNavBarStore();
|
||||
const chartRefreshKey = ref(0);
|
||||
|
||||
const currentStore = computed(() => currentStoreStore.currentStore);
|
||||
const canSelectStore = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
|
||||
@@ -112,6 +116,11 @@ function confirmStorePicker(): void {
|
||||
Message.success("当前门店已切换");
|
||||
}
|
||||
|
||||
function refreshCharts(): void {
|
||||
clearStoreChartCache();
|
||||
chartRefreshKey.value++;
|
||||
}
|
||||
|
||||
// ---------- 门店管理 ----------
|
||||
|
||||
async function goStoreManagement(): Promise<void> {
|
||||
@@ -130,12 +139,17 @@ async function goStoreManagement(): Promise<void> {
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
navBarStore.setRightIcon("refresh", refreshCharts);
|
||||
if (canSelectStore.value) {
|
||||
await currentStoreStore.loadStoreList();
|
||||
} else if (canLoadLoginStore.value) {
|
||||
await currentStoreStore.loadLoginStore();
|
||||
}
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
navBarStore.clearRight();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
|
||||
Reference in New Issue
Block a user