mirror of
https://git.hmsn.ink/kospo/svcm/oa.git
synced 2026-03-20 02:52:18 +09:00
first
This commit is contained in:
38
src/stores/codeStore.ts
Normal file
38
src/stores/codeStore.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { acceptHMRUpdate, defineStore } from 'pinia'
|
||||
import { useStorage } from '@vueuse/core'
|
||||
import { getDetailCode } from '/@src/service/code'
|
||||
|
||||
export const useCodes = defineStore('codeStore', () => {
|
||||
// 🟡 상태
|
||||
const codes = ref<Record<number, Array<{ cd: string; nm: string }>>>({})
|
||||
|
||||
// 🔵 액션: 코드 불러오기
|
||||
const setDetailCode = async (cd_grp: number) => {
|
||||
if (!codes.value[cd_grp]) {
|
||||
const res = await getDetailCode(cd_grp)
|
||||
codes.value[cd_grp] = res
|
||||
}
|
||||
}
|
||||
|
||||
// 🟢 코드 목록 가져오기
|
||||
const getCodeList = (cd_grp: number) => {
|
||||
return codes.value[cd_grp] || []
|
||||
}
|
||||
|
||||
return {
|
||||
codes,
|
||||
setDetailCode,
|
||||
getCodeList,
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* Pinia supports Hot Module replacement so you can edit your stores and
|
||||
* interact with them directly in your app without reloading the page.
|
||||
*
|
||||
* @see https://pinia.esm.dev/cookbook/hot-module-replacement.html
|
||||
* @see https://vitejs.dev/guide/api-hmr.html
|
||||
*/
|
||||
if (import.meta.hot) {
|
||||
import.meta.hot.accept(acceptHMRUpdate(useCodes, import.meta.hot))
|
||||
}
|
||||
Reference in New Issue
Block a user