From ba61d05257ea729e3bee9dd30e6fc2e1c2a8b55b Mon Sep 17 00:00:00 2001 From: riefive Date: Mon, 6 Oct 2025 12:42:08 +0700 Subject: [PATCH] fix: adjustment division app + flow --- .../app/division/entry-form-prev.vue | 145 ------------ app/components/app/division/entry-form.vue | 2 +- app/components/app/division/tree.vue | 165 -------------- app/components/content/division/entry.ts | 145 ------------ app/components/content/division/list-prev.vue | 208 ------------------ 5 files changed, 1 insertion(+), 664 deletions(-) delete mode 100644 app/components/app/division/entry-form-prev.vue delete mode 100644 app/components/app/division/tree.vue delete mode 100644 app/components/content/division/entry.ts delete mode 100644 app/components/content/division/list-prev.vue diff --git a/app/components/app/division/entry-form-prev.vue b/app/components/app/division/entry-form-prev.vue deleted file mode 100644 index 0684fc55..00000000 --- a/app/components/app/division/entry-form-prev.vue +++ /dev/null @@ -1,145 +0,0 @@ - - - diff --git a/app/components/app/division/entry-form.vue b/app/components/app/division/entry-form.vue index 8612b648..c58d83ac 100644 --- a/app/components/app/division/entry-form.vue +++ b/app/components/app/division/entry-form.vue @@ -4,7 +4,7 @@ import Block from '~/components/pub/my-ui/doc-entry/block.vue' import Cell from '~/components/pub/my-ui/doc-entry/cell.vue' import Field from '~/components/pub/my-ui/doc-entry/field.vue' import Label from '~/components/pub/my-ui/doc-entry/label.vue' -import TreeSelect from '~/components/pub/base/select-tree/tree-select.vue' +import TreeSelect from '~/components/pub/my-ui/select-tree/tree-select.vue' // Types import type { DivisionFormData } from '~/schemas/division.schema.ts' diff --git a/app/components/app/division/tree.vue b/app/components/app/division/tree.vue deleted file mode 100644 index a6f66eff..00000000 --- a/app/components/app/division/tree.vue +++ /dev/null @@ -1,165 +0,0 @@ - - - diff --git a/app/components/content/division/entry.ts b/app/components/content/division/entry.ts deleted file mode 100644 index 9f3cb9f4..00000000 --- a/app/components/content/division/entry.ts +++ /dev/null @@ -1,145 +0,0 @@ -import type { TreeItem } from '~/components/pub/my-ui/select-tree/type' -import * as z from 'zod' - -export const divisionConf = { - msg: { - placeholder: '---pilih divisi utama', - search: 'kode, nama divisi', - empty: 'divisi tidak ditemukan', - }, - items: [ - { value: '1', label: 'Medical' }, - { value: '2', label: 'Nursing' }, - { value: '3', label: 'Admin' }, - { value: '4', label: 'Support' }, - { value: '5', label: 'Education' }, - { value: '6', label: 'Pharmacy' }, - { value: '7', label: 'Radiology' }, - { value: '8', label: 'Laboratory' }, - { value: '9', label: 'Finance' }, - { value: '10', label: 'Human Resources' }, - { value: '11', label: 'IT Services' }, - { value: '12', label: 'Maintenance' }, - { value: '13', label: 'Catering' }, - { value: '14', label: 'Security' }, - { value: '15', label: 'Emergency' }, - { value: '16', label: 'Surgery' }, - { value: '17', label: 'Outpatient' }, - { value: '18', label: 'Inpatient' }, - { value: '19', label: 'Rehabilitation' }, - { value: '20', label: 'Research' }, - ], -} - -export const schema = z.object({ - name: z - .string({ - required_error: 'Nama wajib diisi', - }) - .min(1, 'Nama divisi wajib diisi'), - - code: z - .string({ - required_error: 'Kode wajib diisi', - }) - .min(1, 'Kode divisi wajib diisi'), - - parentId: z.string().optional(), -}) - -// State untuk tree data divisi - dimulai dengan data level atas -const divisionTreeData = ref([ - { value: '1', label: 'Medical', hasChildren: true }, - { value: '2', label: 'Nursing', hasChildren: true }, - { value: '3', label: 'Admin', hasChildren: false }, - { value: '4', label: 'Support', hasChildren: true }, - { value: '5', label: 'Education', hasChildren: false }, - { value: '6', label: 'Pharmacy', hasChildren: true }, - { value: '7', label: 'Radiology', hasChildren: false }, - { value: '8', label: 'Laboratory', hasChildren: true }, -]) - -// Helper function untuk mencari dan menyisipkan data anak ke dalam tree -function findAndInsertChildren(nodes: TreeItem[], parentId: string, newChildren: TreeItem[]): boolean { - for (const node of nodes) { - if (node.value === parentId) { - node.children = newChildren - return true - } - if (node.children && findAndInsertChildren(node.children as TreeItem[], parentId, newChildren)) { - return true - } - } - return false -} - -// Fungsi untuk fetch data anak divisi (lazy loading) -async function handleFetchDivisionChildren(parentId: string): Promise { - console.log(`Mengambil data sub-divisi untuk parent: ${parentId}`) - - // Simulasi delay API call - await new Promise((resolve) => setTimeout(resolve, 800)) - - let childrenData: TreeItem[] = [] - - // Sample data berdasarkan parent ID - switch (parentId) { - case '1': // Medical - childrenData = [ - { value: '1-1', label: 'Cardiology', hasChildren: true }, - { value: '1-2', label: 'Neurology', hasChildren: false }, - { value: '1-3', label: 'Oncology', hasChildren: false }, - ] - break - case '2': // Nursing - childrenData = [ - { value: '2-1', label: 'ICU Nursing', hasChildren: false }, - { value: '2-2', label: 'ER Nursing', hasChildren: false }, - { value: '2-3', label: 'Ward Nursing', hasChildren: true }, - ] - break - case '4': // Support - childrenData = [ - { value: '4-1', label: 'IT Support', hasChildren: false }, - { value: '4-2', label: 'Maintenance', hasChildren: false }, - ] - break - case '6': // Pharmacy - childrenData = [ - { value: '6-1', label: 'Inpatient Pharmacy', hasChildren: false }, - { value: '6-2', label: 'Outpatient Pharmacy', hasChildren: false }, - ] - break - case '8': // Laboratory - childrenData = [ - { value: '8-1', label: 'Clinical Lab', hasChildren: false }, - { value: '8-2', label: 'Pathology Lab', hasChildren: false }, - ] - break - case '1-1': // Cardiology sub-divisions - childrenData = [ - { value: '1-1-1', label: 'Cardiac Surgery', hasChildren: false }, - { value: '1-1-2', label: 'Cardiac Cathlab', hasChildren: false }, - ] - break - case '2-3': // Ward Nursing sub-divisions - childrenData = [ - { value: '2-3-1', label: 'Pediatric Ward', hasChildren: false }, - { value: '2-3-2', label: 'Surgical Ward', hasChildren: false }, - ] - break - } - - // Insert data ke dalam tree state - findAndInsertChildren(divisionTreeData.value, parentId, childrenData) -} - -export const divisionTreeConfig = computed(() => ({ - msg: { - placeholder: '--- Pilih divisi induk', - search: 'Cari divisi...', - empty: 'Divisi tidak ditemukan', - }, - data: divisionTreeData.value, - onFetchChildren: handleFetchDivisionChildren, -})) diff --git a/app/components/content/division/list-prev.vue b/app/components/content/division/list-prev.vue deleted file mode 100644 index d072ac9a..00000000 --- a/app/components/content/division/list-prev.vue +++ /dev/null @@ -1,208 +0,0 @@ - - - - -