feat: personnel code on form
This commit is contained in:
parent
0066bcd252
commit
42c38938d7
3 changed files with 78 additions and 39 deletions
|
|
@ -1,11 +1,14 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
import AppBox from './app/AppBox.vue';
|
||||||
|
|
||||||
defineProps<{
|
defineProps<{
|
||||||
title: string;
|
title: string;
|
||||||
isEdit?: boolean;
|
isEdit?: boolean;
|
||||||
bgOn?: boolean;
|
bgOn?: boolean;
|
||||||
statusBranch?: string;
|
statusBranch?: string;
|
||||||
|
badgeLabel?: string;
|
||||||
|
badgeClass?: string;
|
||||||
editData?: (...args: unknown[]) => void;
|
editData?: (...args: unknown[]) => void;
|
||||||
deleteData?: (...args: unknown[]) => void;
|
deleteData?: (...args: unknown[]) => void;
|
||||||
submit?: (...args: unknown[]) => void;
|
submit?: (...args: unknown[]) => void;
|
||||||
|
|
@ -103,6 +106,13 @@ function reset() {
|
||||||
: $t('statusACTIVE')
|
: $t('statusACTIVE')
|
||||||
}}
|
}}
|
||||||
</text>
|
</text>
|
||||||
|
<text
|
||||||
|
v-if="badgeLabel"
|
||||||
|
class="badge-label q-px-sm text-caption"
|
||||||
|
:class="badgeClass"
|
||||||
|
>
|
||||||
|
{{ badgeLabel }}
|
||||||
|
</text>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style="width: 31.98px"></div>
|
<div style="width: 31.98px"></div>
|
||||||
|
|
@ -214,4 +224,11 @@ function reset() {
|
||||||
background-color: hsla(var(--_branch-badge-bg) / 0.1);
|
background-color: hsla(var(--_branch-badge-bg) / 0.1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.badge-label {
|
||||||
|
display: inline-block;
|
||||||
|
border-radius: var(--radius-6);
|
||||||
|
background-color: var(--surface-2);
|
||||||
|
text-wrap: nowrap;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@ defineProps<{
|
||||||
addressTitleEN?: string;
|
addressTitleEN?: string;
|
||||||
addressSeparator?: boolean;
|
addressSeparator?: boolean;
|
||||||
branchStatus?: string;
|
branchStatus?: string;
|
||||||
|
badgeLabel?: string;
|
||||||
|
badgeClass?: string;
|
||||||
submit?: (...args: unknown[]) => void;
|
submit?: (...args: unknown[]) => void;
|
||||||
close?: (...args: unknown[]) => void;
|
close?: (...args: unknown[]) => void;
|
||||||
}>();
|
}>();
|
||||||
|
|
@ -27,7 +29,7 @@ const zipCode = defineModel<string>('zipCode', { default: '' });
|
||||||
style="
|
style="
|
||||||
padding: 0;
|
padding: 0;
|
||||||
border-radius: var(--radius-2);
|
border-radius: var(--radius-2);
|
||||||
max-width: 80%;
|
max-width: 85%;
|
||||||
max-height: 100%;
|
max-height: 100%;
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
|
|
@ -39,7 +41,14 @@ const zipCode = defineModel<string>('zipCode', { default: '' });
|
||||||
<div class="col text-subtitle1 text-weight-bold text-center">
|
<div class="col text-subtitle1 text-weight-bold text-center">
|
||||||
{{ title }}
|
{{ title }}
|
||||||
|
|
||||||
<div>{{ branchStatus ? `(${branchStatus})` : '' }}</div>
|
<text>{{ branchStatus ? `(${branchStatus})` : '' }}</text>
|
||||||
|
<text
|
||||||
|
v-if="badgeLabel"
|
||||||
|
class="badge-label q-px-sm text-caption"
|
||||||
|
:class="badgeClass"
|
||||||
|
>
|
||||||
|
{{ badgeLabel }}
|
||||||
|
</text>
|
||||||
</div>
|
</div>
|
||||||
<q-btn
|
<q-btn
|
||||||
round
|
round
|
||||||
|
|
@ -169,4 +178,11 @@ const zipCode = defineModel<string>('zipCode', { default: '' });
|
||||||
.form-footer {
|
.form-footer {
|
||||||
border-top: 1px solid var(--border-color);
|
border-top: 1px solid var(--border-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.badge-label {
|
||||||
|
display: inline-block;
|
||||||
|
border-radius: var(--radius-6);
|
||||||
|
background-color: var(--surface-2);
|
||||||
|
text-wrap: nowrap;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,7 @@ const defaultFormData = {
|
||||||
checkpointEN: null,
|
checkpointEN: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const userCode = ref<string>();
|
||||||
const currentUser = ref<User>();
|
const currentUser = ref<User>();
|
||||||
const infoPersonCardEdit = ref(false);
|
const infoPersonCardEdit = ref(false);
|
||||||
const infoPersonId = ref<string>('');
|
const infoPersonId = ref<string>('');
|
||||||
|
|
@ -86,7 +87,6 @@ const userId = ref<string>();
|
||||||
const selectorLabel = ref<string>('');
|
const selectorLabel = ref<string>('');
|
||||||
const hqId = ref<string>();
|
const hqId = ref<string>();
|
||||||
const brId = ref<string>();
|
const brId = ref<string>();
|
||||||
const code = ref<string>();
|
|
||||||
const formDialogRef = ref();
|
const formDialogRef = ref();
|
||||||
const userStats = ref<BranchUserStats[]>();
|
const userStats = ref<BranchUserStats[]>();
|
||||||
const typeStats = ref<UserTypeStats>();
|
const typeStats = ref<UserTypeStats>();
|
||||||
|
|
@ -156,12 +156,33 @@ const selectorList = computed(() => [
|
||||||
]);
|
]);
|
||||||
|
|
||||||
async function openDialog(action?: 'FORM' | 'INFO', idEdit?: string) {
|
async function openDialog(action?: 'FORM' | 'INFO', idEdit?: string) {
|
||||||
|
if (userStore.userOption.hqOpts.length === 0) {
|
||||||
|
await userStore.fetchHqOption();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (userStore.userOption.roleOpts.length === 0) {
|
||||||
|
await userStore.fetchRoleOption();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (idEdit && userData.value) {
|
||||||
|
assignFormData(idEdit);
|
||||||
|
isEdit.value = true;
|
||||||
|
|
||||||
|
if (formData.value.userType === 'AGENCY') {
|
||||||
|
const result = await userStore.fetchAttachment(idEdit);
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
agencyFileList.value = result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (action === 'FORM') {
|
if (action === 'FORM') {
|
||||||
modal.value = true;
|
modal.value = true;
|
||||||
} else if (action === 'INFO') {
|
} else if (action === 'INFO') {
|
||||||
|
if (!userData.value) return;
|
||||||
infoDrawer.value = true;
|
infoDrawer.value = true;
|
||||||
infoPersonCardEdit.value = false;
|
infoPersonCardEdit.value = false;
|
||||||
if (!userData.value) return;
|
|
||||||
const user = userData.value.result.find((x) => x.id === idEdit);
|
const user = userData.value.result.find((x) => x.id === idEdit);
|
||||||
infoPersonCard.value = user
|
infoPersonCard.value = user
|
||||||
? [
|
? [
|
||||||
|
|
@ -182,33 +203,8 @@ async function openDialog(action?: 'FORM' | 'INFO', idEdit?: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
statusToggle.value = true;
|
statusToggle.value = true;
|
||||||
profileSubmit.value = false;
|
|
||||||
userStore.userOption.brOpts = [];
|
userStore.userOption.brOpts = [];
|
||||||
|
|
||||||
if (userStore.userOption.hqOpts.length === 0) {
|
|
||||||
await userStore.fetchHqOption();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (userStore.userOption.hqOpts.length === 1) {
|
|
||||||
hqId.value = userStore.userOption.hqOpts[0].value;
|
hqId.value = userStore.userOption.hqOpts[0].value;
|
||||||
}
|
|
||||||
|
|
||||||
if (userStore.userOption.roleOpts.length === 0) {
|
|
||||||
await userStore.fetchRoleOption();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (idEdit && userData.value) {
|
|
||||||
isEdit.value = true;
|
|
||||||
assignFormData(idEdit);
|
|
||||||
|
|
||||||
if (formData.value.userType === 'AGENCY') {
|
|
||||||
const result = await userStore.fetchAttachment(idEdit);
|
|
||||||
|
|
||||||
if (result) {
|
|
||||||
agencyFileList.value = result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function undo() {
|
function undo() {
|
||||||
|
|
@ -218,16 +214,16 @@ function undo() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function onClose() {
|
function onClose() {
|
||||||
code.value = '';
|
|
||||||
hqId.value = '';
|
hqId.value = '';
|
||||||
brId.value = '';
|
brId.value = '';
|
||||||
userId.value = '';
|
userId.value = '';
|
||||||
|
userCode.value = '';
|
||||||
urlProfile.value = '';
|
urlProfile.value = '';
|
||||||
agencyFile.value = [];
|
agencyFile.value = [];
|
||||||
profileSubmit.value = false;
|
|
||||||
modal.value = false;
|
modal.value = false;
|
||||||
infoDrawer.value = false;
|
|
||||||
isEdit.value = false;
|
isEdit.value = false;
|
||||||
|
infoDrawer.value = false;
|
||||||
|
profileSubmit.value = false;
|
||||||
statusToggle.value = true;
|
statusToggle.value = true;
|
||||||
Object.assign(formData.value, defaultFormData);
|
Object.assign(formData.value, defaultFormData);
|
||||||
mapUserType(selectorLabel.value);
|
mapUserType(selectorLabel.value);
|
||||||
|
|
@ -300,7 +296,10 @@ async function onSubmit() {
|
||||||
userType: selectorLabel.value ?? undefined,
|
userType: selectorLabel.value ?? undefined,
|
||||||
});
|
});
|
||||||
typeStats.value = await userStore.typeStats();
|
typeStats.value = await userStore.typeStats();
|
||||||
|
const res = await branchStore.userStats(formData.value.userType);
|
||||||
|
if (res) {
|
||||||
|
userStats.value = res;
|
||||||
|
}
|
||||||
onClose();
|
onClose();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
@ -346,7 +345,10 @@ async function onSubmit() {
|
||||||
userType: selectorLabel.value ?? undefined,
|
userType: selectorLabel.value ?? undefined,
|
||||||
});
|
});
|
||||||
typeStats.value = await userStore.typeStats();
|
typeStats.value = await userStore.typeStats();
|
||||||
|
const res = await branchStore.userStats(formData.value.userType);
|
||||||
|
if (res) {
|
||||||
|
userStats.value = res;
|
||||||
|
}
|
||||||
onClose();
|
onClose();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
@ -380,7 +382,6 @@ function mapUserType(label: string) {
|
||||||
DELEGATE: 'DELEGATE',
|
DELEGATE: 'DELEGATE',
|
||||||
AGENCY: 'AGENCY',
|
AGENCY: 'AGENCY',
|
||||||
};
|
};
|
||||||
|
|
||||||
formData.value.userType = userTypeMap[label];
|
formData.value.userType = userTypeMap[label];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -398,6 +399,7 @@ async function toggleStatus(id: string) {
|
||||||
async function assignFormData(idEdit: string) {
|
async function assignFormData(idEdit: string) {
|
||||||
if (!userData.value) return;
|
if (!userData.value) return;
|
||||||
const foundUser = userData.value.result.find((user) => user.id === idEdit);
|
const foundUser = userData.value.result.find((user) => user.id === idEdit);
|
||||||
|
|
||||||
if (foundUser) {
|
if (foundUser) {
|
||||||
currentUser.value = foundUser;
|
currentUser.value = foundUser;
|
||||||
infoPersonId.value = currentUser.value.id;
|
infoPersonId.value = currentUser.value.id;
|
||||||
|
|
@ -456,7 +458,7 @@ async function assignFormData(idEdit: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
code.value = foundUser.code;
|
userCode.value = foundUser.code;
|
||||||
urlProfile.value = foundUser.profileImageUrl;
|
urlProfile.value = foundUser.profileImageUrl;
|
||||||
isEdit.value = true;
|
isEdit.value = true;
|
||||||
profileSubmit.value = true;
|
profileSubmit.value = true;
|
||||||
|
|
@ -701,6 +703,8 @@ watch(
|
||||||
<DrawerInfo
|
<DrawerInfo
|
||||||
v-if="currentUser"
|
v-if="currentUser"
|
||||||
bg-on
|
bg-on
|
||||||
|
:badgeClass="formData.gender === 'male' ? 'app-bg-male' : 'app-bg-female'"
|
||||||
|
:badgeLabel="userCode"
|
||||||
:isEdit="infoPersonCardEdit"
|
:isEdit="infoPersonCardEdit"
|
||||||
:title="
|
:title="
|
||||||
$i18n.locale === 'en-US'
|
$i18n.locale === 'en-US'
|
||||||
|
|
@ -752,7 +756,7 @@ watch(
|
||||||
v-model:userType="formData.userType"
|
v-model:userType="formData.userType"
|
||||||
v-model:userRole="formData.userRole"
|
v-model:userRole="formData.userRole"
|
||||||
v-model:username="formData.username"
|
v-model:username="formData.username"
|
||||||
v-model:userCode="code"
|
v-model:userCode="userCode"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template #person>
|
<template #person>
|
||||||
|
|
@ -801,6 +805,8 @@ watch(
|
||||||
<FormDialog
|
<FormDialog
|
||||||
removeDialog
|
removeDialog
|
||||||
ref="formDialogRef"
|
ref="formDialogRef"
|
||||||
|
:badgeClass="formData.gender === 'male' ? 'app-bg-male' : 'app-bg-female'"
|
||||||
|
:badgeLabel="userCode"
|
||||||
:title="$t('personnelAdd')"
|
:title="$t('personnelAdd')"
|
||||||
:addressTitle="$t('formDialogTitleAddressPure')"
|
:addressTitle="$t('formDialogTitleAddressPure')"
|
||||||
:addressTitleEN="$t('formDialogTitleAddressPure') + ' ENG'"
|
:addressTitleEN="$t('formDialogTitleAddressPure') + ' ENG'"
|
||||||
|
|
@ -909,7 +915,7 @@ watch(
|
||||||
v-model:userType="formData.userType"
|
v-model:userType="formData.userType"
|
||||||
v-model:userRole="formData.userRole"
|
v-model:userRole="formData.userRole"
|
||||||
v-model:username="formData.username"
|
v-model:username="formData.username"
|
||||||
v-model:userCode="code"
|
v-model:userCode="userCode"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template #person>
|
<template #person>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue