cache for store chard

This commit is contained in:
Timi
2026-08-24 18:32:48 +08:00
parent 6235cb3e3d
commit fe5d190308
8 changed files with 102 additions and 23 deletions
+16 -2
View File
@@ -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">