step 46 : add data master_data di form

This commit is contained in:
sindhu
2025-03-28 13:55:10 +07:00
parent c055fe8958
commit 32cc43e490
4 changed files with 838 additions and 57 deletions

View File

@@ -255,8 +255,8 @@
<table class="min-w-full divide-y-2 divide-gray-200 bg-white text-sm">
<thead>
<tr>
<th class="p-2 font-medium text-gray-900 w-[10%] text-left text-xs">Alat</th>
<th class="p-2 font-medium text-gray-900 w-[85%] text-left text-xs">Assay</th>
<th class="p-2 font-medium text-gray-900 w-[47.5%] text-left text-xs">Alat</th>
<th class="p-2 font-medium text-gray-900 w-[47.5%] text-left text-xs">Assay</th>
<th class="p-2 font-medium text-gray-900 w-[5%] text-left text-xs">
<button @click="formAddDetail()">
<span class="material-symbols-outlined text-black">add</span>
@@ -265,7 +265,112 @@
</tr>
</thead>
<tbody class="divide-y divide-gray-200">
<template x-for="(form, index) in formAddArray" :key="form.idForm">
<tr>
<td class="p-2">
<!-- alat -->
<div class="relative w-full">
<fieldset @click.outside="form.openAlat = false"
class="relative border border-gray-400 rounded-md focus-within:border-blue-500 focus-within:ring-1 focus-within:ring-blue-500 px-3 pt-2 pb-2">
<span
x-text="form.selectedAlat.idAlat != -1 ? 'Alat' : form.selectedAlat.namaAlat"
class="pointer-events-none absolute start-2.5 top-0 -translate-y-1/2 bg-white p-0.5 text-xs text-gray-700 transition-all peer-placeholder-shown:top-1/2 peer-placeholder-shown:text-sm peer-focus:top-0 peer-focus:text-xs">
</span>
<button @click="form.openAlat = !form.openAlat" type="button"
class="w-full flex items-center justify-between bg-transparent text-gray-900 py-0.5 focus:outline-none">
<span x-text="form.selectedAlat.namaAlat"
class="text-left"></span>
<svg xmlns="http://www.w3.org/2000/svg"
class="h-5 w-5 transition-transform"
:class="{ 'rotate-180': form.openAlat }" fill="none"
viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round"
stroke-width="2" d="M19 9l-7 7-7-7" />
</svg>
</button>
</fieldset>
<div x-show="form.openAlat"
class="absolute bg-white w-full border border-gray-300 rounded-md shadow-lg z-10 max-h-[200px] overflow-y-auto">
<ul>
<template x-if="form.dataAlatForm.length === 0">
<li class="py-2 px-3 text-gray-500 text-center">Data
tidak ada</li>
</template>
<template x-for="item in form.dataAlatForm" :key="item.idAlat">
<li :id="item.idAlat" @click="onChangeInstrument(item, form.idForm)"
class="py-2 px-3 hover:bg-blue-100 cursor-pointer text-gray-700">
<button x-text="item.namaAlat"></button>
</li>
</template>
</ul>
</div>
</div>
</td>
<td class="p-2">
<div>
<!-- List Assay yang Dipilih -->
<div class="flex flex-wrap gap-2 mb-2">
<template x-for="(item, idx) in form.selectedAssay"
:key="item.idAssay">
<div
class="flex items-center bg-blue-100 text-blue-700 text-sm px-2 py-1 rounded-md">
<span x-text="item.namaAssay"></span>
<button @click="removeItemAssayToForm(form.idForm, idx)"
class="ml-2 focus:outline-none">
<svg class="w-4 h-4 text-blue-500 hover:text-blue-700"
fill="none" stroke="currentColor"
stroke-width="2" viewBox="0 0 24 24">
<path stroke-linecap="round"
stroke-linejoin="round"
d="M6 18L18 6M6 6l12 12"></path>
</svg>
</button>
</div>
</template>
</div>
<!-- Input Search Assay -->
<label
class="relative block border rounded-md border-gray-400 focus-within:border-blue-600 focus-within:ring-1 focus-within:ring-blue-600">
<input type="text" autocomplete="off" x-model="form.searchAssay"
@input="filterItemAssay(index, form)"
@click="form.openAssayAdd = true"
class="peer pl-2 border-none py-3 bg-transparent placeholder-transparent focus:border-transparent focus:ring-0 focus:outline-hidden"
placeholder="Cari Assay" />
<span
class="pointer-events-none absolute start-2.5 top-0 -translate-y-1/2 bg-white p-0.5 text-xs text-gray-700 transition-all peer-placeholder-shown:top-1/2 peer-placeholder-shown:text-sm peer-focus:top-0 peer-focus:text-xs">
Cari Assay
</span>
</label>
<!-- Dropdown List -->
<div x-show="form.openAssayAdd"
@click.away="form.openAssayAdd = false"
class="absolute left-0 mt-2 w-full bg-white border border-gray-300 rounded-lg shadow-lg z-10 max-h-48 overflow-y-auto transition-all duration-200">
<template x-if="form.filterItemAssay.length === 0">
<div class="p-2 text-gray-500 text-sm text-center">Tidak ada
hasil</div>
</template>
<template x-for="(item, idxAssayForm) in form.filterItemAssay"
:key="item.idAssay">
<div @click="addItemAssayToForm(item, form.idForm)"
class="cursor-pointer p-2 hover:bg-blue-100 flex items-center justify-between"
:class="form.selectedAssay.some(p => p.idAssay === item.idAssay) ? 'bg-yellow-100 text-yellow-800' : ''">
<span x-text="item.namaAssay"></span>
<svg x-show="form.selectedAssay.some(p => p.idAssay === item.idAssay)"
class="w-4 h-4 text-yellow-500" fill="none"
stroke="currentColor" stroke-width="2"
viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round"
d="M5 13l4 4L19 7"></path>
</svg>
</div>
</template>
</div>
</div>
</td>
</tr>
</template>
</tbody>
</table>
@@ -286,7 +391,7 @@
hover:bg-[#1976D2] px-4 py-2 rounded-md">
CANCEL
</button>
<button @click="save()" class="text-white bg-[#4CAF50] font-bold text-sm uppercase px-4 py-2 rounded-md transition duration-200
<button @click="saveA()" class="text-white bg-[#4CAF50] font-bold text-sm uppercase px-4 py-2 rounded-md transition duration-200
hover:bg-[#388E3C]">
SAVE
</button>
@@ -299,7 +404,7 @@
<!-- modal add desktop -->
</div>
<script src="js/master_data.js"></script>
<script src="js/mcoba.js"></script>
</body>
</html>