@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,317 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
// Form definisi KPI — computed (dari resolver) atau manual.
|
|
3
|
+
//
|
|
4
|
+
// ⚠️ **`resolver_key` & `metric_type` TAK BISA diubah sesudah dibuat** (kontrak §2): KPI yang
|
|
5
|
+
// berganti rumus adalah KPI BARU, sebab snapshot periode lama harus tetap bercerita tentang rumus
|
|
6
|
+
// yang sama. Karena itu keduanya DISEMBUNYIKAN dari form Ubah, bukan ditampilkan non-aktif —
|
|
7
|
+
// kontrol mati tetap mengundang orang mencoba.
|
|
8
|
+
//
|
|
9
|
+
// ⚠️ **Daftar resolver datang dari katalog**, tak pernah dihardcode: server sudah menyaringnya
|
|
10
|
+
// menurut lisensi + izin pemanggil, jadi daftar tulisan tangan akan menawarkan KPI yang pasti
|
|
11
|
+
// ditolak. Metric/direction/unit resolver juga dipaksa server — form hanya MENAMPILKANNYA.
|
|
12
|
+
//
|
|
13
|
+
// **Penyetelan skor** (kontrak `kp1-kpi-tracking.md`) — semuanya bisa diubah kapan saja:
|
|
14
|
+
// - `code` diketik huruf besar otomatis, sebab server hanya menerima `^[A-Z0-9-]+$` dan kode yang
|
|
15
|
+
// ditolak karena huruf kecil adalah penolakan yang tak perlu terjadi.
|
|
16
|
+
// - `allow_na` hanya untuk KPI manual: resolver mengenali ketiadaan kejadian dari datanya sendiri,
|
|
17
|
+
// dan server membuang field ini untuk definisi ber-resolver.
|
|
18
|
+
// - `percent_bounded` hanya untuk persen MANUAL: resolver persen selalu dibatasi 100 oleh server
|
|
19
|
+
// apa pun yang dikirim, jadi sakelarnya di sana cuma pura-pura bisa diubah.
|
|
20
|
+
// - Pengali tier bawaan kosong = pakai bawaan global; salah arah = 422 `tier_order_invalid` tanpa
|
|
21
|
+
// `messages`, jadi penjelasannya dipasang sebagai banner yang menyebut arah yang benar.
|
|
22
|
+
import { ref, computed } from 'vue'
|
|
23
|
+
import { useI18n } from 'vue-i18n'
|
|
24
|
+
import { kpiApi } from '@initsolusidigital/worksuite-core/api/endpoints/kpi.js'
|
|
25
|
+
import { useFormSubmit } from '@initsolusidigital/worksuite-core/composables/useFormSubmit.js'
|
|
26
|
+
import AppModal from '@initsolusidigital/worksuite-ui/AppModal.vue'
|
|
27
|
+
import AppInput from '@initsolusidigital/worksuite-ui/AppInput.vue'
|
|
28
|
+
import AppTextarea from '@initsolusidigital/worksuite-ui/AppTextarea.vue'
|
|
29
|
+
import AppCombobox from '@initsolusidigital/worksuite-ui/AppCombobox.vue'
|
|
30
|
+
import AppToggle from '@initsolusidigital/worksuite-ui/AppToggle.vue'
|
|
31
|
+
import AppAlert from '@initsolusidigital/worksuite-ui/AppAlert.vue'
|
|
32
|
+
import AppButton from '@initsolusidigital/worksuite-ui/AppButton.vue'
|
|
33
|
+
|
|
34
|
+
const props = defineProps({
|
|
35
|
+
companyId: { type: String, required: true },
|
|
36
|
+
definition: { type: Object, default: null },
|
|
37
|
+
resolvers: { type: Array, default: () => [] },
|
|
38
|
+
/** Penambat jobdesk hanya bermakna di tenant ber-seat `kpis`. */
|
|
39
|
+
hrisTier: { type: Boolean, default: false },
|
|
40
|
+
occupations: { type: Array, default: () => [] },
|
|
41
|
+
resolverLabel: { type: Function, required: true },
|
|
42
|
+
resolverDescription: { type: Function, required: true },
|
|
43
|
+
})
|
|
44
|
+
const emit = defineEmits(['close', 'saved'])
|
|
45
|
+
|
|
46
|
+
const { t } = useI18n()
|
|
47
|
+
const { fieldErrors, formError, saving, submit } = useFormSubmit()
|
|
48
|
+
const isEdit = computed(() => !!props.definition?.id)
|
|
49
|
+
|
|
50
|
+
const ratioText = (v) => (v === null || v === undefined ? '' : String(v))
|
|
51
|
+
|
|
52
|
+
const form = ref({
|
|
53
|
+
name: props.definition?.name ?? '',
|
|
54
|
+
code: props.definition?.code ?? '',
|
|
55
|
+
allow_na: !!props.definition?.allow_na,
|
|
56
|
+
// `null` = belum disentuh → mengikuti bawaan arah (lihat `percentBoundedEfektif`)
|
|
57
|
+
percent_bounded: props.definition ? !!props.definition.percent_bounded : null,
|
|
58
|
+
default_threshold_ratio: ratioText(props.definition?.default_threshold_ratio),
|
|
59
|
+
default_stretch_ratio: ratioText(props.definition?.default_stretch_ratio),
|
|
60
|
+
description: props.definition?.description ?? '',
|
|
61
|
+
source: props.definition?.resolver_key ? 'resolver' : 'manual',
|
|
62
|
+
resolver_key: props.definition?.resolver_key ?? '',
|
|
63
|
+
metric_type: props.definition?.metric_type ?? 'count',
|
|
64
|
+
direction: props.definition?.direction ?? 'up',
|
|
65
|
+
unit: props.definition?.unit ?? '',
|
|
66
|
+
task_type: props.definition?.settings?.task_type ?? '',
|
|
67
|
+
occupation_id: props.definition?.occupation_id ?? '',
|
|
68
|
+
is_active: props.definition?.is_active !== false,
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
const resolverOptions = computed(() => props.resolvers.map(r => ({ value: r.key, label: props.resolverLabel(r) })))
|
|
72
|
+
const metricOptions = computed(() => ['count', 'currency', 'percent', 'duration']
|
|
73
|
+
.map(m => ({ value: m, label: t(`kpi.metric.${m}`) })))
|
|
74
|
+
const directionOptions = computed(() => ['up', 'down'].map(d => ({ value: d, label: t(`kpi.direction.${d}`) })))
|
|
75
|
+
const occupationOptions = computed(() => [
|
|
76
|
+
{ value: '', label: t('kpi.form.occupationNone') },
|
|
77
|
+
...props.occupations,
|
|
78
|
+
])
|
|
79
|
+
|
|
80
|
+
const resolverTerpilih = computed(() => props.resolvers.find(r => r.key === form.value.resolver_key) ?? null)
|
|
81
|
+
/** `settings.task_type` hanya dipakai resolver demo — kotaknya muncul hanya untuk resolver itu. */
|
|
82
|
+
const butuhTaskType = computed(() => form.value.resolver_key === 'crm_demos_scheduled')
|
|
83
|
+
const tanpaResolver = computed(() => props.resolvers.length === 0)
|
|
84
|
+
|
|
85
|
+
/** Manual = boleh N/A & batas persen bisa disetel; ber-resolver = keduanya milik server. */
|
|
86
|
+
const isManual = computed(() => (isEdit.value ? !props.definition?.resolver_key : form.value.source === 'manual'))
|
|
87
|
+
const metrikEfektif = computed(() => (isEdit.value ? props.definition?.metric_type : form.value.metric_type))
|
|
88
|
+
const arahEfektif = computed(() => {
|
|
89
|
+
if (isEdit.value) return props.definition?.direction ?? 'up'
|
|
90
|
+
if (form.value.source === 'resolver') return resolverTerpilih.value?.direction ?? 'up'
|
|
91
|
+
return form.value.direction
|
|
92
|
+
})
|
|
93
|
+
const tampilBatasPersen = computed(() => isManual.value && metrikEfektif.value === 'percent')
|
|
94
|
+
/** Bawaan server untuk persen manual: arah naik dibatasi 100, arah turun (rasio biaya) tidak. */
|
|
95
|
+
const percentBoundedEfektif = computed(() => form.value.percent_bounded ?? arahEfektif.value === 'up')
|
|
96
|
+
|
|
97
|
+
function onCode(v) { form.value.code = (v ?? '').toUpperCase() }
|
|
98
|
+
const ratioOrNull = (v) => (v === '' || v === null || v === undefined ? null : v)
|
|
99
|
+
|
|
100
|
+
/** Field penyetelan skor — dikirim sama untuk create & update. */
|
|
101
|
+
function scoringFields() {
|
|
102
|
+
const f = {
|
|
103
|
+
code: form.value.code?.trim() || null,
|
|
104
|
+
default_threshold_ratio: ratioOrNull(form.value.default_threshold_ratio),
|
|
105
|
+
default_stretch_ratio: ratioOrNull(form.value.default_stretch_ratio),
|
|
106
|
+
}
|
|
107
|
+
if (isManual.value) f.allow_na = form.value.allow_na
|
|
108
|
+
if (tampilBatasPersen.value) f.percent_bounded = percentBoundedEfektif.value
|
|
109
|
+
return f
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async function simpan() {
|
|
113
|
+
const ok = await submit(
|
|
114
|
+
() => {
|
|
115
|
+
if (isEdit.value) {
|
|
116
|
+
const patch = {
|
|
117
|
+
name: form.value.name?.trim(),
|
|
118
|
+
description: form.value.description?.trim() || null,
|
|
119
|
+
is_active: form.value.is_active,
|
|
120
|
+
...scoringFields(),
|
|
121
|
+
}
|
|
122
|
+
if (props.hrisTier) patch.occupation_id = form.value.occupation_id || null
|
|
123
|
+
if (butuhTaskType.value) patch.settings = { task_type: form.value.task_type?.trim() || 'demo' }
|
|
124
|
+
return kpiApi.updateDefinition(props.companyId, props.definition.id, patch)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const payload = {
|
|
128
|
+
name: form.value.name?.trim(),
|
|
129
|
+
description: form.value.description?.trim() || null,
|
|
130
|
+
...scoringFields(),
|
|
131
|
+
}
|
|
132
|
+
// Pengali kosong saat MEMBUAT cukup tak dikirim; saat MENGUBAH dikirim `null` supaya
|
|
133
|
+
// mengosongkan kotak benar-benar mencabut pengali yang pernah dipasang.
|
|
134
|
+
if (payload.default_threshold_ratio === null) delete payload.default_threshold_ratio
|
|
135
|
+
if (payload.default_stretch_ratio === null) delete payload.default_stretch_ratio
|
|
136
|
+
if (payload.code === null) delete payload.code
|
|
137
|
+
if (form.value.source === 'resolver') {
|
|
138
|
+
payload.resolver_key = form.value.resolver_key
|
|
139
|
+
if (butuhTaskType.value) payload.settings = { task_type: form.value.task_type?.trim() || 'demo' }
|
|
140
|
+
} else {
|
|
141
|
+
payload.metric_type = form.value.metric_type
|
|
142
|
+
payload.direction = form.value.direction
|
|
143
|
+
if (form.value.unit?.trim()) payload.unit = form.value.unit.trim()
|
|
144
|
+
}
|
|
145
|
+
// ⚠️ Kunci `occupation_id` hanya DIKIRIM bila tenantnya tingkat 2 — mengirimkannya dari
|
|
146
|
+
// tenant tingkat 1 dijawab 403, dan penolakan itu tak ada hubungannya dengan yang diisi user.
|
|
147
|
+
if (props.hrisTier && form.value.occupation_id) payload.occupation_id = form.value.occupation_id
|
|
148
|
+
return kpiApi.createDefinition(props.companyId, payload)
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
require: form.value.source === 'resolver' && !isEdit.value ? ['name', 'resolver_key'] : ['name'],
|
|
152
|
+
requireIn: form.value,
|
|
153
|
+
successKey: isEdit.value ? 'kpi.form.updated' : 'kpi.form.created',
|
|
154
|
+
onError: (e) => {
|
|
155
|
+
if (e.reason === 'tier_order_invalid') {
|
|
156
|
+
formError.value = t(arahEfektif.value === 'down' ? 'kpi.form.errRatioOrderDown' : 'kpi.form.errRatioOrderUp')
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
)
|
|
161
|
+
if (ok) emit('saved')
|
|
162
|
+
}
|
|
163
|
+
</script>
|
|
164
|
+
|
|
165
|
+
<template>
|
|
166
|
+
<AppModal :title="isEdit ? t('kpi.form.editTitle') : t('kpi.form.createTitle')" size="lg" @close="emit('close')">
|
|
167
|
+
<form class="space-y-4" @submit.prevent="simpan">
|
|
168
|
+
<AppAlert v-if="formError" variant="error">{{ formError }}</AppAlert>
|
|
169
|
+
|
|
170
|
+
<div class="grid grid-cols-1 sm:grid-cols-[10rem_1fr] gap-4">
|
|
171
|
+
<AppInput
|
|
172
|
+
:model-value="form.code"
|
|
173
|
+
:label="t('kpi.form.fieldCode')"
|
|
174
|
+
:hint="t('kpi.form.fieldCodeHint')"
|
|
175
|
+
:error="fieldErrors.code"
|
|
176
|
+
maxlength="20"
|
|
177
|
+
@update:model-value="onCode"
|
|
178
|
+
/>
|
|
179
|
+
<AppInput v-model="form.name" :label="t('kpi.form.fieldName')" :error="fieldErrors.name" required />
|
|
180
|
+
</div>
|
|
181
|
+
|
|
182
|
+
<AppTextarea v-model="form.description" :label="t('kpi.form.fieldDescription')" :error="fieldErrors.description" :rows="2" />
|
|
183
|
+
|
|
184
|
+
<!-- Sumber angka hanya dipilih saat MEMBUAT; sesudahnya ia identitas KPI-nya. -->
|
|
185
|
+
<template v-if="!isEdit">
|
|
186
|
+
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
|
|
187
|
+
<button
|
|
188
|
+
v-for="opt in ['resolver', 'manual']"
|
|
189
|
+
:key="opt"
|
|
190
|
+
type="button"
|
|
191
|
+
class="text-left rounded-lg border p-3 transition-colors"
|
|
192
|
+
:class="form.source === opt
|
|
193
|
+
? 'border-blue-500 bg-blue-50 dark:bg-blue-900/20'
|
|
194
|
+
: 'border-gray-200 dark:border-gray-700 hover:border-gray-300'"
|
|
195
|
+
:disabled="opt === 'resolver' && tanpaResolver"
|
|
196
|
+
@click="form.source = opt"
|
|
197
|
+
>
|
|
198
|
+
<span class="block text-sm font-medium text-gray-900 dark:text-white">{{ t(`kpi.form.source.${opt}`) }}</span>
|
|
199
|
+
<span class="block text-xs text-gray-500 dark:text-gray-400 mt-0.5">{{ t(`kpi.form.sourceHint.${opt}`) }}</span>
|
|
200
|
+
</button>
|
|
201
|
+
</div>
|
|
202
|
+
|
|
203
|
+
<template v-if="form.source === 'resolver'">
|
|
204
|
+
<AppAlert v-if="tanpaResolver" variant="warning">{{ t('kpi.form.noResolvers') }}</AppAlert>
|
|
205
|
+
<AppCombobox
|
|
206
|
+
v-else
|
|
207
|
+
v-model="form.resolver_key"
|
|
208
|
+
:label="t('kpi.form.fieldResolver')"
|
|
209
|
+
:options="resolverOptions"
|
|
210
|
+
:error="fieldErrors.resolver_key"
|
|
211
|
+
required
|
|
212
|
+
/>
|
|
213
|
+
<p v-if="resolverTerpilih" class="text-xs text-gray-500 dark:text-gray-400 -mt-2">
|
|
214
|
+
{{ resolverDescription(resolverTerpilih) }}
|
|
215
|
+
</p>
|
|
216
|
+
<!-- Jenis angka & arah DIPAKSA registry; ditampilkan supaya penyetel tahu apa yang
|
|
217
|
+
dipilihnya, bukan supaya ia bisa mengubahnya. -->
|
|
218
|
+
<p v-if="resolverTerpilih" class="text-xs text-gray-500 dark:text-gray-400 -mt-2">
|
|
219
|
+
{{ t('kpi.form.resolverLocked', {
|
|
220
|
+
metric: t(`kpi.metric.${resolverTerpilih.metric_type}`),
|
|
221
|
+
direction: t(`kpi.direction.${resolverTerpilih.direction}`),
|
|
222
|
+
}) }}
|
|
223
|
+
</p>
|
|
224
|
+
</template>
|
|
225
|
+
|
|
226
|
+
<div v-else class="grid grid-cols-1 sm:grid-cols-3 gap-4">
|
|
227
|
+
<AppCombobox v-model="form.metric_type" :label="t('kpi.form.fieldMetric')" :options="metricOptions" hide-clear required />
|
|
228
|
+
<AppCombobox v-model="form.direction" :label="t('kpi.form.fieldDirection')" :options="directionOptions" hide-clear required />
|
|
229
|
+
<AppInput v-model="form.unit" :label="t('kpi.form.fieldUnit')" :hint="t('kpi.form.fieldUnitHint')" :error="fieldErrors.unit" />
|
|
230
|
+
</div>
|
|
231
|
+
|
|
232
|
+
<p v-if="form.source === 'manual' && form.metric_type === 'percent'" class="text-xs text-gray-500 dark:text-gray-400 -mt-2">
|
|
233
|
+
{{ t('kpi.form.percentHint') }}
|
|
234
|
+
</p>
|
|
235
|
+
</template>
|
|
236
|
+
|
|
237
|
+
<AppInput
|
|
238
|
+
v-if="butuhTaskType"
|
|
239
|
+
v-model="form.task_type"
|
|
240
|
+
:label="t('kpi.form.fieldTaskType')"
|
|
241
|
+
:hint="t('kpi.form.fieldTaskTypeHint')"
|
|
242
|
+
:error="fieldErrors.settings"
|
|
243
|
+
/>
|
|
244
|
+
|
|
245
|
+
<!-- Penambat jobdesk hanya ada di tenant ber-seat `kpis`; di tenant tingkat 1 mengirimnya
|
|
246
|
+
dijawab 403 yang tak ada hubungannya dengan isian pengguna. -->
|
|
247
|
+
<AppCombobox
|
|
248
|
+
v-if="hrisTier"
|
|
249
|
+
v-model="form.occupation_id"
|
|
250
|
+
:label="t('kpi.form.fieldOccupation')"
|
|
251
|
+
:hint="t('kpi.form.fieldOccupationHint')"
|
|
252
|
+
:options="occupationOptions"
|
|
253
|
+
:error="fieldErrors.occupation_id"
|
|
254
|
+
/>
|
|
255
|
+
|
|
256
|
+
<!-- Penyetelan skor -->
|
|
257
|
+
<div class="space-y-3 rounded-lg border border-gray-200 dark:border-gray-700 p-3">
|
|
258
|
+
<p class="text-sm font-medium text-gray-700 dark:text-gray-300">{{ t('kpi.form.scoringTitle') }}</p>
|
|
259
|
+
|
|
260
|
+
<div v-if="isManual">
|
|
261
|
+
<AppToggle
|
|
262
|
+
:model-value="form.allow_na"
|
|
263
|
+
color="blue"
|
|
264
|
+
:label="t('kpi.form.fieldAllowNa')"
|
|
265
|
+
@toggle="form.allow_na = !form.allow_na"
|
|
266
|
+
/>
|
|
267
|
+
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">{{ t('kpi.form.fieldAllowNaHint') }}</p>
|
|
268
|
+
</div>
|
|
269
|
+
|
|
270
|
+
<div v-if="tampilBatasPersen">
|
|
271
|
+
<AppToggle
|
|
272
|
+
:model-value="percentBoundedEfektif"
|
|
273
|
+
color="blue"
|
|
274
|
+
:label="t('kpi.form.fieldPercentBounded')"
|
|
275
|
+
@toggle="form.percent_bounded = !percentBoundedEfektif"
|
|
276
|
+
/>
|
|
277
|
+
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">{{ t('kpi.form.fieldPercentBoundedHint') }}</p>
|
|
278
|
+
</div>
|
|
279
|
+
|
|
280
|
+
<div class="grid grid-cols-2 gap-4">
|
|
281
|
+
<AppInput
|
|
282
|
+
v-model="form.default_threshold_ratio"
|
|
283
|
+
type="number"
|
|
284
|
+
step="any"
|
|
285
|
+
min="0"
|
|
286
|
+
:label="t('kpi.form.fieldThresholdRatio')"
|
|
287
|
+
:error="fieldErrors.default_threshold_ratio"
|
|
288
|
+
/>
|
|
289
|
+
<AppInput
|
|
290
|
+
v-model="form.default_stretch_ratio"
|
|
291
|
+
type="number"
|
|
292
|
+
step="any"
|
|
293
|
+
min="0"
|
|
294
|
+
:label="t('kpi.form.fieldStretchRatio')"
|
|
295
|
+
:error="fieldErrors.default_stretch_ratio"
|
|
296
|
+
/>
|
|
297
|
+
</div>
|
|
298
|
+
<p class="text-xs text-gray-500 dark:text-gray-400 -mt-1">
|
|
299
|
+
{{ t(arahEfektif === 'down' ? 'kpi.form.ratioHintDown' : 'kpi.form.ratioHintUp') }}
|
|
300
|
+
</p>
|
|
301
|
+
</div>
|
|
302
|
+
|
|
303
|
+
<AppToggle
|
|
304
|
+
v-if="isEdit"
|
|
305
|
+
:model-value="form.is_active"
|
|
306
|
+
color="blue"
|
|
307
|
+
:label="t('kpi.form.fieldActive')"
|
|
308
|
+
@toggle="form.is_active = !form.is_active"
|
|
309
|
+
/>
|
|
310
|
+
</form>
|
|
311
|
+
|
|
312
|
+
<template #footer>
|
|
313
|
+
<AppButton variant="secondary" @click="emit('close')">{{ t('common.cancel') }}</AppButton>
|
|
314
|
+
<AppButton :loading="saving" @click="simpan">{{ t('common.save') }}</AppButton>
|
|
315
|
+
</template>
|
|
316
|
+
</AppModal>
|
|
317
|
+
</template>
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
// Realisasi MANUAL satu subjek satu periode.
|
|
3
|
+
//
|
|
4
|
+
// ⚠️ **KPI ber-`metric_type: percent` TIDAK menerima `value`** — ia menuntut `numerator` +
|
|
5
|
+
// `denominator`, dan persennya DITURUNKAN server (mengirim `value` dijawab 422). Itu bukan
|
|
6
|
+
// kerewelan: persen yang diketik tangan tak bisa dijumlahkan lintas bulan, sedangkan pembilang &
|
|
7
|
+
// penyebut bisa — dan rollup kuartal memang merata-ratakan terbobot dari keduanya.
|
|
8
|
+
//
|
|
9
|
+
// ⚠️ KPI ber-resolver ditolak 422 `not_manual`; periode beku ditolak `period_frozen`. Keduanya
|
|
10
|
+
// datang TANPA error per-field, jadi pesannya dicabangkan dari `data.reason`.
|
|
11
|
+
//
|
|
12
|
+
// **N/A ("tidak ada kejadian")** dikirim sebagai `is_na: true` TANPA angka apa pun — server
|
|
13
|
+
// menolak value/numerator/denominator yang ikut terkirim. Pilihannya hanya ditawarkan bila
|
|
14
|
+
// `definition.allow_na`; selain itu server menjawab `na_not_allowed`. N/A ≠ 0: angka 0 tetap
|
|
15
|
+
// dinilai, sedangkan N/A dikeluarkan dari komposit dan bobotnya dibagi ulang.
|
|
16
|
+
import { ref, computed } from 'vue'
|
|
17
|
+
import { useI18n } from 'vue-i18n'
|
|
18
|
+
import { kpiApi } from '@initsolusidigital/worksuite-core/api/endpoints/kpi.js'
|
|
19
|
+
import { useFormSubmit } from '@initsolusidigital/worksuite-core/composables/useFormSubmit.js'
|
|
20
|
+
import AppModal from '@initsolusidigital/worksuite-ui/AppModal.vue'
|
|
21
|
+
import AppInput from '@initsolusidigital/worksuite-ui/AppInput.vue'
|
|
22
|
+
import AppToggle from '@initsolusidigital/worksuite-ui/AppToggle.vue'
|
|
23
|
+
import AppAlert from '@initsolusidigital/worksuite-ui/AppAlert.vue'
|
|
24
|
+
import AppButton from '@initsolusidigital/worksuite-ui/AppButton.vue'
|
|
25
|
+
import AppKpiPeriodPicker from './AppKpiPeriodPicker.vue'
|
|
26
|
+
|
|
27
|
+
const props = defineProps({
|
|
28
|
+
companyId: { type: String, required: true },
|
|
29
|
+
/** Baris laporan yang jadi konteks: definisi + subjek sudah pasti dari sana. */
|
|
30
|
+
row: { type: Object, required: true },
|
|
31
|
+
period: { type: String, default: '' },
|
|
32
|
+
})
|
|
33
|
+
const emit = defineEmits(['close', 'saved'])
|
|
34
|
+
|
|
35
|
+
const { t } = useI18n()
|
|
36
|
+
const { fieldErrors, formError, saving, submit } = useFormSubmit()
|
|
37
|
+
|
|
38
|
+
const period = ref(props.period)
|
|
39
|
+
const value = ref('')
|
|
40
|
+
const numerator = ref('')
|
|
41
|
+
const denominator = ref('')
|
|
42
|
+
const isNa = ref(false)
|
|
43
|
+
|
|
44
|
+
const isPercent = computed(() => props.row?.definition?.metric_type === 'percent')
|
|
45
|
+
const bolehNa = computed(() => !!props.row?.definition?.allow_na)
|
|
46
|
+
const periodeSpan = computed(() => !/^\d{4}-\d{2}$/.test(period.value))
|
|
47
|
+
|
|
48
|
+
function nilai() {
|
|
49
|
+
if (isNa.value) return { is_na: true }
|
|
50
|
+
return isPercent.value
|
|
51
|
+
? { numerator: numerator.value, denominator: denominator.value }
|
|
52
|
+
: { value: value.value }
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function simpan() {
|
|
56
|
+
const ok = await submit(
|
|
57
|
+
() => kpiApi.upsertEntry(props.companyId, props.row.definition.id, {
|
|
58
|
+
period: period.value,
|
|
59
|
+
subject_type: props.row.subject_type,
|
|
60
|
+
subject_id: props.row.subject_id,
|
|
61
|
+
...nilai(),
|
|
62
|
+
}),
|
|
63
|
+
{
|
|
64
|
+
require: isNa.value ? [] : (isPercent.value ? ['numerator', 'denominator'] : ['value']),
|
|
65
|
+
requireIn: isNa.value ? {} : nilai(),
|
|
66
|
+
successKey: 'kpi.entry.saved',
|
|
67
|
+
onError: (e) => {
|
|
68
|
+
if (e.reason === 'not_manual') formError.value = t('kpi.entry.errNotManual')
|
|
69
|
+
else if (e.reason === 'period_frozen') formError.value = t('kpi.entry.errFrozen')
|
|
70
|
+
else if (e.reason === 'na_not_allowed') formError.value = t('kpi.entry.errNaNotAllowed')
|
|
71
|
+
else if (e.reason === 'percent_above_bound') formError.value = t('kpi.entry.errPercentAboveBound')
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
)
|
|
75
|
+
if (ok) emit('saved')
|
|
76
|
+
}
|
|
77
|
+
</script>
|
|
78
|
+
|
|
79
|
+
<template>
|
|
80
|
+
<AppModal :title="t('kpi.entry.title')" size="md" @close="emit('close')">
|
|
81
|
+
<div class="space-y-4">
|
|
82
|
+
<AppAlert v-if="formError" variant="error">{{ formError }}</AppAlert>
|
|
83
|
+
|
|
84
|
+
<dl class="rounded-lg border border-gray-200 dark:border-gray-700 p-3 space-y-1">
|
|
85
|
+
<div class="flex justify-between gap-3 text-sm">
|
|
86
|
+
<dt class="text-gray-500 dark:text-gray-400">{{ t('kpi.report.colDefinition') }}</dt>
|
|
87
|
+
<dd class="text-gray-900 dark:text-white">{{ row.definition?.code ? `${row.definition.code} — ${row.definition.name}` : row.definition?.name }}</dd>
|
|
88
|
+
</div>
|
|
89
|
+
<div class="flex justify-between gap-3 text-sm">
|
|
90
|
+
<dt class="text-gray-500 dark:text-gray-400">{{ t('kpi.report.colSubject') }}</dt>
|
|
91
|
+
<dd class="text-gray-900 dark:text-white">{{ row.subject_name || '—' }}</dd>
|
|
92
|
+
</div>
|
|
93
|
+
</dl>
|
|
94
|
+
|
|
95
|
+
<div>
|
|
96
|
+
<p class="text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">{{ t('kpi.entry.fieldPeriod') }}</p>
|
|
97
|
+
<AppKpiPeriodPicker v-model="period" />
|
|
98
|
+
<p v-if="periodeSpan" class="mt-1 text-xs text-amber-600 dark:text-amber-400">{{ t('kpi.entry.errSpan') }}</p>
|
|
99
|
+
</div>
|
|
100
|
+
|
|
101
|
+
<div v-if="bolehNa">
|
|
102
|
+
<AppToggle :model-value="isNa" color="blue" :label="t('kpi.entry.fieldNa')" @toggle="isNa = !isNa" />
|
|
103
|
+
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">{{ t('kpi.entry.naHint') }}</p>
|
|
104
|
+
</div>
|
|
105
|
+
|
|
106
|
+
<template v-if="!isNa">
|
|
107
|
+
<div v-if="isPercent" class="grid grid-cols-2 gap-4">
|
|
108
|
+
<AppInput v-model="numerator" type="number" step="any" :label="t('kpi.entry.fieldNumerator')" :error="fieldErrors.numerator" required />
|
|
109
|
+
<AppInput v-model="denominator" type="number" step="any" :label="t('kpi.entry.fieldDenominator')" :error="fieldErrors.denominator" required />
|
|
110
|
+
</div>
|
|
111
|
+
<AppInput v-else v-model="value" type="number" step="any" :label="t('kpi.entry.fieldValue')" :error="fieldErrors.value" required />
|
|
112
|
+
|
|
113
|
+
<p v-if="isPercent" class="text-xs text-gray-500 dark:text-gray-400">{{ t('kpi.entry.percentHint') }}</p>
|
|
114
|
+
</template>
|
|
115
|
+
</div>
|
|
116
|
+
|
|
117
|
+
<template #footer>
|
|
118
|
+
<AppButton variant="secondary" @click="emit('close')">{{ t('common.cancel') }}</AppButton>
|
|
119
|
+
<AppButton :loading="saving" :disabled="periodeSpan" @click="simpan">{{ t('common.save') }}</AppButton>
|
|
120
|
+
</template>
|
|
121
|
+
</AppModal>
|
|
122
|
+
</template>
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
// Peringkat satu definisi KPI lintas subjek + agregat per departemen.
|
|
3
|
+
//
|
|
4
|
+
// ⚠️ **Gerbangnya BEDA dari laporan.** Laporan menyaring per-orang (visibilitas berlapis); papan
|
|
5
|
+
// ini lintas-orang by design, jadi backend menuntut `kpis,can_read` ATAU `can_configure` modul
|
|
6
|
+
// sumber dan menjawab 403 untuk yang lain. Menu-nya karena itu disembunyikan lebih dulu — 403
|
|
7
|
+
// yang mendarat di layar terbaca sebagai kerusakan, padahal ia kebijakan.
|
|
8
|
+
//
|
|
9
|
+
// ⚠️ **`rank: null` = belum ada skor**, dan barisnya duduk di buntut. Itu BUKAN peringkat
|
|
10
|
+
// terakhir: orang tanpa skor belum berkompetisi, dan menomorinya menyatakan sesuatu yang tidak
|
|
11
|
+
// diukur. Urutan milik server dan berbasis `score` (bukan rasio) — jangan diurutkan ulang di sini.
|
|
12
|
+
import { useI18n } from 'vue-i18n'
|
|
13
|
+
import { Medal } from '@lucide/vue'
|
|
14
|
+
import AppBadge from '@initsolusidigital/worksuite-ui/AppBadge.vue'
|
|
15
|
+
import AppCard from '@initsolusidigital/worksuite-ui/AppCard.vue'
|
|
16
|
+
import AppEmptyState from '@initsolusidigital/worksuite-ui/AppEmptyState.vue'
|
|
17
|
+
import AppSpinner from '@initsolusidigital/worksuite-ui/AppSpinner.vue'
|
|
18
|
+
|
|
19
|
+
defineProps({
|
|
20
|
+
definition: { type: Object, default: null },
|
|
21
|
+
rows: { type: Array, default: () => [] },
|
|
22
|
+
byDepartment:{ type: Array, default: () => [] },
|
|
23
|
+
loading: { type: Boolean, default: false },
|
|
24
|
+
error: { type: String, default: '' },
|
|
25
|
+
formatMetric: { type: Function, required: true },
|
|
26
|
+
formatAchievement: { type: Function, required: true },
|
|
27
|
+
formatScore: { type: Function, required: true },
|
|
28
|
+
statusTone: { type: Function, required: true },
|
|
29
|
+
definitionLabel: { type: Function, required: true },
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
const { t } = useI18n()
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<template>
|
|
36
|
+
<div class="space-y-6">
|
|
37
|
+
<AppCard :title="t('kpi.leaderboard.rankTitle')" :description="definitionLabel(definition)" padding="none" title-tag="h3">
|
|
38
|
+
<div v-if="loading" class="py-12 text-center"><AppSpinner /></div>
|
|
39
|
+
|
|
40
|
+
<div v-else-if="error" class="p-6 text-sm text-red-600 dark:text-red-400">{{ error }}</div>
|
|
41
|
+
|
|
42
|
+
<div v-else-if="!rows.length" class="p-6">
|
|
43
|
+
<AppEmptyState :label="t('kpi.leaderboard.empty')" :description="t('kpi.leaderboard.emptyHint')">
|
|
44
|
+
<template #icon><Medal class="w-6 h-6 text-gray-400 dark:text-gray-500" :stroke-width="1.5" /></template>
|
|
45
|
+
</AppEmptyState>
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
<div v-else class="overflow-x-auto scrollbar-rounded">
|
|
49
|
+
<table class="min-w-full text-sm">
|
|
50
|
+
<thead class="bg-gray-50 dark:bg-gray-900/40 text-xs text-gray-500 dark:text-gray-400">
|
|
51
|
+
<tr>
|
|
52
|
+
<th scope="col" class="text-left font-medium px-6 py-2 w-16">{{ t('kpi.leaderboard.colRank') }}</th>
|
|
53
|
+
<th scope="col" class="text-left font-medium px-6 py-2">{{ t('kpi.report.colSubject') }}</th>
|
|
54
|
+
<th scope="col" class="text-left font-medium px-6 py-2">{{ t('kpi.leaderboard.colDepartment') }}</th>
|
|
55
|
+
<th scope="col" class="text-right font-medium px-6 py-2">{{ t('kpi.report.colActual') }}</th>
|
|
56
|
+
<th scope="col" class="text-right font-medium px-6 py-2">{{ t('kpi.report.colTarget') }}</th>
|
|
57
|
+
<th scope="col" class="text-right font-medium px-6 py-2">{{ t('kpi.report.colAchievement') }}</th>
|
|
58
|
+
</tr>
|
|
59
|
+
</thead>
|
|
60
|
+
<tbody class="divide-y divide-gray-100 dark:divide-gray-700">
|
|
61
|
+
<tr v-for="r in rows" :key="`${r.subject_type}|${r.subject_id}`">
|
|
62
|
+
<td class="px-6 py-3 tabular-nums text-gray-500 dark:text-gray-400">
|
|
63
|
+
<span v-if="r.rank">{{ r.rank }}</span>
|
|
64
|
+
<span v-else class="text-xs">{{ t('kpi.leaderboard.unranked') }}</span>
|
|
65
|
+
</td>
|
|
66
|
+
<td class="px-6 py-3 text-gray-900 dark:text-white">{{ r.subject_name || '—' }}</td>
|
|
67
|
+
<td class="px-6 py-3 text-gray-600 dark:text-gray-300">{{ r.department || '—' }}</td>
|
|
68
|
+
<td class="px-6 py-3 text-right tabular-nums text-gray-900 dark:text-white">
|
|
69
|
+
<span v-if="r.state === 'na'" class="text-gray-500 dark:text-gray-400">{{ t('kpi.state.na') }}</span>
|
|
70
|
+
<span v-else-if="r.state === 'missing'" class="text-amber-600 dark:text-amber-400">{{ t('kpi.state.missing') }}</span>
|
|
71
|
+
<template v-else>{{ formatMetric(r.actual, definition) }}</template>
|
|
72
|
+
</td>
|
|
73
|
+
<td class="px-6 py-3 text-right tabular-nums text-gray-600 dark:text-gray-300">{{ formatMetric(r.target, definition) }}</td>
|
|
74
|
+
<td class="px-6 py-3 text-right">
|
|
75
|
+
<AppBadge v-if="r.score !== null && r.score !== undefined" :color="statusTone(r.status)">{{ formatScore(r.score) }}</AppBadge>
|
|
76
|
+
<span v-else class="text-gray-400 dark:text-gray-500">—</span>
|
|
77
|
+
<span
|
|
78
|
+
v-if="r.achievement_pct !== null && r.achievement_pct !== undefined"
|
|
79
|
+
class="block text-[11px] text-gray-400 dark:text-gray-500"
|
|
80
|
+
:title="t('kpi.report.ratioHint')"
|
|
81
|
+
>{{ t('kpi.report.ratio', { pct: formatAchievement(r.achievement_pct) }) }}</span>
|
|
82
|
+
</td>
|
|
83
|
+
</tr>
|
|
84
|
+
</tbody>
|
|
85
|
+
</table>
|
|
86
|
+
</div>
|
|
87
|
+
</AppCard>
|
|
88
|
+
|
|
89
|
+
<!-- Agregat departemen hanya lahir untuk subjek `employee`; tenant tingkat 1 (subjek user)
|
|
90
|
+
tak punya departemen, jadi kartunya memang tak muncul — bukan gagal memuat. -->
|
|
91
|
+
<AppCard v-if="byDepartment.length" :title="t('kpi.leaderboard.deptTitle')" padding="none" title-tag="h3">
|
|
92
|
+
<ul class="divide-y divide-gray-100 dark:divide-gray-700">
|
|
93
|
+
<li v-for="d in byDepartment" :key="d.department" class="px-6 py-3 flex items-center justify-between gap-3">
|
|
94
|
+
<div class="min-w-0">
|
|
95
|
+
<p class="text-sm text-gray-900 dark:text-white truncate">{{ d.department }}</p>
|
|
96
|
+
<p class="text-xs text-gray-500 dark:text-gray-400">{{ t('kpi.leaderboard.members', { n: d.members }) }}</p>
|
|
97
|
+
</div>
|
|
98
|
+
<!-- Rata-rata SKOR (bukan rasio), urutannya juga milik server. Tanpa warna `status`:
|
|
99
|
+
server tak mengirimnya untuk agregat, dan ambang tulisan tangan di sini akan jadi
|
|
100
|
+
aturan kedua yang bisa berbeda dari aturan server. -->
|
|
101
|
+
<span class="text-sm font-medium tabular-nums text-gray-900 dark:text-white" :title="t('kpi.leaderboard.avgScoreHint')">
|
|
102
|
+
{{ formatScore(d.avg_score) }}
|
|
103
|
+
</span>
|
|
104
|
+
</li>
|
|
105
|
+
</ul>
|
|
106
|
+
</AppCard>
|
|
107
|
+
</div>
|
|
108
|
+
</template>
|