fix: 01 sub branch stat, hold dialog, tree table

This commit is contained in:
puriphatt 2024-07-19 04:16:07 +00:00
parent 61ccab506e
commit 97c5c88721

View file

@ -30,7 +30,7 @@ const $q = useQuasar();
const { t } = useI18n(); const { t } = useI18n();
const utilsStore = useUtilsStore(); const utilsStore = useUtilsStore();
const labelBtnStatus = ref<string>(t('all')); const holdDialog = ref(false);
const columns = [ const columns = [
{ {
@ -492,6 +492,11 @@ function changeTitle(
return ''; return '';
} }
function handleHold() {
if ($q.screen.gt.xs) return;
holdDialog.value = true;
}
watch(locale, () => { watch(locale, () => {
fieldSelectedBranch.value = { fieldSelectedBranch.value = {
label: t(`${fieldSelectedBranch.value.label}`), label: t(`${fieldSelectedBranch.value.label}`),
@ -524,13 +529,26 @@ watch(
style="transition: 0.1s ease-in-out" style="transition: 0.1s ease-in-out"
/> />
</div> </div>
<transition name="slide"> <transition name="slide">
<StatCard <StatCard
v-if="!hideStat" v-if="!hideStat"
class="q-pb-md" class="q-pb-md"
label-i18n label-i18n
:branch="stats" :branch="
expandedTree[0]
? [
{
...stats[1],
count: (() => {
const foundItem = treeData.find(
(i) => i.id === expandedTree[0],
);
return foundItem ? foundItem._count.branch : 0;
})(),
},
]
: stats
"
:dark="$q.dark.isActive" :dark="$q.dark.isActive"
/> />
</transition> </transition>
@ -568,10 +586,10 @@ watch(
<template v-slot:before> <template v-slot:before>
<div class="surface-1 column full-height"> <div class="surface-1 column full-height">
<div <div
class="row bordered-b text-weight-bold surface-3 items-center q-px-md q-py-sm" class="row no-wrap full-width bordered-b text-weight-bold surface-3 items-center q-px-md q-py-sm"
:style="`min-height: ${$q.screen.gt.sm ? '57px' : '100.8px'}`" :style="`min-height: ${$q.screen.gt.sm ? '57px' : '100.8px'}`"
> >
<div class="col">ดการสาขาทงหมด</div> <div class="col ellipsis-2-lines">ดการสาขาทงหมด</div>
<q-btn <q-btn
round round
flat flat
@ -601,20 +619,21 @@ watch(
</q-btn> </q-btn>
</div> </div>
<div class="col"> <div class="col full-width">
<div class="scroll q-pa-md"> <div class="q-pa-md">
<q-tree <q-tree
:nodes="treeData" :nodes="treeData"
node-key="id" node-key="id"
label-key="name" label-key="name"
children-key="branch" children-key="branch"
v-model:expanded="expandedTree"
color="transparent" color="transparent"
v-model:expanded="expandedTree"
style="color: var(--foreground)" style="color: var(--foreground)"
> >
<template #default-header="{ node }"> <template #default-header="{ node }">
<div <div
class="column full-width q-py-sm" class="full-width q-py-sm"
v-touch-hold.mouse="handleHold"
@click.stop=" @click.stop="
() => { () => {
if ( if (
@ -658,21 +677,29 @@ watch(
<div <div
class="row col items-center justify-between full-width no-wrap" class="row col items-center justify-between full-width no-wrap"
> >
<span <div class="col row">
:class="{ <span
'text-weight-bold': expandedTree[0] === node.id, class="ellipsis col-12"
'app-text-info': expandedTree[0] === node.id, style="white-space: nowrap"
}" :class="{
> 'text-weight-bold':
{{ node.name }} expandedTree[0] === node.id,
<div class="app-text-muted text-caption"> 'app-text-info': expandedTree[0] === node.id,
}"
>
{{ node.name }}
</span>
<span
class="app-text-muted text-caption ellipsis"
>
{{ node.code }} {{ node.code }}
</div> </span>
</span> </div>
<div <div
class="row q-gutter-xs items-center no-wrap" class="row q-gutter-xs items-center no-wrap"
@click.stop @click.stop
v-if="$q.screen.gt.xs"
> >
<q-btn <q-btn
v-if="node.isHeadOffice" v-if="node.isHeadOffice"
@ -1048,6 +1075,8 @@ watch(
id: '', id: '',
code: '', code: '',
}; };
expandedTree = [];
expandedTree.push(props.row.id);
} }
} }
" "
@ -1275,6 +1304,8 @@ watch(
id: '', id: '',
code: '', code: '',
}; };
expandedTree = [];
expandedTree.push(props.row.id);
} }
} }
" "
@ -1659,6 +1690,66 @@ watch(
</InfoForm> </InfoForm>
</template> </template>
</DrawerInfo> </DrawerInfo>
<q-dialog v-model="holdDialog" position="bottom">
<div class="surface-1 full-width rounded column" style="height: 280px">
<div class="flex q-py-sm justify-center full-width">
<div
class="rounded"
style="
width: 8%;
height: 4px;
background-color: hsla(0, 0%, 50%, 0.75);
"
></div>
</div>
<q-list>
<q-item clickable v-ripple>
<q-item-section avatar>
<q-icon name="mdi-file-plus" class="app-text-muted-2" />
</q-item-section>
<q-item-section>
{{ $t('formDialogTitleCreateSubBranch') }}
</q-item-section>
</q-item>
<q-item clickable v-ripple>
<q-item-section avatar>
<q-icon
name="mdi-eye-outline"
style="color: hsl(var(--green-6-hsl))"
/>
</q-item-section>
<q-item-section>{{ $t('viewDetail') }}</q-item-section>
</q-item>
<q-item clickable v-ripple>
<q-item-section avatar>
<q-icon
name="mdi-pencil-outline"
style="color: hsl(var(--cyan-6-hsl))"
/>
</q-item-section>
<q-item-section>{{ $t('edit') }}</q-item-section>
</q-item>
<q-item clickable v-ripple>
<q-item-section avatar>
<q-icon name="mdi-trash-can-outline" class="app-text-negative" />
</q-item-section>
<q-item-section>{{ $t('delete') }}</q-item-section>
</q-item>
<q-item clickable v-ripple>
<q-item-section avatar>
<q-toggle dense size="sm" :model-value="holdDialog" />
</q-item-section>
<q-item-section>{{ $t('switchOnLabel') }}</q-item-section>
</q-item>
</q-list>
</div>
</q-dialog>
</template> </template>
<style scoped> <style scoped>