feat: search employee

This commit is contained in:
oat_dev 2024-06-13 11:48:08 +07:00
parent c5a44034f0
commit 48a4c6492c

View file

@ -637,6 +637,7 @@ async function onSubmitCustomerBranch() {
}
const resultSearch = ref<(Customer & { branch: CustomerBranch[] })[]>();
const resultSearchEmployee = ref();
async function searchCustomer() {
const resultList = await fetchList({
@ -649,6 +650,16 @@ async function searchCustomer() {
}
}
async function searchEmployee() {
const resultList = await employeeStore.fetchList({
query: inputSearch.value,
});
if (resultList) {
resultSearchEmployee.value = resultList.result;
}
}
async function fetchListCustomer() {
const resultList = await fetchList({
includeBranch: true,
@ -1129,7 +1140,9 @@ watch(fieldSelectedCustomer, async () => {
:bg-color="$q.dark.isActive ? 'dark' : 'white'"
v-model="inputSearch"
debounce="500"
@update:model-value="searchCustomer()"
@update:model-value="
selectorLabel === 'EMPLOYEE' ? searchEmployee() : searchCustomer()
"
/>
<q-btn
@ -1266,27 +1279,29 @@ watch(fieldSelectedCustomer, async () => {
<div>
<PersonCard
:list="
listEmployee.map((v: Employee) => ({
img: v.profileImageUrl,
id: v.id,
name:
$i18n.locale === 'en-US'
? `${v.firstNameEN} ${v.lastNameEN}`
: `${v.firstName} ${v.lastName}`,
male: v.gender === 'male',
female: v.gender === 'female',
badge: v.code,
detail: [
{
label: $t('personnelCardNationality'),
value: v.nationality,
},
{
label: $t('personnelCardAge'),
value: calculateAge(v.dateOfBirth),
},
],
})) || []
(!!inputSearch ? resultSearchEmployee : listEmployee).map(
(v: Employee) => ({
img: v.profileImageUrl,
id: v.id,
name:
$i18n.locale === 'en-US'
? `${v.firstNameEN} ${v.lastNameEN}`
: `${v.firstName} ${v.lastName}`,
male: v.gender === 'male',
female: v.gender === 'female',
badge: v.code,
detail: [
{
label: $t('personnelCardNationality'),
value: v.nationality,
},
{
label: $t('personnelCardAge'),
value: calculateAge(v.dateOfBirth),
},
],
}),
) || []
"
@update-card="openDialogInputForm"
@enter-card="openDialogInputForm"