Bladeren bron

fix: components

Muhammad Iqbal Afandi 3 jaren geleden
bovenliggende
commit
1ad42d62eb

+ 14
- 22
resources/js/components/AppDateRangeFilter.vue Bestand weergeven

9
     type: Object,
9
     type: Object,
10
     required: true,
10
     required: true,
11
   },
11
   },
12
-  refreshData: {
12
+  url: {
13
     type: String,
13
     type: String,
14
     required: true,
14
     required: true,
15
   },
15
   },
16
+  refreshData: {
17
+    type: Array,
18
+    default: [],
19
+    required: false,
20
+  },
16
 })
21
 })
17
 
22
 
18
 const filters = reactive({
23
 const filters = reactive({
47
       filters.endDate = null
52
       filters.endDate = null
48
     }
53
     }
49
 
54
 
50
-    Inertia.reload({
51
-      data: pickBy({
55
+    Inertia.get(
56
+      props.url,
57
+      pickBy({
52
         start_date: filters.startDate,
58
         start_date: filters.startDate,
53
         end_date: filters.endDate,
59
         end_date: filters.endDate,
54
       }),
60
       }),
55
-      only: [props.refreshData],
56
-    })
61
+      {
62
+        preserveState: true,
63
+        only: [...props.refreshData],
64
+      }
65
+    )
57
   }
66
   }
58
 )
67
 )
59
-
60
-const removeParams = (...params) => {
61
-  const urlParams = new URLSearchParams(location.search)
62
-
63
-  params.forEach((value) => urlParams.delete(value))
64
-
65
-  history.replaceState({}, '', `${location.pathname}?${urlParams}`)
66
-}
67
-
68
-const dateSelect = () => {
69
-  if (filters.dates[0]) {
70
-    removeParams('end_date')
71
-  }
72
-
73
-  removeParams('page')
74
-}
75
 </script>
68
 </script>
76
 
69
 
77
 <template>
70
 <template>
80
     selection-mode="range"
73
     selection-mode="range"
81
     date-format="dd/mm/yy"
74
     date-format="dd/mm/yy"
82
     :manual-input="false"
75
     :manual-input="false"
83
-    @date-select="dateSelect"
84
     v-model="filters.dates"
76
     v-model="filters.dates"
85
   />
77
   />
86
 </template>
78
 </template>

+ 18
- 0
resources/js/components/AppResetFilter.vue Bestand weergeven

1
+<script setup>
2
+import { Inertia } from '@inertiajs/inertia'
3
+
4
+const props = defineProps({
5
+  url: {
6
+    type: String,
7
+    required: true,
8
+  },
9
+})
10
+
11
+const reset = () => {
12
+  Inertia.get(props.url)
13
+}
14
+</script>
15
+
16
+<template>
17
+  <Button label="reset" class="p-button-link" @click="reset()" />
18
+</template>

+ 10
- 4
resources/js/components/AppSearchFilter.vue Bestand weergeven

4
 import { pickBy } from 'lodash'
4
 import { pickBy } from 'lodash'
5
 
5
 
6
 const props = defineProps({
6
 const props = defineProps({
7
+  initialSearch: {
8
+    required: true,
9
+  },
7
   url: {
10
   url: {
8
     type: String,
11
     type: String,
9
     required: true,
12
     required: true,
10
   },
13
   },
11
-  initialSearch: {
12
-    required: true,
14
+  refreshData: {
15
+    type: Array,
16
+    default: [],
17
+    required: false,
13
   },
18
   },
14
 })
19
 })
15
 
20
 
16
 const search = ref(props.initialSearch)
21
 const search = ref(props.initialSearch)
17
 
22
 
18
-watch(search, () => {
19
-  Inertia.get(props.url, pickBy({ search: search.value }), {
23
+watch(search, (value) => {
24
+  Inertia.get(props.url, pickBy({ search: value }), {
20
     preserveState: true,
25
     preserveState: true,
26
+    only: [...props.refreshData],
21
   })
27
   })
22
 })
28
 })
23
 </script>
29
 </script>

+ 1
- 1
resources/js/pages/Products/Index.vue Bestand weergeven

48
               <AppSearchFilter
48
               <AppSearchFilter
49
                 class="w-full md:w-27rem"
49
                 class="w-full md:w-27rem"
50
                 placeholder="nomor, nama"
50
                 placeholder="nomor, nama"
51
-                url="/products"
51
+                :url="route('products.index')"
52
                 :initial-search="initialSearch"
52
                 :initial-search="initialSearch"
53
               />
53
               />
54
             </div>
54
             </div>

+ 1
- 1
resources/js/pages/Purchases/Index.vue Bestand weergeven

28
             <AppSearchFilter
28
             <AppSearchFilter
29
               class="w-full md:w-27rem"
29
               class="w-full md:w-27rem"
30
               placeholder="nama, email, no hp, status"
30
               placeholder="nama, email, no hp, status"
31
-              url="/purchases"
31
+              :url="route('purchases.index')"
32
               :initial-search="initialSearch"
32
               :initial-search="initialSearch"
33
             />
33
             />
34
           </div>
34
           </div>

+ 1
- 1
resources/js/pages/Sales/Index.vue Bestand weergeven

29
               <AppSearchFilter
29
               <AppSearchFilter
30
                 class="w-full md:w-27rem"
30
                 class="w-full md:w-27rem"
