feat: add employee under employer (#35)
* refactor: btn add in table * refactor: Emits addEmployee * fix: visa can is null * refactor: update data * fix: number not update --------- Co-authored-by: Thanaphon Frappet <thanaphon@frappet.com>
This commit is contained in:
parent
a9c9467643
commit
05c1c07384
5 changed files with 61 additions and 20 deletions
|
|
@ -7,6 +7,8 @@ import PersonCard from 'components/shared/PersonCard.vue';
|
||||||
import KebabAction from '../shared/KebabAction.vue';
|
import KebabAction from '../shared/KebabAction.vue';
|
||||||
import useOptionStore from 'stores/options';
|
import useOptionStore from 'stores/options';
|
||||||
|
|
||||||
|
import { AddButton } from 'components/button';
|
||||||
|
|
||||||
const optionStore = useOptionStore();
|
const optionStore = useOptionStore();
|
||||||
const pageSize = defineModel<number>('pageSize', { default: 30 });
|
const pageSize = defineModel<number>('pageSize', { default: 30 });
|
||||||
const currentPage = defineModel<number>('currentPage', { default: 1 });
|
const currentPage = defineModel<number>('currentPage', { default: 1 });
|
||||||
|
|
@ -18,6 +20,7 @@ const prop = withDefaults(
|
||||||
columnsEmployee: any[];
|
columnsEmployee: any[];
|
||||||
fieldSelected?: string[];
|
fieldSelected?: string[];
|
||||||
inTable?: boolean;
|
inTable?: boolean;
|
||||||
|
addButton?: boolean;
|
||||||
}>(),
|
}>(),
|
||||||
{
|
{
|
||||||
gridView: false,
|
gridView: false,
|
||||||
|
|
@ -37,6 +40,7 @@ const prop = withDefaults(
|
||||||
);
|
);
|
||||||
|
|
||||||
defineEmits<{
|
defineEmits<{
|
||||||
|
(e: 'add'): void;
|
||||||
(e: 'view', data: any): void;
|
(e: 'view', data: any): void;
|
||||||
(e: 'edit', data: any): void;
|
(e: 'edit', data: any): void;
|
||||||
(e: 'delete', data: any): void;
|
(e: 'delete', data: any): void;
|
||||||
|
|
@ -68,7 +72,9 @@ defineEmits<{
|
||||||
<span v-if="col.label === 'nameEmployee'">
|
<span v-if="col.label === 'nameEmployee'">
|
||||||
{{ $t('fullname') }}
|
{{ $t('fullname') }}
|
||||||
</span>
|
</span>
|
||||||
|
<span v-if="col.label === '' && !!addButton">
|
||||||
|
<AddButton icon-only @click.stop="() => $emit('add')" />
|
||||||
|
</span>
|
||||||
<span v-if="col.label !== ''">
|
<span v-if="col.label !== ''">
|
||||||
{{ $t(col.label) }}
|
{{ $t(col.label) }}
|
||||||
</span>
|
</span>
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,8 @@ const currentPageBranch = ref<number>(1);
|
||||||
const maxPageBranch = ref<number>(1);
|
const maxPageBranch = ref<number>(1);
|
||||||
const pageSizeBranch = ref<number>(30);
|
const pageSizeBranch = ref<number>(30);
|
||||||
|
|
||||||
|
const statusEmployeeCreate = defineModel<boolean>('statusEmployeeCreate');
|
||||||
|
|
||||||
const prop = withDefaults(
|
const prop = withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
index?: string | number;
|
index?: string | number;
|
||||||
|
|
@ -84,12 +86,13 @@ const prop = withDefaults(
|
||||||
color: 'green',
|
color: 'green',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
const currentBranchEmployee = ref<string>('');
|
||||||
const listEmployee = ref<Employee[]>([]);
|
const listEmployee = ref<Employee[]>([]);
|
||||||
|
|
||||||
const customerId = defineModel<string>('customerId', { required: true });
|
const customerId = defineModel<string>('customerId', { required: true });
|
||||||
|
|
||||||
defineEmits<{
|
defineEmits<{
|
||||||
|
(e: 'addEmployee', currentBranch: CustomerBranch): void;
|
||||||
(e: 'back'): void;
|
(e: 'back'): void;
|
||||||
(e: 'viewDetail', branch: CustomerBranch, index: number): void;
|
(e: 'viewDetail', branch: CustomerBranch, index: number): void;
|
||||||
(e: 'dialog'): void;
|
(e: 'dialog'): void;
|
||||||
|
|
@ -210,6 +213,14 @@ function openEmployerBranchForm(formType: 'create' | 'edit' | 'info') {
|
||||||
customerBranchFormState.value.dialogModal = true;
|
customerBranchFormState.value.dialogModal = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function fetchEmployee(branchId: string) {
|
||||||
|
const res = await fetchBranchEmployee(branchId);
|
||||||
|
|
||||||
|
if (res) {
|
||||||
|
listEmployee.value = res.data.result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await fetchList();
|
await fetchList();
|
||||||
});
|
});
|
||||||
|
|
@ -217,6 +228,19 @@ onMounted(async () => {
|
||||||
watch([customerId, inputSearch, currentStatus], async () => {
|
watch([customerId, inputSearch, currentStatus], async () => {
|
||||||
await fetchList();
|
await fetchList();
|
||||||
});
|
});
|
||||||
|
watch(
|
||||||
|
() => statusEmployeeCreate.value,
|
||||||
|
async () => {
|
||||||
|
if (statusEmployeeCreate.value) {
|
||||||
|
await fetchEmployee(currentBranchEmployee.value);
|
||||||
|
|
||||||
|
const br = branch.value?.find(
|
||||||
|
(v) => v.id === currentBranchEmployee.value,
|
||||||
|
);
|
||||||
|
if (br) br._count.employee += 1;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -487,20 +511,17 @@ watch([customerId, inputSearch, currentStatus], async () => {
|
||||||
flat
|
flat
|
||||||
@click.stop="
|
@click.stop="
|
||||||
async () => {
|
async () => {
|
||||||
const res = await fetchBranchEmployee(props.row.id);
|
currentBranchEmployee = props.row.id;
|
||||||
|
await fetchEmployee(currentBranchEmployee);
|
||||||
|
|
||||||
if (res) {
|
currentBtnOpen.map((v, i) => {
|
||||||
listEmployee = res.data.result;
|
if (i !== props.rowIndex) {
|
||||||
|
currentBtnOpen[i] = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
currentBtnOpen.map((v, i) => {
|
currentBtnOpen[props.rowIndex] =
|
||||||
if (i !== props.rowIndex) {
|
!currentBtnOpen[props.rowIndex];
|
||||||
currentBtnOpen[i] = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
currentBtnOpen[props.rowIndex] =
|
|
||||||
!currentBtnOpen[props.rowIndex];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
|
|
@ -537,6 +558,7 @@ watch([customerId, inputSearch, currentStatus], async () => {
|
||||||
<q-td colspan="100%" style="padding: 16px">
|
<q-td colspan="100%" style="padding: 16px">
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<TableEmpoloyee
|
<TableEmpoloyee
|
||||||
|
add-button
|
||||||
in-table
|
in-table
|
||||||
:list-employee="listEmployee"
|
:list-employee="listEmployee"
|
||||||
:columns-employee="columnsEmployee"
|
:columns-employee="columnsEmployee"
|
||||||
|
|
@ -550,6 +572,12 @@ watch([customerId, inputSearch, currentStatus], async () => {
|
||||||
'formDialogEmployeeNRCNo',
|
'formDialogEmployeeNRCNo',
|
||||||
'action',
|
'action',
|
||||||
]"
|
]"
|
||||||
|
@add="
|
||||||
|
() => {
|
||||||
|
statusEmployeeCreate = false;
|
||||||
|
$emit('addEmployee', props.row);
|
||||||
|
}
|
||||||
|
"
|
||||||
@history="(item) => {}"
|
@history="(item) => {}"
|
||||||
@view="
|
@view="
|
||||||
(item) => {
|
(item) => {
|
||||||
|
|
@ -627,7 +655,6 @@ watch([customerId, inputSearch, currentStatus], async () => {
|
||||||
"
|
"
|
||||||
@submit="
|
@submit="
|
||||||
async () => {
|
async () => {
|
||||||
console.log('asasd');
|
|
||||||
const res = await customerBranchFormStore.submitForm();
|
const res = await customerBranchFormStore.submitForm();
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,7 @@ import FormEmployeeOther from 'components/03_customer-management/FormEmployeeOth
|
||||||
import useOptionStore from 'stores/options';
|
import useOptionStore from 'stores/options';
|
||||||
import { DialogContainer, DialogHeader } from 'components/dialog';
|
import { DialogContainer, DialogHeader } from 'components/dialog';
|
||||||
import KebabAction from 'src/components/shared/KebabAction.vue';
|
import KebabAction from 'src/components/shared/KebabAction.vue';
|
||||||
|
import { nextTick } from 'vue';
|
||||||
|
|
||||||
const { t, locale } = useI18n();
|
const { t, locale } = useI18n();
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
|
|
@ -91,6 +92,7 @@ const employeeFormStore = useEmployeeForm();
|
||||||
const optionStore = useOptionStore();
|
const optionStore = useOptionStore();
|
||||||
const ocrStore = useOcrStore();
|
const ocrStore = useOcrStore();
|
||||||
|
|
||||||
|
const statusEmployeeCreate = ref<boolean>(false);
|
||||||
const mrz = ref<Awaited<ReturnType<typeof parseResultMRZ>>>();
|
const mrz = ref<Awaited<ReturnType<typeof parseResultMRZ>>>();
|
||||||
const tabFieldRequired = ref<{ [key: string]: (keyof CustomerBranchCreate)[] }>(
|
const tabFieldRequired = ref<{ [key: string]: (keyof CustomerBranchCreate)[] }>(
|
||||||
{
|
{
|
||||||
|
|
@ -1833,6 +1835,7 @@ const emptyCreateDialog = ref(false);
|
||||||
v-if="$route.name === 'CustomerBranchManagement'"
|
v-if="$route.name === 'CustomerBranchManagement'"
|
||||||
>
|
>
|
||||||
<BranchPage
|
<BranchPage
|
||||||
|
v-model:status-employee-create="statusEmployeeCreate"
|
||||||
v-if="currentCustomer"
|
v-if="currentCustomer"
|
||||||
:customer-type="currentCustomer.customerType"
|
:customer-type="currentCustomer.customerType"
|
||||||
:current-customer-name="
|
:current-customer-name="
|
||||||
|
|
@ -1850,6 +1853,13 @@ const emptyCreateDialog = ref(false);
|
||||||
v-model:customer-id="currentCustomer.id"
|
v-model:customer-id="currentCustomer.id"
|
||||||
v-model:mode-view="gridView"
|
v-model:mode-view="gridView"
|
||||||
@back="$router.push('/customer-management')"
|
@back="$router.push('/customer-management')"
|
||||||
|
@add-employee="
|
||||||
|
async (currentBranch) => {
|
||||||
|
createEmployeeForm();
|
||||||
|
await nextTick();
|
||||||
|
employeeFormState.formDataEmployeeOwner = { ...currentBranch };
|
||||||
|
}
|
||||||
|
"
|
||||||
v-model:branch="branch"
|
v-model:branch="branch"
|
||||||
v-model:current-customer-url-image="currentCustomer.imageUrl"
|
v-model:current-customer-url-image="currentCustomer.imageUrl"
|
||||||
/>
|
/>
|
||||||
|
|
@ -2301,7 +2311,7 @@ const emptyCreateDialog = ref(false);
|
||||||
if (employeeFormState.currentTab === 'other') {
|
if (employeeFormState.currentTab === 'other') {
|
||||||
await employeeFormStore.submitOther();
|
await employeeFormStore.submitOther();
|
||||||
}
|
}
|
||||||
|
statusEmployeeCreate = true;
|
||||||
employeeFormState.isEmployeeEdit = false;
|
employeeFormState.isEmployeeEdit = false;
|
||||||
employeeFormState.currentIndex = -1;
|
employeeFormState.currentIndex = -1;
|
||||||
|
|
||||||
|
|
@ -2582,7 +2592,7 @@ const emptyCreateDialog = ref(false);
|
||||||
separator
|
separator
|
||||||
title="form.field.basicInformation"
|
title="form.field.basicInformation"
|
||||||
:readonly="!employeeFormState.isEmployeeEdit"
|
:readonly="!employeeFormState.isEmployeeEdit"
|
||||||
:employee-owner-option="employeeStore.ownerOption"
|
:employee-owner-option="employeeStore.ownerOption || []"
|
||||||
v-model:customer-branch="employeeFormState.formDataEmployeeOwner"
|
v-model:customer-branch="employeeFormState.formDataEmployeeOwner"
|
||||||
v-model:employee-id="employeeFormState.currentEmployeeCode"
|
v-model:employee-id="employeeFormState.currentEmployeeCode"
|
||||||
v-model:nrc-no="currentFromDataEmployee.nrcNo"
|
v-model:nrc-no="currentFromDataEmployee.nrcNo"
|
||||||
|
|
|
||||||
|
|
@ -612,7 +612,6 @@ export const useEmployeeForm = defineStore('form-employee', () => {
|
||||||
provinceId: string;
|
provinceId: string;
|
||||||
districtId: string;
|
districtId: string;
|
||||||
subDistrictId: string;
|
subDistrictId: string;
|
||||||
zipCode: string;
|
|
||||||
}
|
}
|
||||||
| undefined;
|
| undefined;
|
||||||
ocr: boolean;
|
ocr: boolean;
|
||||||
|
|
@ -1126,7 +1125,6 @@ export const useEmployeeForm = defineStore('form-employee', () => {
|
||||||
|
|
||||||
currentFromDataEmployee.value = structuredClone(resetEmployeeData);
|
currentFromDataEmployee.value = structuredClone(resetEmployeeData);
|
||||||
|
|
||||||
|
|
||||||
state.value.currentIndexPassport =
|
state.value.currentIndexPassport =
|
||||||
(currentFromDataEmployee.value.employeePassport?.length || 0) - 1;
|
(currentFromDataEmployee.value.employeePassport?.length || 0) - 1;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ const useEmployeeStore = defineStore('api-employee', () => {
|
||||||
gender?: string;
|
gender?: string;
|
||||||
status?: Status;
|
status?: Status;
|
||||||
passport?: boolean;
|
passport?: boolean;
|
||||||
visa: boolean;
|
visa?: boolean;
|
||||||
zipCode?: string;
|
zipCode?: string;
|
||||||
customerId?: string;
|
customerId?: string;
|
||||||
}) {
|
}) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue