diff --git a/Services/client/src/components/FileForm.vue b/Services/client/src/components/FileForm.vue index caaddb0..b8fd34b 100644 --- a/Services/client/src/components/FileForm.vue +++ b/Services/client/src/components/FileForm.vue @@ -190,6 +190,7 @@ const file = ref()
()
() - -const { foundFile } = storeToRefs(useSearchDataStore()) +const props = withDefaults( + defineProps<{ + action: boolean + viewMode: 'view_list' | 'view_module' + }>(), + { + action: false, + }, +) +const { foundFile, isActFoundFile } = storeToRefs(useSearchDataStore()) const { getFileInfo, getSize, getType } = useFileInfoStore() +const { updateFile, deleteFile, checkFile } = useTreeDataStore() const keywordList = ref([]) const categoryList = ref([]) const selectKeyword = ref([]) const selectCategory = ref([]) const filterFoundFile = ref() + +const fileExistNotification = ref(false) +const fileFormError = ref<{ fileExist?: boolean }>({}) +const deleteFormType = ref<'deleteFile'>('deleteFile') +const dialogDeleteState = ref(false) +const deleteFormPath = ref('') + +const fileFormType = ref<'edit'>('edit') +const fileFormState = ref(false) +const fileFormPath = ref('') +const fileFormData = ref<{ + file?: File + title?: string + description?: string + keyword?: string[] + category?: string[] +}>({}) + const columns: QTableProps['columns'] = [ { name: 'name', @@ -53,6 +84,82 @@ const columns: QTableProps['columns'] = [ }, ] +const currentParam = ref[0]>() + +async function submitFileForm( + value: { + mode: 'create' | 'edit' + file?: File + title: string + description: string + keyword: string[] + category: string[] + }, + force = false, +) { + currentParam.value = value + if (value.file && checkFile(value.file.name) && !force) { + fileExistNotification.value = true + return + } + + if (value.mode === 'edit') { + await updateFile( + fileFormPath.value, + { + title: value.title, + description: value.description, + keyword: value.keyword, + category: value.category, + }, + value.file, + ) + setTimeout(() => { + isActFoundFile.value = true + }, 300) + } + + fileFormData.value = {} + fileFormState.value = false + currentParam.value = undefined +} + +function triggerFileEdit( + value: { + title: string + description: string + keyword: string[] + category: string[] + }, + pathname: string, +) { + fileFormState.value = true + fileFormType.value = 'edit' + fileFormPath.value = pathname + fileFormData.value = { + title: value.title, + description: value.description, + keyword: value.keyword, + category: value.category, + } +} + +function triggerFileDelete(pathname: string) { + deleteFormType.value = 'deleteFile' + deleteFormPath.value = pathname + dialogDeleteState.value = !dialogDeleteState.value +} + +function confirmDelete() { + if (deleteFormType) { + deleteFile(deleteFormPath.value) + + setTimeout(() => { + isActFoundFile.value = true + }, 300) + } +} + function filterSearch() { function updateList() { keywordList.value = [] @@ -101,7 +208,7 @@ onMounted(() => { - diff --git a/Services/client/src/components/PageLayout.vue b/Services/client/src/components/PageLayout.vue index 4b87b4c..ed84c84 100644 --- a/Services/client/src/components/PageLayout.vue +++ b/Services/client/src/components/PageLayout.vue @@ -23,7 +23,6 @@ const { data, currentDept, currentPath } = storeToRefs(useTreeDataStore()) const { createFolder, getCabinet, gotoParent, getFolder } = useTreeDataStore() const viewMode = ref<'view_list' | 'view_module'>('view_list') -const inputSearch = ref() const props = defineProps<{ mode: 'admin' | 'user' }>() @@ -71,10 +70,12 @@ onMounted(getCabinet)
ตู้จัดเก็บเอกสาร
@@ -110,6 +111,7 @@ onMounted(getCabinet) > + ผลการค้นหา
- ผลการค้นหา + + -import { ref } from 'vue' import { storeToRefs } from 'pinia' import { useSearchDataStore } from '@/stores/searched-data' -const { isAdvSearchCall } = storeToRefs(useSearchDataStore()) +const { isAdvSearchCall, advSearchDataRow, advSearchDataField } = + storeToRefs(useSearchDataStore()) const optionsField = [ { label: 'ชื่อเรื่อง (title)', value: 'title' }, { label: 'คำสำคัญ (keyword)', value: 'keyword' }, @@ -16,26 +16,6 @@ const optionsOp = [ { label: 'และ', value: 'AND' }, { label: 'หรือ', value: 'OR' }, ] -const advSearchDataRow = ref< - { - op: 'AND' | 'OR' - field: 'title' | 'keyword' - value: string - }[] ->([ - { - op: 'AND', - field: 'title', - value: '', - }, -]) -const advSearchDataField = ref<{ - keyword: string - description: string -}>({ - keyword: '', - description: '', -}) const props = defineProps<{ searchSubmit: Function submitSearchData: { @@ -50,11 +30,6 @@ const props = defineProps<{ } }>() -defineExpose({ - advSearchDataRow, - advSearchDataField, -}) - function addAdvSearchData() { advSearchDataRow.value.push({ op: 'AND', @@ -75,7 +50,7 @@ function clearAdvSearchData() { }, ] advSearchDataField.value = { - keyword: '', + keyword: [], description: '', } } @@ -193,13 +168,17 @@ function clearAdvSearchData() {
-
diff --git a/Services/client/src/modules/01_user/components/SearchBar.vue b/Services/client/src/modules/01_user/components/SearchBar.vue index 4e8d186..824bfde 100644 --- a/Services/client/src/modules/01_user/components/SearchBar.vue +++ b/Services/client/src/modules/01_user/components/SearchBar.vue @@ -1,5 +1,5 @@