Muhammad Iqbal Afandi 3 лет назад
Родитель
Сommit
460ef34eaa

+ 17
- 1
app/Http/Controllers/PurchaseController.php Просмотреть файл

127
      */
127
      */
128
     public function show(Purchase $purchase)
128
     public function show(Purchase $purchase)
129
     {
129
     {
130
-        //
130
+        return inertia("Purchases/Show", [
131
+            "id" => $purchase->id,
132
+            "number" => $purchase->number,
133
+            "ppn" => Ppn::first()->ppn,
134
+            "status" => $purchase->status,
135
+            "ppnChecked" => $purchase->ppn ? true : false,
136
+            "purchaseDetail" => $purchase->purchaseDetail->transform(
137
+                fn($purchase) => [
138
+                    "id" => $purchase->id,
139
+                    "number" => $purchase->product_number,
140
+                    "name" => $purchase->product->name,
141
+                    "price" => $purchase->price,
142
+                    "qty" => $purchase->qty,
143
+                    "unit" => $purchase->product->unit,
144
+                ]
145
+            ),
146
+        ]);
131
     }
147
     }
132
 
148
 
133
     /**
149
     /**

+ 15
- 1
resources/js/pages/Purchases/Components/Cart.vue Просмотреть файл

14
     required: true,
14
     required: true,
15
     type: Array,
15
     type: Array,
16
   },
16
   },
17
+  btnEditShow: {
18
+    default: true,
19
+    type: Boolean,
20
+  },
21
+  btnDeleteShow: {
22
+    default: true,
23
+    type: Boolean,
24
+  },
25
+  btnPpnDisabled: {
26
+    default: false,
27
+    type: Boolean,
28
+  },
17
   checkedPpn: Boolean,
29
   checkedPpn: Boolean,
18
 })
30
 })
19
 
31
 
42
         <input
54
         <input
43
           type="checkbox"
55
           type="checkbox"
44
           id="ppn"
56
           id="ppn"
57
+          :disabled="btnPpnDisabled"
45
           :checked="checkedPpn"
58
           :checked="checkedPpn"
46
           @input="$emit('update:checkedPpn', $event.target.checked)"
59
           @input="$emit('update:checkedPpn', $event.target.checked)"
47
         />
60
         />
80
       </template>
93
       </template>
81
     </Column>
94
     </Column>
82
 
95
 
83
-    <Column :row-editor="true" />
96
+    <Column v-if="btnEditShow" :row-editor="true" />
84
 
97
 
85
     <Column>
98
     <Column>
86
       <template #body="{ index }">
99
       <template #body="{ index }">
87
         <Button
100
         <Button
101
+          v-if="btnDeleteShow"
88
           icon="pi pi-trash"
102
           icon="pi pi-trash"
89
           class="p-button-icon-only p-button-rounded p-button-text"
103
           class="p-button-icon-only p-button-rounded p-button-text"
90
           v-tooltip.bottom="'hapus'"
104
           v-tooltip.bottom="'hapus'"

+ 0
- 2
resources/js/pages/Purchases/Composables/useProductCart.js Просмотреть файл

54
 
54
 
55
   const onClearProductCartDelete = () => {
55
   const onClearProductCartDelete = () => {
56
     productCartDeleted.splice(0)
56
     productCartDeleted.splice(0)
57
-
58
-    console.info('this is running')
59
   }
57
   }
60
 
58
 
61
   const totalProductPrice = () => {
59
   const totalProductPrice = () => {

+ 1
- 1
resources/js/pages/Purchases/Create.vue Просмотреть файл

79
         <div class="grid">
79
         <div class="grid">
80
           <div class="col-12">
80
           <div class="col-12">
81
             <Card>
81
             <Card>
82
-              <template #title> Penjual </template>
82
+              <template #title> Transaksi </template>
83
               <template #content>
83
               <template #content>
84
                 <div class="grid">
84
                 <div class="grid">
85
                   <div class="col-12 md:col-6">
85
                   <div class="col-12 md:col-6">

+ 1
- 1
resources/js/pages/Purchases/Edit.vue Просмотреть файл

70
         <div class="grid">
70
         <div class="grid">
71
           <div class="col-12">
71
           <div class="col-12">
72
             <Card>
72
             <Card>
73
-              <template #title> Penjual </template>
73
+              <template #title> Transaksi </template>
74
               <template #content>
74
               <template #content>
75
                 <div class="grid">
75
                 <div class="grid">
76
                   <div class="col-12 md:col-6">
76
                   <div class="col-12 md:col-6">

+ 9
- 0
resources/js/pages/Purchases/Index.vue Просмотреть файл

56
       <Column>
56
       <Column>
57
         <template #body="{ data }">
57
         <template #body="{ data }">
58
           <AppButtonLink
58
           <AppButtonLink
59
+            v-if="data.status == 'pending'"
59
             icon="pi pi-pencil"
60
             icon="pi pi-pencil"
60
             class="p-button-icon-only p-button-rounded p-button-text"
61
             class="p-button-icon-only p-button-rounded p-button-text"
61
             v-tooltip.bottom="'Ubah Pembelian'"
62
             v-tooltip.bottom="'Ubah Pembelian'"
62
             :href="route('purchases.edit', data.id)"
63
             :href="route('purchases.edit', data.id)"
63
           />
64
           />
65
+
66
+          <AppButtonLink
67
+            v-else
68
+            icon="pi pi-eye"
69
+            class="p-button-icon-only p-button-rounded p-button-text"
70
+            v-tooltip.bottom="'Lihat Pembelian'"
71
+            :href="route('purchases.show', data.id)"
72
+          />
64
         </template>
73
         </template>
65
       </Column>
74
       </Column>
66
     </DataTable>
75
     </DataTable>

+ 74
- 0
resources/js/pages/Purchases/Show.vue Просмотреть файл

1
+<script setup>
2
+import { useForm } from '@/composables/useForm'
3
+import { IDRCurrencyFormat } from '@/utils/currencyFormat'
4
+import { cartTable } from './config'
5
+import Cart from './Components/Cart.vue'
6
+import { useProductCart } from './Composables/useProductCart'
7
+import DashboardLayout from '@/layouts/Dashboard/DashboardLayout.vue'
8
+
9
+const props = defineProps({
10
+  number: String,
11
+  ppn: Number,
12
+  status: String,
13
+  ppnChecked: Boolean,
14
+  supplier: Object,
15
+  purchaseDetail: Array,
16
+})
17
+
18
+const form = useForm({
19
+  status: props.status,
20
+  supplier: props.supplier,
21
+  ppn: props.ppn,
22
+  checkedPpn: props.ppnChecked,
23
+})
24
+
25
+const { productCart, onDeleteProduct, onEditProduct, totalProductPrice } =
26
+  useProductCart(form, props.purchaseDetail)
27
+</script>
28
+
29
+<template>
30
+  <DashboardLayout title="Lihat Pembelian">
31
+    <DynamicDialog />
32
+
33
+    <div class="grid">
34
+      <div class="col-12 md:col-8">
35
+        <div class="grid">
36
+          <div class="col-12">
37
+            <Card>
38
+              <template #title>
39
+                <h2 class="text-2xl font-bold">Detail Pembelian</h2>
40
+              </template>
41
+              <template #content>
42
+                <div class="grid">
43
+                  <div class="col">
44
+                    <h3 class="text-base">Nomor Pembelian</h3>
45
+                    <span>{{ number }}</span>
46
+                  </div>
47
+                  <div class="col">
48
+                    <h3 class="text-base">Status Pembelian</h3>
49
+                    <span>{{ status }}</span>
50
+                  </div>
51
+                  <div class="col">
52
+                    <h3 class="text-base">Total Harga</h3>
53
+                    <span>{{ IDRCurrencyFormat(totalProductPrice()) }}</span>
54
+                  </div>
55
+                </div>
56
+              </template>
57
+            </Card>
58
+          </div>
59
+          <div class="col-12">
60
+            <Cart
61
+              title="Keranjang Produk"
62
+              :product-cart="productCart"
63
+              :header-table="cartTable"
64
+              :btn-ppn-disabled="true"
65
+              :btn-delete-show="false"
66
+              :btn-edit-show="false"
67
+              v-model:checked-ppn="form.checkedPpn"
68
+            />
69
+          </div>
70
+        </div>
71
+      </div>
72
+    </div>
73
+  </DashboardLayout>
74
+</template>

+ 7
- 2
resources/js/pages/Sales/Composables/useProductCart.js Просмотреть файл

48
     productCart.splice(index, 1)
48
     productCart.splice(index, 1)
49
   }
49
   }
50
 
50
 
51
-  const onClearProduct = () => {
51
+  const onClearProductCart = () => {
52
     productCart.splice(0)
52
     productCart.splice(0)
53
   }
53
   }
54
 
54
 
55
+  const onClearProductCartDelete = () => {
56
+    productCartDeleted.splice(0)
57
+  }
58
+
55
   const totalProductPrice = () => {
59
   const totalProductPrice = () => {
56
     const productPrices = productCart.map((product) => {
60
     const productPrices = productCart.map((product) => {
57
       if (form.checkedPpn) {
61
       if (form.checkedPpn) {
76
   return {
80
   return {
77
     productCart,
81
     productCart,
78
     productCartDeleted,
82
     productCartDeleted,
83
+    onClearProductCart,
84
+    onClearProductCartDelete,
79
     onAddProduct,
85
     onAddProduct,
80
     onDeleteProduct,
86
     onDeleteProduct,
81
     onEditProduct,
87
     onEditProduct,
82
-    onClearProduct,
83
     totalProductPrice,
88
     totalProductPrice,
84
   }
89
   }
85
 }
90
 }

+ 1
- 1
resources/js/pages/Sales/Create.vue Просмотреть файл

74
         <div class="grid">
74
         <div class="grid">
75
           <div class="col-12">
75
           <div class="col-12">
76
             <Card>
76
             <Card>
77
-              <template #title> Pembeli </template>
77
+              <template #title> Transaksi </template>
78
               <template #content>
78
               <template #content>
79
                 <div class="grid">
79
                 <div class="grid">
80
                   <div class="col-12 md:col-6">
80
                   <div class="col-12 md:col-6">

+ 3
- 6
resources/js/pages/Sales/Edit.vue Просмотреть файл

43
       products: [...productCart, ...productCartDeleted],
43
       products: [...productCart, ...productCartDeleted],
44
     }))
44
     }))
45
     .post(route('sales.store'), {
45
     .post(route('sales.store'), {
46
-      onSuccess: () => {
47
-        form.reset()
48
-
49
-        onClearProduct()
50
-      },
46
+      onSuccess: () => onClearProductCartDelete(),
51
     })
47
     })
52
 }
48
 }
53
 
49
 
54
 const {
50
 const {
55
   productCart,
51
   productCart,
56
   productCartDeleted,
52
   productCartDeleted,
53
+  onClearProductCartDelete,
57
   onAddProduct,
54
   onAddProduct,
58
   onDeleteProduct,
55
   onDeleteProduct,
59
   onEditProduct,
56
   onEditProduct,
70
         <div class="grid">
67
         <div class="grid">
71
           <div class="col-12">
68
           <div class="col-12">
72
             <Card>
69
             <Card>
73
-              <template #title> Pembeli </template>
70
+              <template #title> Transaksi </template>
74
               <template #content>
71
               <template #content>
75
                 <div class="grid">
72
                 <div class="grid">
76
                   <div class="col-12 md:col-6">
73
                   <div class="col-12 md:col-6">