feat(division): add entry form and view components for division management
This commit is contained in:
@@ -1,57 +1,59 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
// #region Props & Emits
|
import Block from '~/components/pub/custom-ui/form/block.vue'
|
||||||
const props = defineProps<{
|
import Combobox from '~/components/pub/custom-ui/form/combobox.vue'
|
||||||
id: string
|
import FieldGroup from '~/components/pub/custom-ui/form/field-group.vue'
|
||||||
code: string
|
import Field from '~/components/pub/custom-ui/form/field.vue'
|
||||||
name: string
|
import Label from '~/components/pub/custom-ui/form/label.vue'
|
||||||
parentId: string
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const props = defineProps<{ modelValue: any }>()
|
||||||
(e: 'update', value: string): void
|
const emit = defineEmits(['update:modelValue', 'event'])
|
||||||
}>()
|
|
||||||
// #endregion
|
|
||||||
|
|
||||||
// #region State & Computed
|
const data = computed({
|
||||||
// =============================
|
get: () => props.modelValue,
|
||||||
const count = ref(0)
|
set: (val) => emit('update:modelValue', val),
|
||||||
const double = computed(() => count.value * 2)
|
|
||||||
// #endregion
|
|
||||||
|
|
||||||
// #region Lifecycle Hooks
|
|
||||||
onMounted(() => {
|
|
||||||
// init code
|
|
||||||
fetchData()
|
|
||||||
})
|
})
|
||||||
// #endregion
|
|
||||||
|
|
||||||
// #region Functions
|
const parentDivision = [
|
||||||
async function fetchData() {
|
{ value: '1', label: 'Medical', code: 'MED' },
|
||||||
console.log('fetched')
|
{ value: '2', label: 'Nursing', code: 'NUR' },
|
||||||
}
|
{ value: '3', label: 'Admin', code: 'ADM' },
|
||||||
// #endregion region
|
{ value: '4', label: 'Support', code: 'SUP' },
|
||||||
|
{ value: '5', label: 'Education', code: 'EDU' },
|
||||||
// #region Utilities & event handlers
|
]
|
||||||
function increment() {
|
const defParentDivision = '---pilih divisi utama'
|
||||||
count.value++
|
|
||||||
}
|
|
||||||
// #endregion
|
|
||||||
|
|
||||||
// #region Watchers
|
|
||||||
watch(count, (newVal, oldVal) => {
|
|
||||||
console.log('count changed:', oldVal, '->', newVal)
|
|
||||||
})
|
|
||||||
// #endregion
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<form id="entry-form">
|
||||||
<p>Count: {{ count }}</p>
|
<div class="mb-5 border-b border-b-slate-300 pb-3 text-lg xl:text-xl">
|
||||||
<p>Double: {{ double }}</p>
|
<div class="flex flex-col justify-between">
|
||||||
<button @click="increment">+1</button>
|
<Block>
|
||||||
</div>
|
<FieldGroup :column="2">
|
||||||
|
<Label>Nama</Label>
|
||||||
|
<Field>
|
||||||
|
<Input v-model="data.name" />
|
||||||
|
</Field>
|
||||||
|
</FieldGroup>
|
||||||
|
<FieldGroup :column="2">
|
||||||
|
<Label>Kode</Label>
|
||||||
|
<Field>
|
||||||
|
<Input v-model="data.code" />
|
||||||
|
</Field>
|
||||||
|
</FieldGroup>
|
||||||
|
<FieldGroup :column="2">
|
||||||
|
<Label>Divisi</Label>
|
||||||
|
<Field>
|
||||||
|
<Combobox
|
||||||
|
v-model="data.parentId"
|
||||||
|
:items="parentDivision"
|
||||||
|
:placeholder="defParentDivision"
|
||||||
|
search-placeholder="kode, nama divisi"
|
||||||
|
empty-message="divisi tidak ditemukan."
|
||||||
|
/>
|
||||||
|
</Field>
|
||||||
|
</FieldGroup>
|
||||||
|
</Block>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
/* component style */
|
|
||||||
</style>
|
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import Action from '~/components/pub/custom-ui/nav-footer/ba-dr-su.vue'
|
||||||
|
|
||||||
|
const data = ref({
|
||||||
|
code: '',
|
||||||
|
name: '',
|
||||||
|
parentId: 0,
|
||||||
|
})
|
||||||
|
|
||||||
|
function onClick(type: string) {
|
||||||
|
if (type === 'cancel') {
|
||||||
|
navigateTo('/human-src/user')
|
||||||
|
} else if (type === 'draft') {
|
||||||
|
// do something
|
||||||
|
} else if (type === 'submit') {
|
||||||
|
// do something
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="mb-5 border-b border-b-slate-300 pb-3 text-lg xl:text-xl">
|
||||||
|
<Icon name="i-lucide-user" class="me-2" />
|
||||||
|
<span class="font-semibold">Tambah</span> Divisi
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<AppDivisonEntryForm v-model="data" />
|
||||||
|
</div>
|
||||||
|
<div class="my-2 flex justify-end py-2">
|
||||||
|
<Action @click="onClick" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
Reference in New Issue
Block a user