refactor: quotation tree view

This commit is contained in:
puriphatt 2024-10-01 09:53:24 +07:00
parent fde6335706
commit 009d5d8adf
2 changed files with 52 additions and 15 deletions

View file

@ -393,7 +393,10 @@ async function openProductServiceTree(node: Node, anchestor?: Node[]) {
id: w.id, id: w.id,
title: w.name, title: w.name,
subtitle: ' ', subtitle: ' ',
attributes: w.attributes, attributes: {
additional: w.attributes.additional,
showTotalPrice: w.attributes.showTotalPrice,
},
type: 'work', type: 'work',
displayDropIcon: w.productOnWork.length > 0, displayDropIcon: w.productOnWork.length > 0,
children: w.productOnWork.map((p) => ({ children: w.productOnWork.map((p) => ({

View file

@ -2,12 +2,7 @@
import DialogForm from 'src/components/DialogForm.vue'; import DialogForm from 'src/components/DialogForm.vue';
import { onMounted, ref, watch } from 'vue'; import { onMounted, ref, watch } from 'vue';
import TreeView from 'src/components/shared/TreeView.vue'; import TreeView from 'src/components/shared/TreeView.vue';
import useOptionStore from 'stores/options';
import {
ProductGroup,
ProductList,
Service,
} from 'src/stores/product-service/types';
type Node = { type Node = {
[key: string]: any; [key: string]: any;
@ -23,6 +18,7 @@ defineEmits<{
(e: 'open', node: Node, ancestorNode?: Node[]): void; (e: 'open', node: Node, ancestorNode?: Node[]): void;
}>(); }>();
const optionStore = useOptionStore();
const model = defineModel<boolean>(); const model = defineModel<boolean>();
const inputSearch = defineModel<string>('inputSearch'); const inputSearch = defineModel<string>('inputSearch');
const nodes = defineModel<Node[]>('nodes', { default: [] }); const nodes = defineModel<Node[]>('nodes', { default: [] });
@ -84,9 +80,25 @@ watch(
{{ $t('productService.group.title') }} {{ $t('productService.group.title') }}
</span> </span>
</header> </header>
<article class="surface-1 col"> <article class="surface-1 col q-pa-md scroll">
<!-- TODO: tree component --> <nav
waiting for tree v-for="node in nodes"
:key="node.id"
:class="{ 'active-nav': currentSelectedNode.includes(node) }"
class="column q-py-xs q-px-md rounded q-mb-sm cursor-pointer"
@click.stop="
() => {
toggleSelected(node);
$emit('open', node);
node.opened = !node.opened;
}
"
>
<span style="font-weight: 600">{{ node.title }}</span>
<span class="text-caption app-text-muted">
{{ node.subtitle }}
</span>
</nav>
</article> </article>
</section> </section>
</template> </template>
@ -253,7 +265,7 @@ watch(
</q-tab> </q-tab>
</q-tabs> </q-tabs>
<div class="q-pa-md column"> <div class="q-pa-md column scroll">
<span v-if="currentTab === '1'"> <span v-if="currentTab === '1'">
<span class="app-text-muted"> <span class="app-text-muted">
{{ {{
@ -269,7 +281,9 @@ watch(
}) })
}} }}
</span> </span>
<aside class="surface-3 q-pa-md">-</aside> <aside class="surface-3 q-pa-md">
{{ currentSelectedNode[0].detail || '-' }}
</aside>
</span> </span>
<span v-if="currentTab === '2'"> <span v-if="currentTab === '2'">
@ -291,11 +305,26 @@ watch(
v-if="currentSelectedType !== 'work'" v-if="currentSelectedType !== 'work'"
class="surface-3 q-pa-md" class="surface-3 q-pa-md"
> >
- {{ currentSelectedNode[0].remark || '-' }}
</aside> </aside>
<aside v-else class="q-pt-md row q-gutter-sm"> <aside v-else class="q-pt-md row q-gutter-sm">
<div class="bordered q-py-xs q-px-sm rounded"> <template
นทกบรการ_Name v-if="
currentSelectedNode[0].attributes.additional
.length > 0
"
>
<div
v-for="att in currentSelectedNode[0].attributes
.additional"
:key="att"
class="bordered q-py-xs q-px-sm rounded"
>
{{ optionStore.mapOption(att.fieldName) }}
</div>
</template>
<div v-else>
{{ $t('productService.service.noProperties') }}
</div> </div>
</aside> </aside>
</span> </span>
@ -326,4 +355,9 @@ watch(
.info-slide-leave-to { .info-slide-leave-to {
transform: translate(100%, 0); transform: translate(100%, 0);
} }
.active-nav {
background: hsla(var(--info-bg) / 0.1);
color: hsl(var(--info-bg));
}
</style> </style>