| 123456789101112131415161718192021222324252627282930313233 |
- import { defineStore } from 'pinia';
- import { ref } from 'vue';
- const useQuestionListStore = defineStore('questionList', () => {
- const showQuestionList = ref(false);
- const ListType = ref<'all' | 'workshop' | 'camera'>('all');
- const workshopCodes = ref<string[]>([]);
- const cameraId = ref<number | null>();
- const openList = () => {
- if (showQuestionList.value === false) showQuestionList.value = true;
- };
- const closeList = () => {
- if (showQuestionList.value === true) showQuestionList.value = false;
- };
- const getState = () => ({ type: ListType.value, workshopCodes: workshopCodes.value, cameraId: cameraId.value });
- const setState = (data: { type: 'all' | 'workshop' | 'camera'; workshopCodes?: string[]; cameraId?: number }) => {
- ListType.value = data.type;
- console.log('setState', ListType.value);
- workshopCodes.value = data.workshopCodes || [];
- cameraId.value = data.cameraId || null;
- };
- const clearStore = () => {
- ListType.value = 'all';
- workshopCodes.value = [];
- cameraId.value = null;
- };
- return { showQuestionList, ListType, workshopCodes, cameraId, openList, closeList, getState, setState, clearStore };
- });
- export default useQuestionListStore;
|