81 lines
1.8 KiB
TypeScript
81 lines
1.8 KiB
TypeScript
import type { SiteType } from '~/types/sys/site';
|
|
import type { GridCodeType } from '~/types';
|
|
import { defineStore } from 'pinia';
|
|
import { computed, ref } from 'vue';
|
|
import { useAxios } from '~/composables/useAxios';
|
|
|
|
export const useLoadingStore = defineStore('useLoadingStore', () => {
|
|
const loadCount = ref<number>(0);
|
|
|
|
const incrementLoadCount = () => {
|
|
loadCount.value++;
|
|
};
|
|
|
|
const decrementLoadCount = () => {
|
|
loadCount.value--;
|
|
};
|
|
|
|
const resetLoadCount = () => {
|
|
loadCount.value = 0;
|
|
};
|
|
|
|
const isLoading = computed(() => {
|
|
return loadCount.value > 0;
|
|
});
|
|
|
|
return {
|
|
isLoading,
|
|
resetLoadCount,
|
|
incrementLoadCount,
|
|
decrementLoadCount
|
|
};
|
|
});
|
|
|
|
export const useDefaultStore = defineStore('useDefaultStore', () => {
|
|
const siteInfo = ref<SiteType>({
|
|
siteId: '',
|
|
siteName: '',
|
|
siteDescription: '',
|
|
siteDomain: '',
|
|
siteType: '',
|
|
sitePrefix: '',
|
|
siteLocale: '',
|
|
siteLogo: '',
|
|
bscUrl: '',
|
|
lgnUrl: '',
|
|
delYn: false,
|
|
useYn: true,
|
|
frstRgtrId: '',
|
|
frstRegDt: '',
|
|
lastMdfrId: '',
|
|
lastMdfcnDt: ''
|
|
});
|
|
|
|
const fetchSiteInfo = async () => {
|
|
const { data } = await useAxios().get<SiteType>('/api/admin/siteInfo');
|
|
siteInfo.value = data;
|
|
};
|
|
|
|
return { siteInfo, fetchSiteInfo };
|
|
});
|
|
|
|
export const useCommonCodeStore = defineStore('useCommonCodeStore', () => {
|
|
|
|
const searchSiteCodeList = async (): Promise<GridCodeType[]> => {
|
|
const { data } = await useAxios().get('/api/admin/code/siteList');
|
|
return data;
|
|
};
|
|
|
|
const searchInstCodeList = async (): Promise<GridCodeType[]> => {
|
|
const { data } = await useAxios().get<GridCodeType[]>(
|
|
'/api/admin/code/instList'
|
|
);
|
|
return data;
|
|
};
|
|
|
|
return {
|
|
searchInstCodeList,
|
|
searchSiteCodeList
|
|
};
|
|
});
|