refactor: package => step count

This commit is contained in:
puriphatt 2024-12-04 13:35:36 +07:00
parent e1a27aa8d4
commit 4a6f192d5f
2 changed files with 21 additions and 5 deletions

View file

@ -5,7 +5,6 @@ import { onMounted } from 'vue';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { useQuasar, type QTableProps } from 'quasar'; import { useQuasar, type QTableProps } from 'quasar';
import SelectFlow from 'src/components/shared/select/SelectFlow.vue';
import DialogProperties from 'src/components/dialog/DialogProperties.vue'; import DialogProperties from 'src/components/dialog/DialogProperties.vue';
import ProductCardComponent from 'components/04_product-service/ProductCardComponent.vue'; import ProductCardComponent from 'components/04_product-service/ProductCardComponent.vue';
import StatCard from 'components/StatCardComponent.vue'; import StatCard from 'components/StatCardComponent.vue';
@ -926,6 +925,7 @@ async function assignFormDataProductService(id: string) {
product: item.productOnWork.map((productOnWorkItem) => ({ product: item.productOnWork.map((productOnWorkItem) => ({
id: productOnWorkItem.product.id, id: productOnWorkItem.product.id,
installmentNo: productOnWorkItem.installmentNo, installmentNo: productOnWorkItem.installmentNo,
stepCount: productOnWorkItem.stepCount,
})), })),
}); });
}); });
@ -1075,10 +1075,23 @@ function assignFormDataProductServiceCreate() {
id: item.id, id: item.id,
name: item.name, name: item.name,
attributes: item.attributes, attributes: item.attributes,
product: item.product.map((productItem) => ({ product: item.product.map((productItem) => {
id: productItem.id, const stepCount = item.attributes.workflowStep.reduce((count, step) => {
installmentNo: productItem.installmentNo, if (
})), step.attributes?.properties?.length > 0 &&
step.productsId.includes(productItem.id)
) {
return count + 1;
}
return count;
}, 0);
return {
id: productItem.id,
installmentNo: productItem.installmentNo,
stepCount: stepCount,
};
}),
}); });
}); });
} }
@ -1089,6 +1102,7 @@ async function submitService(notClose = false) {
if (profileFileImg.value) if (profileFileImg.value)
formDataProductService.value.image = profileFileImg.value; formDataProductService.value.image = profileFileImg.value;
if (dialogService.value) { if (dialogService.value) {
formDataProductService.value.productGroupId = currentIdGroup.value; formDataProductService.value.productGroupId = currentIdGroup.value;
formDataProductService.value.work.forEach((s) => (s.id = undefined)); formDataProductService.value.work.forEach((s) => (s.id = undefined));

View file

@ -58,6 +58,7 @@ export interface ServiceCreate {
product: { product: {
id: string; id: string;
installmentNo?: number; installmentNo?: number;
stepCount: number;
}[]; }[];
name: string; name: string;
}[]; }[];
@ -136,6 +137,7 @@ export interface ProductOnWork {
workId: string; workId: string;
order: number; order: number;
installmentNo: number; installmentNo: number;
stepCount: number;
} }
export interface WorkItems { export interface WorkItems {