|
|
@@ -1,12 +1,10 @@
|
|
1
|
1
|
<script setup>
|
|
2
|
|
-import { useDialog } from 'primevue/usedialog'
|
|
3
|
|
-import { optionStatus, dialogStyle } from './config'
|
|
|
2
|
+import { optionStatus } from './config'
|
|
4
|
3
|
import { cartTable } from './config'
|
|
5
|
|
-import SupplierCreate from './Components/SupplierCreate.vue'
|
|
6
|
|
-import ProductCreate from './Components/ProductCreate.vue'
|
|
7
|
4
|
import Details from './Components/Details.vue'
|
|
8
|
5
|
import Cart from './Components/Cart.vue'
|
|
9
|
6
|
import { useProductCart } from './Composables/useProductCart'
|
|
|
7
|
+import { onShowDialog } from './Composables/onShowDialog'
|
|
10
|
8
|
import { useForm } from '@/composables/useForm'
|
|
11
|
9
|
import AppInputText from '@/components/AppInputText.vue'
|
|
12
|
10
|
import AppInputNumber from '@/components/AppInputNumber.vue'
|
|
|
@@ -34,6 +32,7 @@ const form = useForm({
|
|
34
|
32
|
qty: null,
|
|
35
|
33
|
supplier: null,
|
|
36
|
34
|
product: null,
|
|
|
35
|
+ ppn: props.ppn,
|
|
37
|
36
|
})
|
|
38
|
37
|
|
|
39
|
38
|
const onSubmit = () => {
|
|
|
@@ -41,38 +40,27 @@ const onSubmit = () => {
|
|
41
|
40
|
.transform((data) => ({
|
|
42
|
41
|
number: data.number,
|
|
43
|
42
|
status: data.status,
|
|
44
|
|
- price: data.price,
|
|
45
|
|
- qty: data.qty,
|
|
46
|
43
|
supplier_id: data.supplier.id,
|
|
47
|
|
- product_number: data.product.number,
|
|
|
44
|
+ products: productCart,
|
|
48
|
45
|
}))
|
|
49
|
46
|
.post(route('purchases.store'), {
|
|
50
|
|
- onSuccess: () => form.reset(),
|
|
|
47
|
+ onSuccess: () => {
|
|
|
48
|
+ form.reset()
|
|
|
49
|
+
|
|
|
50
|
+ onClearProduct()
|
|
|
51
|
+ },
|
|
51
|
52
|
})
|
|
52
|
53
|
}
|
|
53
|
54
|
|
|
54
|
|
-const { cartProduct, onAddProduct, onDeleteProduct, onClearProduct } =
|
|
55
|
|
- useProductCart(form)
|
|
56
|
|
-
|
|
57
|
|
-const dialog = useDialog()
|
|
58
|
|
-
|
|
59
|
|
-const onShowCreateSupplier = () => {
|
|
60
|
|
- dialog.open(SupplierCreate, {
|
|
61
|
|
- props: {
|
|
62
|
|
- header: 'Tambah Supplier',
|
|
63
|
|
- ...dialogStyle,
|
|
64
|
|
- },
|
|
65
|
|
- })
|
|
66
|
|
-}
|
|
|
55
|
+const {
|
|
|
56
|
+ productCart,
|
|
|
57
|
+ onAddProduct,
|
|
|
58
|
+ onDeleteProduct,
|
|
|
59
|
+ onClearProduct,
|
|
|
60
|
+ totalProductPrice,
|
|
|
61
|
+} = useProductCart(form)
|
|
67
|
62
|
|
|
68
|
|
-const onShowCreateProduct = () => {
|
|
69
|
|
- dialog.open(ProductCreate, {
|
|
70
|
|
- props: {
|
|
71
|
|
- header: 'Tambah Produk',
|
|
72
|
|
- ...dialogStyle,
|
|
73
|
|
- },
|
|
74
|
|
- })
|
|
75
|
|
-}
|
|
|
63
|
+const { onShowCreateProduct, onShowCreateSupplier } = onShowDialog()
|
|
76
|
64
|
</script>
|
|
77
|
65
|
|
|
78
|
66
|
<template>
|
|
|
@@ -80,156 +68,179 @@ const onShowCreateProduct = () => {
|
|
80
|
68
|
<DynamicDialog />
|
|
81
|
69
|
|
|
82
|
70
|
<div class="grid">
|
|
83
|
|
- <div class="col-12 md:col-8 flex-order-1 md:flex-order-0">
|
|
84
|
|
- <Card>
|
|
85
|
|
- <template #title> Pembeli </template>
|
|
86
|
|
- <template #content>
|
|
87
|
|
- <div class="grid">
|
|
88
|
|
- <div class="col-12 md:col-6">
|
|
89
|
|
- <AppInputText
|
|
90
|
|
- disabled
|
|
91
|
|
- label="Nomor Pembelian"
|
|
92
|
|
- placeholder="nomor pembelian"
|
|
93
|
|
- :error="form.errors.number"
|
|
94
|
|
- v-model="form.number"
|
|
95
|
|
- />
|
|
96
|
|
- </div>
|
|
97
|
|
-
|
|
98
|
|
- <div class="col-12 md:col-6">
|
|
99
|
|
- <AppDropdown
|
|
100
|
|
- label="Status"
|
|
101
|
|
- placeholder="status"
|
|
102
|
|
- :options="optionStatus"
|
|
103
|
|
- :error="form.errors.status"
|
|
104
|
|
- v-model="form.status"
|
|
105
|
|
- />
|
|
106
|
|
- </div>
|
|
107
|
|
-
|
|
108
|
|
- <div class="col-12 md:col-6">
|
|
109
|
|
- <AppAutoComplete
|
|
110
|
|
- label="Supplier"
|
|
111
|
|
- placeholder="supplier"
|
|
112
|
|
- field="name"
|
|
113
|
|
- refresh-data="suppliers"
|
|
114
|
|
- v-model="form.supplier"
|
|
115
|
|
- :error="form.errors.suppliers_id"
|
|
116
|
|
- :suggestions="suppliers"
|
|
117
|
|
- >
|
|
118
|
|
- <template #item="slotProps">
|
|
119
|
|
- <template v-if="slotProps.item">
|
|
120
|
|
- <div class="flex flex-column">
|
|
121
|
|
- <span>{{ slotProps.item.name }}</span>
|
|
122
|
|
- <span>{{ slotProps.item.npwp }}</span>
|
|
123
|
|
- </div>
|
|
124
|
|
- </template>
|
|
125
|
|
- </template>
|
|
126
|
|
-
|
|
127
|
|
- <template #empty>
|
|
128
|
|
- <span
|
|
129
|
|
- class="cursor-pointer"
|
|
130
|
|
- style="color: var(--primary-color)"
|
|
131
|
|
- @click="onShowCreateSupplier"
|
|
|
71
|
+ <div class="col-12 md:col-8">
|
|
|
72
|
+ <div class="grid">
|
|
|
73
|
+ <div class="col-12">
|
|
|
74
|
+ <Card>
|
|
|
75
|
+ <template #title> Pembeli </template>
|
|
|
76
|
+ <template #content>
|
|
|
77
|
+ <div class="grid">
|
|
|
78
|
+ <div class="col-12 md:col-6">
|
|
|
79
|
+ <AppInputText
|
|
|
80
|
+ disabled
|
|
|
81
|
+ label="Nomor Pembelian"
|
|
|
82
|
+ placeholder="nomor pembelian"
|
|
|
83
|
+ :error="form.errors.number"
|
|
|
84
|
+ v-model="form.number"
|
|
|
85
|
+ />
|
|
|
86
|
+ </div>
|
|
|
87
|
+
|
|
|
88
|
+ <div class="col-12 md:col-6">
|
|
|
89
|
+ <AppDropdown
|
|
|
90
|
+ label="Status"
|
|
|
91
|
+ placeholder="status"
|
|
|
92
|
+ :options="optionStatus"
|
|
|
93
|
+ :error="form.errors.status"
|
|
|
94
|
+ v-model="form.status"
|
|
|
95
|
+ />
|
|
|
96
|
+ </div>
|
|
|
97
|
+
|
|
|
98
|
+ <div class="col-12 md:col-6">
|
|
|
99
|
+ <AppAutoComplete
|
|
|
100
|
+ empty
|
|
|
101
|
+ label="Supplier"
|
|
|
102
|
+ placeholder="supplier"
|
|
|
103
|
+ field="name"
|
|
|
104
|
+ refresh-data="suppliers"
|
|
|
105
|
+ v-model="form.supplier"
|
|
|
106
|
+ :error="form.errors.suppliers_id"
|
|
|
107
|
+ :suggestions="suppliers"
|
|
|
108
|
+ >
|
|
|
109
|
+ <template #item="slotProps">
|
|
|
110
|
+ <template v-if="slotProps.item">
|
|
|
111
|
+ <div class="flex flex-column">
|
|
|
112
|
+ <span>{{ slotProps.item.name }}</span>
|
|
|
113
|
+ <span>{{ slotProps.item.npwp }}</span>
|
|
|
114
|
+ </div>
|
|
|
115
|
+ </template>
|
|
|
116
|
+ </template>
|
|
|
117
|
+
|
|
|
118
|
+ <template #empty>
|
|
|
119
|
+ <span
|
|
|
120
|
+ class="cursor-pointer"
|
|
|
121
|
+ style="color: var(--primary-color)"
|
|
|
122
|
+ @click="onShowCreateSupplier"
|
|
|
123
|
+ >
|
|
|
124
|
+ Tambah Supplier
|
|
|
125
|
+ </span>
|
|
|
126
|
+ </template>
|
|
|
127
|
+ </AppAutoComplete>
|
|
|
128
|
+ </div>
|
|
|
129
|
+ </div>
|
|
|
130
|
+ </template>
|
|
|
131
|
+ </Card>
|
|
|
132
|
+ </div>
|
|
|
133
|
+
|
|
|
134
|
+ <div class="col-12">
|
|
|
135
|
+ <Card>
|
|
|
136
|
+ <template #title>Produk</template>
|
|
|
137
|
+ <template #content>
|
|
|
138
|
+ <div class="grid">
|
|
|
139
|
+ <div class="col-12 md:col-6">
|
|
|
140
|
+ <AppAutoComplete
|
|
|
141
|
+ :disabled="!form.supplier?.id"
|
|
|
142
|
+ empty
|
|
|
143
|
+ label="Produk"
|
|
|
144
|
+ placeholder="produk"
|
|
|
145
|
+ field="name"
|
|
|
146
|
+ refresh-data="products"
|
|
|
147
|
+ v-model="form.product"
|
|
|
148
|
+ :error="form.errors.product"
|
|
|
149
|
+ :suggestions="products"
|
|
132
|
150
|
>
|
|
133
|
|
- Tambah Supplier
|
|
134
|
|
- </span>
|
|
135
|
|
- </template>
|
|
136
|
|
- </AppAutoComplete>
|
|
137
|
|
- </div>
|
|
138
|
|
- </div>
|
|
139
|
|
- </template>
|
|
140
|
|
- </Card>
|
|
|
151
|
+ <template #item="slotProps">
|
|
|
152
|
+ <template v-if="slotProps.item">
|
|
|
153
|
+ <div class="flex flex-column">
|
|
|
154
|
+ <span>{{ slotProps.item.number }}</span>
|
|
|
155
|
+ <span>{{ slotProps.item.name }}</span>
|
|
|
156
|
+ </div>
|
|
|
157
|
+ </template>
|
|
|
158
|
+ </template>
|
|
|
159
|
+
|
|
|
160
|
+ <template #empty>
|
|
|
161
|
+ <span
|
|
|
162
|
+ class="cursor-pointer"
|
|
|
163
|
+ style="color: var(--primary-color)"
|
|
|
164
|
+ @click="onShowCreateProduct"
|
|
|
165
|
+ >
|
|
|
166
|
+ Tambah Produk
|
|
|
167
|
+ </span>
|
|
|
168
|
+ </template>
|
|
|
169
|
+ </AppAutoComplete>
|
|
|
170
|
+ </div>
|
|
|
171
|
+
|
|
|
172
|
+ <div v-if="form.product?.unit" class="col-12 md:col-6">
|
|
|
173
|
+ <AppInputText
|
|
|
174
|
+ disabled
|
|
|
175
|
+ label="Satuan"
|
|
|
176
|
+ placeholder="satuan"
|
|
|
177
|
+ v-model="form.product.unit"
|
|
|
178
|
+ />
|
|
|
179
|
+ </div>
|
|
|
180
|
+
|
|
|
181
|
+ <div class="col-12 md:col-6">
|
|
|
182
|
+ <AppInputNumber
|
|
|
183
|
+ :disabled="!form.supplier?.id"
|
|
|
184
|
+ label="Harga"
|
|
|
185
|
+ placeholder="harga"
|
|
|
186
|
+ v-model="form.price"
|
|
|
187
|
+ />
|
|
|
188
|
+ </div>
|
|
|
189
|
+
|
|
|
190
|
+ <div class="col-12 md:col-6">
|
|
|
191
|
+ <AppInputText
|
|
|
192
|
+ :disabled="!form.supplier?.id"
|
|
|
193
|
+ label="Kuantitas"
|
|
|
194
|
+ placeholder="kuantitas"
|
|
|
195
|
+ type="number"
|
|
|
196
|
+ v-model="form.qty"
|
|
|
197
|
+ />
|
|
|
198
|
+ </div>
|
|
|
199
|
+ </div>
|
|
|
200
|
+ </template>
|
|
|
201
|
+ <template #footer>
|
|
|
202
|
+ <div class="flex flex-column md:flex-row justify-content-end">
|
|
|
203
|
+ <Button
|
|
|
204
|
+ label="Tambah Produk"
|
|
|
205
|
+ icon="pi pi-check"
|
|
|
206
|
+ class="p-button-outlined"
|
|
|
207
|
+ :disabled="
|
|
|
208
|
+ !form.price || !form.qty || !form.product?.number
|
|
|
209
|
+ "
|
|
|
210
|
+ @click="onAddProduct"
|
|
|
211
|
+ />
|
|
|
212
|
+ </div>
|
|
|
213
|
+ </template>
|
|
|
214
|
+ </Card>
|
|
|
215
|
+ </div>
|
|
|
216
|
+
|
|
|
217
|
+ <div class="col-12">
|
|
|
218
|
+ <Cart
|
|
|
219
|
+ title="Keranjang Produk"
|
|
|
220
|
+ :header-table="cartTable"
|
|
|
221
|
+ :value="productCart"
|
|
|
222
|
+ @delete="onDeleteProduct"
|
|
|
223
|
+ />
|
|
|
224
|
+ </div>
|
|
|
225
|
+ </div>
|
|
141
|
226
|
</div>
|
|
142
|
227
|
|
|
143
|
|
- <div class="col-12 md:col-4 flex-order-4 md:flex-order-0">
|
|
|
228
|
+ <div class="col-12 md:col-4">
|
|
144
|
229
|
<Details
|
|
145
|
230
|
title="Detail Pembelian"
|
|
|
231
|
+ message="Pastikan semua produk sudah benar"
|
|
146
|
232
|
:number="number"
|
|
147
|
|
- :ppn="ppn"
|
|
148
|
233
|
:status="form.status"
|
|
149
|
234
|
:person="form.supplier"
|
|
150
|
235
|
:product="form.product"
|
|
151
|
|
- :disabled="form.processing"
|
|
152
|
|
- @click="onSubmit"
|
|
153
|
|
- />
|
|
154
|
|
- </div>
|
|
155
|
|
-
|
|
156
|
|
- <div class="col-12 md:col-8 flex-order-2 md:flex-order-0">
|
|
157
|
|
- <Card>
|
|
158
|
|
- <template #title>Produk</template>
|
|
159
|
|
- <template #content>
|
|
160
|
|
- <div class="grid">
|
|
161
|
|
- <div class="col-12 md:col-6">
|
|
162
|
|
- <AppAutoComplete
|
|
163
|
|
- label="Produk"
|
|
164
|
|
- placeholder="produk"
|
|
165
|
|
- field="name"
|
|
166
|
|
- refresh-data="products"
|
|
167
|
|
- v-model="form.product"
|
|
168
|
|
- :error="form.errors.product_number"
|
|
169
|
|
- :suggestions="products"
|
|
170
|
|
- >
|
|
171
|
|
- <template #item="slotProps">
|
|
172
|
|
- <template v-if="slotProps.item">
|
|
173
|
|
- <div class="flex flex-column">
|
|
174
|
|
- <span>{{ slotProps.item.number }}</span>
|
|
175
|
|
- <span>{{ slotProps.item.name }}</span>
|
|
176
|
|
- </div>
|
|
177
|
|
- </template>
|
|
178
|
|
- </template>
|
|
179
|
|
-
|
|
180
|
|
- <template #empty>
|
|
181
|
|
- <span
|
|
182
|
|
- class="cursor-pointer"
|
|
183
|
|
- style="color: var(--primary-color)"
|
|
184
|
|
- @click="onShowCreateProduct"
|
|
185
|
|
- >
|
|
186
|
|
- Tambah Produk
|
|
187
|
|
- </span>
|
|
188
|
|
- </template>
|
|
189
|
|
- </AppAutoComplete>
|
|
190
|
|
- </div>
|
|
191
|
|
-
|
|
192
|
|
- <div class="col-12 md:col-6">
|
|
193
|
|
- <AppInputNumber
|
|
194
|
|
- label="Harga"
|
|
195
|
|
- placeholder="harga"
|
|
196
|
|
- :error="form.errors.price"
|
|
197
|
|
- v-model="form.price"
|
|
198
|
|
- />
|
|
199
|
|
- </div>
|
|
200
|
|
-
|
|
201
|
|
- <div class="col-12 md:col-6">
|
|
202
|
|
- <AppInputText
|
|
203
|
|
- label="Kuantitas"
|
|
204
|
|
- placeholder="kuantitas"
|
|
205
|
|
- type="number"
|
|
206
|
|
- :error="form.errors.qty"
|
|
207
|
|
- v-model="form.qty"
|
|
208
|
|
- />
|
|
209
|
|
- </div>
|
|
210
|
|
- </div>
|
|
211
|
|
- </template>
|
|
212
|
|
- <template #footer>
|
|
213
|
|
- <div class="flex flex-column md:flex-row justify-content-end">
|
|
214
|
|
- <Button
|
|
215
|
|
- label="Tambah Produk"
|
|
216
|
|
- icon="pi pi-check"
|
|
217
|
|
- class="p-button-outlined"
|
|
218
|
|
- :disabled="form.processing"
|
|
219
|
|
- @click="onAddProduct"
|
|
220
|
|
- />
|
|
221
|
|
- </div>
|
|
222
|
|
- </template>
|
|
223
|
|
- </Card>
|
|
224
|
|
- </div>
|
|
225
|
|
-
|
|
226
|
|
- <div class="col-12 md:col-8 flex-order-3 md:flex-order-0">
|
|
227
|
|
- <Cart
|
|
228
|
|
- title="Keranjang Produk"
|
|
229
|
|
- :header-table="cartTable"
|
|
230
|
|
- :form="form"
|
|
231
|
|
- :value="cartProduct"
|
|
232
|
|
- @delete="onDeleteProduct"
|
|
|
236
|
+ :price="totalProductPrice()"
|
|
|
237
|
+ :disabled="
|
|
|
238
|
+ form.processing ||
|
|
|
239
|
+ !form.status ||
|
|
|
240
|
+ !form.supplier?.id ||
|
|
|
241
|
+ productCart.length === 0
|
|
|
242
|
+ "
|
|
|
243
|
+ @submit="onSubmit"
|
|
233
|
244
|
/>
|
|
234
|
245
|
</div>
|
|
235
|
246
|
</div>
|