fix: new 02 ui & layout

This commit is contained in:
puriphatt 2024-07-05 11:01:40 +00:00
parent 70f3959c08
commit 701d82e7a7
2 changed files with 296 additions and 91 deletions

View file

@ -76,6 +76,9 @@ const defaultFormData = {
checkpointEN: null, checkpointEN: null,
}; };
const modeView = ref(true);
const fieldSelected = ref();
const fieldDisplay = ref();
const hideStat = ref(false); const hideStat = ref(false);
const userCode = ref<string>(); const userCode = ref<string>();
const currentUser = ref<User>(); const currentUser = ref<User>();
@ -91,7 +94,7 @@ const statusToggle = ref(true);
const statusFilter = ref<'all' | 'statusACTIVE' | 'statusINACTIVE'>('all'); const statusFilter = ref<'all' | 'statusACTIVE' | 'statusINACTIVE'>('all');
const inputSearch = ref(''); const inputSearch = ref('');
const userId = ref<string>(); const userId = ref<string>();
const selectorLabel = ref<string>('MESSENGER'); const selectorLabel = ref<string>('ALL');
const hqId = ref<string>(); const hqId = ref<string>();
const brId = ref<string>(); const brId = ref<string>();
const formDialogRef = ref(); const formDialogRef = ref();
@ -459,11 +462,11 @@ onMounted(async () => {
: ''; : '';
typeStats.value = await userStore.typeStats(); typeStats.value = await userStore.typeStats();
const firstTypeIncludeUser = Object.entries(typeStats.value || {}).find( // const firstTypeIncludeUser = Object.entries(typeStats.value || {}).find(
(v) => v[1] > 0, // (v) => v[1] > 0,
); // );
firstTypeIncludeUser && (selectorLabel.value = firstTypeIncludeUser[0]); // firstTypeIncludeUser && (selectorLabel.value = firstTypeIncludeUser[0]);
const res = await branchStore.userStats(formData.value.userType); const res = await branchStore.userStats(formData.value.userType);
if (res) { if (res) {
@ -513,7 +516,7 @@ async function fetchUserList() {
pageSize: pageSize.value, pageSize: pageSize.value,
page: currentPage.value, page: currentPage.value,
query: !!inputSearch.value ? inputSearch.value : undefined, query: !!inputSearch.value ? inputSearch.value : undefined,
userType: selectorLabel.value ?? undefined, userType: selectorLabel.value === 'ALL' ? undefined : selectorLabel.value,
}); });
} }
@ -538,8 +541,23 @@ watch(inputSearch, async () => await fetchUserList());
<div class="column full-height no-wrap"> <div class="column full-height no-wrap">
<div class="text-body-2 q-mb-xs flex items-center"> <div class="text-body-2 q-mb-xs flex items-center">
{{ $t('personnelStatTitle') }} {{ $t('personnelStatTitle') }}
<q-badge
v-if="typeStats"
rounded
class="q-ml-sm"
style="
background-color: hsla(var(--info-bg) / 0.15);
color: hsl(var(--info-bg));
"
>
{{
selectorLabel === 'ALL'
? Object.values(typeStats).reduce((acc, val) => acc + val, 0)
: typeStats[selectorLabel]
}}
</q-badge>
<q-btn <q-btn
class="q-ml-xs" class="q-ml-sm"
icon="mdi-pin" icon="mdi-pin"
color="primary" color="primary"
size="sm" size="sm"
@ -556,22 +574,39 @@ watch(inputSearch, async () => await fetchUserList());
<div v-if="!hideStat" class="scroll q-mb-md"> <div v-if="!hideStat" class="scroll q-mb-md">
<div style="display: inline-block"> <div style="display: inline-block">
<StatCardComponent <StatCardComponent
v-if="typeStats" v-if="typeStats && userData?.result"
labelI18n
:branch=" :branch="
Object.entries(typeStats).map(([key, val]) => ({ selectorLabel === 'ALL'
count: val, ? Object.entries(typeStats).map(([key, val]) => ({
label: key, count: val,
icon: 'mdi-account', label: key,
color: icon: 'mdi-account',
( color:
(
{
USER: 'cyan',
MESSENGER: 'yellow',
DELEGATE: 'red',
AGENCY: 'magenta',
} as const
)[key] || 'pink',
}))
: [
{ {
USER: 'cyan', label: selectorLabel,
MESSENGER: 'yellow', count: typeStats[selectorLabel],
DELEGATE: 'red', icon: 'mdi-account',
AGENCY: 'magenta', color:
} as const selectorLabel === 'USER'
)[key] || 'pink', ? 'cyan'
})) : selectorLabel === 'MESSENGER'
? 'yellow'
: selectorLabel === 'DELEGATE'
? 'red'
: 'magenta',
},
]
" "
:dark="$q.dark.isActive" :dark="$q.dark.isActive"
/> />
@ -584,65 +619,234 @@ watch(inputSearch, async () => await fetchUserList());
class="col surface-1 rounded justify-between column no-wrap" class="col surface-1 rounded justify-between column no-wrap"
style="overflow: hidden" style="overflow: hidden"
> >
<div class="surface-2 bordered-b q-px-md q-py-sm"> <div class="column">
<div class="row justify-end" style="gap: var(--size-2)"> <div
<q-input class="row surface-3 bordered-b justify-between full-width items-center surface-1"
for="input-search" style="z-index: 1"
style="width: 250px" >
outlined <div class="row q-py-sm q-px-md justify-between full-width">
<q-input
for="input-search"
outlined
dense
style="width: 250px"
:label="$t('search')"
class="q-mr-md"
:bg-color="$q.dark.isActive ? 'dark' : 'white'"
v-model="inputSearch"
debounce="200"
>
<template #prepend>
<q-icon name="mdi-magnify" />
</template>
</q-input>
<div class="row">
<q-select
v-model="statusFilter"
outlined
dense
option-value="value"
option-label="label"
class="q-pr-md"
map-options
emit-value
:options="[
{ label: $t('all'), value: 'all' },
{ label: $t('statusACTIVE'), value: 'statusACTIVE' },
{ label: $t('statusINACTIVE'), value: 'statusINACTIVE' },
]"
></q-select>
<q-select
id="select-field"
for="select-field"
:options="[
{ label: 'กันว่าง 1', value: 'กันว่าง 1' },
{ label: 'กันว่าง 2', value: 'กันว่าง 2' },
]"
:display-value="$t('displayField')"
v-model="fieldSelected"
option-label="label"
option-value="value"
map-options
emit-value
outlined
multiple
dense
/>
<q-btn-toggle
id="btn-mode"
v-model="modeView"
dense
class="no-shadow bordered rounded surface-1 q-ml-md"
:toggle-color="$q.dark.isActive ? 'grey-9' : 'grey-2'"
size="xs"
:options="[
{ value: true, slot: 'folder' },
{ value: false, slot: 'list' },
]"
>
<template v-slot:folder>
<q-icon
name="mdi-view-grid-outline"
size="16px"
class="q-px-sm q-py-xs rounded"
:style="{
color: $q.dark.isActive
? modeView
? '#C9D3DB '
: '#787B7C'
: modeView
? '#787B7C'
: '#C9D3DB',
}"
/>
</template>
<template v-slot:list>
<q-icon
name="mdi-format-list-bulleted"
class="q-px-sm q-py-xs rounded"
size="16px"
:style="{
color: $q.dark.isActive
? modeView === false
? '#C9D3DB'
: '#787B7C'
: modeView === false
? '#787B7C'
: '#C9D3DB',
}"
/>
</template>
</q-btn-toggle>
</div>
</div>
</div>
<div class="surface-2 bordered-b q-px-md">
<q-tabs
dense dense
:label="$t('search')" v-model="selectorLabel"
debounce="500" align="left"
v-model="inputSearch" class="full-height"
></q-input> active-color="info"
<q-btn
id="btn-filter"
icon="mdi-tune-vertical-variant"
size="sm"
class="bordered rounded surface-1"
:class="{ 'app-text-info': statusFilter !== 'all' }"
unelevated
> >
<q-menu class="bordered"> <q-tab
<q-list v-close-popup dense> name="employer"
<q-item @click="
id="btn-filter-all" async () => {
clickable currentPage = 1;
class="flex items-center" inputSearch = '';
:class="{ 'app-text-info': statusFilter === 'all' }" selectorLabel = 'ALL';
@click="statusFilter = 'all'" statusFilter = 'all';
> flowStore.rotate();
{{ $t('all') }} }
</q-item> "
<q-item >
id="btn-filter-active" <div
clickable class="row"
class="flex items-center" :class="
:class="{ selectorLabel === 'ALL' ? 'text-bold' : 'app-text-muted'
'app-text-info': statusFilter === 'statusACTIVE', "
}" >
@click="statusFilter = 'statusACTIVE'" {{ $t('all') }}
> </div>
{{ $t('statusACTIVE') }} </q-tab>
</q-item> <q-tab
<q-item name="employee"
id="btn-filter-inactive" @click="
clickable async () => {
class="flex items-center" selectorLabel = 'USER';
:class="{ statusFilter = 'all';
'app-text-info': statusFilter === 'statusINACTIVE', currentPage = 1;
}" inputSearch = '';
@click="statusFilter = 'statusINACTIVE'" flowStore.rotate();
> }
{{ $t('statusINACTIVE') }} "
</q-item> >
</q-list> <div
</q-menu> class="row"
</q-btn> :class="
selectorLabel === 'USER' ? 'text-bold' : 'app-text-muted'
"
>
{{ $t('USER') }}
</div>
</q-tab>
<q-tab
name="MESSENGER"
@click="
async () => {
selectorLabel = 'MESSENGER';
statusFilter = 'all';
currentPage = 1;
inputSearch = '';
flowStore.rotate();
}
"
>
<div
class="row"
:class="
selectorLabel === 'MESSENGER' ? 'text-bold' : 'app-text-muted'
"
>
{{ $t('MESSENGER') }}
</div>
</q-tab>
<q-tab
name="DELEGATE"
@click="
async () => {
selectorLabel = 'DELEGATE';
statusFilter = 'all';
currentPage = 1;
inputSearch = '';
flowStore.rotate();
}
"
>
<div
class="row"
:class="
selectorLabel === 'DELEGATE' ? 'text-bold' : 'app-text-muted'
"
>
{{ $t('DELEGATE') }}
</div>
</q-tab>
<q-tab
name="AGENCY"
@click="
async () => {
selectorLabel = 'AGENCY';
statusFilter = 'all';
currentPage = 1;
inputSearch = '';
flowStore.rotate();
}
"
>
<div
class="row"
:class="
selectorLabel === 'AGENCY' ? 'text-bold' : 'app-text-muted'
"
>
{{ $t('AGENCY') }}
</div>
</q-tab>
</q-tabs>
</div> </div>
</div> </div>
<div class="col scroll">
<div class="q-pa-md q-col-gutter-md row"> <div class="col scroll column">
<div
v-if="userData && userData.total > 0 && !inputSearch"
class="q-pa-md q-col-gutter-md row"
>
<div <div
v-for="v in userData?.result.filter((v) => { v-for="v in userData?.result.filter((v) => {
if (statusFilter === 'statusACTIVE' && v.status === 'INACTIVE') { if (statusFilter === 'statusACTIVE' && v.status === 'INACTIVE') {
@ -704,31 +908,31 @@ watch(inputSearch, async () => await fetchUserList());
/> />
</div> </div>
</div> </div>
<template v-if="userData && userData.total === 0 && !inputSearch">
<div class="col-1 self-end"> <div
<div class="row"> v-if="userData && userData.total === 0 && !inputSearch"
<TooltipComponent class="col column"
title="personnelTooltipTitle" >
caption="personnelTooltipCaption" <div class="flex justify-end q-pa-md">
imgSrc="personnel-table-" <TooltipComponent
/> title="personnelTooltipTitle"
</div> caption="personnelTooltipCaption"
imgSrc="personnel-table-"
/>
</div> </div>
<div
class="col self-center" <div class="col items-center flex justify-center">
style="display: flex; flex-grow: 1; align-items: center"
>
<AddButton <AddButton
:label="'personnelAdd'" :label="'personnelAdd'"
:cyanOn="true" :cyanOn="true"
@trigger="openDialog('FORM')" @trigger="openDialog('FORM')"
/> />
</div> </div>
</template> </div>
<div <div
v-if="userData?.total === 0 && !!inputSearch" v-if="userData?.total === 0 && !!inputSearch"
class="row full-width items-center justify-center" class="row col full-width items-center justify-center"
style="min-height: 250px" style="min-height: 250px"
> >
<NoData :not-found="!!inputSearch" /> <NoData :not-found="!!inputSearch" />

View file

@ -97,6 +97,7 @@ export type UserAttachmentDelete = {
}; };
export type UserTypeStats = { export type UserTypeStats = {
[x: string]: number;
USER: number; USER: number;
MESSENGER: number; MESSENGER: number;
DELEGATE: number; DELEGATE: number;