@initsolusidigital/worksuite-shell 0.0.0-stage → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +16 -0
- package/README.md +122 -2
- package/package.json +44 -4
- package/src/components/ai/AppAssistantDraft.vue +120 -0
- package/src/components/ai/AppAssistantWidget.vue +245 -0
- package/src/components/ai/AppCitedAnswer.vue +86 -0
- package/src/components/approvals/AppApprovalInbox.vue +265 -0
- package/src/components/approvals/AppApprovalSubjectModal.vue +197 -0
- package/src/components/chat/AppChatBubble.vue +324 -0
- package/src/components/chat/AppChatList.vue +249 -0
- package/src/components/chat/AppChatPanel.vue +315 -0
- package/src/components/chat/AppChatWidget.vue +126 -0
- package/src/components/communications/AppChannelBadge.vue +47 -0
- package/src/components/communications/AppConversationThread.vue +439 -0
- package/src/components/customFields/CustomFieldFilterPanel.vue +50 -0
- package/src/components/customFields/CustomFieldInput.vue +422 -0
- package/src/components/customFields/CustomFieldValue.vue +129 -0
- package/src/components/customFields/CustomFieldsSection.vue +65 -0
- package/src/components/customFields/fieldTypes.js +23 -0
- package/src/components/dashboard/AppCustomWidget.vue +138 -0
- package/src/components/dashboard/AppCustomWidgetForm.vue +173 -0
- package/src/components/dashboard/AppDashboardGrid.vue +200 -0
- package/src/components/dashboard/AppDashboardToolbar.vue +66 -0
- package/src/components/dashboard/AppSubAppsCatalog.vue +89 -0
- package/src/components/dataTools/AppImportExport.vue +724 -0
- package/src/components/dataTools/AppImportSchemaGuide.vue +130 -0
- package/src/components/hrMetrics/AppHrMetricsDashboard.vue +231 -0
- package/src/components/hrMetrics/AppHrMetricsEmployees.vue +87 -0
- package/src/components/hrMetrics/AppHrMetricsStat.vue +61 -0
- package/src/components/kpi/AppKpiAppraisalConfig.vue +284 -0
- package/src/components/kpi/AppKpiAppraisals.vue +733 -0
- package/src/components/kpi/AppKpiDefinitionModal.vue +317 -0
- package/src/components/kpi/AppKpiEntryModal.vue +122 -0
- package/src/components/kpi/AppKpiLeaderboard.vue +108 -0
- package/src/components/kpi/AppKpiMyCard.vue +134 -0
- package/src/components/kpi/AppKpiPeriodPicker.vue +115 -0
- package/src/components/kpi/AppKpiReportTable.vue +214 -0
- package/src/components/kpi/AppKpiScorecard.vue +242 -0
- package/src/components/kpi/AppKpiTargetsModal.vue +299 -0
- package/src/components/kpi/AppKpiTeam.vue +221 -0
- package/src/components/kpi/AppKpiWeightProfiles.vue +244 -0
- package/src/components/kpi/AppKpiWorkspace.vue +479 -0
- package/src/components/layout/AppGlobalSearch.vue +149 -0
- package/src/components/layout/AppLanguagePopup.vue +94 -0
- package/src/components/layout/AppLauncherPopup.vue +147 -0
- package/src/components/layout/AppLegalConsentModal.vue +484 -0
- package/src/components/layout/AppNavbar.vue +402 -0
- package/src/components/layout/AppNotificationContent.vue +173 -0
- package/src/components/layout/AppNotificationDrawer.vue +98 -0
- package/src/components/layout/AppNotificationPopup.vue +67 -0
- package/src/components/layout/AppPlatformBanners.vue +192 -0
- package/src/components/layout/AppSidebar.vue +226 -0
- package/src/components/layout/AppSidebarNav.vue +119 -0
- package/src/components/layout/AppUserMenu.vue +89 -0
- package/src/components/layout/AppUserMenuContent.vue +59 -0
- package/src/composables/useKpi.js +232 -0
- package/src/composables/useLgViewport.js +25 -0
- package/src/composables/useNavigation.js +177 -0
- package/src/layouts/AppLayout.vue +207 -0
- package/src/locales/en.json +1362 -0
- package/src/locales/id.json +1396 -0
- package/src/pages/auth/AccountBlocked.vue +55 -0
- package/src/pages/auth/IdentityRedirect.vue +37 -0
- package/src/pages/profile/Layout.vue +210 -0
- package/src/pages/profile/partials/AccountSection.vue +139 -0
- package/src/pages/profile/partials/ApprovalDelegationSection.vue +389 -0
- package/src/pages/profile/partials/DevicesCard.vue +222 -0
- package/src/pages/profile/partials/PreferencesSection.vue +87 -0
- package/src/pages/profile/partials/SecuritySection.vue +93 -0
- package/src/pages/profile/partials/SessionsCard.vue +418 -0
- package/src/pages/profile/partials/SessionsSection.vue +58 -0
- package/src/pages/profile/partials/SupportAccessSection.vue +173 -0
- package/src/pages/profile/partials/TrustedDevicesCard.vue +141 -0
- package/src/pages/profile/partials/TwoFactorSection.vue +304 -0
- package/src/shellSetup.js +46 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
// Widget dashboard "KPI Saya" — realisasi bulan berjalan untuk subjek yang sedang login.
|
|
3
|
+
//
|
|
4
|
+
// Ia sengaja TIPIS: dashboard menjawab "apakah saya perlu membuka sesuatu hari ini?", bukan
|
|
5
|
+
// menggantikan halaman KPI. Karena itu isinya hanya nama KPI, realisasi terhadap target, dan
|
|
6
|
+
// pencapaiannya — tanpa penyaring periode, tanpa aksi tulis, tanpa baris orang lain.
|
|
7
|
+
//
|
|
8
|
+
// ⚠️ **Baris disaring ke SUBJEK SAYA di klien, bukan lewat parameter server** — dan itu
|
|
9
|
+
// disengaja. `GET /kpi/report` sudah menyaring lewat `canView()`, tapi bagi seorang manajer ia
|
|
10
|
+
// juga mengembalikan baris ANAK BUAHnya; widget berjudul "KPI Saya" yang diam-diam memuat baris
|
|
11
|
+
// orang lain adalah judul yang berbohong. Menyaring lewat `subject_id` server pun tak cukup:
|
|
12
|
+
// satu orang bisa punya KPI ber-subjek `user` DAN `employee` sekaligus, sehingga penyaringan di
|
|
13
|
+
// server menuntut dua permintaan untuk satu kartu kecil.
|
|
14
|
+
//
|
|
15
|
+
// ⚠️ Rute tujuan dioper sebagai PROP: paket tak boleh mengenal rute app mana pun, dan ketiga app
|
|
16
|
+
// pemakainya kebetulan memakai nama rute yang sama — kebetulan yang tak boleh dijadikan asumsi.
|
|
17
|
+
import { computed, onMounted, ref } from 'vue'
|
|
18
|
+
import { useI18n } from 'vue-i18n'
|
|
19
|
+
import { ChevronRight, Target } from '@lucide/vue'
|
|
20
|
+
import { useAuthStore } from '@initsolusidigital/worksuite-core/stores/auth.js'
|
|
21
|
+
import { useKpi } from '../../composables/useKpi.js'
|
|
22
|
+
import AppBadge from '@initsolusidigital/worksuite-ui/AppBadge.vue'
|
|
23
|
+
import AppSpinner from '@initsolusidigital/worksuite-ui/AppSpinner.vue'
|
|
24
|
+
|
|
25
|
+
const props = defineProps({
|
|
26
|
+
companyId: { type: String, default: '' },
|
|
27
|
+
/** Tujuan tautan "lihat semua" — tanpa ini tautannya tak dirender sama sekali. */
|
|
28
|
+
to: { type: [Object, String], default: null },
|
|
29
|
+
/** Batas baris yang digambar; sisanya dihitung & disebut di kaki kartu. */
|
|
30
|
+
max: { type: Number, default: 4 },
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const { t, locale } = useI18n()
|
|
34
|
+
const authStore = useAuthStore()
|
|
35
|
+
const { rows, loadingReport, reportError, fetchReport, formatMetric, formatScore, statusTone, definitionLabel } =
|
|
36
|
+
useKpi(() => props.companyId)
|
|
37
|
+
|
|
38
|
+
const dimuat = ref(false)
|
|
39
|
+
|
|
40
|
+
// Periode = bulan berjalan. Widget tak menawarkan pemilih periode: yang ingin membandingkan
|
|
41
|
+
// antar-bulan sedang menganalisis, dan itu pekerjaan halaman KPI, bukan kartu setinggi 3 baris.
|
|
42
|
+
const periode = computed(() => {
|
|
43
|
+
const d = new Date()
|
|
44
|
+
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}`
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
const labelPeriode = computed(() =>
|
|
48
|
+
new Date().toLocaleDateString(locale.value === 'id' ? 'id-ID' : 'en-US', { month: 'long', year: 'numeric' }))
|
|
49
|
+
|
|
50
|
+
const idUser = computed(() => authStore.user?.id ?? null)
|
|
51
|
+
const idKaryawan = computed(() => authStore.user?.employee?.id ?? null)
|
|
52
|
+
|
|
53
|
+
/** Baris yang subjeknya benar-benar orang yang sedang login (dua bentuk subjek, satu orang). */
|
|
54
|
+
const barisSaya = computed(() => rows.value.filter(r =>
|
|
55
|
+
(r.subject_type === 'user' && idUser.value && r.subject_id === idUser.value) ||
|
|
56
|
+
(r.subject_type === 'employee' && idKaryawan.value && r.subject_id === idKaryawan.value)))
|
|
57
|
+
|
|
58
|
+
const tampil = computed(() => barisSaya.value.slice(0, props.max))
|
|
59
|
+
const sisa = computed(() => Math.max(0, barisSaya.value.length - tampil.value.length))
|
|
60
|
+
|
|
61
|
+
onMounted(async () => {
|
|
62
|
+
if (!props.companyId) return
|
|
63
|
+
await fetchReport({ period: periode.value })
|
|
64
|
+
dimuat.value = true
|
|
65
|
+
})
|
|
66
|
+
</script>
|
|
67
|
+
|
|
68
|
+
<template>
|
|
69
|
+
<div class="h-full flex flex-col bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-sm overflow-hidden">
|
|
70
|
+
<div class="shrink-0 flex items-center justify-between gap-2 px-4 pt-3.5 pb-2">
|
|
71
|
+
<div class="min-w-0">
|
|
72
|
+
<h3 class="text-sm font-semibold text-gray-900 dark:text-white truncate">{{ t('kpi.widget.title') }}</h3>
|
|
73
|
+
<p class="text-xs text-gray-500 dark:text-gray-400 truncate">{{ labelPeriode }}</p>
|
|
74
|
+
</div>
|
|
75
|
+
<component
|
|
76
|
+
:is="to ? 'router-link' : 'span'"
|
|
77
|
+
v-if="to"
|
|
78
|
+
:to="to"
|
|
79
|
+
class="shrink-0 inline-flex items-center gap-0.5 text-xs font-medium text-blue-600 dark:text-blue-400 hover:underline"
|
|
80
|
+
>
|
|
81
|
+
{{ t('kpi.widget.seeAll') }}<ChevronRight class="w-3.5 h-3.5" />
|
|
82
|
+
</component>
|
|
83
|
+
</div>
|
|
84
|
+
|
|
85
|
+
<div class="flex-1 min-h-0 overflow-y-auto scrollbar-rounded px-4 pb-3">
|
|
86
|
+
<div v-if="loadingReport && !dimuat" class="h-full flex items-center justify-center py-6">
|
|
87
|
+
<AppSpinner />
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
<!-- Galat dirender sebagai kalimat, bukan banner merah: kartu ini duduk di antara widget
|
|
91
|
+
lain, dan blok merah setinggi kartunya akan terbaca seperti dashboard yang rusak. -->
|
|
92
|
+
<p v-else-if="reportError" class="text-xs text-red-600 dark:text-red-400 py-4">{{ reportError }}</p>
|
|
93
|
+
|
|
94
|
+
<ul v-else-if="tampil.length" class="space-y-2">
|
|
95
|
+
<li
|
|
96
|
+
v-for="r in tampil"
|
|
97
|
+
:key="`${r.definition.id}-${r.subject_type}-${r.subject_id}`"
|
|
98
|
+
class="flex items-center justify-between gap-3 rounded-lg bg-gray-50 dark:bg-gray-900/40 px-3 py-2"
|
|
99
|
+
>
|
|
100
|
+
<div class="min-w-0">
|
|
101
|
+
<p class="text-sm text-gray-900 dark:text-white truncate">{{ definitionLabel(r.definition) }}</p>
|
|
102
|
+
<!-- Realisasi & target selalu berdampingan: angka realisasi sendirian tak bisa
|
|
103
|
+
dinilai, dan capaian sendirian menyembunyikan besaran yang dikejar. -->
|
|
104
|
+
<p class="text-xs text-gray-500 dark:text-gray-400 truncate">
|
|
105
|
+
<template v-if="r.state === 'missing'">{{ t('kpi.state.missing') }}</template>
|
|
106
|
+
<template v-else-if="r.state === 'na'">{{ t('kpi.state.na') }}</template>
|
|
107
|
+
<template v-else>{{ formatMetric(r.actual, r.definition) }}</template>
|
|
108
|
+
<span class="text-gray-400 dark:text-gray-500">/ {{ formatMetric(r.target, r.definition) }}</span>
|
|
109
|
+
</p>
|
|
110
|
+
</div>
|
|
111
|
+
<!-- Capaian = `score` berwarna `status` server, bukan rasio `achievement_pct`: realisasi 0
|
|
112
|
+
pada KPI arah turun berskor 120 sementara rasionya `null`, sehingga kartu yang
|
|
113
|
+
merender rasio menampilkan "—" justru untuk kinerja terbaik. -->
|
|
114
|
+
<AppBadge v-if="r.score !== null && r.score !== undefined" :color="statusTone(r.status)" class="shrink-0">
|
|
115
|
+
{{ formatScore(r.score) }}
|
|
116
|
+
</AppBadge>
|
|
117
|
+
<AppBadge v-else-if="r.state === 'na'" color="gray" class="shrink-0">{{ t('kpi.state.na') }}</AppBadge>
|
|
118
|
+
<span v-else class="shrink-0 text-xs text-gray-400 dark:text-gray-500">—</span>
|
|
119
|
+
</li>
|
|
120
|
+
</ul>
|
|
121
|
+
|
|
122
|
+
<!-- Kosong = keterangan, bukan ajakan: menetapkan KPI adalah wewenang atasan/HR, jadi
|
|
123
|
+
tombol "buat KPI" di sini akan menjanjikan sesuatu yang pembacanya tak berhak lakukan. -->
|
|
124
|
+
<div v-else class="h-full flex flex-col items-center justify-center text-center py-4">
|
|
125
|
+
<Target class="w-5 h-5 text-gray-300 dark:text-gray-600 mb-1.5" />
|
|
126
|
+
<p class="text-xs text-gray-500 dark:text-gray-400">{{ t('kpi.widget.empty') }}</p>
|
|
127
|
+
</div>
|
|
128
|
+
</div>
|
|
129
|
+
|
|
130
|
+
<p v-if="sisa" class="shrink-0 px-4 pb-3 text-xs text-gray-400 dark:text-gray-500">
|
|
131
|
+
{{ t('kpi.widget.more', { n: sisa }) }}
|
|
132
|
+
</p>
|
|
133
|
+
</div>
|
|
134
|
+
</template>
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
// Pemilih periode KPI — bulan · kuartal · semester · tahun · rentang kustom.
|
|
3
|
+
//
|
|
4
|
+
// Yang ditawarkan HANYA bentuk yang benar-benar dipahami backend (`2026-09`, `2026-Q3`, `2026-S1`,
|
|
5
|
+
// `2026`, `2026-01:2026-06`). Menawarkan bentuk lain — pekan, misalnya — hanya memindahkan
|
|
6
|
+
// penolakan 422 `invalid_period_span` ke sesudah pengguna menekan tombol.
|
|
7
|
+
//
|
|
8
|
+
// ⚠️ Rentang kustom dibatasi **24 bulan** oleh backend; batasnya dijepit di sini supaya kiriman
|
|
9
|
+
// yang pasti ditolak tak pernah dikirim, dan hint-nya menyebut angkanya.
|
|
10
|
+
import { ref, computed, watch } from 'vue'
|
|
11
|
+
import { useI18n } from 'vue-i18n'
|
|
12
|
+
import { buildPeriod } from '../../composables/useKpi.js'
|
|
13
|
+
import AppCombobox from '@initsolusidigital/worksuite-ui/AppCombobox.vue'
|
|
14
|
+
|
|
15
|
+
const props = defineProps({
|
|
16
|
+
/** String periode siap kirim, mis. `2026-09` atau `2026-Q3`. */
|
|
17
|
+
modelValue: { type: String, default: '' },
|
|
18
|
+
})
|
|
19
|
+
const emit = defineEmits(['update:modelValue'])
|
|
20
|
+
|
|
21
|
+
const { t } = useI18n()
|
|
22
|
+
|
|
23
|
+
const now = new Date()
|
|
24
|
+
const kind = ref('month')
|
|
25
|
+
const year = ref(now.getFullYear())
|
|
26
|
+
const month = ref(now.getMonth() + 1)
|
|
27
|
+
const quarter = ref(Math.floor(now.getMonth() / 3) + 1)
|
|
28
|
+
const semester = ref(now.getMonth() < 6 ? 1 : 2)
|
|
29
|
+
const from = ref(`${now.getFullYear()}-01`)
|
|
30
|
+
const to = ref(`${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}`)
|
|
31
|
+
|
|
32
|
+
const kindOptions = computed(() => ['month', 'quarter', 'semester', 'year', 'custom']
|
|
33
|
+
.map(k => ({ value: k, label: t(`kpi.period.kind.${k}`) })))
|
|
34
|
+
|
|
35
|
+
const yearOptions = computed(() => {
|
|
36
|
+
const y = now.getFullYear()
|
|
37
|
+
return [y + 1, y, y - 1, y - 2].map(v => ({ value: v, label: String(v) }))
|
|
38
|
+
})
|
|
39
|
+
const monthOptions = computed(() => Array.from({ length: 12 }, (_, i) => ({
|
|
40
|
+
value: i + 1,
|
|
41
|
+
label: new Date(2000, i, 1).toLocaleDateString(undefined, { month: 'long' }),
|
|
42
|
+
})))
|
|
43
|
+
const quarterOptions = computed(() => [1, 2, 3, 4].map(q => ({ value: q, label: `Q${q}` })))
|
|
44
|
+
const semesterOptions = computed(() => [1, 2].map(s => ({ value: s, label: `S${s}` })))
|
|
45
|
+
const monthValueOptions = computed(() => yearOptions.value.flatMap(y =>
|
|
46
|
+
monthOptions.value.map(m => ({
|
|
47
|
+
value: `${y.value}-${String(m.value).padStart(2, '0')}`,
|
|
48
|
+
label: `${m.label} ${y.value}`,
|
|
49
|
+
})),
|
|
50
|
+
))
|
|
51
|
+
|
|
52
|
+
/** Rentang kustom terbalik/ketumpahan dijepit DI SINI, bukan diserahkan ke 422 server. */
|
|
53
|
+
const customError = computed(() => {
|
|
54
|
+
if (kind.value !== 'custom') return ''
|
|
55
|
+
if (!from.value || !to.value) return ''
|
|
56
|
+
if (from.value > to.value) return t('kpi.period.errReversed')
|
|
57
|
+
const [fy, fm] = from.value.split('-').map(Number)
|
|
58
|
+
const [ty, tm] = to.value.split('-').map(Number)
|
|
59
|
+
const jarak = (ty - fy) * 12 + (tm - fm) + 1
|
|
60
|
+
return jarak > 24 ? t('kpi.period.errTooLong') : ''
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
function pancarkan() {
|
|
64
|
+
if (customError.value) return
|
|
65
|
+
emit('update:modelValue', buildPeriod(kind.value, {
|
|
66
|
+
year: year.value, month: month.value, quarter: quarter.value,
|
|
67
|
+
semester: semester.value, from: from.value, to: to.value,
|
|
68
|
+
}))
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
watch([kind, year, month, quarter, semester, from, to], pancarkan)
|
|
72
|
+
|
|
73
|
+
// Pancarkan sekali saat mount supaya pemanggil tak perlu menebak nilai awalnya.
|
|
74
|
+
if (!props.modelValue) pancarkan()
|
|
75
|
+
</script>
|
|
76
|
+
|
|
77
|
+
<template>
|
|
78
|
+
<div class="flex flex-wrap items-start gap-2">
|
|
79
|
+
<div class="w-40">
|
|
80
|
+
<AppCombobox
|
|
81
|
+
v-model="kind"
|
|
82
|
+
:options="kindOptions"
|
|
83
|
+
:aria-label="t('kpi.period.kindLabel')"
|
|
84
|
+
hide-clear
|
|
85
|
+
dense
|
|
86
|
+
/>
|
|
87
|
+
</div>
|
|
88
|
+
|
|
89
|
+
<template v-if="kind !== 'custom'">
|
|
90
|
+
<div v-if="kind === 'month'" class="w-36">
|
|
91
|
+
<AppCombobox v-model="month" :options="monthOptions" :aria-label="t('kpi.period.monthLabel')" hide-clear dense />
|
|
92
|
+
</div>
|
|
93
|
+
<div v-if="kind === 'quarter'" class="w-28">
|
|
94
|
+
<AppCombobox v-model="quarter" :options="quarterOptions" :aria-label="t('kpi.period.quarterLabel')" hide-clear dense />
|
|
95
|
+
</div>
|
|
96
|
+
<div v-if="kind === 'semester'" class="w-28">
|
|
97
|
+
<AppCombobox v-model="semester" :options="semesterOptions" :aria-label="t('kpi.period.semesterLabel')" hide-clear dense />
|
|
98
|
+
</div>
|
|
99
|
+
<div class="w-28">
|
|
100
|
+
<AppCombobox v-model="year" :options="yearOptions" :aria-label="t('kpi.period.yearLabel')" hide-clear dense />
|
|
101
|
+
</div>
|
|
102
|
+
</template>
|
|
103
|
+
|
|
104
|
+
<template v-else>
|
|
105
|
+
<div class="w-44">
|
|
106
|
+
<AppCombobox v-model="from" :options="monthValueOptions" :aria-label="t('kpi.period.fromLabel')" hide-clear dense />
|
|
107
|
+
</div>
|
|
108
|
+
<span class="text-sm text-gray-400 pt-2">–</span>
|
|
109
|
+
<div class="w-44">
|
|
110
|
+
<AppCombobox v-model="to" :options="monthValueOptions" :aria-label="t('kpi.period.toLabel')" hide-clear dense />
|
|
111
|
+
</div>
|
|
112
|
+
<p v-if="customError" class="w-full text-xs text-red-600 dark:text-red-400">{{ customError }}</p>
|
|
113
|
+
</template>
|
|
114
|
+
</div>
|
|
115
|
+
</template>
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
// Tabel laporan KPI — realisasi vs target vs capaian, per subjek per definisi.
|
|
3
|
+
//
|
|
4
|
+
// **Semantik kontrak dirender, bukan disembunyikan** (kontrak `kp1-kpi-tracking.md`):
|
|
5
|
+
// 1. Kolom Capaian = `score` 0–120 berwarna `status` server. `achievement_pct` cuma rasio mentah
|
|
6
|
+
// di bawahnya — realisasi 0 pada KPI arah turun berskor 120 tapi rasionya `null`.
|
|
7
|
+
// 2. `state`: `na` → "N/A" (dikeluarkan dari komposit, bukan nol) · `missing` → "Belum diisi"
|
|
8
|
+
// beserta aksinya. Ketiganya "tanpa skor", tapi tindak lanjutnya berbeda.
|
|
9
|
+
// 3. `direction: down` = makin kecil makin baik → ikon ↓ di samping nama KPI.
|
|
10
|
+
// 4. `frozen: true` = angka beku penilaian → gembok. Baris beku yang masih `missing` TETAP boleh
|
|
11
|
+
// diisi susulan (server memperbarui snapshot-nya); baris beku yang sudah berisi tidak.
|
|
12
|
+
// 5. Tier EFEKTIF (`threshold`/`stretch`) ditulis di bawah target — tanpa itu orang tak bisa
|
|
13
|
+
// menjelaskan kenapa 33 dari target 30 bernilai 110.
|
|
14
|
+
//
|
|
15
|
+
// ⚠️ **`months` adalah OBJEK ber-kunci periode** (`{"2026-07": {...}}`), bukan array: backend
|
|
16
|
+
// membangunnya sebagai map, dan PHP menyerialkan map jadi objek JSON. `Array.isArray()` SELALU
|
|
17
|
+
// false dan `m.period` tak pernah ada (periodenya adalah KUNCI-nya).
|
|
18
|
+
import { ref } from 'vue'
|
|
19
|
+
import { useI18n } from 'vue-i18n'
|
|
20
|
+
import { ArrowDown, ArrowUp, Lock, ChevronDown, ChevronRight } from '@lucide/vue'
|
|
21
|
+
import AppBadge from '@initsolusidigital/worksuite-ui/AppBadge.vue'
|
|
22
|
+
import AppEmptyState from '@initsolusidigital/worksuite-ui/AppEmptyState.vue'
|
|
23
|
+
import AppSpinner from '@initsolusidigital/worksuite-ui/AppSpinner.vue'
|
|
24
|
+
|
|
25
|
+
const props = defineProps({
|
|
26
|
+
rows: { type: Array, default: () => [] },
|
|
27
|
+
loading: { type: Boolean, default: false },
|
|
28
|
+
/** Sembunyikan kolom KPI saat tabel sudah tersaring ke satu definisi. */
|
|
29
|
+
showDefinition: { type: Boolean, default: true },
|
|
30
|
+
formatMetric: { type: Function, required: true },
|
|
31
|
+
formatAchievement: { type: Function, required: true },
|
|
32
|
+
formatScore: { type: Function, required: true },
|
|
33
|
+
statusTone: { type: Function, required: true },
|
|
34
|
+
formatTiers: { type: Function, required: true },
|
|
35
|
+
definitionLabel: { type: Function, required: true },
|
|
36
|
+
/** Tampilkan tombol isi realisasi manual pada baris yang berhak. */
|
|
37
|
+
canEnter: { type: Boolean, default: false },
|
|
38
|
+
})
|
|
39
|
+
const emit = defineEmits(['enter', 'target'])
|
|
40
|
+
|
|
41
|
+
const { t } = useI18n()
|
|
42
|
+
const expanded = ref(new Set())
|
|
43
|
+
|
|
44
|
+
function toggle(key) {
|
|
45
|
+
const next = new Set(expanded.value)
|
|
46
|
+
if (next.has(key)) next.delete(key)
|
|
47
|
+
else next.add(key)
|
|
48
|
+
expanded.value = next
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const rowKey = (r) => `${r.definition?.id}|${r.subject_type}|${r.subject_id}`
|
|
52
|
+
const isManual = (r) => !r.definition?.resolver_key
|
|
53
|
+
const hasScore = (x) => x?.score !== null && x?.score !== undefined
|
|
54
|
+
/** `months` objek → pasangan [periode, angka]; kosong/absen = baris bulanan biasa. */
|
|
55
|
+
const monthEntries = (r) => Object.entries(r?.months ?? {})
|
|
56
|
+
/**
|
|
57
|
+
* Baris bulan tunggal membawa `can_edit_entry`/`can_edit_target` dari server — pimpinan TANPA izin
|
|
58
|
+
* `kpis` boleh mengisi untuk orang yang ia pimpin, jadi izin modul saja menyembunyikan tombol dari
|
|
59
|
+
* orang yang justru berhak. Baris tanpa flag (server lama / span) jatuh ke aturan lama.
|
|
60
|
+
*/
|
|
61
|
+
const bolehIsi = (r) => (r.can_edit_entry !== undefined
|
|
62
|
+
? !!r.can_edit_entry && isManual(r)
|
|
63
|
+
: props.canEnter && isManual(r) && (!r.frozen || r.state === 'missing'))
|
|
64
|
+
const bolehTarget = (r) => !!r.can_edit_target
|
|
65
|
+
</script>
|
|
66
|
+
|
|
67
|
+
<template>
|
|
68
|
+
<div>
|
|
69
|
+
<div v-if="loading" class="py-12 text-center"><AppSpinner /></div>
|
|
70
|
+
|
|
71
|
+
<div v-else-if="!rows.length" class="p-6">
|
|
72
|
+
<AppEmptyState :label="t('kpi.report.empty')" :description="t('kpi.report.emptyHint')" />
|
|
73
|
+
</div>
|
|
74
|
+
|
|
75
|
+
<div v-else class="overflow-x-auto scrollbar-rounded">
|
|
76
|
+
<table class="min-w-full text-sm">
|
|
77
|
+
<thead class="bg-gray-50 dark:bg-gray-900/40 text-xs text-gray-500 dark:text-gray-400">
|
|
78
|
+
<tr>
|
|
79
|
+
<th v-if="showDefinition" scope="col" class="text-left font-medium px-6 py-2">{{ t('kpi.report.colDefinition') }}</th>
|
|
80
|
+
<th scope="col" class="text-left font-medium px-6 py-2">{{ t('kpi.report.colSubject') }}</th>
|
|
81
|
+
<th scope="col" class="text-right font-medium px-6 py-2">{{ t('kpi.report.colActual') }}</th>
|
|
82
|
+
<th scope="col" class="text-right font-medium px-6 py-2">{{ t('kpi.report.colTarget') }}</th>
|
|
83
|
+
<th scope="col" class="text-right font-medium px-6 py-2">{{ t('kpi.report.colAchievement') }}</th>
|
|
84
|
+
<th scope="col" class="text-right font-medium px-6 py-2"><span class="sr-only">{{ t('kpi.report.colActions') }}</span></th>
|
|
85
|
+
</tr>
|
|
86
|
+
</thead>
|
|
87
|
+
|
|
88
|
+
<tbody class="divide-y divide-gray-100 dark:divide-gray-700">
|
|
89
|
+
<template v-for="r in rows" :key="rowKey(r)">
|
|
90
|
+
<tr>
|
|
91
|
+
<td v-if="showDefinition" class="px-6 py-3">
|
|
92
|
+
<div class="flex items-center gap-1.5 min-w-0">
|
|
93
|
+
<!-- Arah metrik: satu ikon menggantikan kalimat penjelas di tiap baris. -->
|
|
94
|
+
<component
|
|
95
|
+
:is="r.definition?.direction === 'down' ? ArrowDown : ArrowUp"
|
|
96
|
+
class="w-3.5 h-3.5 shrink-0"
|
|
97
|
+
:class="r.definition?.direction === 'down' ? 'text-blue-500' : 'text-gray-400'"
|
|
98
|
+
:aria-label="t(`kpi.direction.${r.definition?.direction || 'up'}`)"
|
|
99
|
+
/>
|
|
100
|
+
<span class="text-gray-900 dark:text-white truncate">{{ definitionLabel(r.definition) }}</span>
|
|
101
|
+
</div>
|
|
102
|
+
</td>
|
|
103
|
+
|
|
104
|
+
<td class="px-6 py-3">
|
|
105
|
+
<span class="text-gray-900 dark:text-white">{{ r.subject_name || '—' }}</span>
|
|
106
|
+
<span class="ml-1 text-xs text-gray-400">{{ t(`kpi.subject.${r.subject_type}`) }}</span>
|
|
107
|
+
</td>
|
|
108
|
+
|
|
109
|
+
<td class="px-6 py-3 text-right tabular-nums text-gray-900 dark:text-white">
|
|
110
|
+
<span v-if="r.state === 'na'" class="text-gray-500 dark:text-gray-400">{{ t('kpi.state.na') }}</span>
|
|
111
|
+
<span v-else-if="r.state === 'missing'" class="text-amber-600 dark:text-amber-400">{{ t('kpi.state.missing') }}</span>
|
|
112
|
+
<span v-else>{{ formatMetric(r.actual, r.definition) }}</span>
|
|
113
|
+
<!-- Realisasi yang masuk dari SISTEM LUAR (API klien) ditandai: penilai berhak
|
|
114
|
+
tahu angka ini tidak diketik siapa pun di sini sebelum memakainya menilai
|
|
115
|
+
orang. Baris tanpa `entry_source` (manual/computed) tak diberi apa-apa —
|
|
116
|
+
penanda yang muncul di semua baris berhenti berarti apa pun. -->
|
|
117
|
+
<span
|
|
118
|
+
v-if="r.entry_source === 'external'"
|
|
119
|
+
class="ml-1.5 align-middle inline-flex items-center rounded px-1.5 py-0.5 text-[10px] font-medium bg-indigo-50 text-indigo-700 dark:bg-indigo-900/30 dark:text-indigo-300"
|
|
120
|
+
:title="t('kpi.report.sourceExternalHint')"
|
|
121
|
+
>{{ t('kpi.report.sourceExternal') }}</span>
|
|
122
|
+
<!-- Diisi sendiri oleh orang yang dinilai (pimpinan mengisi KPI-nya sendiri) — penilainya
|
|
123
|
+
perlu tahu angka ini bukan isian atasan atau HR. -->
|
|
124
|
+
<span
|
|
125
|
+
v-if="r.entry_source === 'self'"
|
|
126
|
+
class="ml-1.5 align-middle inline-flex items-center rounded px-1.5 py-0.5 text-[10px] font-medium bg-amber-50 text-amber-700 dark:bg-amber-900/30 dark:text-amber-300"
|
|
127
|
+
:title="t('kpi.report.sourceSelfHint')"
|
|
128
|
+
>{{ t('kpi.report.sourceSelf') }}</span>
|
|
129
|
+
</td>
|
|
130
|
+
<td class="px-6 py-3 text-right tabular-nums text-gray-600 dark:text-gray-300">
|
|
131
|
+
{{ formatMetric(r.target, r.definition) }}
|
|
132
|
+
<span v-if="formatTiers(r, r.definition)" class="block text-[11px] text-gray-400 dark:text-gray-500 whitespace-nowrap">
|
|
133
|
+
{{ formatTiers(r, r.definition) }}
|
|
134
|
+
</span>
|
|
135
|
+
</td>
|
|
136
|
+
|
|
137
|
+
<td class="px-6 py-3 text-right">
|
|
138
|
+
<div class="inline-flex items-center gap-1.5">
|
|
139
|
+
<!-- Capaian tanpa skor dirender sebagai teks POLOS, bukan badge kosong: pil abu
|
|
140
|
+
tanpa isi terbaca sebagai komponen rusak. -->
|
|
141
|
+
<AppBadge v-if="hasScore(r)" :color="statusTone(r.status)">{{ formatScore(r.score) }}</AppBadge>
|
|
142
|
+
<span v-else-if="r.state === 'na'" class="text-gray-500 dark:text-gray-400">{{ t('kpi.state.na') }}</span>
|
|
143
|
+
<span v-else class="text-gray-400 dark:text-gray-500">—</span>
|
|
144
|
+
<Lock v-if="r.frozen" class="w-3.5 h-3.5 text-gray-400" :aria-label="t('kpi.report.frozen')" />
|
|
145
|
+
</div>
|
|
146
|
+
<span
|
|
147
|
+
v-if="r.achievement_pct !== null && r.achievement_pct !== undefined"
|
|
148
|
+
class="block text-[11px] text-gray-400 dark:text-gray-500"
|
|
149
|
+
:title="t('kpi.report.ratioHint')"
|
|
150
|
+
>{{ t('kpi.report.ratio', { pct: formatAchievement(r.achievement_pct) }) }}</span>
|
|
151
|
+
</td>
|
|
152
|
+
|
|
153
|
+
<td class="px-6 py-3 text-right whitespace-nowrap">
|
|
154
|
+
<button
|
|
155
|
+
v-if="monthEntries(r).length"
|
|
156
|
+
type="button"
|
|
157
|
+
class="inline-flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400 hover:underline"
|
|
158
|
+
@click="toggle(rowKey(r))"
|
|
159
|
+
>
|
|
160
|
+
<component :is="expanded.has(rowKey(r)) ? ChevronDown : ChevronRight" class="w-3.5 h-3.5" />
|
|
161
|
+
{{ t('kpi.report.months', { n: monthEntries(r).length }) }}
|
|
162
|
+
</button>
|
|
163
|
+
<div v-else class="inline-flex items-center gap-3">
|
|
164
|
+
<button
|
|
165
|
+
v-if="bolehTarget(r)"
|
|
166
|
+
type="button"
|
|
167
|
+
class="text-xs text-blue-600 dark:text-blue-400 hover:underline"
|
|
168
|
+
@click="emit('target', r)"
|
|
169
|
+
>
|
|
170
|
+
{{ t('kpi.report.setTarget') }}
|
|
171
|
+
</button>
|
|
172
|
+
<button
|
|
173
|
+
v-if="bolehIsi(r)"
|
|
174
|
+
type="button"
|
|
175
|
+
class="text-xs text-blue-600 dark:text-blue-400 hover:underline"
|
|
176
|
+
@click="emit('enter', r)"
|
|
177
|
+
>
|
|
178
|
+
{{ t('kpi.report.fillActual') }}
|
|
179
|
+
</button>
|
|
180
|
+
</div>
|
|
181
|
+
</td>
|
|
182
|
+
</tr>
|
|
183
|
+
|
|
184
|
+
<!-- Bulan penyusun rollup. Angkanya milik server; di sini murni dirender. -->
|
|
185
|
+
<tr v-if="expanded.has(rowKey(r))" class="bg-gray-50 dark:bg-gray-900/30">
|
|
186
|
+
<td :colspan="showDefinition ? 6 : 5" class="px-6 py-3">
|
|
187
|
+
<!-- Kolomnya disejajarkan (grid), bukan dialirkan: angka bulan yang berpindah
|
|
188
|
+
posisi tiap baris mustahil dibandingkan dengan mata. -->
|
|
189
|
+
<dl class="grid grid-cols-[6rem_1fr_1fr_5rem_1rem] gap-x-4 gap-y-1 text-xs max-w-2xl">
|
|
190
|
+
<template v-for="[bulan, m] in monthEntries(r)" :key="bulan">
|
|
191
|
+
<dt class="text-gray-500 dark:text-gray-400">{{ bulan }}</dt>
|
|
192
|
+
<dd class="tabular-nums text-gray-700 dark:text-gray-300 text-right">
|
|
193
|
+
<template v-if="m.state === 'na'">{{ t('kpi.state.na') }}</template>
|
|
194
|
+
<span v-else-if="m.state === 'missing'" class="text-amber-600 dark:text-amber-400">{{ t('kpi.state.missing') }}</span>
|
|
195
|
+
<template v-else>{{ formatMetric(m.actual, r.definition) }}</template>
|
|
196
|
+
</dd>
|
|
197
|
+
<dd class="tabular-nums text-gray-500 dark:text-gray-400 text-right">
|
|
198
|
+
{{ formatMetric(m.target, r.definition) }}
|
|
199
|
+
</dd>
|
|
200
|
+
<dd class="text-right">
|
|
201
|
+
<AppBadge v-if="hasScore(m)" :color="statusTone(m.status)">{{ formatScore(m.score) }}</AppBadge>
|
|
202
|
+
<span v-else class="text-gray-400 dark:text-gray-500">—</span>
|
|
203
|
+
</dd>
|
|
204
|
+
<dd><Lock v-if="m.frozen" class="w-3 h-3 text-gray-400" :aria-label="t('kpi.report.frozen')" /></dd>
|
|
205
|
+
</template>
|
|
206
|
+
</dl>
|
|
207
|
+
</td>
|
|
208
|
+
</tr>
|
|
209
|
+
</template>
|
|
210
|
+
</tbody>
|
|
211
|
+
</table>
|
|
212
|
+
</div>
|
|
213
|
+
</div>
|
|
214
|
+
</template>
|