Compare commits

..

No commits in common. "55213cee6491bfe30433378eea500b4ef52edc52" and "d51b73c347421a0d6e2ccae9f47eab63643acf08" have entirely different histories.

4 changed files with 41 additions and 27 deletions

View File

@ -3,7 +3,6 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Models\Nampan; use App\Models\Nampan;
use App\Models\Item;
use Illuminate\Http\Request; use Illuminate\Http\Request;
class NampanController extends Controller class NampanController extends Controller
@ -86,14 +85,4 @@ class NampanController extends Controller
'message' => 'Nampan berhasil dihapus' 'message' => 'Nampan berhasil dihapus'
], 204); ], 204);
} }
public function kosongkan()
{
Item::query()->update(['id_nampan' => null]);
return response()->json([
'message' => 'Semua nampan berhasil dikosongkan'
], 200);
}
} }

View File

@ -9,27 +9,44 @@
</div> </div>
<div v-else class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4"> <div v-else class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4">
<div v-for="tray in filteredTrays" :key="tray.id" <div
class="border rounded-lg p-4 shadow-sm hover:shadow-md transition"> v-for="tray in filteredTrays"
:key="tray.id"
class="border rounded-lg p-4 shadow-sm hover:shadow-md transition"
>
<div class="flex justify-between items-center mb-3"> <div class="flex justify-between items-center mb-3">
<h2 class="font-bold text-lg" style="color: #102C57;">{{ tray.nama }}</h2> <h2 class="font-bold text-lg" style="color: #102C57;">{{ tray.nama }}</h2>
<div class="flex gap-2"> <div class="flex gap-2">
<button class="p-2 rounded bg-yellow-400 hover:bg-yellow-500" @click="emit('edit', tray)"> <button
class="p-2 rounded bg-yellow-400 hover:bg-yellow-500"
@click="emit('edit', tray)"
>
</button> </button>
<button class="bg-red-500 text-white p-1 rounded" @click="emit('delete', tray.id)"> <button
class="bg-red-500 text-white p-1 rounded"
@click="emit('delete', tray.id)"
>
🗑 🗑
</button> </button>
</div> </div>
</div> </div>
<div v-if="tray.items && tray.items.length > 0" class="space-y-2 max-h-64 overflow-y-auto pr-2"> <div v-if="tray.items && tray.items.length > 0" class="space-y-2 max-h-64 overflow-y-auto pr-2">
<div v-for="item in tray.items" :key="item.id" class="flex justify-between items-center border rounded-lg p-2" <div
@click="openMovePopup(item)"> v-for="item in tray.items"
:key="item.id"
class="flex justify-between items-center border rounded-lg p-2"
@click="openMovePopup(item)"
>
<div class="flex items-center gap-3"> <div class="flex items-center gap-3">
<img v-if="item.produk.foto && item.produk.foto.length > 0" :src="item.produk.foto[0].url" <img
alt="foto produk" class="w-12 h-12 object-cover rounded" /> v-if="item.produk.foto && item.produk.foto.length > 0"
:src="item.produk.foto[0].url"
alt="foto produk"
class="w-12 h-12 object-cover rounded"
/>
<div> <div>
<p class="text-sm" style="color: #102C57;">{{ item.produk.nama }}</p> <p class="text-sm" style="color: #102C57;">{{ item.produk.nama }}</p>
<p class="text-sm" style="color: #102C57;">{{ item.produk.kategori }}</p> <p class="text-sm" style="color: #102C57;">{{ item.produk.kategori }}</p>
@ -71,8 +88,11 @@
</div> </div>
<div class="mb-4"> <div class="mb-4">
<label for="tray-select" class="block text-sm font-medium text-gray-700 mb-1">Nama Nampan</label> <label for="tray-select" class="block text-sm font-medium text-gray-700 mb-1">Nama Nampan</label>
<select id="tray-select" v-model="selectedTrayId" <select
class="block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50"> id="tray-select"
v-model="selectedTrayId"
class="block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50"
>
<option value="" disabled>Pilih Nampan</option> <option value="" disabled>Pilih Nampan</option>
<option v-for="tray in availableTrays" :key="tray.id" :value="tray.id"> <option v-for="tray in availableTrays" :key="tray.id" :value="tray.id">
{{ tray.nama }} {{ tray.nama }}
@ -80,12 +100,18 @@
</select> </select>
</div> </div>
<div class="flex justify-end gap-2"> <div class="flex justify-end gap-2">
<button @click="closePopup" <button
class="px-4 py-2 rounded border border-gray-300 text-gray-700 hover:bg-gray-100 transition"> @click="closePopup"
class="px-4 py-2 rounded border border-gray-300 text-gray-700 hover:bg-gray-100 transition"
>
Batal Batal
</button> </button>
<button @click="saveMove" :disabled="!selectedTrayId" class="px-4 py-2 rounded text-white transition" <button
:class="selectedTrayId ? 'bg-orange-500 hover:bg-orange-600' : 'bg-gray-400 cursor-not-allowed'"> @click="saveMove"
:disabled="!selectedTrayId"
class="px-4 py-2 rounded text-white transition"
:class="selectedTrayId ? 'bg-orange-500 hover:bg-orange-600' : 'bg-gray-400 cursor-not-allowed'"
>
Simpan Simpan
</button> </button>
</div> </div>

View File

@ -150,7 +150,7 @@ const closeConfirmModal = () => { showConfirmModal.value = false }
const confirmEmptyTray = async () => { const confirmEmptyTray = async () => {
try { try {
await axios.delete("/api/kosongkan-nampan",) await axios.post("/api/brankas", { action: "move_all_from_tray" })
alert("Semua item berhasil dipindahkan ke Brankas") alert("Semua item berhasil dipindahkan ke Brankas")
closeConfirmModal() closeConfirmModal()
location.reload() location.reload()

View File

@ -21,7 +21,6 @@ Route::prefix('api')->group(function () {
Route::apiResource('kategori', KategoriController::class); Route::apiResource('kategori', KategoriController::class);
Route::get('brankas', [ItemController::class, 'brankasItem']); Route::get('brankas', [ItemController::class, 'brankasItem']);
Route::delete('kosongkan-nampan', [NampanController::class, 'kosongkan']);
// Foto Sementara // Foto Sementara
Route::post('foto/upload', [FotoSementaraController::class, 'upload']); Route::post('foto/upload', [FotoSementaraController::class, 'upload']);