mirror of
https://github.com/faiztyanirh/clqms-shadcn-v1.git
synced 2026-04-28 17:52:31 +07:00
initial finish ordertest
This commit is contained in:
parent
47873b172a
commit
cdb3fdc7dd
@ -155,9 +155,9 @@ export function buildOrderTestPayload(mainForm){
|
||||
|
||||
let payload = {
|
||||
...rest,
|
||||
// Tests: Tests.map(test => ({
|
||||
// TestSiteID: test.testSiteID,
|
||||
// }))
|
||||
Tests: Tests.map(test => ({
|
||||
TestSiteID: test.TestSiteID,
|
||||
}))
|
||||
}
|
||||
|
||||
return cleanEmptyStrings(payload)
|
||||
|
||||
@ -30,18 +30,18 @@
|
||||
const payload = buildOrderTestPayload(formState.form);
|
||||
console.log(payload);
|
||||
|
||||
// const result = await formState.save(masterDetail.mode, payload);
|
||||
const result = await formState.save(masterDetail.mode, payload);
|
||||
|
||||
// if (result.status === 'success') {
|
||||
// toast('Order Test Created!');
|
||||
// masterDetail?.exitForm(true);
|
||||
// } else {
|
||||
// console.error('Failed to save order test');
|
||||
// const errorMessages = result.messages ? Object.values(result.messages).join('\n') : 'Failed to save order test';
|
||||
// toast.error(errorMessages)
|
||||
// }
|
||||
if (result.status === 'success') {
|
||||
toast('Order Test Created!');
|
||||
masterDetail?.exitForm(true);
|
||||
} else {
|
||||
console.error('Failed to save order test');
|
||||
const errorMessages = result.messages ? Object.values(result.messages).join('\n') : 'Failed to save order test';
|
||||
toast.error(errorMessages)
|
||||
}
|
||||
}
|
||||
$inspect(formState.errors)
|
||||
|
||||
const primaryAction = $derived({
|
||||
label: 'Save',
|
||||
onClick: handleSave,
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
import { buildOrderTestPayload } from "$lib/components/order/ordertest/config/ordertest-form-config";
|
||||
import { getChangedFields } from "$lib/utils/getChangedFields";
|
||||
import { orderStore } from "$lib/components/order/ordertest/store/order-store.svelte";
|
||||
import { onMount } from "svelte";
|
||||
|
||||
let props = $props();
|
||||
|
||||
@ -99,7 +100,10 @@
|
||||
// idCounter = maxId;
|
||||
// }
|
||||
// });
|
||||
$inspect(formState.form)
|
||||
$inspect(formState.form);
|
||||
onMount(()=>{
|
||||
console.log('mount dr edit page');
|
||||
})
|
||||
</script>
|
||||
|
||||
<FormPageContainer title="Edit Order for {orderStore.selectedPatient.PatientID} - {orderStore.selectedPatient.FullName}" {primaryAction} {secondaryActions}>
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
import * as Collapsible from "$lib/components/ui/collapsible/index.js";
|
||||
import { Checkbox } from "$lib/components/ui/checkbox/index.js";
|
||||
import { untrack } from 'svelte';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
let {
|
||||
formState,
|
||||
@ -78,6 +79,10 @@
|
||||
);
|
||||
});
|
||||
|
||||
let activeSelectedCount = $derived(
|
||||
selectedTests.filter(t => !isPending(t)).length
|
||||
);
|
||||
|
||||
function toggleTest(test) {
|
||||
const exists = selectedTests.find(t => t.rawItem.TestSiteID === test.rawItem.TestSiteID);
|
||||
if (exists) {
|
||||
@ -146,6 +151,19 @@
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
onMount(() => {
|
||||
console.log('mount dr render')
|
||||
if (!formState.form.Tests?.length) return;
|
||||
|
||||
pendingTests = formState.form.Tests.map(test => ({
|
||||
value: test.TestSiteID,
|
||||
label: `${test.TestSiteCode} - ${test.TestSiteName}`,
|
||||
rawItem: test
|
||||
}));
|
||||
|
||||
selectedTests = [...pendingTests];
|
||||
});
|
||||
</script>
|
||||
|
||||
{#snippet Fieldset({
|
||||
@ -339,7 +357,7 @@
|
||||
{/each}
|
||||
</div>
|
||||
<div class="shrink-0 p-2 border-t border-b flex items-center justify-between">
|
||||
<span class="text-sm">{selectedTests.length} selected</span>
|
||||
<span class="text-sm">{activeSelectedCount} selected</span>
|
||||
<Button
|
||||
size="sm"
|
||||
class="px-4 py-2 rounded"
|
||||
|
||||
@ -21,13 +21,13 @@
|
||||
saveEndpoint: createOrder,
|
||||
editEndpoint: editOrder,
|
||||
idKey: 'OrderID',
|
||||
mapToForm: (data) => ({
|
||||
...data,
|
||||
Tests: (data.Tests || []).map((t, i) => ({
|
||||
...t,
|
||||
id: t.id ?? i + 1
|
||||
}))
|
||||
})
|
||||
// mapToForm: (data) => ({
|
||||
// ...data,
|
||||
// Tests: (data.Tests || []).map((t, i) => ({
|
||||
// ...t,
|
||||
// id: t.id ?? i + 1
|
||||
// }))
|
||||
// })
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user