Compare commits
No commits in common. "f82b56d540b534f35234cb74eac68dc2b4d318b2" and "6cbb6f7cbb0812ac2654e833ea93c125f1c3dce8" have entirely different histories.
f82b56d540
...
6cbb6f7cbb
@ -61,15 +61,6 @@ public function destroyCombination(Request $request, int $combinationId): JsonRe
|
|||||||
return response()->json(['ok' => true]);
|
return response()->json(['ok' => true]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateCombinationResult(Request $request, int $combinationId): JsonResponse
|
|
||||||
{
|
|
||||||
$result = $request->input('material_result');
|
|
||||||
|
|
||||||
$this->cuttingService->updateDraftCombinationResult($request->user(), $combinationId, $result);
|
|
||||||
|
|
||||||
return response()->json(['ok' => true]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function quickCreateProduct(CuttingQuickCreateProductRequest $request): JsonResponse
|
public function quickCreateProduct(CuttingQuickCreateProductRequest $request): JsonResponse
|
||||||
{
|
{
|
||||||
$product = $this->cuttingService->quickCreateProduct($request->validated());
|
$product = $this->cuttingService->quickCreateProduct($request->validated());
|
||||||
|
|||||||
@ -173,7 +173,6 @@ public function findForShare(Cutting $cutting): Cutting
|
|||||||
$cutting->load([
|
$cutting->load([
|
||||||
'media',
|
'media',
|
||||||
'createdBy.profile',
|
'createdBy.profile',
|
||||||
'results',
|
|
||||||
'materials.rawMaterialPrice.rawMaterial:id,name,unit',
|
'materials.rawMaterialPrice.rawMaterial:id,name,unit',
|
||||||
'materials.rawMaterialPrice.media',
|
'materials.rawMaterialPrice.media',
|
||||||
'materials.combination',
|
'materials.combination',
|
||||||
@ -412,23 +411,6 @@ public function removeDraftCombination(User $user, int $combinationId): void
|
|||||||
$combination->forceDelete();
|
$combination->forceDelete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateDraftCombinationResult(User $user, int $combinationId, mixed $result): void
|
|
||||||
{
|
|
||||||
$combination = CuttingMaterialCombination::query()
|
|
||||||
->whereNull('cutting_id')
|
|
||||||
->where('user_id', $user->id)
|
|
||||||
->where('id', $combinationId)
|
|
||||||
->first();
|
|
||||||
|
|
||||||
if ($combination === null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$materialResult = $result !== null ? (int) $result : null;
|
|
||||||
|
|
||||||
$combination->update(['material_result' => $materialResult]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function create(array $validated, User $user): Cutting
|
public function create(array $validated, User $user): Cutting
|
||||||
{
|
{
|
||||||
$cutting = $this->runInTransaction(
|
$cutting = $this->runInTransaction(
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { Briefcase, Copy, MessageCircle, Share2 } from '@lucide/vue';
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
import { toast } from 'vue-sonner';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import {
|
import {
|
||||||
Popover,
|
Popover,
|
||||||
@ -8,9 +11,6 @@ import {
|
|||||||
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
|
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
|
||||||
import { share } from '@/routes/admin/manage/cuttings';
|
import { share } from '@/routes/admin/manage/cuttings';
|
||||||
import type { CuttingListItem } from '@/types/cutting';
|
import type { CuttingListItem } from '@/types/cutting';
|
||||||
import { Briefcase, Copy, MessageCircle, Share2 } from '@lucide/vue';
|
|
||||||
import { computed, ref } from 'vue';
|
|
||||||
import { toast } from 'vue-sonner';
|
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
cutting: CuttingListItem;
|
cutting: CuttingListItem;
|
||||||
@ -40,7 +40,7 @@ const whatsappText = computed(() => {
|
|||||||
const productNames = new Set<string>();
|
const productNames = new Set<string>();
|
||||||
|
|
||||||
c.results.forEach((result) => {
|
c.results.forEach((result) => {
|
||||||
const productName = result.product_name ?? 'Produk Tidak Diketahui';
|
const productName = result.product_variant?.product?.name ?? 'Produk Tidak Diketahui';
|
||||||
productNames.add(productName);
|
productNames.add(productName);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -65,7 +65,6 @@ const {
|
|||||||
resultCart,
|
resultCart,
|
||||||
filteredRawMaterials,
|
filteredRawMaterials,
|
||||||
totalMaterialCost,
|
totalMaterialCost,
|
||||||
totalMaterialResult,
|
|
||||||
totalResultPieces,
|
totalResultPieces,
|
||||||
materialLineCost,
|
materialLineCost,
|
||||||
setCarts,
|
setCarts,
|
||||||
@ -151,13 +150,6 @@ if (isCreateMode.value && resultCart.value.length === 0) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(totalMaterialResult, (newVal) => {
|
|
||||||
const val = newVal > 0 ? String(newVal) : null;
|
|
||||||
resultCart.value.forEach((item) => {
|
|
||||||
item.cutting_result = val;
|
|
||||||
});
|
|
||||||
}, { immediate: true });
|
|
||||||
|
|
||||||
function buildFormData(): FormData {
|
function buildFormData(): FormData {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
|
|
||||||
|
|||||||
@ -84,24 +84,6 @@ export function useCuttingPosCart(options: {
|
|||||||
materialCart.value.reduce((sum, item) => sum + materialLineCost(item), 0),
|
materialCart.value.reduce((sum, item) => sum + materialLineCost(item), 0),
|
||||||
);
|
);
|
||||||
|
|
||||||
const totalMaterialResult = computed(() => {
|
|
||||||
const seenCombinations = new Set<number>();
|
|
||||||
let total = 0;
|
|
||||||
|
|
||||||
materialCart.value.forEach((item) => {
|
|
||||||
if (item.combination_id) {
|
|
||||||
if (!seenCombinations.has(item.combination_id)) {
|
|
||||||
seenCombinations.add(item.combination_id);
|
|
||||||
total += Number(item.combination_material_result) || 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
total += Number(item.material_result) || 0;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return total;
|
|
||||||
});
|
|
||||||
|
|
||||||
const totalResultPieces = computed(() =>
|
const totalResultPieces = computed(() =>
|
||||||
resultCart.value.reduce(
|
resultCart.value.reduce(
|
||||||
(sum, item) => sum + (Number(item.cutting_result) || 0),
|
(sum, item) => sum + (Number(item.cutting_result) || 0),
|
||||||
@ -213,17 +195,6 @@ export function useCuttingPosCart(options: {
|
|||||||
item.combination_material_result = result;
|
item.combination_material_result = result;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (toValue(options.isCreateMode)) {
|
|
||||||
try {
|
|
||||||
await apiFetch(draft_combinations.update_result.url(combinationId), {
|
|
||||||
method: 'PUT',
|
|
||||||
body: JSON.stringify({ material_result: result }),
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
toast.error(error instanceof Error ? error.message : 'Gagal menyimpan hasil kombinasi.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMaterialCartItem(priceId: number): CuttingMaterialCartItem | undefined {
|
function getMaterialCartItem(priceId: number): CuttingMaterialCartItem | undefined {
|
||||||
@ -339,7 +310,6 @@ export function useCuttingPosCart(options: {
|
|||||||
resultCart,
|
resultCart,
|
||||||
filteredRawMaterials,
|
filteredRawMaterials,
|
||||||
totalMaterialCost,
|
totalMaterialCost,
|
||||||
totalMaterialResult,
|
|
||||||
totalResultPieces,
|
totalResultPieces,
|
||||||
estimatedCostPerUnit,
|
estimatedCostPerUnit,
|
||||||
materialLineCost,
|
materialLineCost,
|
||||||
|
|||||||
@ -404,10 +404,6 @@
|
|||||||
->middleware('permission:'.Permission::CUTTINGS_CREATE->value)
|
->middleware('permission:'.Permission::CUTTINGS_CREATE->value)
|
||||||
->name('draft_combinations.destroy');
|
->name('draft_combinations.destroy');
|
||||||
|
|
||||||
Route::put('draft-combinations/{combinationId}/result', [CuttingDraftItemController::class, 'updateCombinationResult'])
|
|
||||||
->middleware('permission:'.Permission::CUTTINGS_CREATE->value)
|
|
||||||
->name('draft_combinations.update_result');
|
|
||||||
|
|
||||||
Route::post('quick-create-product', [CuttingDraftItemController::class, 'quickCreateProduct'])
|
Route::post('quick-create-product', [CuttingDraftItemController::class, 'quickCreateProduct'])
|
||||||
->middleware('permission:'.Permission::CUTTINGS_CREATE->value)
|
->middleware('permission:'.Permission::CUTTINGS_CREATE->value)
|
||||||
->name('quick_create_product');
|
->name('quick_create_product');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user