31
                 placeholder="nama, no hp, status"
31
                 placeholder="nama, no hp, status"
32
-                url="/sales"
32
+                :url="route('sales.index')"
33
                 :initial-search="initialSearch"
33
                 :initial-search="initialSearch"
34
               />
34
               />
35
             </div>
35
             </div>

+ 8
- 2
resources/js/pages/Sales/Report.vue Bestand weergeven

4
 import AppButtonLink from '@/components/AppButtonLink.vue'
4
 import AppButtonLink from '@/components/AppButtonLink.vue'
5
 import AppPagination from '@/components/AppPagination.vue'
5
 import AppPagination from '@/components/AppPagination.vue'
6
 import DashboardLayout from '@/layouts/Dashboard/DashboardLayout.vue'
6
 import DashboardLayout from '@/layouts/Dashboard/DashboardLayout.vue'
7
+import AppResetFilter from '@/components/AppResetFilter.vue'
7
 
8
 
8
 defineProps({
9
 defineProps({
9
   filters: Object,
10
   filters: Object,
18
 })
19
 })
19
 
20
 
20
 const exportExcel = () => {
21
 const exportExcel = () => {
21
-  return `/sales/excel/report${location.search}`
22
+  return route('sales.report.excel', location.search)
22
 }
23
 }
23
 </script>
24
 </script>
24
 
25
 
38
           <div class="col-12 sm:col-6 lg:col-4">
39
           <div class="col-12 sm:col-6 lg:col-4">
39
             <AppDateRangeFilter
40
             <AppDateRangeFilter
40
               placeholder="filter waktu..."
41
               placeholder="filter waktu..."
41
-              refresh-data="sales"
42
+              :url="route('sales.report')"
43
+              :refresh-data="['sales']"
42
               :initial-filter="filters"
44
               :initial-filter="filters"
43
             />
45
             />
44
           </div>
46
           </div>
45
 
47
 
48
+          <div class="col-12 sm:col-6 lg:col-4">
49
+            <AppResetFilter :url="route('sales.report')" />
50
+          </div>
51
+
46
           <div class="col-12">
52
           <div class="col-12">
47
             <AppButtonLink
53
             <AppButtonLink
48
               v-if="sales.total"
54
               v-if="sales.total"

+ 1
- 1
resources/js/pages/StockProducts/Index.vue Bestand weergeven

25
         <AppSearchFilter
25
         <AppSearchFilter
26
           class="w-full md:w-27rem"
26
           class="w-full md:w-27rem"
27
           placeholder="nama"
27
           placeholder="nama"
28
-          url="/stock-products"
28
+          :url="route('stock-products.index')"
29
           :initial-search="initialSearch"
29
           :initial-search="initialSearch"
30
         />
30
         />
31
       </template>
31
       </template>

+ 1
- 1
resources/js/pages/Suppliers/Index.vue Bestand weergeven

48
               <AppSearchFilter
48
               <AppSearchFilter
49
                 class="w-full md:w-27rem"
49
                 class="w-full md:w-27rem"
50
                 placeholder="nama, no hp, npwp"
50
                 placeholder="nama, no hp, npwp"
51
-                url="/suppliers"
51
+                :url="route('suppliers.index')"
52
                 :initial-search="initialSearch"
52
                 :initial-search="initialSearch"
53
               />
53
               />
54
             </div>
54
             </div>

+ 1
- 1
resources/js/pages/Users/Index.vue Bestand weergeven

65
               <AppSearchFilter
65
               <AppSearchFilter
66
                 class="w-full md:w-27rem"
66
                 class="w-full md:w-27rem"
67
                 placeholder="nama, nama pengguna"
67
                 placeholder="nama, nama pengguna"
68
-                url="/users"
68
+                :url="route('users.index')"
69
                 :initialSearch="initialSearch"
69
                 :initialSearch="initialSearch"
70
               />
70
               />
71
             </div>
71
             </div>

+ 9
- 4
routes/web.php Bestand weergeven

64
         "deliveryOrder",
64
         "deliveryOrder",
65
     ])->name("purchases.pdf.do");
65
     ])->name("purchases.pdf.do");
66
 
66
 
67
-    Route::get("/purchases/excel/report", [
67
+    Route::get("/purchases/report/excel", [
68
         PurchaseController::class,
68
         PurchaseController::class,
69
         "reportExcel",
69
         "reportExcel",
70
-    ]);
70
+    ])->name("purchases.report.excel");
71
 
71
 
72
     Route::get("/purchases/report", [PurchaseController::class, "report"]);
72
     Route::get("/purchases/report", [PurchaseController::class, "report"]);
73
 
73
 
83
         "deliveryOrder",
83
         "deliveryOrder",
84
     ])->name("sales.pdf.do");
84
     ])->name("sales.pdf.do");
85
 
85
 
86
-    Route::get("/sales/excel/report", [SalesController::class, "reportExcel"]);
86
+    Route::get("/sales/report/excel", [
87
+        SalesController::class,
88
+        "reportExcel",
89
+    ])->name("sales.report.excel");
87
 
90
 
88
-    Route::get("/sales/report", [SalesController::class, "report"]);
91
+    Route::get("/sales/report", [SalesController::class, "report"])->name(
92
+        "sales.report"
93
+    );
89
 
94
 
90
     Route::resource("/sales", SalesController::class);
95
     Route::resource("/sales", SalesController::class);
91
 
96