Merge branch 'net' into development

This commit is contained in:
somnetsak123 2023-11-30 18:05:08 +07:00
commit a497ec0a21
2 changed files with 64 additions and 30 deletions

View file

@ -2,8 +2,12 @@
import { onMounted, onUnmounted, ref } from 'vue' import { onMounted, onUnmounted, ref } from 'vue'
const storesKeyword = ['test1', 'test2', 'test3', 'test4', 'test5'] const storesKeyword = ['test1', 'test2', 'test3', 'test4', 'test5']
const filterOptions = ref(storesKeyword) const storesCategory = ['Category1', 'Category2', 'Category3', 'Category4', 'Category5']
const filterDataKeyword = ref(storesKeyword)
const filterDataCategory = ref(storesCategory)
const inputKeyword = ref<string[]>([]) const inputKeyword = ref<string[]>([])
const inputCategory = ref<string[]>([])
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
@ -73,10 +77,32 @@ function createkeyword(val, done) {
function filterkeyword(val, update) { function filterkeyword(val, update) {
update(() => { update(() => {
if (val === '') { if (val === '') {
filterOptions.value = storesKeyword filterDataKeyword.value = storesKeyword
} else { } else {
const needle = val.toLowerCase() const needle = val.toLowerCase()
filterOptions.value = storesKeyword.filter( filterDataKeyword.value = storesKeyword.filter(
(v) => v.toLowerCase().indexOf(needle) > -1
)
}
})
}
function createCategory(val, done) {
if (val.length > 2) {
if (!inputCategory.value.includes(val)) {
done(val, 'add-unique')
}
}
}
function filterCategory(val, update) {
update(() => {
if (val === '') {
filterDataCategory.value = storesCategory
} else {
const needle = val.toLowerCase()
filterDataCategory.value = storesCategory.filter(
(v) => v.toLowerCase().indexOf(needle) > -1 (v) => v.toLowerCase().indexOf(needle) > -1
) )
} }
@ -135,8 +161,8 @@ const file = ref<File | undefined>()
error.fileExist error.fileExist
? 'พบไฟล์ในระบบ ข้อมูลในระบบจะถูกเขียนทับ' ? 'พบไฟล์ในระบบ ข้อมูลในระบบจะถูกเขียนทับ'
: error.fileName2Long : error.fileName2Long
? 'ไม่สามารถเพิ่มไฟล์ที่ชื่อยาวเกิน 85 ตัวอักษรได้' ? 'ไม่สามารถเพิ่มไฟล์ที่ชื่อยาวเกิน 85 ตัวอักษรได้'
: '' : ''
" "
> >
<template v-slot:prepend> <template v-slot:prepend>
@ -171,15 +197,28 @@ const file = ref<File | undefined>()
</section> </section>
<section class="q-mb-md"> <section class="q-mb-md">
<span class="text-weight-bold">กล/หมวดหม</span> <span class="text-weight-bold">กล/หมวดหม</span>
<q-input <div class="q-mt-md">
outlined <q-select
dense outlined
class="q-mt-sm" :model-value="category"
placeholder="เลือกกลุ่ม/หมวดหมู่" use-input
:model-value="category" use-chips
@update:model-value="(v) => $emit('update:category', v)" multiple
/> input-debounce="0"
@new-value="createCategory"
:options="filterDataCategory"
@filter="filterCategory"
style="width: 250px"
@update:model-value="(v) => $emit('update:category', v)"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey"> No results </q-item-section>
</q-item>
</template>
</q-select>
</div>
</section> </section>
<section class="q-mb-md"> <section class="q-mb-md">
@ -187,15 +226,16 @@ const file = ref<File | undefined>()
<div class="q-mt-md"> <div class="q-mt-md">
<q-select <q-select
outlined outlined
v-model="inputKeyword" :model-value="keyword"
use-input use-input
use-chips use-chips
multiple multiple
input-debounce="0" input-debounce="0"
@new-value="createkeyword" @new-value="createkeyword"
:options="filterOptions" :options="filterDataKeyword"
@filter="filterkeyword" @filter="filterkeyword"
style="width: 250px" style="width: 250px"
@update:model-value="(v) => $emit('update:keyword', v)"
> >
<template v-slot:no-option> <template v-slot:no-option>
<q-item> <q-item>

View file

@ -30,7 +30,6 @@ const {
updateFile, updateFile,
deleteFile, deleteFile,
checkFile, checkFile,
checkFileName,
} = useTreeDataStore() } = useTreeDataStore()
const currentIcon = computed(() => const currentIcon = computed(() =>
@ -61,7 +60,7 @@ const fileFormData = ref<{
category?: string category?: string
}>({}) }>({})
const fileFormType = ref<'edit' | 'create'>('create') const fileFormType = ref<'edit' | 'create'>('create')
const fileFormError = ref<{ fileExist?: boolean; fileName2Long?: boolean }>({}) const fileFormError = ref<{ fileExist?: boolean }>({})
const fileExistNotification = ref<boolean>(false) const fileExistNotification = ref<boolean>(false)
function triggerFolderDelete(pathname: string) { function triggerFolderDelete(pathname: string) {
@ -134,8 +133,8 @@ async function submitFileForm(
file?: File file?: File
title: string title: string
description: string description: string
keyword: string keyword: string[]
category: string category: string[]
}, },
force = false, force = false,
) { ) {
@ -150,8 +149,8 @@ async function submitFileForm(
await uploadFile(currentPath.value, value.file, { await uploadFile(currentPath.value, value.file, {
title: value.title, title: value.title,
description: value.description, description: value.description,
keyword: value.keyword, keyword: value.keyword.join(''),
category: value.category, category: value.category.join(''),
}) })
} else { } else {
await updateFile( await updateFile(
@ -159,8 +158,8 @@ async function submitFileForm(
{ {
title: value.title, title: value.title,
description: value.description, description: value.description,
keyword: value.keyword, keyword: value.keyword.join(''),
category: value.category, category: value.category.join(''),
}, },
value.file, value.file,
) )
@ -369,12 +368,7 @@ async function submitFileForm(
v-model:description="fileFormData.description" v-model:description="fileFormData.description"
v-model:keyword="fileFormData.keyword" v-model:keyword="fileFormData.keyword"
v-model:category="fileFormData.category" v-model:category="fileFormData.category"
@filechange=" @filechange="(name: string) => (fileFormError.fileExist = checkFile(name))"
(name: string) => (
(fileFormError.fileExist = checkFile(name)),
(fileFormError.fileName2Long = checkFileName(name))
)
"
@submit="submitFileForm" @submit="submitFileForm"
/> />