Blame view

泰额版/Food Labeling Management Code/Yi.Vben5.Vue3/apps/web-antd/src/store/th-tenant.ts 770 Bytes
91821909   杨鑫   最新
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
  import type { ThAppBoundLocationDto } from '#/api/th';
  
  import { defineStore } from 'pinia';
  
  export interface ThTenantContext {
    tenantId: string;
    tenantName: string;
    locations: ThAppBoundLocationDto[];
  }
  
  export const useThTenantStore = defineStore('th-tenant', {
    actions: {
      setTenantContext(ctx: Partial<ThTenantContext>) {
        if (ctx.tenantId != null) {
          this.tenantId = ctx.tenantId;
        }
        if (ctx.tenantName != null) {
          this.tenantName = ctx.tenantName;
        }
        if (ctx.locations != null) {
          this.locations = ctx.locations;
        }
      },
    },
    persist: {
      pick: ['tenantId', 'tenantName', 'locations'],
    },
    state: (): ThTenantContext => ({
      tenantId: '',
      tenantName: '',
      locations: [],
    }),
  });