refactor: view detail on hq and br

This commit is contained in:
Methapon2001 2024-04-11 09:43:48 +07:00
parent f618766d54
commit f310b6fe19

View file

@ -378,15 +378,20 @@ async function submitForm(
} }
} }
async function fetchCard(id: string) { async function fetchCard(id: string, drawer = false) {
const result = await branchStore.fetchById<Branch>(id); const result = await branchStore.fetchById<Branch>(id);
if (result) { if (result) {
showCurrentBranch.value = result; showCurrentBranch.value = result;
openCardDetails.value = true;
openTableCard.value = false; if (drawer) openBranchDrawer.value = true;
else {
openCardDetails.value = true;
openTableCard.value = false;
}
} }
} }
async function fetchSubBranch(id: string) { async function fetchSubBranch(id: string) {
const result = await branchStore.fetchById<BranchWithChildren>(id, { const result = await branchStore.fetchById<BranchWithChildren>(id, {
includeSubBranch: true, includeSubBranch: true,
@ -436,7 +441,7 @@ onMounted(async () => {
class="q-mb-md" class="q-mb-md"
:class="{ 'bg-card-branch-title': $q.dark.isActive }" :class="{ 'bg-card-branch-title': $q.dark.isActive }"
> >
<StatCardComponent :branch="branchStats" /> <StatCardComponent :branch="branchStats" :dark="$q.dark.isActive" />
</AppBox> </AppBox>
<AppBox bordered style="width: 100%" v-if="!branchData?.total"> <AppBox bordered style="width: 100%" v-if="!branchData?.total">
@ -704,7 +709,7 @@ onMounted(async () => {
<AppBox> <AppBox>
<TableCardComponent <TableCardComponent
@navigate="(v) => fetchSubBranch(v.id)" @navigate="(v) => fetchSubBranch(v.id)"
@show-info="(v) => fetchCard(v.id)" @show-info="(v) => fetchCard(v.id, !subBranch)"
:sub-branch="subBranch" :sub-branch="subBranch"
:rows="rowsBranch" :rows="rowsBranch"
/> />
@ -726,8 +731,9 @@ onMounted(async () => {
</div> </div>
<DetailBranchDrawerComponent <DetailBranchDrawerComponent
v-if="showCurrentBranch"
v-model:open="openBranchDrawer" v-model:open="openBranchDrawer"
:data="showCurrentBranch as Branch" :data="showCurrentBranch"
/> />
<FormDialog <FormDialog