fix: type

This commit is contained in:
Methapon2001 2023-12-01 15:53:38 +07:00
parent 7d15f7bc24
commit 2614df7d58
No known key found for this signature in database
GPG key ID: 849924FEF46BD132

View file

@ -1,15 +1,10 @@
<script setup lang="ts"> <script setup lang="ts">
import { onMounted, onUnmounted, ref } from 'vue' import { onMounted, onUnmounted, ref } from 'vue'
const storesCategory = [ import { QSelect } from 'quasar'
'Category1',
'Category2',
'Category3',
'Category4',
'Category5',
]
const filterDataCategory = ref(storesCategory) const storesCategory: string[] = []
const filterDataCategory = ref<string[]>(storesCategory)
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
@ -26,7 +21,7 @@ const props = withDefaults(
}>(), }>(),
{ {
open: false, open: false,
} },
) )
const inputKeyword = ref<string[]>(props.keyword || []) const inputKeyword = ref<string[]>(props.keyword || [])
@ -69,35 +64,34 @@ function submit() {
emit('update:open', !open), reset() emit('update:open', !open), reset()
} }
function createkeyword(val, done) { const createKeyword = ((val, done) => {
if (val.length > 2) { if (val.length > 2) {
if (!inputKeyword.value.includes(val)) { if (!inputKeyword.value.includes(val)) {
done(val, 'add-unique') done(val, 'add-unique')
console.log(inputKeyword.value)
} }
} }
} }) satisfies QSelect['onNewValue']
function createCategory(val, done) { const createCategory = ((val, done) => {
if (val.length > 2) { if (val.length > 2) {
if (!inputCategory.value.includes(val)) { if (!inputCategory.value.includes(val)) {
done(val, 'add-unique') done(val, 'add-unique')
} }
} }
} }) satisfies QSelect['onNewValue']
function filterCategory(val, update) { const filterCategory = ((val, update) => {
update(() => { update(() => {
if (val === '') { if (val === '') {
filterDataCategory.value = storesCategory filterDataCategory.value = storesCategory
} else { } else {
const needle = val.toLowerCase() const needle = val.toLowerCase()
filterDataCategory.value = storesCategory.filter( filterDataCategory.value = storesCategory.filter(
(v) => v.toLowerCase().indexOf(needle) > -1 (v) => v.toLowerCase().indexOf(needle) > -1,
) )
} }
}) })
} }) satisfies QSelect['onFilter']
onMounted(() => window.addEventListener('keydown', keydown)) onMounted(() => window.addEventListener('keydown', keydown))
onUnmounted(() => window.addEventListener('keydown', keydown)) onUnmounted(() => window.addEventListener('keydown', keydown))
@ -151,8 +145,8 @@ const file = ref<File | undefined>()
error.fileExist error.fileExist
? 'พบไฟล์ในระบบ ข้อมูลในระบบจะถูกเขียนทับ' ? 'พบไฟล์ในระบบ ข้อมูลในระบบจะถูกเขียนทับ'
: error.fileName2Long : error.fileName2Long
? 'ไม่สามารถเพิ่มไฟล์ที่ชื่อยาวเกิน 85 ตัวอักษรได้' ? 'ไม่สามารถเพิ่มไฟล์ที่ชื่อยาวเกิน 85 ตัวอักษรได้'
: '' : ''
" "
> >
<template v-slot:prepend> <template v-slot:prepend>
@ -225,7 +219,7 @@ const file = ref<File | undefined>()
style="width: 250px" style="width: 250px"
:model-value="props.keyword" :model-value="props.keyword"
@update:model-value="(v) => $emit('update:keyword', v)" @update:model-value="(v) => $emit('update:keyword', v)"
@new-value="createkeyword" @new-value="createKeyword"
> >
</q-select> </q-select>
</div> </div>