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