feat: toggle status and filter text
This commit is contained in:
parent
66b603a7f1
commit
05a6bed15b
1 changed files with 98 additions and 23 deletions
|
|
@ -63,6 +63,8 @@ const urlProfile = ref<string>();
|
||||||
const isEdit = ref(false);
|
const isEdit = ref(false);
|
||||||
const modal = ref(false);
|
const modal = ref(false);
|
||||||
const status = ref(false);
|
const status = ref(false);
|
||||||
|
const statusFilter = ref<'all' | 'statusACTIVE' | 'statusINACTIVE'>('all');
|
||||||
|
const inputSearch = ref('');
|
||||||
const userId = ref('');
|
const userId = ref('');
|
||||||
const selectorLabel = ref('');
|
const selectorLabel = ref('');
|
||||||
const hqId = ref('');
|
const hqId = ref('');
|
||||||
|
|
@ -287,6 +289,17 @@ function mapUserType(label: string) {
|
||||||
formData.value.userType = userTypeMap[label];
|
formData.value.userType = userTypeMap[label];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function toggleStatus(id: string) {
|
||||||
|
const record = userData.value?.result.find((v) => v.id === id);
|
||||||
|
|
||||||
|
if (!record) return;
|
||||||
|
|
||||||
|
const res = await userStore.editById(record.id, {
|
||||||
|
status: record.status !== 'INACTIVE' ? 'INACTIVE' : 'ACTIVE',
|
||||||
|
});
|
||||||
|
if (res) record.status = res.status;
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await userStore.fetchList({ includeBranch: true });
|
await userStore.fetchList({ includeBranch: true });
|
||||||
userStore.userOption.roleOpts.length === 0
|
userStore.userOption.roleOpts.length === 0
|
||||||
|
|
@ -370,32 +383,94 @@ watch(
|
||||||
|
|
||||||
<!-- main -->
|
<!-- main -->
|
||||||
<AppBox bordered style="width: 100%; height: 70vh; overflow-y: auto">
|
<AppBox bordered style="width: 100%; height: 70vh; overflow-y: auto">
|
||||||
|
<div class="row q-mb-md justify-between">
|
||||||
|
<q-btn
|
||||||
|
icon="mdi-tune-vertical-variant"
|
||||||
|
class="bordered rounded"
|
||||||
|
:class="{ 'app-text-info': statusFilter !== 'all' }"
|
||||||
|
unelevated
|
||||||
|
>
|
||||||
|
<q-menu class="bordered">
|
||||||
|
<q-list v-close-popup dense>
|
||||||
|
<q-item
|
||||||
|
clickable
|
||||||
|
class="flex items-center"
|
||||||
|
:class="{ 'app-text-info': statusFilter === 'all' }"
|
||||||
|
@click="statusFilter = 'all'"
|
||||||
|
>
|
||||||
|
{{ $t('all') }}
|
||||||
|
</q-item>
|
||||||
|
<q-item
|
||||||
|
clickable
|
||||||
|
class="flex items-center"
|
||||||
|
:class="{
|
||||||
|
'app-text-info': statusFilter === 'statusACTIVE',
|
||||||
|
}"
|
||||||
|
@click="statusFilter = 'statusACTIVE'"
|
||||||
|
>
|
||||||
|
{{ $t('statusACTIVE') }}
|
||||||
|
</q-item>
|
||||||
|
<q-item
|
||||||
|
clickable
|
||||||
|
class="flex items-center"
|
||||||
|
:class="{
|
||||||
|
'app-text-info': statusFilter === 'statusINACTIVE',
|
||||||
|
}"
|
||||||
|
@click="statusFilter = 'statusINACTIVE'"
|
||||||
|
>
|
||||||
|
{{ $t('statusINACTIVE') }}
|
||||||
|
</q-item>
|
||||||
|
</q-list>
|
||||||
|
</q-menu>
|
||||||
|
</q-btn>
|
||||||
|
<q-input
|
||||||
|
style="width: 250px"
|
||||||
|
outlined
|
||||||
|
dense
|
||||||
|
label="ค้นหา"
|
||||||
|
v-model="inputSearch"
|
||||||
|
></q-input>
|
||||||
|
</div>
|
||||||
<PersonCard
|
<PersonCard
|
||||||
:list="
|
:list="
|
||||||
userData?.result.map((v) => ({
|
userData?.result
|
||||||
id: v.id,
|
.filter((v) => {
|
||||||
img: `${v.profileImageUrl}`,
|
if (statusFilter === 'statusACTIVE' && v.status === 'INACTIVE') {
|
||||||
name:
|
return false;
|
||||||
$i18n.locale === 'en-US'
|
}
|
||||||
? `${v.firstNameEN} ${v.lastNameEN}`
|
if (
|
||||||
: `${v.firstName} ${v.lastName}`,
|
statusFilter === 'statusINACTIVE' &&
|
||||||
male: v.gender === 'male',
|
v.status !== 'INACTIVE'
|
||||||
female: v.gender === 'female',
|
) {
|
||||||
detail: [
|
return false;
|
||||||
{ label: 'ประเภท', value: $t(v.userType) },
|
}
|
||||||
{ label: 'โทรศัพท์', value: v.telephoneNo },
|
return true;
|
||||||
{
|
})
|
||||||
label: 'อายุ',
|
.map((v) => ({
|
||||||
value: userStore.calculateAge(v.birthDate as Date),
|
id: v.id,
|
||||||
},
|
img: `${v.profileImageUrl}`,
|
||||||
],
|
name:
|
||||||
badge: v.code,
|
$i18n.locale === 'en-US'
|
||||||
disabled: v.status === 'INACTIVE',
|
? `${v.firstNameEN} ${v.lastNameEN}`
|
||||||
})) || []
|
: `${v.firstName} ${v.lastName}`,
|
||||||
|
male: v.gender === 'male',
|
||||||
|
female: v.gender === 'female',
|
||||||
|
detail: [
|
||||||
|
{ label: 'ประเภท', value: $t(v.userType) },
|
||||||
|
{ label: 'โทรศัพท์', value: v.telephoneNo },
|
||||||
|
{
|
||||||
|
label: 'อายุ',
|
||||||
|
value: userStore.calculateAge(v.birthDate as Date),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
badge: v.code,
|
||||||
|
disabled: v.status === 'INACTIVE',
|
||||||
|
})) || []
|
||||||
"
|
"
|
||||||
@updateCard="openDialog"
|
@update-card="openDialog"
|
||||||
@deleteCard="onDelete"
|
@delete-card="onDelete"
|
||||||
@enterCard="cardClick"
|
@enter-card="cardClick"
|
||||||
|
@toggle-status="toggleStatus"
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
class="column"
|
class="column"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue