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