diff --git a/Services/client/src/modules/01_user/components/AdvancedSearch.vue b/Services/client/src/modules/01_user/components/AdvancedSearch.vue
index 4e0390c..7181c36 100644
--- a/Services/client/src/modules/01_user/components/AdvancedSearch.vue
+++ b/Services/client/src/modules/01_user/components/AdvancedSearch.vue
@@ -9,6 +9,8 @@ const { isAdvSearchCall } = storeToRefs(useSearchDataStore())
const optionsField = [
{ label: 'ชื่อเรื่อง (title)', value: 'title' },
{ label: 'คำสำคัญ (keyword)', value: 'keyword' },
+ { label: 'หมวดหมู่ (category)', value: 'category' },
+ { label: 'เนื้อหาในไฟล์ (content)', value: 'attachment.content' },
]
const optionsOp = [
{ label: 'และ', value: 'AND' },
@@ -126,6 +128,7 @@ 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 58d979d..aab8c48 100644
--- a/Services/client/src/modules/01_user/components/SearchBar.vue
+++ b/Services/client/src/modules/01_user/components/SearchBar.vue
@@ -16,6 +16,8 @@ const advSearchComp = ref
>()
const optionsField = [
{ label: 'ชื่อเรื่อง (title)', value: 'title' },
{ label: 'คำสำคัญ (keyword)', value: 'keyword' },
+ { label: 'หมวดหมู่ (category)', value: 'category' },
+ { label: 'เนื้อหาในไฟล์ (content)', value: 'attachment.content' },
]
const searchData = ref<{
field: string
@@ -31,37 +33,48 @@ const submitSearchData = ref<{
AND: [],
OR: [],
})
+const props = defineProps<{
+ mode: 'admin' | 'user'
+}>()
async function searchSubmit() {
if (searchData.value.value.trim() !== '') {
submitSearchData.value = { AND: [], OR: [] }
-
- submitSearchData.value.OR.push({
- field: searchData.value.field,
- value: searchData.value.value,
- })
-
- if (isAdvSearchCall.value && advSearchComp.value) {
- const advField = advSearchComp.value.advSearchDataField
- const advRow = advSearchComp.value.advSearchDataRow
-
- advRow.forEach((d: { field: string; value: string; op: string }) => {
- if (d.field && d.value.trim() !== '') {
- const op = d.op === 'AND' ? 'AND' : 'OR'
- submitSearchData.value[op].push({ field: d.field, value: d.value })
- }
+ if (props.mode === 'admin') {
+ optionsField.forEach((option) => {
+ submitSearchData.value.OR.push({
+ field: option.value,
+ value: searchData.value.value,
+ })
})
- if (advField.keyword.trim() !== '') {
- submitSearchData.value.AND.push({
- field: 'keyword',
- value: advField.keyword,
- })
- }
- if (advField.description.trim() !== '') {
- submitSearchData.value.AND.push({
- field: 'description',
- value: advField.description,
+ } else {
+ submitSearchData.value.OR.push({
+ field: searchData.value.field,
+ value: searchData.value.value,
+ })
+
+ if (isAdvSearchCall.value && advSearchComp.value) {
+ const advField = advSearchComp.value.advSearchDataField
+ const advRow = advSearchComp.value.advSearchDataRow
+
+ advRow.forEach((d: { field: string; value: string; op: string }) => {
+ if (d.field && d.value.trim() !== '') {
+ const op = d.op === 'AND' ? 'AND' : 'OR'
+ submitSearchData.value[op].push({ field: d.field, value: d.value })
+ }
})
+ if (advField.keyword.trim() !== '') {
+ submitSearchData.value.AND.push({
+ field: 'keyword',
+ value: advField.keyword,
+ })
+ }
+ if (advField.description.trim() !== '') {
+ submitSearchData.value.AND.push({
+ field: 'description',
+ value: advField.description,
+ })
+ }
}
}
@@ -69,11 +82,8 @@ async function searchSubmit() {
loaderStore.show()
const res = await axiosClient.post(
`${import.meta.env.VITE_API_ENDPOINT}/search`,
- submitSearchData.value
+ submitSearchData.value,
)
- console.log(submitSearchData.value);
- console.log(res.data);
-
getFoundFile(res.data)
isSearch.value = true
} catch (error) {
@@ -86,59 +96,78 @@ async function searchSubmit() {
-
-
-
-
-
-
-
-
- (searchData.value = '', isSearch = false)"
- class="cursor-pointer"
- />
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ((searchData.value = ''), (isSearch = false))"
+ class="cursor-pointer"
+ />
+
+
+
+
+
+
+
+
-