refactor: add go inside/outside by Product Group
This commit is contained in:
parent
eec539be7d
commit
7f67e787bc
1 changed files with 54 additions and 36 deletions
|
|
@ -151,8 +151,8 @@ const treeProductTypeAndGroup = computed(() => {
|
|||
...item,
|
||||
type: 'group',
|
||||
children:
|
||||
item.id === currentId.value
|
||||
? recordTreeProductType.value[currentId.value]?.map((x) => ({
|
||||
item.id === currentIdGrop.value
|
||||
? recordTreeProductType.value[currentIdGrop.value]?.map((x) => ({
|
||||
...x,
|
||||
type: 'type',
|
||||
})) ?? []
|
||||
|
|
@ -404,7 +404,7 @@ const totalGroup = ref<number>(0);
|
|||
const total = ref<number>(0);
|
||||
|
||||
// เก็บ id ที่เข้ามา
|
||||
const currentId = ref<string>('');
|
||||
const currentIdGrop = ref<string>('');
|
||||
const currentIdType = ref<string>('');
|
||||
const currentIdService = ref<string>('');
|
||||
const currentIdProduct = ref<string>('');
|
||||
|
|
@ -495,7 +495,7 @@ async function fetchListType() {
|
|||
page: currentPageType.value,
|
||||
pageSize: pageSizeType.value,
|
||||
query: !!inputSearch.value ? inputSearch.value : undefined,
|
||||
productGroupId: currentId.value,
|
||||
productGroupId: currentIdGrop.value,
|
||||
status:
|
||||
currentStatus.value === 'All'
|
||||
? undefined
|
||||
|
|
@ -631,13 +631,13 @@ async function submitType() {
|
|||
if (drawerInfo.value) {
|
||||
await editProductServiceType(currentIdType.value, {
|
||||
...formDataGroup.value,
|
||||
productGroupId: currentId.value,
|
||||
productGroupId: currentIdGrop.value,
|
||||
});
|
||||
drawerInfo.value = false;
|
||||
} else {
|
||||
dialogInputForm.value = false;
|
||||
const res = await createProductServiceType(
|
||||
currentId.value,
|
||||
currentIdGrop.value,
|
||||
formDataGroup.value,
|
||||
);
|
||||
|
||||
|
|
@ -799,7 +799,9 @@ async function deleteProductById(productId?: string) {
|
|||
}
|
||||
if (editByTree.value === 'group') {
|
||||
// Product Group
|
||||
const res = await deleteProductService(productId ?? currentId.value);
|
||||
const res = await deleteProductService(
|
||||
productId ?? currentIdGrop.value,
|
||||
);
|
||||
if (res) {
|
||||
}
|
||||
await fetchListGroups();
|
||||
|
|
@ -817,7 +819,9 @@ async function deleteProductById(productId?: string) {
|
|||
}
|
||||
if (productMode.value === 'group') {
|
||||
// Product Group
|
||||
const res = await deleteProductService(productId ?? currentId.value);
|
||||
const res = await deleteProductService(
|
||||
productId ?? currentIdGrop.value,
|
||||
);
|
||||
if (res) {
|
||||
}
|
||||
await fetchListGroups();
|
||||
|
|
@ -1093,7 +1097,7 @@ async function submitProduct() {
|
|||
|
||||
async function submitGroup() {
|
||||
if (drawerInfo.value) {
|
||||
await editProductService(currentId.value, formDataGroup.value);
|
||||
await editProductService(currentIdGrop.value, formDataGroup.value);
|
||||
} else {
|
||||
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) {
|
||||
if ($q.screen.gt.xs) return;
|
||||
return function (props: unknown) {
|
||||
|
|
@ -1229,6 +1243,8 @@ onMounted(async () => {
|
|||
{
|
||||
text: 'manage',
|
||||
handler: () => {
|
||||
expandedTree.value = [];
|
||||
currentIdGrop.value = '';
|
||||
productMode.value = 'group';
|
||||
},
|
||||
},
|
||||
|
|
@ -1250,6 +1266,8 @@ watch(productMode, () => {
|
|||
text: 'manage',
|
||||
handler: () => {
|
||||
productMode.value = 'group';
|
||||
expandedTree.value = [];
|
||||
currentIdGrop.value = '';
|
||||
filterStat.value = [];
|
||||
},
|
||||
},
|
||||
|
|
@ -1444,19 +1462,27 @@ watch(
|
|||
v-touch-hold.mouse="handleHold(node)"
|
||||
@click.stop="
|
||||
async () => {
|
||||
if (node.type === 'group' && node._count.type > 0) {
|
||||
pathGroupName = node.name;
|
||||
currentId = node.id;
|
||||
if (node.type === 'group') {
|
||||
if (currentIdGrop !== node.id) {
|
||||
await enterGroup(node.id, node.name);
|
||||
return;
|
||||
}
|
||||
|
||||
await fetchListType();
|
||||
expandedTree.push(node.id);
|
||||
flowStore.rotate();
|
||||
if (currentIdGrop === node.id) {
|
||||
expandedTree = expandedTree.filter(
|
||||
(i) => node.id !== i,
|
||||
);
|
||||
currentIdGrop = '';
|
||||
productMode = 'group';
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
"
|
||||
:class="{
|
||||
'cursor-pointer':
|
||||
node.type === 'group' && node._count.type > 0,
|
||||
node.type === 'group' || node.type === 'type',
|
||||
'selector-tree':
|
||||
node.type === 'group' && node._count.type > 0,
|
||||
}"
|
||||
|
|
@ -1517,7 +1543,7 @@ watch(
|
|||
clearFormGroup();
|
||||
assignFormDataGroup(node);
|
||||
isEdit = false;
|
||||
currentId = node.id;
|
||||
currentIdGrop = node.id;
|
||||
drawerInfo = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1558,7 +1584,7 @@ watch(
|
|||
clearFormGroup();
|
||||
assignFormDataGroup(node);
|
||||
isEdit = false;
|
||||
currentId = node.id;
|
||||
currentIdGrop = node.id;
|
||||
drawerInfo = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1599,7 +1625,7 @@ watch(
|
|||
clearFormGroup();
|
||||
assignFormDataGroup(node);
|
||||
isEdit = true;
|
||||
currentId = node.id;
|
||||
currentIdGrop = node.id;
|
||||
|
||||
drawerInfo = true;
|
||||
}
|
||||
|
|
@ -1892,11 +1918,7 @@ watch(
|
|||
flowStore.rotate();
|
||||
}
|
||||
if (productMode === 'group') {
|
||||
pathGroupName = props.row.name;
|
||||
currentId = props.row.id;
|
||||
productMode = 'type';
|
||||
await fetchListType();
|
||||
flowStore.rotate();
|
||||
await enterGroup(props.row.id, props.row.name);
|
||||
}
|
||||
}
|
||||
"
|
||||
|
|
@ -1996,7 +2018,7 @@ watch(
|
|||
clearFormGroup();
|
||||
assignFormDataGroup(props.row);
|
||||
isEdit = false;
|
||||
currentId = props.row.id;
|
||||
currentIdGrop = props.row.id;
|
||||
drawerInfo = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -2036,7 +2058,7 @@ watch(
|
|||
clearFormGroup();
|
||||
assignFormDataGroup(props.row);
|
||||
isEdit = false;
|
||||
currentId = props.row.id;
|
||||
currentIdGrop = props.row.id;
|
||||
drawerInfo = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -2076,7 +2098,7 @@ watch(
|
|||
clearFormGroup();
|
||||
assignFormDataGroup(props.row);
|
||||
isEdit = true;
|
||||
currentId = props.row.id;
|
||||
currentIdGrop = props.row.id;
|
||||
|
||||
drawerInfo = true;
|
||||
}
|
||||
|
|
@ -2218,7 +2240,7 @@ watch(
|
|||
clearFormGroup();
|
||||
assignFormDataGroup(props.row);
|
||||
isEdit = false;
|
||||
currentId = props.row.id;
|
||||
currentIdGrop = props.row.id;
|
||||
drawerInfo = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -2236,7 +2258,7 @@ watch(
|
|||
clearFormGroup();
|
||||
assignFormDataGroup(props.row);
|
||||
isEdit = true;
|
||||
currentId = props.row.id;
|
||||
currentIdGrop = props.row.id;
|
||||
|
||||
drawerInfo = true;
|
||||
}
|
||||
|
|
@ -2267,11 +2289,7 @@ watch(
|
|||
flowStore.rotate();
|
||||
}
|
||||
if (productMode === 'group') {
|
||||
pathGroupName = props.row.name;
|
||||
currentId = props.row.id;
|
||||
productMode = 'type';
|
||||
await fetchListType();
|
||||
flowStore.rotate();
|
||||
await enterGroup(props.row.id, props.row.name);
|
||||
}
|
||||
}
|
||||
"
|
||||
|
|
@ -3805,7 +3823,7 @@ watch(
|
|||
clearFormGroup();
|
||||
assignFormDataGroup(currentNode);
|
||||
isEdit = false;
|
||||
currentId = currentNode.id;
|
||||
currentIdGrop = currentNode.id;
|
||||
drawerInfo = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -3839,7 +3857,7 @@ watch(
|
|||
clearFormGroup();
|
||||
assignFormDataGroup(currentNode);
|
||||
isEdit = true;
|
||||
currentId = currentNode.id;
|
||||
currentIdGrop = currentNode.id;
|
||||
|
||||
drawerInfo = true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue