瀏覽代碼

fix: components

Muhammad Iqbal Afandi 3 年之前
父節點
當前提交
bead5baa0e
共有 1 個文件被更改,包括 7 次插入5 次删除
  1. 7
    5
      resources/js/components/AppAutoComplete.vue

+ 7
- 5
resources/js/components/AppAutoComplete.vue 查看文件

1
 <script setup>
1
 <script setup>
2
-import { computed, onMounted } from 'vue'
2
+import { computed } from 'vue'
3
 import { Inertia } from '@inertiajs/inertia'
3
 import { Inertia } from '@inertiajs/inertia'
4
 
4
 
5
 const props = defineProps({
5
 const props = defineProps({
19
     type: String,
19
     type: String,
20
     required: true,
20
     required: true,
21
   },
21
   },
22
+  param: {
23
+    type: String,
24
+    required: true,
25
+  },
22
 })
26
 })
23
 
27
 
24
 const emit = defineEmits(['update:modelValue'])
28
 const emit = defineEmits(['update:modelValue'])
29
   () => props.label?.toLowerCase().replace(/\s+/g, '-') + '-error'
33
   () => props.label?.toLowerCase().replace(/\s+/g, '-') + '-error'
30
 )
34
 )
31
 
35
 
32
-let param = props.refreshData.slice(0, -1).replace('-', '_')
33
-
34
 const removeParams = (...params) => {
36
 const removeParams = (...params) => {
35
   const urlParams = new URLSearchParams(location.search)
37
   const urlParams = new URLSearchParams(location.search)
36
 
38
 
41
 
43
 
42
 const onInput = (event) => {
44
 const onInput = (event) => {
43
   if (event.target.value === '') {
45
   if (event.target.value === '') {
44
-    removeParams(param)
46
+    removeParams(props.param)
45
   }
47
   }
46
 
48
 
47
   emit('update:modelValue', event.target.value)
49
   emit('update:modelValue', event.target.value)
50
 const onComplete = (event) => {
52
 const onComplete = (event) => {
51
   Inertia.reload({
53
   Inertia.reload({
52
     data: {
54
     data: {
53
-      [param]: event.query,
55
+      [props.param]: event.query,
54
     },
56
     },
55
     only: [props.refreshData],
57
     only: [props.refreshData],
56
   })
58
   })