fix: move searchData to store

This commit is contained in:
puri-ph4tt 2023-12-06 09:12:07 +07:00
parent 94d1af70ea
commit 0d0ba5068b

View file

@ -2,10 +2,42 @@ import { ref } from 'vue'
import { defineStore } from 'pinia'
import type { EhrFile } from '@/stores/tree-data'
export interface searchData {
field: string
value: string
}
export interface advSearchDataRow {
op: 'AND' | 'OR'
field: 'title' | 'keyword'
value: string
}
export interface advSearchDataField {
keyword: string[]
description: string
}
export const useSearchDataStore = defineStore('searched', () => {
const foundFile = ref<EhrFile[]>([])
const isAdvSearchCall = ref<boolean>(false)
const isSearch = ref<Boolean>(false)
const isActFoundFile = ref<Boolean>(false)
const searchData = ref<searchData>({
field: 'title',
value: '',
})
const advSearchDataRow = ref<advSearchDataRow[]>([
{
op: 'AND',
field: 'title',
value: '',
},
])
const advSearchDataField = ref<advSearchDataField>({
keyword: [],
description: '',
})
async function getFoundFile(data: EhrFile[]) {
foundFile.value = data
@ -15,6 +47,10 @@ export const useSearchDataStore = defineStore('searched', () => {
foundFile,
isSearch,
isAdvSearchCall,
isActFoundFile,
searchData,
advSearchDataRow,
advSearchDataField,
getFoundFile,
}
})