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

@@ -2,13 +2,9 @@ document.addEventListener('alpine:init', () => {
Alpine.data('masterData', () => ({
// 0. Init dijalankan sebelum inisialisasi
init() {
this.filteredItemAssay = [...this.dataAssay];
},
// 1. Inisialisasi Start
// multiple select
openAssayAdd: false,
searchAssay: "",
selectedAssay: [],
dataAssay: [
{
idAssay: 1,
@@ -31,25 +27,20 @@ document.addEventListener('alpine:init', () => {
namaAssay: 'PLT'
},
],
filteredItemAssay: [],
filterItemAssay() {
this.filteredItemAssay = this.dataAssay.filter(item =>
item.namaAssay.toLowerCase().includes(this.searchAssay.toLowerCase())
);
},
addItemAssay(item) {
if (!this.selectedAssay.some(p => p.idAssay === item.idAssay)) {
this.selectedAssay.push(item);
this.objForm.Assay.push(item);
}
this.searchAssay = "";
this.filterItemAssay();
},
removeItemAssay(index) {
this.selectedAssay.splice(index, 1);
},
dataAlat: [
{
idAlat: 1,
namaAlat: 'Hema 01',
},
{
idAlat: 2,
namaAlat: 'Axsym',
},
{
idAlat: 3,
namaAlat: 'Cobas C311',
},
],
// multiple select
dataMaster: [
@@ -87,19 +78,14 @@ document.addEventListener('alpine:init', () => {
kodeAdd: '',
namaAdd: '',
hargaAdd: '',
formAddArray: [
{
idForm: 1,
selectedInstrument: {},
selectedAssay: []
}
],
formAddArray: [],
showDialogEdit: false,
objForm: {
nama: '',
kode: '',
harga: '',
dataAssay: [],
alat: {},
assay: []
},
objFormEdit: {
nama: '',
@@ -109,18 +95,63 @@ document.addEventListener('alpine:init', () => {
},
// 1. Inisialisasi End
// 2. Fungsi Start
formAddDetail(){
const lastId = this.formAddArray[this.formAddArray. length - 1];
this.formAddArray = this.formAddArray.push([{
formAddDetail() {
const lastId = this.formAddArray.length;
this.formAddArray.push({
idForm: lastId + 1,
selectedInstrument: {},
selectedAssay: []
}])
openAlat: false,
dataAlatForm: this.dataAlat,
selectedAlat: {
idAlat: -1,
namaAlat: 'Alat'
},
selectedAssay: [],
searchAssay: "",
filterItemAssay: this.dataAssay,
dataAssayForm: this.dataAssay,
openAssayAdd: false,
})
},
filterItemAssay(idx, formItem) {
let formId = formItem.idForm
// console.log('formItem ',formItem)
let targetForm = this.formAddArray.find(e => e.idForm === formId);
if (targetForm) {
targetForm.openAssayAdd = true
let searchTerm = targetForm.searchAssay ? targetForm.searchAssay.toLowerCase() : "";
targetForm.filterItemAssay = targetForm.dataAssayForm.filter(item =>
item.namaAssay.toLowerCase().includes(searchTerm)
);
// targetForm.dataAssayForm = targetForm.filterItemAssay
console.log('Filtered Assay:', targetForm.filterItemAssay);
} else {
console.warn('Tidak match ID Form nya');
}
},
addItemAssayToForm(item, idForm) {
let form = this.formAddArray.find(f => f.idForm === idForm);
if (form) {
let exists = form.selectedAssay.some(a => a.idAssay === item.idAssay);
if (!exists) {
form.selectedAssay.push(item);
} else {
console.warn("Item sudah dipilih:", item);
}
}
},
removeItemAssayToForm(idForm, index) {
let form = this.formAddArray.find(f => f.idForm === idForm);
if (!form) return;
form.selectedAssay.splice(index, 1);
},
closeDialog() {
this.AssayAdd = []
this.filteredItemAssay = []
this.selectedAssay = []
this.formAddArray = []
this.kodeAdd = ''
this.namaAdd = ''
this.hargaAdd = ''
@@ -132,13 +163,22 @@ document.addEventListener('alpine:init', () => {
}
this.showDialogAdd = false
},
onChangeInstrumentSearch(item) {
this.openInstrumentSearch = false;
this.selectedInstrument = item;
saveA() {
this.objForm.alat = this.formAddArray.map(form => form.selectedAlat);
this.objForm.assay = this.formAddArray.map(form => form.selectedAssay);
console.log('Data yang disimpan:', this.objForm);
},
onChangeInstrument(item) {
this.openInstrument = false;
this.selectedInstrumentAdd = item;
onChangeInstrument(item, idForm) {
let form = this.formAddArray.find(f => f.idForm === idForm);
if (!form) return;
form.selectedAlat = {
idAlat: item.idAlat,
namaAlat: item.namaAlat
}
form.openAlat = false
},
onChangeInstrumentEdit(item) {
this.openInstrument = false;
@@ -159,14 +199,9 @@ document.addEventListener('alpine:init', () => {
onChangeHargaAdd() {
this.objForm.harga = this.hargaAdd;
},
onChangeHargaAdd() {
onChangeHargaEdit() {
this.objFormEdit.harga = this.e_harga;
},
onChangeInstrumentMobile(item) {
this.openInstrumentSearchMobile = false;
// this.selectedInstrument = item;
this.selectedInstrument = { ...item };
},
openModalEdit(item) {
// mrn
this.e_mrn = item.mrn

231
v1/js/mcoba.js Normal file
View File

@@ -0,0 +1,231 @@
document.addEventListener('alpine:init', () => {
Alpine.data('masterData', () => ({
// 0. Init dijalankan sebelum inisialisasi
init() {
},
// 1. Inisialisasi Start
// multiple select
dataAssay: [
{
idAssay: 1,
namaAssay: 'Xn500'
},
{
idAssay: 2,
namaAssay: 'HGB'
},
{
idAssay: 3,
namaAssay: 'WBC'
},
{
idAssay: 4,
namaAssay: 'RBC'
},
{
idAssay: 5,
namaAssay: 'PLT'
},
],
dataAlat: [
{
idAlat: 1,
namaAlat: 'Hema 01',
},
{
idAlat: 2,
namaAlat: 'Axsym',
},
{
idAlat: 3,
namaAlat: 'Cobas C311',
},
],
// multiple select
dataMaster: [
{
idMaster: 1,
kode: 'A04',
namaPemeriksaan: 'Darah Lengkap',
harga: '50.000',
pemeriksaanStr: 'Xn500, HCB, WBC, RBC, PLT',
dataAssay: [
{
idAssay: 1,
namaAssay: 'Xn500'
},
{
idAssay: 2,
namaAssay: 'HGB'
},
{
idAssay: 3,
namaAssay: 'WBC'
},
{
idAssay: 4,
namaAssay: 'RBC'
},
{
idAssay: 5,
namaAssay: 'PLT'
},
],
},
],
showDialogAdd: false,
kodeAdd: '',
namaAdd: '',
hargaAdd: '',
formAddArray: [],
showDialogEdit: false,
objForm: {
nama: '',
kode: '',
harga: '',
alat: {},
assay: []
},
objFormEdit: {
nama: '',
kode: '',
harga: '',
dataAssay: [],
},
// 1. Inisialisasi End
// 2. Fungsi Start
formAddDetail() {
const lastId = this.formAddArray.length;
this.formAddArray.push({
idForm: lastId + 1,
openAlat: false,
dataAlatForm: this.dataAlat,
selectedAlat: {
idAlat: -1,
namaAlat: 'Alat'
},
selectedAssay: [],
searchAssay: "",
filterItemAssay: this.dataAssay,
dataAssayForm: this.dataAssay,
openAssayAdd: false,
})
},
filterItemAssay(idx, formItem) {
let formId = formItem.idForm
// console.log('formItem ',formItem)
let targetForm = this.formAddArray.find(e => e.idForm === formId);
if (targetForm) {
targetForm.openAssayAdd = true
let searchTerm = targetForm.searchAssay ? targetForm.searchAssay.toLowerCase() : "";
targetForm.filterItemAssay = targetForm.dataAssayForm.filter(item =>
item.namaAssay.toLowerCase().includes(searchTerm)
);
// targetForm.dataAssayForm = targetForm.filterItemAssay
console.log('Filtered Assay:', targetForm.filterItemAssay);
} else {
console.warn('Tidak match ID Form nya');
}
},
addItemAssayToForm(item, idForm) {
let form = this.formAddArray.find(f => f.idForm === idForm);
if (form) {
let exists = form.selectedAssay.some(a => a.idAssay === item.idAssay);
if (!exists) {
form.selectedAssay.push(item);
} else {
console.warn("Item sudah dipilih:", item);
}
}
},
removeItemAssayToForm(idForm, index) {
let form = this.formAddArray.find(f => f.idForm === idForm);
if (!form) return;
form.selectedAssay.splice(index, 1);
},
closeDialog() {
this.formAddArray = []
this.kodeAdd = ''
this.namaAdd = ''
this.hargaAdd = ''
this.objForm = {
nama: '',
kode: '',
harga: '',
dataAssay: [],
}
this.showDialogAdd = false
},
saveA() {
this.objForm.alat = this.formAddArray.map(form => form.selectedAlat);
this.objForm.assay = this.formAddArray.map(form => form.selectedAssay);
console.log('Data yang disimpan:', this.objForm);
},
onChangeInstrument(item, idForm) {
let form = this.formAddArray.find(f => f.idForm === idForm);
if (!form) return;
form.selectedAlat = {
idAlat: item.idAlat,
namaAlat: item.namaAlat
}
form.openAlat = false
},
onChangeInstrumentEdit(item) {
this.openInstrument = false;
this.selectedInstrumentEdit = item;
},
onChangeNamaAdd() {
this.objForm.nama = this.namaAdd;
},
onChangeNamaEdit() {
this.objFormEdit.nama = this.e_nama;
},
onChangeKodeAdd() {
this.objForm.kode = this.kodeAdd;
},
onChangeKodeEdit() {
this.objFormEdit.kode = this.e_kode;
},
onChangeHargaAdd() {
this.objForm.harga = this.hargaAdd;
},
onChangeHargaEdit() {
this.objFormEdit.harga = this.e_harga;
},
openModalEdit(item) {
// mrn
this.e_mrn = item.mrn
// sid
this.e_sid = item.sid
// name
this.e_name = item.name
// multiple pemeriksaan
this.e_selectedPemeriksaan = [...item.dataPemeriksaan];
this.e_filteredPemeriksaan = [...this.dataPemeriksaan];
this.showDialogEdit = !this.showDialogEdit;
},
closeDialogEdit() {
this.showDialogEdit = !this.showDialogEdit;
},
editMobilePage(item) {
var json = JSON.stringify(item);
localStorage.setItem('itemEditMobile', json)
window.location.href = "order_mobile_edit.html";
},
// 2. Fungsi End
}))
})

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>

410
v1/mcoba.html Normal file
View File

@@ -0,0 +1,410 @@
<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Master Data XPORT</title>
<!-- tailwind cdn -->
<script src="https://unpkg.com/@tailwindcss/browser@4"></script>
<!-- alpine cdn -->
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.14.8/dist/cdn.min.js"></script>
<!-- material Symbols -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined" />
</head>
<body class="bg-[#F2F9FF] h-screen flex flex-col">
<!-- Navbar -->
<div class="bg-white h-20 flex items-center justify-between px-6">
<!-- Logo -->
<a class="block text-teal-600" href="#">
<div class="flex items-center space-x-2">
<img src="../images/logoServer.png" class="mr-3 h-10" />
<p class="lg:text-lg xl:text-xl text-[#2196F3] font-normal">Port Server</p>
</div>
</a>
<!-- Navigasi (Desktop) -->
<nav class="hidden lg:flex items-center text-sm gap-6 ml-auto">
<ul class="flex items-center gap-6 text-sm">
<li>
<a href="settings.html" class="text-black/87 transition font-bold hover:text-[#2196F3]">SETTING</a>
</li>
<li>
<a href="assay_format.html" class="text-black/87 transition font-bold hover:text-[#2196F3] ">ASSAY
FORMAT</a>
</li>
<li>
<a href="result.html" class="text-black/87 transition font-bold hover:text-[#2196F3]">RESULT</a>
</li>
<li>
<a href="order.html" class="text-black/87 transition font-bold hover:text-[#2196F3]">ORDER</a>
</li>
<li class="bg-[#E3F2FD] rounded-sm p-3">
<a href="master_data.html" class="text-[#2196F3] transition font-bold hover:text-black/87">MASTER
DATA</a>
</li>
<li>
<a href="#" class="text-black/87 transition font-bold hover:text-[#2196F3]">ONLINE</a>
</li>
<li>
<img src="../images/avatar.png" class="mr-3" />
</li>
</ul>
</nav>
<!-- Hamburger Menu (Mobile) -->
<div x-data="{ open: false }">
<button @click="open = true" class="block lg:hidden text-[#2196F3] hover:text-gray-600/75">
<span class="material-symbols-outlined text-3xl">menu</span>
</button>
<!-- Bottom Sheet Menu (Mobile) -->
<div>
<!-- Overlay -->
<div x-show="open" class="fixed inset-0 bg-black/50 transition-opacity z-50" @click="open = false">
</div>
<!-- Modal -->
<div x-show="open" x-transition
class="fixed bottom-0 left-0 w-full bg-white p-6 rounded-t-[32px] shadow-lg transform transition-transform duration-300 ease-in-out z-50"
x-bind:class="open ? 'translate-y-0' : 'translate-y-full'">
<ul class="space-y-2">
<li>
<a href="settings.html"
class="block px-4 py-2 hover:bg-gray-100 rounded-lg text-black/87 font-medium text-lg">
<div class="flex items-center gap-2">
<span class="material-symbols-outlined text-black/87">settings</span>
Setting
</div>
</a>
</li>
<li>
<a href="assay_format.html"
class="block px-4 py-2 hover:bg-gray-100 rounded-lg text-black/87 font-medium text-lg">
<div class="flex items-center gap-2">
<span class="material-symbols-outlined text-black/87">edit</span>
Assay Format
</div>
</a>
</li>
<li>
<a href="result.html"
class="block px-4 py-2 hover:bg-gray-100 rounded-lg text-black/87 font-medium text-lg">
<div class="flex items-center gap-2">
<span class="material-symbols-outlined text-black/87">calculate</span>
Result
</div>
</a>
</li>
<li>
<a href="order.html"
class="block px-4 py-2 hover:bg-gray-100 rounded-lg text-black/87 font-medium text-lg">
<div class="flex items-center gap-2">
<span class="material-symbols-outlined text-black/87">calculate</span>
Order
</div>
</a>
</li>
<li class="bg-[#E3F2FD] p-2 rounded">
<a href="master_data.html"
class="block px-4 py-2 hover:bg-gray-100 rounded-lg text-[#2196F3] font-medium text-lg">
<div class="flex items-center gap-2">
<span class="material-symbols-outlined text-[#2196F3]">calculate</span>
Master Data
</div>
</a>
</li>
<li>
<a href="#"
class="block px-4 py-2 hover:bg-gray-100 rounded-lg text-black/87 font-medium text-lg">
<div class="flex items-center gap-2">
<span class="material-symbols-outlined text-black/87">online_prediction</span>
Status
</div>
</a>
</li>
<li>
<a href="#"
class="block px-4 py-2 hover:bg-gray-100 rounded-lg text-black/87 font-medium text-lg">
<div class="flex items-center gap-2">
<span class="material-symbols-outlined text-black/87">person</span>
Akun
</div>
</a>
</li>
</ul>
</div>
</div>
</div>
</div>
<!-- Konten utama -->
<div class="flex-1 flex flex-col lg:flex-row p-6 gap-5 overflow-hidden h-screen" x-data="masterData">
<!-- Bagian Kiri Full (Tabel) -->
<div class="hidden lg: bg-white w-full rounded-lg p-5 lg:flex flex-col flex-1 overflow-hidden">
<div class="flex justify-between space-x-2">
<div class="p-2 text-black font-medium text-lg rounded-lg">Master Data</div>
</div>
<!-- space 20 -->
<div class="mb-0 lg:mb-5"></div>
<!-- Table Desktop -->
<div class="flex-1 overflow-auto h-full">
<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">Kode</th>
<th class="p-2 font-medium text-gray-900 w-[35%] text-left text-xs">Nama Pemeriksaan</th>
<th class="p-2 font-medium text-gray-900 w-[15%] text-left text-xs">Harga</th>
<th class="p-2 font-medium text-gray-900 w-[35%] text-left text-xs">Assay Details</th>
<th class="p-2 font-medium text-gray-900 w-[5%] text-left text-xs">
<button @click="showDialogAdd = !showDialogAdd">
<span class="material-symbols-outlined text-black">add</span>
</button>
</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200">
<template x-for="item in dataMaster" :key="item.idMaster">
<tr>
<td class="text-wrap align-top text-left font-normal text-xs text-black/87 p-2"
x-text="item.kode"></td>
<td class="text-wrap align-top text-left font-normal text-xs text-black/87 p-2"
x-text="item.namaPemeriksaan"></td>
<td class="text-wrap align-top text-left font-normal text-xs text-black/87 p-2"
x-text="item.harga"></td>
<td class="text-wrap align-top text-left font-normal text-xs text-black/87 p-2"
x-text="item.pemeriksaanStr"></td>
<td class="text-wrap align-top text-center font-normal text-xs text-[#2196F3] p-2">
<button @click="openModalEdit(item)"><span
class="material-symbols-outlined">edit</span></button>
</td>
</tr>
</template>
</tbody>
</table>
</div>
</div>
<!-- modal add desktop -->
<div x-show="showDialogAdd" x-transition.duration.200ms class="fixed z-10 inset-0">
<div class="flex items-center justify-center min-h-screen bg-[#0F0F0F4D] transition-all">
<!-- box -->
<div class="flex flex-col bg-white rounded-lg w-2/3 min-h-[300px] max-h-[90vh] overflow-y-auto">
<!-- header -->
<div class="bg-[#2196F3] flex w-full h-10 rounded-tl-lg rounded-tr-lg">
<h3 class="text-xl font-bold uppercase text-white px-4 py-1">add</h3>
</div>
<!-- body -->
<div class="flex flex-1 bg-white px-6 py-5">
<div class="relative w-full">
<!-- Kode -->
<label for="Kode"
class="relative block rounded-md border border-gray-400 focus-within:border-blue-600 focus-within:ring-1 focus-within:ring-blue-600">
<input type="text" id="Kode" autocomplete="off" x-model="kodeAdd"
@change="onChangeKodeAdd()"
class="peer pl-2 border-none py-3 bg-transparent placeholder-transparent focus:border-transparent focus:ring-0 focus:outline-hidden"
placeholder="Kode" />
<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">
Kode
</span>
</label>
<!-- space 20 -->
<div class="mb-0 lg:mb-5"></div>
<!-- Nama -->
<label for="Nama"
class="relative block rounded-md border border-gray-400 focus-within:border-blue-600 focus-within:ring-1 focus-within:ring-blue-600">
<input type="text" id="Nama" autocomplete="off" x-model="namaAdd"
@change="onChangeNamaAdd()"
class="peer pl-2 border-none py-3 bg-transparent placeholder-transparent focus:border-transparent focus:ring-0 focus:outline-hidden"
placeholder="Nama" />
<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">
Nama
</span>
</label>
<!-- space 20 -->
<div class="mb-0 lg:mb-5"></div>
<!-- Harga -->
<label for="Harga"
class="relative block rounded-md border border-gray-400 focus-within:border-blue-600 focus-within:ring-1 focus-within:ring-blue-600">
<input type="text" id="Harga" autocomplete="off" x-model="hargaAdd"
@change="onChangeHargaAdd()"
class="peer pl-2 border-none py-3 bg-transparent placeholder-transparent focus:border-transparent focus:ring-0 focus:outline-hidden"
placeholder="Harga" />
<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">
Harga
</span>
</label>
<!-- space 20 -->
<div class="mb-0 lg:mb-5"></div>
<!-- table form alat, assay -->
<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-[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>
</button>
</th>
</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>
<!-- table form alat, assay -->
</div>
</div>
<!-- footer -->
<div class="h-10 px-4 py-2 mb-5">
<div class="flex justify-between items-center">
<button @click="closeDialog()" class="text-[#FF5252] hover:text-white font-bold text-sm uppercase transition duration-200
hover:bg-[#FF5252] px-4 py-2 rounded-md">
DELETE
</button>
<div class="flex items-center space-x-3">
<button @click="closeDialog()" class="text-[#1976D2] hover:text-white font-bold text-sm uppercase transition duration-200
hover:bg-[#1976D2] px-4 py-2 rounded-md">
CANCEL
</button>
<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>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- modal add desktop -->
</div>
<script src="js/mcoba.js"></script>
</body>
</html>