From 997d6c4afaa84af7d6d6620e6d7ceaba8fd353f8 Mon Sep 17 00:00:00 2001
From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com>
Date: Thu, 23 Jan 2025 11:20:36 +0700
Subject: [PATCH 01/11] chore: clean
---
src/components/05_quotation/ProductItem.vue | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/components/05_quotation/ProductItem.vue b/src/components/05_quotation/ProductItem.vue
index 597107ce..5276ff60 100644
--- a/src/components/05_quotation/ProductItem.vue
+++ b/src/components/05_quotation/ProductItem.vue
@@ -57,7 +57,6 @@ const currentBtnOpen = ref<{ title: string; opened: boolean[] }[]>([
]);
function calcPrice(c: (typeof rows.value)[number]) {
- console.log(c);
const originalPrice = c.pricePerUnit;
const finalPriceWithVat = precisionRound(
originalPrice + originalPrice * (config.value?.vat || 0.07),
From 6c299b8c1b3cc4dd66dbc1afb9fd7cd9c9c112de Mon Sep 17 00:00:00 2001
From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com>
Date: Thu, 23 Jan 2025 13:51:53 +0700
Subject: [PATCH 02/11] fix: calc price
---
src/pages/05_quotation/QuotationForm.vue | 31 ++++++++++++------------
1 file changed, 16 insertions(+), 15 deletions(-)
diff --git a/src/pages/05_quotation/QuotationForm.vue b/src/pages/05_quotation/QuotationForm.vue
index c1edbf4d..4ea677b6 100644
--- a/src/pages/05_quotation/QuotationForm.vue
+++ b/src/pages/05_quotation/QuotationForm.vue
@@ -704,18 +704,22 @@ function handleUpdateProductTable(
newInstallmentNo: number;
},
) {
+ handleChangePayType(quotationFormData.value.payCondition);
// calc price
const calc = (c: QuotationPayload['productServiceList'][number]) => {
- const pricePerUnit = c.pricePerUnit || 0;
- const discount = c.discount || 0;
-
- return (
- pricePerUnit * c.amount -
- discount +
- (c.product.calcVat
- ? (pricePerUnit * c.amount - discount) * (config.value?.vat || 0.07)
- : 0)
+ const originalPrice = c.pricePerUnit || 0;
+ const finalPriceWithVat = precisionRound(
+ originalPrice * (1 + (config.value?.vat || 0.07)),
);
+ const finalPriceNoVat =
+ finalPriceWithVat / (1 + (config.value?.vat || 0.07));
+
+ const price = finalPriceNoVat * c.amount;
+ const vat = c.product.calcVat
+ ? (finalPriceNoVat * c.amount - (c.discount || 0)) *
+ (config.value?.vat || 0.07)
+ : 0;
+ return precisionRound(price + vat);
};
// installment
@@ -2057,23 +2061,20 @@ watch(
-
{{ $t('general.view', { msg: $t('general.example') }) }}
-
+ -->
Date: Thu, 23 Jan 2025 14:08:28 +0700
Subject: [PATCH 03/11] fix: value not reflect real amount
---
src/pages/09_task-order/document_view/MainPage.vue | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/src/pages/09_task-order/document_view/MainPage.vue b/src/pages/09_task-order/document_view/MainPage.vue
index a301ae2f..dbdf0ca8 100644
--- a/src/pages/09_task-order/document_view/MainPage.vue
+++ b/src/pages/09_task-order/document_view/MainPage.vue
@@ -174,12 +174,11 @@ onMounted(async () => {
product.value = [];
summaryPrice.value = taskListGroup
.flatMap((v) => {
- const list = v.list.filter(
- (item) => item._status === TaskStatus.Complete,
- );
- if (viewType.value === 'docReceive' && list.length === 0) {
- return [];
- }
+ const list =
+ (viewType.value === 'docReceive'
+ ? v.list.filter((item) => item._status === TaskStatus.Complete)
+ : v.list) || [];
+
return {
product: v.product,
pricePerUnit: v.product.serviceCharge,
From c7438edd799c5b5081a56dfbf679f9f22832ecb6 Mon Sep 17 00:00:00 2001
From: Thanaphon Frappet
Date: Thu, 23 Jan 2025 14:19:56 +0700
Subject: [PATCH 04/11] refactor: handle price 0 baht
---
.../components/employer/EmployerFormBusiness.vue | 2 +-
src/pages/05_quotation/preview/ViewForm.vue | 2 +-
src/pages/09_task-order/document_view/MainPage.vue | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/pages/03_customer-management/components/employer/EmployerFormBusiness.vue b/src/pages/03_customer-management/components/employer/EmployerFormBusiness.vue
index c99ef26c..5f3ab63f 100644
--- a/src/pages/03_customer-management/components/employer/EmployerFormBusiness.vue
+++ b/src/pages/03_customer-management/components/employer/EmployerFormBusiness.vue
@@ -71,7 +71,7 @@ watch(
(newValue) => {
if (newValue !== undefined && typeof newValue === 'string') {
const numericValue = newValue.replace(/,/g, '');
- wageRateText.value = ThaiBahtText(numericValue);
+ wageRateText.value = ThaiBahtText(numericValue) || 'ศูนย์บาทถ้วน';
wageRate.value = parseFloat(numericValue);
}
},
diff --git a/src/pages/05_quotation/preview/ViewForm.vue b/src/pages/05_quotation/preview/ViewForm.vue
index bdb3899c..cc80d367 100644
--- a/src/pages/05_quotation/preview/ViewForm.vue
+++ b/src/pages/05_quotation/preview/ViewForm.vue
@@ -448,7 +448,7 @@ function print() {
class="column set-width bg-color full-height"
style="padding: 12px"
>
- ({{ ThaiBahtText(summaryPrice.finalPrice) }})
+ ({{ ThaiBahtText(summaryPrice.finalPrice) || 'ศูนย์บาทถ้วน' }})
- ({{ ThaiBahtText(summaryPrice.finalPrice) }})
+ ({{ ThaiBahtText(summaryPrice.finalPrice) || 'ศูนย์บาทถ้วน' }})
Date: Thu, 23 Jan 2025 14:23:18 +0700
Subject: [PATCH 05/11] feat: 09 => edit task order (order)
---
.../09_task-order/SelectReadyRequestWork.vue | 131 ++++++++++++------
src/pages/09_task-order/form.ts | 9 +-
.../09_task-order/order_view/MainPage.vue | 27 +++-
src/stores/task-order/index.ts | 1 +
4 files changed, 124 insertions(+), 44 deletions(-)
diff --git a/src/pages/09_task-order/SelectReadyRequestWork.vue b/src/pages/09_task-order/SelectReadyRequestWork.vue
index b79133c1..54f3fa2b 100644
--- a/src/pages/09_task-order/SelectReadyRequestWork.vue
+++ b/src/pages/09_task-order/SelectReadyRequestWork.vue
@@ -22,6 +22,18 @@ const emit = defineEmits<{
}>();
const props = defineProps<{
+ taskListGroup: {
+ product: RequestWork['productService']['product'];
+ list: (RequestWork & {
+ _template?: {
+ id: string;
+ templateName: string;
+ templateStepName: string;
+ step: number;
+ responsibleInstitution: (string | { group: string })[];
+ } | null;
+ })[];
+ }[];
creditNote?: boolean;
fetchParams?: Parameters
[0];
}>();
@@ -39,6 +51,20 @@ const taskList = defineModel<
});
const open = defineModel('open', { default: false });
+const tempGroupEdit = defineModel<
+ {
+ product: RequestWork['productService']['product'];
+ list: (RequestWork & {
+ _template?: {
+ id: string;
+ templateName: string;
+ templateStepName: string;
+ step: number;
+ responsibleInstitution: (string | { group: string })[];
+ } | null;
+ })[];
+ }[]
+>('tempGroupEdit', { default: [] });
const selectedEmployee = ref<
(RequestWork & {
taskStatus: TaskStatus;
@@ -56,15 +82,28 @@ let group = computed(() =>
data.value.reduce<
{
product: RequestWork['productService']['product'];
- list: RequestWork[];
+ list: (RequestWork & {
+ _template?: {
+ id: string;
+ templateName: string;
+ templateStepName: string;
+ step: number;
+ responsibleInstitution: (string | { group: string })[];
+ } | null;
+ })[];
}[]
>((acc, curr) => {
let exist = acc.find(
(item) => curr.productService.productId == item.product.id,
);
- if (exist) exist.list.push(curr);
- else acc.push({ product: curr.productService.product, list: [curr] });
+ if (exist) exist.list.push({ ...curr, _template: getTemplateData(curr) });
+ else
+ acc.push({
+ product: curr.productService.product,
+ // list: [curr],
+ list: [{ ...curr, _template: getTemplateData(curr) }],
+ });
return acc;
}, []),
@@ -74,7 +113,12 @@ let state = reactive({
search: '',
});
-onMounted(getList);
+onMounted(async () => {
+ await getList();
+ if (tempGroupEdit.value.length === 0) {
+ tempGroupEdit.value = JSON.parse(JSON.stringify(group.value));
+ }
+});
watch(() => state.search, getList);
async function getList() {
@@ -90,35 +134,11 @@ async function getList() {
data.value = res.result;
}
-// function toggle(item: RequestWork) {
-// switch (selected(item)) {
-// case true:
-// return deselect(item);
-// case false:
-// return select(item);
-// }
-// }
-
-// function select(item: RequestWork) {
-// if (selected(item)) return;
-// selectedEmployee.value = selectedEmployee.value
-// ? selectedEmployee.value.concat(item)
-// : [item];
-// }
-
-// function deselect(item: RequestWork) {
-// const idx = selectedEmployee.value?.findIndex((v) => v.id === item.id);
-// if (idx !== -1) selectedEmployee.value?.splice(idx, 1);
-// }
-
-// function selected(item: RequestWork): boolean {
-// return !!selectedEmployee.value?.some((v) => v.id === item.id);
-// }
-//
-
function getStep(requestWork: RequestWork) {
const target = requestWork.stepStatus.find(
- (v) => v.workStatus === RequestWorkStatus.Ready,
+ (v) =>
+ v.workStatus === RequestWorkStatus.Ready ||
+ v.workStatus === RequestWorkStatus.InProgress,
);
return target?.step || 0;
}
@@ -135,6 +155,7 @@ function getTemplateData(requestWork: RequestWork) {
step: step.order,
templateName: flow.name,
templateStepName: step.name || '-',
+ responsibleInstitution: step.responsibleInstitution || [],
};
}
@@ -149,17 +170,22 @@ function submit() {
const curr = v.stepStatus.find(
(s) =>
s.workStatus ===
- (props.creditNote
- ? RequestWorkStatus.Canceled
- : RequestWorkStatus.Ready),
+ (props.creditNote
+ ? RequestWorkStatus.Canceled
+ : RequestWorkStatus.Ready) ||
+ s.workStatus ===
+ (props.creditNote
+ ? RequestWorkStatus.Canceled
+ : RequestWorkStatus.InProgress),
);
if (curr) {
const task: Task = {
...curr,
attributes: curr.attributes,
- workStatus: props.creditNote
- ? RequestWorkStatus.Canceled
- : RequestWorkStatus.Ready,
+ workStatus:
+ curr.workStatus || props.creditNote
+ ? RequestWorkStatus.Ready
+ : RequestWorkStatus.Canceled,
taskOrderId: '',
requestWork: selectedEmployee.value[i],
};
@@ -183,9 +209,13 @@ function close() {
}
function onDialogOpen() {
+ // assign selected to group
+ assignTempGroup();
+
+ // match group to check
selectedEmployee.value = [];
if (taskList.value.length === 0) return;
- const matchingItems = group.value
+ const matchingItems = tempGroupEdit.value
.flatMap((g) => g.list)
.filter((l) =>
l.stepStatus.some((s) =>
@@ -194,6 +224,27 @@ function onDialogOpen() {
);
selectedEmployee.value = JSON.parse(JSON.stringify(matchingItems));
}
+
+function assignTempGroup() {
+ props.taskListGroup.forEach((newGroup) => {
+ const existingGroup = tempGroupEdit.value.find(
+ (g) => g.product.id === newGroup.product.id,
+ );
+
+ if (existingGroup) {
+ newGroup.list.forEach((newItem) => {
+ if (!existingGroup.list.some((item) => item.id === newItem.id)) {
+ existingGroup.list.push(newItem);
+ }
+ });
+ } else {
+ tempGroupEdit.value.push({
+ ...newGroup,
+ list: [...newGroup.list], // Ensure a new reference
+ });
+ }
+ });
+}
@@ -205,9 +256,9 @@ function onDialogOpen() {