feat: rotate log id

This commit is contained in:
Net 2024-06-26 17:21:26 +07:00
parent 7fedab36df
commit 14eb498133

View file

@ -20,9 +20,12 @@ import WorkNameManagement from 'src/components/04_product-service/WorkNameManage
import useOptionStore from 'src/stores/options'; import useOptionStore from 'src/stores/options';
import FormServiceProperties from 'src/components/04_product-service/FormServiceProperties.vue'; import FormServiceProperties from 'src/components/04_product-service/FormServiceProperties.vue';
import useFlowStore from 'src/stores/flow';
import { Status } from 'src/stores/types'; import { Status } from 'src/stores/types';
import NoData from 'components/NoData.vue'; import NoData from 'components/NoData.vue';
const flowStore = useFlowStore();
import { dialog, dialogWarningClose } from 'src/stores/utils'; import { dialog, dialogWarningClose } from 'src/stores/utils';
import useProductServiceStore from 'src/stores/product-service'; import useProductServiceStore from 'src/stores/product-service';
@ -100,6 +103,7 @@ const stat = ref<
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { onMounted } from 'vue'; import { onMounted } from 'vue';
import { time } from 'console';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
const { t } = useI18n(); const { t } = useI18n();
@ -255,6 +259,7 @@ async function searchGroup() {
if (resultList) { if (resultList) {
resultSearchGroup.value = resultList.result; resultSearchGroup.value = resultList.result;
} }
flowStore.rotate();
} }
async function searchProductAndService() { async function searchProductAndService() {
@ -265,6 +270,7 @@ async function searchProductAndService() {
if (res) { if (res) {
productAndService.value = res.result; productAndService.value = res.result;
} }
flowStore.rotate();
} }
async function searchProduct(isAdd: boolean = true) { async function searchProduct(isAdd: boolean = true) {
@ -286,6 +292,7 @@ async function searchProduct(isAdd: boolean = true) {
}); });
} }
} }
flowStore.rotate();
} }
async function searchService() { async function searchService() {
@ -301,12 +308,14 @@ async function searchService() {
}; };
}); });
} }
flowStore.rotate();
} }
async function featchStatsService() { async function featchStatsService() {
const resStatsService = await fetchStatsService(); const resStatsService = await fetchStatsService();
totalService.value = resStatsService; totalService.value = resStatsService;
flowStore.rotate();
} }
async function featchStatsProduct() { async function featchStatsProduct() {
@ -315,6 +324,7 @@ async function featchStatsProduct() {
}); });
totalProduct.value = resStatsProduct; totalProduct.value = resStatsProduct;
flowStore.rotate();
} }
async function fetchListType() { async function fetchListType() {
@ -408,7 +418,7 @@ async function fetchListOfService() {
} }
async function searchType() { async function searchType() {
const res = await await fetchListProductServiceType({ const res = await fetchListProductServiceType({
query: inputSearch.value, query: inputSearch.value,
productGroupId: currentId.value, productGroupId: currentId.value,
}); });
@ -459,6 +469,7 @@ async function toggleStatusProduct(id: string, status: Status) {
}); });
await fetchListOfProduct(currentIdType.value); await fetchListOfProduct(currentIdType.value);
flowStore.rotate();
} }
async function toggleStatusService(id: string, status: Status) { async function toggleStatusService(id: string, status: Status) {
@ -467,6 +478,7 @@ async function toggleStatusService(id: string, status: Status) {
}); });
await fetchListOfService(); await fetchListOfService();
flowStore.rotate();
} }
async function toggleStatusType(id: string, status: Status) { async function toggleStatusType(id: string, status: Status) {
await editProductServiceType(id, { await editProductServiceType(id, {
@ -474,6 +486,7 @@ async function toggleStatusType(id: string, status: Status) {
}); });
await fetchListType(); await fetchListType();
flowStore.rotate();
} }
async function toggleStatusGroup(id: string, status: Status) { async function toggleStatusGroup(id: string, status: Status) {
@ -482,6 +495,7 @@ async function toggleStatusGroup(id: string, status: Status) {
}); });
await fetchListGroups(); await fetchListGroups();
flowStore.rotate();
} }
async function fetchListOfProductAndService() { async function fetchListOfProductAndService() {
@ -528,6 +542,7 @@ async function deleteServiceById(serviceId?: string) {
if (res) { if (res) {
totalService.value = totalService.value - 1; totalService.value = totalService.value - 1;
} }
flowStore.rotate();
calculateStats(); calculateStats();
}, },
cancel: () => {}, cancel: () => {},
@ -551,6 +566,7 @@ async function deleteTypeOfProduct(id?: string) {
if (res) { if (res) {
totalProduct.value = totalProduct.value - 1; totalProduct.value = totalProduct.value - 1;
} }
flowStore.rotate();
calculateStats(); calculateStats();
}, },
cancel: () => {}, cancel: () => {},
@ -579,6 +595,7 @@ async function deleteProductById(productId?: string) {
} }
await fetchListGroups(); await fetchListGroups();
} }
flowStore.rotate();
calculateStats(); calculateStats();
drawerInfo.value = false; drawerInfo.value = false;
}, },
@ -594,6 +611,7 @@ function undoProductGroup() {
code: previousValue.value.code, code: previousValue.value.code,
}; };
isEdit.value = false; isEdit.value = false;
flowStore.rotate();
} }
function assignFormDataGroup(data: ProductGroup) { function assignFormDataGroup(data: ProductGroup) {
@ -617,14 +635,12 @@ const prevService = ref<ServiceCreate>({
code: '', code: '',
productTypeId: '', productTypeId: '',
}); });
const currentService = ref<ServiceById>();
async function assignFormDataProductService(id: string) { async function assignFormDataProductService(id: string) {
const res = await fetchListServiceById(id); const res = await fetchListServiceById(id);
if (res) { if (res) {
statusToggle.value = res.status === 'INACTIVE' ? false : true; statusToggle.value = res.status === 'INACTIVE' ? false : true;
currentService.value = JSON.parse(JSON.stringify(res));
prevService.value = { prevService.value = {
code: res.code, code: res.code,
@ -658,7 +674,7 @@ async function assignFormDataProductService(id: string) {
product: item.productOnWork.map((productOnWorkItem) => { product: item.productOnWork.map((productOnWorkItem) => {
return { return {
...productOnWorkItem.product, ...productOnWorkItem.product,
nameEn: productOnWorkItem.product.name, nameEn: '',
}; };
}), }),
}; };
@ -783,7 +799,7 @@ async function submitService() {
if (productAndServiceTab.value === 'service') { if (productAndServiceTab.value === 'service') {
await fetchListOfService(); await fetchListOfService();
} }
flowStore.rotate();
clearFormService(); clearFormService();
} }
@ -816,6 +832,8 @@ async function submitProduct() {
if (productAndServiceTab.value === 'product') { if (productAndServiceTab.value === 'product') {
await fetchListOfProduct(currentIdType.value); await fetchListOfProduct(currentIdType.value);
} }
flowStore.rotate();
} }
async function submitGroup() { async function submitGroup() {
@ -832,6 +850,7 @@ async function submitGroup() {
drawerInfo.value = false; drawerInfo.value = false;
await fetchListGroups(); await fetchListGroups();
clearFormGroup(); clearFormGroup();
flowStore.rotate();
} }
function confirmDeleteWork(id: string) { function confirmDeleteWork(id: string) {
@ -843,6 +862,7 @@ function confirmDeleteWork(id: string) {
message: t('deleteConfirmMessage'), message: t('deleteConfirmMessage'),
action: async () => { action: async () => {
deleteWork(id); deleteWork(id);
flowStore.rotate();
}, },
cancel: () => {}, cancel: () => {},
}); });
@ -897,53 +917,38 @@ async function calculateStats() {
async function fetchStatus() { async function fetchStatus() {
if (productAndServiceTab.value === 'all') { if (productAndServiceTab.value === 'all') {
await fetchListOfProductAndService(); await fetchListOfProductAndService();
flowStore.rotate();
} }
if (productAndServiceTab.value === 'product') { if (productAndServiceTab.value === 'product') {
await fetchListOfProduct(currentIdType.value); await fetchListOfProduct(currentIdType.value);
flowStore.rotate();
} }
if (productAndServiceTab.value === 'service') { if (productAndServiceTab.value === 'service') {
await fetchListOfService(); await fetchListOfService();
flowStore.rotate();
} }
} }
async function fetchSearch() { async function fetchSearch() {
if (productAndServiceTab.value === 'all') { if (productAndServiceTab.value === 'all') {
await searchProductAndService(); await searchProductAndService();
flowStore.rotate();
} }
if (productAndServiceTab.value === 'product') { if (productAndServiceTab.value === 'product') {
await searchProduct(false); await searchProduct(false);
flowStore.rotate();
} }
if (productAndServiceTab.value === 'service') { if (productAndServiceTab.value === 'service') {
await searchService(); await searchService();
flowStore.rotate();
} }
} }
function cloneData() {
if (!currentService.value) return;
formDataProductService.value = {
...prevService.value,
attributes: JSON.parse(JSON.stringify(currentService.value.attributes)),
};
workItems.value = currentService.value.work.map((item) => {
return {
id: item.id,
name: item.name,
attributes: JSON.parse(JSON.stringify(item.attributes)),
product: item.productOnWork.map((productOnWorkItem) => {
return {
...productOnWorkItem.product,
nameEn: productOnWorkItem.product.name,
};
}),
};
});
}
onMounted(async () => { onMounted(async () => {
calculateStats(); calculateStats();
await fetchListGroups(); await fetchListGroups();
flowStore.rotate();
}); });
watch(productMode, () => { watch(productMode, () => {
@ -957,26 +962,32 @@ watch(currentStatus, async () => {
} else { } else {
await fetchListType(); await fetchListType();
} }
flowStore.rotate();
}); });
watch(currentPageGroup, async () => { watch(currentPageGroup, async () => {
await fetchListGroups(); await fetchListGroups();
flowStore.rotate();
}); });
watch(currentPageType, async () => { watch(currentPageType, async () => {
await fetchListType(); await fetchListType();
flowStore.rotate();
}); });
watch(currentPageServiceAndProduct, async () => { watch(currentPageServiceAndProduct, async () => {
await fetchListOfProductAndService(); await fetchListOfProductAndService();
flowStore.rotate();
}); });
watch(currentPageProduct, async () => { watch(currentPageProduct, async () => {
await fetchListOfProduct(currentIdType.value); await fetchListOfProduct(currentIdType.value);
flowStore.rotate();
}); });
watch(currentPageService, async () => { watch(currentPageService, async () => {
await fetchListOfService(); await fetchListOfService();
flowStore.rotate();
}); });
</script> </script>
@ -1282,6 +1293,7 @@ watch(currentPageService, async () => {
await featchStatsService(); await featchStatsService();
await featchStatsProduct(); await featchStatsProduct();
await fetchListOfProductAndService(); await fetchListOfProductAndService();
flowStore.rotate();
} }
" "
/> />
@ -1326,6 +1338,7 @@ watch(currentPageService, async () => {
currentId = v.id; currentId = v.id;
productMode = 'type'; productMode = 'type';
await fetchListType(); await fetchListType();
flowStore.rotate();
} }
" "
/> />
@ -1383,6 +1396,7 @@ watch(currentPageService, async () => {
inputSearchProductAndService = ''; inputSearchProductAndService = '';
currentStatus = 'All'; currentStatus = 'All';
await fetchListOfProductAndService(); await fetchListOfProductAndService();
flowStore.rotate();
} }
" "
> >
@ -1414,6 +1428,7 @@ watch(currentPageService, async () => {
inputSearchProductAndService = ''; inputSearchProductAndService = '';
currentStatus = 'All'; currentStatus = 'All';
await fetchListOfProduct(currentIdType); await fetchListOfProduct(currentIdType);
flowStore.rotate();
} }
" "
> >
@ -1445,6 +1460,7 @@ watch(currentPageService, async () => {
inputSearchProductAndService = ''; inputSearchProductAndService = '';
currentStatus = 'All'; currentStatus = 'All';
await fetchListOfService(); await fetchListOfService();
flowStore.rotate();
} }
" "
> >
@ -1868,6 +1884,7 @@ watch(currentPageService, async () => {
:close=" :close="
() => { () => {
dialogProduct = false; dialogProduct = false;
flowStore.rotate();
} }
" "
> >
@ -1914,6 +1931,7 @@ watch(currentPageService, async () => {
() => { () => {
formDataProduct = { ...prevProduct }; formDataProduct = { ...prevProduct };
infoProductEdit = false; infoProductEdit = false;
flowStore.rotate();
} }
" "
:deleteData=" :deleteData="
@ -1929,6 +1947,7 @@ watch(currentPageService, async () => {
:close=" :close="
() => { () => {
dialogProductEdit = false; dialogProductEdit = false;
flowStore.rotate();
} }
" "
> >
@ -1984,6 +2003,7 @@ watch(currentPageService, async () => {
() => { () => {
clearFormService(); clearFormService();
dialogService = false; dialogService = false;
flowStore.rotate();
} }
" "
> >
@ -2128,6 +2148,7 @@ watch(currentPageService, async () => {
:close=" :close="
() => { () => {
clearFormService(); clearFormService();
flowStore.rotate();
dialogServiceEdit = false; dialogServiceEdit = false;
} }
" "
@ -2139,8 +2160,9 @@ watch(currentPageService, async () => {
:undo=" :undo="
() => { () => {
infoServiceEdit = false; infoServiceEdit = false;
cloneData(); formDataProductService = { ...prevService };
statusToggle = prevService.status === 'INACTIVE' ? false : true; statusToggle = prevService.status === 'INACTIVE' ? false : true;
flowStore.rotate();
} }
" "
:delete-data="() => deleteServiceById()" :delete-data="() => deleteServiceById()"
@ -2165,6 +2187,12 @@ watch(currentPageService, async () => {
v-if="currentServiceTab === 'serviceInformation'" v-if="currentServiceTab === 'serviceInformation'"
dense dense
service service
@service-properties="
() => {
tempValueProperties = formDataProductService.attributes;
openPropertiesDialog('service');
}
"
v-model:service-code="formDataProductService.code" v-model:service-code="formDataProductService.code"
v-model:service-description="formDataProductService.detail" v-model:service-description="formDataProductService.detail"
v-model:service-name-th="formDataProductService.name" v-model:service-name-th="formDataProductService.name"