refactor: add go inside/outside by Product Group

This commit is contained in:
Net 2024-07-23 10:24:22 +07:00
parent eec539be7d
commit 7f67e787bc

View file

@ -151,8 +151,8 @@ const treeProductTypeAndGroup = computed(() => {
...item, ...item,
type: 'group', type: 'group',
children: children:
item.id === currentId.value item.id === currentIdGrop.value
? recordTreeProductType.value[currentId.value]?.map((x) => ({ ? recordTreeProductType.value[currentIdGrop.value]?.map((x) => ({
...x, ...x,
type: 'type', type: 'type',
})) ?? [] })) ?? []
@ -404,7 +404,7 @@ const totalGroup = ref<number>(0);
const total = ref<number>(0); const total = ref<number>(0);
// id // id
const currentId = ref<string>(''); const currentIdGrop = ref<string>('');
const currentIdType = ref<string>(''); const currentIdType = ref<string>('');
const currentIdService = ref<string>(''); const currentIdService = ref<string>('');
const currentIdProduct = ref<string>(''); const currentIdProduct = ref<string>('');
@ -495,7 +495,7 @@ async function fetchListType() {
page: currentPageType.value, page: currentPageType.value,
pageSize: pageSizeType.value, pageSize: pageSizeType.value,
query: !!inputSearch.value ? inputSearch.value : undefined, query: !!inputSearch.value ? inputSearch.value : undefined,
productGroupId: currentId.value, productGroupId: currentIdGrop.value,
status: status:
currentStatus.value === 'All' currentStatus.value === 'All'
? undefined ? undefined
@ -631,13 +631,13 @@ async function submitType() {
if (drawerInfo.value) { if (drawerInfo.value) {
await editProductServiceType(currentIdType.value, { await editProductServiceType(currentIdType.value, {
...formDataGroup.value, ...formDataGroup.value,
productGroupId: currentId.value, productGroupId: currentIdGrop.value,
}); });
drawerInfo.value = false; drawerInfo.value = false;
} else { } else {
dialogInputForm.value = false; dialogInputForm.value = false;
const res = await createProductServiceType( const res = await createProductServiceType(
currentId.value, currentIdGrop.value,
formDataGroup.value, formDataGroup.value,
); );
@ -799,7 +799,9 @@ async function deleteProductById(productId?: string) {
} }
if (editByTree.value === 'group') { if (editByTree.value === 'group') {
// Product Group // Product Group
const res = await deleteProductService(productId ?? currentId.value); const res = await deleteProductService(
productId ?? currentIdGrop.value,
);
if (res) { if (res) {
} }
await fetchListGroups(); await fetchListGroups();
@ -817,7 +819,9 @@ async function deleteProductById(productId?: string) {
} }
if (productMode.value === 'group') { if (productMode.value === 'group') {
// Product Group // Product Group
const res = await deleteProductService(productId ?? currentId.value); const res = await deleteProductService(
productId ?? currentIdGrop.value,
);
if (res) { if (res) {
} }
await fetchListGroups(); await fetchListGroups();
@ -1093,7 +1097,7 @@ async function submitProduct() {
async function submitGroup() { async function submitGroup() {
if (drawerInfo.value) { if (drawerInfo.value) {
await editProductService(currentId.value, formDataGroup.value); await editProductService(currentIdGrop.value, formDataGroup.value);
} else { } else {
const res = await createProductService(formDataGroup.value); const res = await createProductService(formDataGroup.value);
@ -1215,6 +1219,16 @@ function cloneData() {
}); });
} }
async function enterGroup(id: string, name: string) {
expandedTree.value = [];
expandedTree.value.push(id);
pathGroupName.value = name;
currentIdGrop.value = id;
await fetchListType();
productMode.value = 'type';
flowStore.rotate();
}
function handleHold(node: ProductGroup) { function handleHold(node: ProductGroup) {
if ($q.screen.gt.xs) return; if ($q.screen.gt.xs) return;
return function (props: unknown) { return function (props: unknown) {
@ -1229,6 +1243,8 @@ onMounted(async () => {
{ {
text: 'manage', text: 'manage',
handler: () => { handler: () => {
expandedTree.value = [];
currentIdGrop.value = '';
productMode.value = 'group'; productMode.value = 'group';
}, },
}, },
@ -1250,6 +1266,8 @@ watch(productMode, () => {
text: 'manage', text: 'manage',
handler: () => { handler: () => {
productMode.value = 'group'; productMode.value = 'group';
expandedTree.value = [];
currentIdGrop.value = '';
filterStat.value = []; filterStat.value = [];
}, },
}, },
@ -1444,19 +1462,27 @@ watch(
v-touch-hold.mouse="handleHold(node)" v-touch-hold.mouse="handleHold(node)"
@click.stop=" @click.stop="
async () => { async () => {
if (node.type === 'group' && node._count.type > 0) { if (node.type === 'group') {
pathGroupName = node.name; if (currentIdGrop !== node.id) {
currentId = node.id; await enterGroup(node.id, node.name);
return;
}
await fetchListType(); if (currentIdGrop === node.id) {
expandedTree.push(node.id); expandedTree = expandedTree.filter(
flowStore.rotate(); (i) => node.id !== i,
);
currentIdGrop = '';
productMode = 'group';
return;
}
} }
} }
" "
:class="{ :class="{
'cursor-pointer': 'cursor-pointer':
node.type === 'group' && node._count.type > 0, node.type === 'group' || node.type === 'type',
'selector-tree': 'selector-tree':
node.type === 'group' && node._count.type > 0, node.type === 'group' && node._count.type > 0,
}" }"
@ -1517,7 +1543,7 @@ watch(
clearFormGroup(); clearFormGroup();
assignFormDataGroup(node); assignFormDataGroup(node);
isEdit = false; isEdit = false;
currentId = node.id; currentIdGrop = node.id;
drawerInfo = true; drawerInfo = true;
} }
} }
@ -1558,7 +1584,7 @@ watch(
clearFormGroup(); clearFormGroup();
assignFormDataGroup(node); assignFormDataGroup(node);
isEdit = false; isEdit = false;
currentId = node.id; currentIdGrop = node.id;
drawerInfo = true; drawerInfo = true;
} }
} }
@ -1599,7 +1625,7 @@ watch(
clearFormGroup(); clearFormGroup();
assignFormDataGroup(node); assignFormDataGroup(node);
isEdit = true; isEdit = true;
currentId = node.id; currentIdGrop = node.id;
drawerInfo = true; drawerInfo = true;
} }
@ -1892,11 +1918,7 @@ watch(
flowStore.rotate(); flowStore.rotate();
} }
if (productMode === 'group') { if (productMode === 'group') {
pathGroupName = props.row.name; await enterGroup(props.row.id, props.row.name);
currentId = props.row.id;
productMode = 'type';
await fetchListType();
flowStore.rotate();
} }
} }
" "
@ -1996,7 +2018,7 @@ watch(
clearFormGroup(); clearFormGroup();
assignFormDataGroup(props.row); assignFormDataGroup(props.row);
isEdit = false; isEdit = false;
currentId = props.row.id; currentIdGrop = props.row.id;
drawerInfo = true; drawerInfo = true;
} }
} }
@ -2036,7 +2058,7 @@ watch(
clearFormGroup(); clearFormGroup();
assignFormDataGroup(props.row); assignFormDataGroup(props.row);
isEdit = false; isEdit = false;
currentId = props.row.id; currentIdGrop = props.row.id;
drawerInfo = true; drawerInfo = true;
} }
} }
@ -2076,7 +2098,7 @@ watch(
clearFormGroup(); clearFormGroup();
assignFormDataGroup(props.row); assignFormDataGroup(props.row);
isEdit = true; isEdit = true;
currentId = props.row.id; currentIdGrop = props.row.id;
drawerInfo = true; drawerInfo = true;
} }
@ -2218,7 +2240,7 @@ watch(
clearFormGroup(); clearFormGroup();
assignFormDataGroup(props.row); assignFormDataGroup(props.row);
isEdit = false; isEdit = false;
currentId = props.row.id; currentIdGrop = props.row.id;
drawerInfo = true; drawerInfo = true;
} }
} }
@ -2236,7 +2258,7 @@ watch(
clearFormGroup(); clearFormGroup();
assignFormDataGroup(props.row); assignFormDataGroup(props.row);
isEdit = true; isEdit = true;
currentId = props.row.id; currentIdGrop = props.row.id;
drawerInfo = true; drawerInfo = true;
} }
@ -2267,11 +2289,7 @@ watch(
flowStore.rotate(); flowStore.rotate();
} }
if (productMode === 'group') { if (productMode === 'group') {
pathGroupName = props.row.name; await enterGroup(props.row.id, props.row.name);
currentId = props.row.id;
productMode = 'type';
await fetchListType();
flowStore.rotate();
} }
} }
" "
@ -3805,7 +3823,7 @@ watch(
clearFormGroup(); clearFormGroup();
assignFormDataGroup(currentNode); assignFormDataGroup(currentNode);
isEdit = false; isEdit = false;
currentId = currentNode.id; currentIdGrop = currentNode.id;
drawerInfo = true; drawerInfo = true;
} }
} }
@ -3839,7 +3857,7 @@ watch(
clearFormGroup(); clearFormGroup();
assignFormDataGroup(currentNode); assignFormDataGroup(currentNode);
isEdit = true; isEdit = true;
currentId = currentNode.id; currentIdGrop = currentNode.id;
drawerInfo = true; drawerInfo = true;
} }