2024-04-03 18:28:59 +07:00
|
|
|
<script setup lang="ts">
|
2024-04-05 17:26:40 +07:00
|
|
|
import { ref, onMounted } from 'vue';
|
|
|
|
|
import useUserStore from 'stores/user';
|
|
|
|
|
import { storeToRefs } from 'pinia';
|
2024-04-04 15:03:39 +07:00
|
|
|
|
2024-04-05 17:36:54 +07:00
|
|
|
import PersonCard from 'components/home/PersonCard.vue';
|
2024-04-03 18:28:59 +07:00
|
|
|
import AppBox from 'components/app/AppBox.vue';
|
2024-04-05 17:36:54 +07:00
|
|
|
import StatCardComponent from 'components/StatCardComponent.vue';
|
|
|
|
|
import SelectorList from 'components/SelectorList.vue';
|
2024-04-05 17:43:16 +07:00
|
|
|
import BtnAddComponent from 'components/01_branch-management/BtnAddComponent.vue';
|
|
|
|
|
import TooltipComponent from 'components/TooltipComponent.vue';
|
2024-04-05 19:05:51 +07:00
|
|
|
import FormDialog from 'src/components/FormDialog.vue';
|
2024-04-04 15:03:39 +07:00
|
|
|
|
2024-04-05 17:26:40 +07:00
|
|
|
const userStore = useUserStore();
|
|
|
|
|
const { data: userData } = storeToRefs(userStore);
|
2024-04-03 18:28:59 +07:00
|
|
|
|
2024-04-05 17:26:40 +07:00
|
|
|
onMounted(async () => {
|
|
|
|
|
await userStore.fetchList();
|
|
|
|
|
});
|
2024-04-04 15:03:39 +07:00
|
|
|
|
2024-04-05 17:31:29 +07:00
|
|
|
const branchStat = ref([
|
|
|
|
|
{ label: 'Branch A', amount: 1 },
|
|
|
|
|
{ label: 'Branch B', amount: 5 },
|
|
|
|
|
{ label: 'Branch C', amount: 3 },
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
const selectorLabel = ref('');
|
2024-04-05 19:05:51 +07:00
|
|
|
const modal = ref(false);
|
|
|
|
|
|
|
|
|
|
const hqId = ref('');
|
|
|
|
|
const branchId = ref('');
|
|
|
|
|
|
|
|
|
|
const genderOptions = ref([
|
|
|
|
|
{ label: 'ชาย', value: '1' },
|
|
|
|
|
{ label: 'หญิง', value: '2' },
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
const hqOptions = ref([
|
|
|
|
|
{ label: '0000000001', value: '1' },
|
|
|
|
|
{ label: '0000000002', value: '2' },
|
|
|
|
|
]);
|
|
|
|
|
const branchOptions = ref([
|
|
|
|
|
{ label: '0000000001-1', value: '1' },
|
|
|
|
|
{ label: '0000000001-2', value: '2' },
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
const formData = ref({
|
|
|
|
|
hqId: '',
|
|
|
|
|
branchId: '',
|
|
|
|
|
tel: '',
|
|
|
|
|
gender: '',
|
|
|
|
|
email: '',
|
|
|
|
|
addressL: {
|
|
|
|
|
address: '',
|
|
|
|
|
province: '',
|
|
|
|
|
district: '',
|
|
|
|
|
subDistrict: '',
|
|
|
|
|
zip: '',
|
|
|
|
|
},
|
|
|
|
|
addressEng: {
|
|
|
|
|
address: '',
|
|
|
|
|
province: '',
|
|
|
|
|
district: '',
|
|
|
|
|
subDistrict: '',
|
|
|
|
|
zip: '',
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
2024-04-04 15:03:39 +07:00
|
|
|
const selectorList = [
|
2024-04-05 17:31:29 +07:00
|
|
|
{ label: 'personnelSelector1', count: 0 },
|
|
|
|
|
{ label: 'personnelSelector2', count: 0 },
|
|
|
|
|
{ label: 'personnelSelector3', count: 0 },
|
|
|
|
|
{ label: 'personnelSelector4', count: 0 },
|
2024-04-04 15:03:39 +07:00
|
|
|
] satisfies InstanceType<typeof SelectorList>['$props']['list'];
|
2024-04-05 19:05:51 +07:00
|
|
|
|
|
|
|
|
function openDialog() {
|
|
|
|
|
modal.value = true;
|
|
|
|
|
}
|
2024-04-03 18:28:59 +07:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2024-04-04 15:03:39 +07:00
|
|
|
<div class="column q-pb-lg">
|
2024-04-04 16:39:50 +07:00
|
|
|
<div class="text-h6 text-weight-bold q-mb-md">
|
|
|
|
|
{{ $t('personnelManagement') }}
|
|
|
|
|
</div>
|
2024-04-04 15:03:39 +07:00
|
|
|
|
|
|
|
|
<div class="row full-width q-mb-md no-wrap">
|
|
|
|
|
<!-- selector -->
|
2024-04-04 16:39:50 +07:00
|
|
|
<SelectorList
|
|
|
|
|
:list="selectorList"
|
|
|
|
|
v-model:selector="selectorLabel"
|
|
|
|
|
class="q-mr-md col-4"
|
|
|
|
|
/>
|
2024-04-04 15:03:39 +07:00
|
|
|
|
|
|
|
|
<!-- stat -->
|
2024-04-05 10:37:57 +07:00
|
|
|
<AppBox bordered class="column full-width">
|
2024-04-05 19:05:51 +07:00
|
|
|
<div class="row q-pb-lg justify-between items-center">
|
|
|
|
|
<div class="text-weight-bold text-subtitle1">
|
|
|
|
|
{{ $t('personnelStatTitle') + $t(selectorLabel) }}
|
|
|
|
|
</div>
|
|
|
|
|
<q-btn
|
|
|
|
|
dense
|
|
|
|
|
unelevated
|
|
|
|
|
label="+ เพิ่มบุคลากร"
|
|
|
|
|
padding="4px 16px"
|
|
|
|
|
@click="openDialog"
|
|
|
|
|
style="background-color: var(--cyan-6); color: white"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2024-04-05 10:37:57 +07:00
|
|
|
<div class="row col full-width" style="overflow-x: auto">
|
2024-04-05 17:36:54 +07:00
|
|
|
<StatCardComponent :branch="branchStat" class="no-wrap" />
|
2024-04-04 16:39:50 +07:00
|
|
|
</div>
|
2024-04-04 15:03:39 +07:00
|
|
|
</AppBox>
|
|
|
|
|
</div>
|
2024-04-03 18:28:59 +07:00
|
|
|
|
2024-04-04 15:03:39 +07:00
|
|
|
<!-- main -->
|
|
|
|
|
<AppBox bordered style="width: 100%; height: 580px; overflow-y: auto">
|
2024-04-05 17:26:40 +07:00
|
|
|
<PersonCard
|
|
|
|
|
:list="
|
|
|
|
|
userData?.result.map((v) => ({
|
|
|
|
|
img: `${v.profileImageUrl}`,
|
|
|
|
|
name: `${v.firstName} ${v.lastName}`,
|
|
|
|
|
male: v.gender === 'male',
|
|
|
|
|
female: v.gender === 'female',
|
|
|
|
|
detail: [
|
|
|
|
|
{ label: 'Email', value: v.email },
|
|
|
|
|
{ label: 'Telephone No', value: v.telephoneNo },
|
|
|
|
|
],
|
|
|
|
|
badge: v.code.slice(0, 10),
|
|
|
|
|
disabled: v.status === 'INACTIVE',
|
|
|
|
|
})) || []
|
|
|
|
|
"
|
|
|
|
|
/>
|
|
|
|
|
<div
|
|
|
|
|
class="column"
|
|
|
|
|
style="height: 100%"
|
|
|
|
|
v-if="userData && userData.total === 0"
|
|
|
|
|
>
|
2024-04-04 16:39:50 +07:00
|
|
|
<div class="col-1 self-end">
|
|
|
|
|
<div class="row">
|
2024-04-05 17:43:16 +07:00
|
|
|
<TooltipComponent
|
2024-04-04 16:39:50 +07:00
|
|
|
title="personnelTooltipTitle"
|
|
|
|
|
caption="personnelTooltipCaption"
|
|
|
|
|
imgSrc="personnel-table-"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col self-center" style="display: flex; align-items: center">
|
2024-04-05 17:43:16 +07:00
|
|
|
<BtnAddComponent
|
2024-04-04 18:08:37 +07:00
|
|
|
:label="'personnelAdd'"
|
2024-04-05 09:24:10 +07:00
|
|
|
:cyanOn="true"
|
2024-04-05 19:05:51 +07:00
|
|
|
@trigger="openDialog"
|
2024-04-04 16:39:50 +07:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-04-03 18:28:59 +07:00
|
|
|
</AppBox>
|
|
|
|
|
</div>
|
2024-04-05 19:05:51 +07:00
|
|
|
|
|
|
|
|
<FormDialog
|
|
|
|
|
v-model:modal="modal"
|
|
|
|
|
v-model:addressL="formData.addressL"
|
|
|
|
|
v-model:addressEng="formData.addressEng"
|
|
|
|
|
title="เพิ่มบุคลากร"
|
|
|
|
|
addressLocaleTitle="ที่อยู่พนักงาน"
|
|
|
|
|
addressEngTitle="ที่อยู่พนักงาน ENG"
|
|
|
|
|
>
|
|
|
|
|
<template #top>
|
|
|
|
|
<q-select
|
|
|
|
|
dense
|
|
|
|
|
outlined
|
|
|
|
|
emit-value
|
|
|
|
|
map-options
|
|
|
|
|
v-model="hqId"
|
|
|
|
|
class="col-6"
|
|
|
|
|
option-value="value"
|
|
|
|
|
option-label="label"
|
|
|
|
|
label="รหัสสำนักงานใหญ่"
|
|
|
|
|
:options="hqOptions"
|
|
|
|
|
bg-color="white"
|
|
|
|
|
/>
|
|
|
|
|
<q-select
|
|
|
|
|
dense
|
|
|
|
|
outlined
|
|
|
|
|
emit-value
|
|
|
|
|
map-options
|
|
|
|
|
v-model="branchId"
|
|
|
|
|
class="col-6"
|
|
|
|
|
option-value="value"
|
|
|
|
|
option-label="label"
|
|
|
|
|
label="รหัสสาขา"
|
|
|
|
|
:options="branchOptions"
|
|
|
|
|
bg-color="white"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<template #prepend>
|
|
|
|
|
<div>asd</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<template #midTop>
|
|
|
|
|
<!-- <q-input dense outlined label="รหัสไปรษณีย์" class="col-3" />
|
|
|
|
|
<q-input dense outlined label="รหัสไปรษณีย์" class="col-3" />
|
|
|
|
|
<q-input dense outlined label="รหัสไปรษณีย์" class="col-3" />
|
|
|
|
|
<q-input dense outlined label="รหัสไปรษณีย์" class="col-3" /> -->
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<template #midBottom>
|
|
|
|
|
<q-input
|
|
|
|
|
dense
|
|
|
|
|
outlined
|
|
|
|
|
label="เบอร์โทร"
|
|
|
|
|
class="col-3"
|
|
|
|
|
v-model="formData.tel"
|
|
|
|
|
/>
|
|
|
|
|
<q-select
|
|
|
|
|
dense
|
|
|
|
|
outlined
|
|
|
|
|
emit-value
|
|
|
|
|
map-options
|
|
|
|
|
v-model="formData.gender"
|
|
|
|
|
class="col-3"
|
|
|
|
|
option-value="value"
|
|
|
|
|
option-label="label"
|
|
|
|
|
label="เพศ"
|
|
|
|
|
:options="genderOptions"
|
|
|
|
|
bg-color="white"
|
|
|
|
|
/>
|
|
|
|
|
<q-input
|
|
|
|
|
dense
|
|
|
|
|
outlined
|
|
|
|
|
label="อีเมล"
|
|
|
|
|
class="col-6"
|
|
|
|
|
v-model="formData.email"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<!-- <template #append>
|
|
|
|
|
<div style="background-color: blue">asd</div>
|
|
|
|
|
</template> -->
|
|
|
|
|
</FormDialog>
|
2024-04-03 18:28:59 +07:00
|
|
|
</template>
|
2024-04-05 19:05:51 +07:00
|
|
|
<style>
|
|
|
|
|
.bg-white {
|
|
|
|
|
background-color: var(--surface-1) !important;
|
|
|
|
|
}
|
|
|
|
|
</style>
|