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