refactor(04): hide q-fab btn if group inactive

This commit is contained in:
puriphatt 2024-09-05 17:01:58 +07:00
parent 9e540bf6d3
commit 26feb2bf1d

View file

@ -731,8 +731,6 @@ async function triggerChangeStatus(
.then(resolve) .then(resolve)
.catch(reject); .catch(reject);
} }
currentNoAction.value = handleStatus();
}, },
cancel: () => {}, cancel: () => {},
}); });
@ -1280,7 +1278,6 @@ function cloneData() {
}); });
} }
const currentStatusList = ref<Status[]>([]);
async function enterGroup( async function enterGroup(
id: string, id: string,
name: string, name: string,
@ -1293,7 +1290,7 @@ async function enterGroup(
pathGroupName.value = name; pathGroupName.value = name;
currentIdType.value = ''; currentIdType.value = '';
currentIdGrop.value = id; currentIdGrop.value = id;
currentStatusList.value.push(status); currentNoAction.value = status === 'INACTIVE';
pathTypeName.value = name; pathTypeName.value = name;
await fetchListOfService(); await fetchListOfService();
await fetchListOfProduct(); await fetchListOfProduct();
@ -1336,18 +1333,6 @@ async function enterNext(type: 'service' | 'product') {
flowStore.rotate(); flowStore.rotate();
} }
function handleStatus() {
let tempValue = false;
currentStatusList.value.forEach((item) => {
if (item === 'INACTIVE') {
tempValue = true;
}
});
return tempValue;
}
function handleHold(node: ProductGroup & { type: string }) { function handleHold(node: ProductGroup & { type: string }) {
if ($q.screen.gt.xs) return; if ($q.screen.gt.xs) return;
holdDialog.value = true; holdDialog.value = true;
@ -1391,7 +1376,6 @@ watch(
currentIdGrop.value = ''; currentIdGrop.value = '';
currentIdType.value = ''; currentIdType.value = '';
filterStat.value = []; filterStat.value = [];
currentStatusList.value = [];
}, },
}, },
]; ];
@ -1413,8 +1397,6 @@ watch(
currentIdType.value = ''; currentIdType.value = '';
filterStat.value = []; filterStat.value = [];
productMode.value = 'group'; productMode.value = 'group';
currentStatusList.value.splice(1);
expandedTree.value.pop(); expandedTree.value.pop();
utilsStore.currentTitle.path.pop(); utilsStore.currentTitle.path.pop();
} }
@ -1471,8 +1453,7 @@ watch(
}, },
); );
watch([currentStatusList, productMode], async () => { watch(productMode, async () => {
currentNoAction.value = handleStatus();
if (productMode.value === 'group') { if (productMode.value === 'group') {
await calculateStats(); await calculateStats();
} }
@ -1621,7 +1602,6 @@ watch([currentStatusList, productMode], async () => {
expandedTree = expandedTree.filter((i) => v.id !== i); expandedTree = expandedTree.filter((i) => v.id !== i);
currentIdGrop = ''; currentIdGrop = '';
currentIdType = ''; currentIdType = '';
currentStatusList = [];
productMode = 'group'; productMode = 'group';
return; return;
} }
@ -1693,9 +1673,6 @@ watch([currentStatusList, productMode], async () => {
async (v: (typeof treeProductTypeAndGroup)[number]) => { async (v: (typeof treeProductTypeAndGroup)[number]) => {
if (v.type === 'group') { if (v.type === 'group') {
await triggerChangeStatus(v.id, v.status, v.type); await triggerChangeStatus(v.id, v.status, v.type);
currentStatusList[0] =
v.status === 'INACTIVE' ? 'ACTIVE' : 'INACTIVE';
} }
} }
" "
@ -2079,7 +2056,6 @@ watch([currentStatusList, productMode], async () => {
:id="`enter-${props.row.name}`" :id="`enter-${props.row.name}`"
:for="`enter-${props.row.name}`" :for="`enter-${props.row.name}`"
:is-disabled="props.row.status === 'INACTIVE'" :is-disabled="props.row.status === 'INACTIVE'"
:no-action="handleStatus()"
:color=" :color="
{ {
type: $q.dark.isActive type: $q.dark.isActive