Merge branch 'develop'
This commit is contained in:
commit
dc163e6e97
13 changed files with 273 additions and 109 deletions
|
|
@ -57,7 +57,6 @@ const currentBtnOpen = ref<{ title: string; opened: boolean[] }[]>([
|
||||||
]);
|
]);
|
||||||
|
|
||||||
function calcPrice(c: (typeof rows.value)[number]) {
|
function calcPrice(c: (typeof rows.value)[number]) {
|
||||||
console.log(c);
|
|
||||||
const originalPrice = c.pricePerUnit;
|
const originalPrice = c.pricePerUnit;
|
||||||
const finalPriceWithVat = precisionRound(
|
const finalPriceWithVat = precisionRound(
|
||||||
originalPrice + originalPrice * (config.value?.vat || 0.07),
|
originalPrice + originalPrice * (config.value?.vat || 0.07),
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ watch(
|
||||||
(newValue) => {
|
(newValue) => {
|
||||||
if (newValue !== undefined && typeof newValue === 'string') {
|
if (newValue !== undefined && typeof newValue === 'string') {
|
||||||
const numericValue = newValue.replace(/,/g, '');
|
const numericValue = newValue.replace(/,/g, '');
|
||||||
wageRateText.value = ThaiBahtText(numericValue);
|
wageRateText.value = ThaiBahtText(numericValue) || 'ศูนย์บาทถ้วน';
|
||||||
wageRate.value = parseFloat(numericValue);
|
wageRate.value = parseFloat(numericValue);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -704,18 +704,22 @@ function handleUpdateProductTable(
|
||||||
newInstallmentNo: number;
|
newInstallmentNo: number;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
|
handleChangePayType(quotationFormData.value.payCondition);
|
||||||
// calc price
|
// calc price
|
||||||
const calc = (c: QuotationPayload['productServiceList'][number]) => {
|
const calc = (c: QuotationPayload['productServiceList'][number]) => {
|
||||||
const pricePerUnit = c.pricePerUnit || 0;
|
const originalPrice = c.pricePerUnit || 0;
|
||||||
const discount = c.discount || 0;
|
const finalPriceWithVat = precisionRound(
|
||||||
|
originalPrice * (1 + (config.value?.vat || 0.07)),
|
||||||
return (
|
|
||||||
pricePerUnit * c.amount -
|
|
||||||
discount +
|
|
||||||
(c.product.calcVat
|
|
||||||
? (pricePerUnit * c.amount - discount) * (config.value?.vat || 0.07)
|
|
||||||
: 0)
|
|
||||||
);
|
);
|
||||||
|
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
|
// installment
|
||||||
|
|
@ -2057,23 +2061,20 @@ watch(
|
||||||
|
|
||||||
<div class="surface-1 q-pa-md flex" style="gap: var(--size-2)">
|
<div class="surface-1 q-pa-md flex" style="gap: var(--size-2)">
|
||||||
<SelectInput
|
<SelectInput
|
||||||
style="max-width: 250px"
|
class="q-mr-sm"
|
||||||
class="q-mr-xl"
|
|
||||||
incremental
|
|
||||||
v-model="templateForm"
|
v-model="templateForm"
|
||||||
id="quotation-branch"
|
id="quotation-branch"
|
||||||
:option="templateFormOption"
|
:option="templateFormOption"
|
||||||
:label="$t('quotation.templateForm')"
|
:label="$t('quotation.templateForm')"
|
||||||
:option-label="locale === 'eng' ? 'labelEN' : 'label'"
|
|
||||||
/>
|
/>
|
||||||
<MainButton
|
<!-- <MainButton
|
||||||
outlined
|
outlined
|
||||||
icon="mdi-play-box-outline"
|
icon="mdi-play-box-outline"
|
||||||
color="207 96% 32%"
|
color="207 96% 32%"
|
||||||
@click="storeDataLocal"
|
@click="storeDataLocal"
|
||||||
>
|
>
|
||||||
{{ $t('general.view', { msg: $t('general.example') }) }}
|
{{ $t('general.view', { msg: $t('general.example') }) }}
|
||||||
</MainButton>
|
</MainButton> -->
|
||||||
<MainButton
|
<MainButton
|
||||||
solid
|
solid
|
||||||
icon="mdi-pencil-outline"
|
icon="mdi-pencil-outline"
|
||||||
|
|
|
||||||
|
|
@ -448,7 +448,7 @@ function print() {
|
||||||
class="column set-width bg-color full-height"
|
class="column set-width bg-color full-height"
|
||||||
style="padding: 12px"
|
style="padding: 12px"
|
||||||
>
|
>
|
||||||
({{ ThaiBahtText(summaryPrice.finalPrice) }})
|
({{ ThaiBahtText(summaryPrice.finalPrice) || 'ศูนย์บาทถ้วน' }})
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="row text-right border-5 items-center"
|
class="row text-right border-5 items-center"
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ async function triggerTaskOrder(opts: {
|
||||||
window.location.origin,
|
window.location.origin,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (pageState.currentTab === 'Pending') {
|
if (pageState.currentTab === 'Pending' && opts.statusDialog === 'edit') {
|
||||||
url.searchParams.append('edit', String(opts.statusDialog === 'edit'));
|
url.searchParams.append('edit', String(opts.statusDialog === 'edit'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,18 @@ const emit = defineEmits<{
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const props = defineProps<{
|
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;
|
creditNote?: boolean;
|
||||||
fetchParams?: Parameters<typeof requestListStore.getRequestWorkList>[0];
|
fetchParams?: Parameters<typeof requestListStore.getRequestWorkList>[0];
|
||||||
}>();
|
}>();
|
||||||
|
|
@ -39,6 +51,20 @@ const taskList = defineModel<
|
||||||
});
|
});
|
||||||
const open = defineModel<boolean>('open', { default: false });
|
const open = defineModel<boolean>('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<
|
const selectedEmployee = ref<
|
||||||
(RequestWork & {
|
(RequestWork & {
|
||||||
taskStatus: TaskStatus;
|
taskStatus: TaskStatus;
|
||||||
|
|
@ -56,15 +82,28 @@ let group = computed(() =>
|
||||||
data.value.reduce<
|
data.value.reduce<
|
||||||
{
|
{
|
||||||
product: RequestWork['productService']['product'];
|
product: RequestWork['productService']['product'];
|
||||||
list: RequestWork[];
|
list: (RequestWork & {
|
||||||
|
_template?: {
|
||||||
|
id: string;
|
||||||
|
templateName: string;
|
||||||
|
templateStepName: string;
|
||||||
|
step: number;
|
||||||
|
responsibleInstitution: (string | { group: string })[];
|
||||||
|
} | null;
|
||||||
|
})[];
|
||||||
}[]
|
}[]
|
||||||
>((acc, curr) => {
|
>((acc, curr) => {
|
||||||
let exist = acc.find(
|
let exist = acc.find(
|
||||||
(item) => curr.productService.productId == item.product.id,
|
(item) => curr.productService.productId == item.product.id,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (exist) exist.list.push(curr);
|
if (exist) exist.list.push({ ...curr, _template: getTemplateData(curr) });
|
||||||
else acc.push({ product: curr.productService.product, list: [curr] });
|
else
|
||||||
|
acc.push({
|
||||||
|
product: curr.productService.product,
|
||||||
|
// list: [curr],
|
||||||
|
list: [{ ...curr, _template: getTemplateData(curr) }],
|
||||||
|
});
|
||||||
|
|
||||||
return acc;
|
return acc;
|
||||||
}, []),
|
}, []),
|
||||||
|
|
@ -74,7 +113,12 @@ let state = reactive({
|
||||||
search: '',
|
search: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
onMounted(getList);
|
onMounted(async () => {
|
||||||
|
await getList();
|
||||||
|
if (tempGroupEdit.value.length === 0) {
|
||||||
|
tempGroupEdit.value = JSON.parse(JSON.stringify(group.value));
|
||||||
|
}
|
||||||
|
});
|
||||||
watch(() => state.search, getList);
|
watch(() => state.search, getList);
|
||||||
|
|
||||||
async function getList() {
|
async function getList() {
|
||||||
|
|
@ -90,35 +134,11 @@ async function getList() {
|
||||||
data.value = res.result;
|
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) {
|
function getStep(requestWork: RequestWork) {
|
||||||
const target = requestWork.stepStatus.find(
|
const target = requestWork.stepStatus.find(
|
||||||
(v) => v.workStatus === RequestWorkStatus.Ready,
|
(v) =>
|
||||||
|
v.workStatus === RequestWorkStatus.Ready ||
|
||||||
|
v.workStatus === RequestWorkStatus.InProgress,
|
||||||
);
|
);
|
||||||
return target?.step || 0;
|
return target?.step || 0;
|
||||||
}
|
}
|
||||||
|
|
@ -135,6 +155,7 @@ function getTemplateData(requestWork: RequestWork) {
|
||||||
step: step.order,
|
step: step.order,
|
||||||
templateName: flow.name,
|
templateName: flow.name,
|
||||||
templateStepName: step.name || '-',
|
templateStepName: step.name || '-',
|
||||||
|
responsibleInstitution: step.responsibleInstitution || [],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -149,17 +170,22 @@ function submit() {
|
||||||
const curr = v.stepStatus.find(
|
const curr = v.stepStatus.find(
|
||||||
(s) =>
|
(s) =>
|
||||||
s.workStatus ===
|
s.workStatus ===
|
||||||
(props.creditNote
|
(props.creditNote
|
||||||
? RequestWorkStatus.Canceled
|
? RequestWorkStatus.Canceled
|
||||||
: RequestWorkStatus.Ready),
|
: RequestWorkStatus.Ready) ||
|
||||||
|
s.workStatus ===
|
||||||
|
(props.creditNote
|
||||||
|
? RequestWorkStatus.Canceled
|
||||||
|
: RequestWorkStatus.InProgress),
|
||||||
);
|
);
|
||||||
if (curr) {
|
if (curr) {
|
||||||
const task: Task = {
|
const task: Task = {
|
||||||
...curr,
|
...curr,
|
||||||
attributes: curr.attributes,
|
attributes: curr.attributes,
|
||||||
workStatus: props.creditNote
|
workStatus:
|
||||||
? RequestWorkStatus.Canceled
|
curr.workStatus || props.creditNote
|
||||||
: RequestWorkStatus.Ready,
|
? RequestWorkStatus.Ready
|
||||||
|
: RequestWorkStatus.Canceled,
|
||||||
taskOrderId: '',
|
taskOrderId: '',
|
||||||
requestWork: selectedEmployee.value[i],
|
requestWork: selectedEmployee.value[i],
|
||||||
};
|
};
|
||||||
|
|
@ -183,9 +209,13 @@ function close() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function onDialogOpen() {
|
function onDialogOpen() {
|
||||||
|
// assign selected to group
|
||||||
|
!props.creditNote && assignTempGroup();
|
||||||
|
|
||||||
|
// match group to check
|
||||||
selectedEmployee.value = [];
|
selectedEmployee.value = [];
|
||||||
if (taskList.value.length === 0) return;
|
if (taskList.value.length === 0) return;
|
||||||
const matchingItems = group.value
|
const matchingItems = tempGroupEdit.value
|
||||||
.flatMap((g) => g.list)
|
.flatMap((g) => g.list)
|
||||||
.filter((l) =>
|
.filter((l) =>
|
||||||
l.stepStatus.some((s) =>
|
l.stepStatus.some((s) =>
|
||||||
|
|
@ -194,6 +224,28 @@ function onDialogOpen() {
|
||||||
);
|
);
|
||||||
selectedEmployee.value = JSON.parse(JSON.stringify(matchingItems));
|
selectedEmployee.value = JSON.parse(JSON.stringify(matchingItems));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function assignTempGroup() {
|
||||||
|
if (!props.taskListGroup) return;
|
||||||
|
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
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -205,9 +257,9 @@ function onDialogOpen() {
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<section class="col column full-width no-wrap surface-2 scroll">
|
<section class="col column full-width no-wrap surface-2 scroll">
|
||||||
<template v-if="group.length > 0">
|
<template v-if="tempGroupEdit.length > 0">
|
||||||
<div
|
<div
|
||||||
v-for="{ product, list } in group"
|
v-for="{ product, list } in tempGroupEdit"
|
||||||
:key="product.id"
|
:key="product.id"
|
||||||
class="bordered-b"
|
class="bordered-b"
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import {
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import { useTaskOrderStore } from 'src/stores/task-order';
|
import { useTaskOrderStore } from 'src/stores/task-order';
|
||||||
import { RequestWork } from 'src/stores/request-list';
|
import { RequestWork } from 'src/stores/request-list';
|
||||||
|
import { convertTemplate } from 'src/utils/string-template';
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const taskOrder = useTaskOrderStore();
|
const taskOrder = useTaskOrderStore();
|
||||||
|
|
@ -105,6 +106,12 @@ function getHeight(el: HTMLElement) {
|
||||||
|
|
||||||
const STORAGE_KEY = 'task-order-preview';
|
const STORAGE_KEY = 'task-order-preview';
|
||||||
|
|
||||||
|
const taskListGroup = ref<
|
||||||
|
{
|
||||||
|
product: RequestWork['productService']['product'];
|
||||||
|
list: (RequestWork & { _status: TaskStatus })[];
|
||||||
|
}[]
|
||||||
|
>([]);
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
if (route.params['id'] && typeof route.params['id'] === 'string') {
|
if (route.params['id'] && typeof route.params['id'] === 'string') {
|
||||||
viewType.value = route.name as 'docOrder' | 'docReceive';
|
viewType.value = route.name as 'docOrder' | 'docReceive';
|
||||||
|
|
@ -132,7 +139,7 @@ onMounted(async () => {
|
||||||
branch.value = jsonObject.registeredBranch;
|
branch.value = jsonObject.registeredBranch;
|
||||||
}
|
}
|
||||||
|
|
||||||
const taskListGroup = data.value?.taskList.reduce<
|
const _taskListGroup = data.value?.taskList.reduce<
|
||||||
{
|
{
|
||||||
product: RequestWork['productService']['product'];
|
product: RequestWork['productService']['product'];
|
||||||
list: (RequestWork & { _status: TaskStatus })[];
|
list: (RequestWork & { _status: TaskStatus })[];
|
||||||
|
|
@ -172,14 +179,14 @@ onMounted(async () => {
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
product.value = [];
|
product.value = [];
|
||||||
summaryPrice.value = taskListGroup
|
taskListGroup.value = _taskListGroup;
|
||||||
|
summaryPrice.value = _taskListGroup
|
||||||
.flatMap((v) => {
|
.flatMap((v) => {
|
||||||
const list = v.list.filter(
|
const list =
|
||||||
(item) => item._status === TaskStatus.Complete,
|
(viewType.value === 'docReceive'
|
||||||
);
|
? v.list.filter((item) => item._status === TaskStatus.Complete)
|
||||||
if (viewType.value === 'docReceive' && list.length === 0) {
|
: v.list) || [];
|
||||||
return [];
|
|
||||||
}
|
|
||||||
return {
|
return {
|
||||||
product: v.product,
|
product: v.product,
|
||||||
pricePerUnit: v.product.serviceCharge,
|
pricePerUnit: v.product.serviceCharge,
|
||||||
|
|
@ -374,7 +381,7 @@ function print() {
|
||||||
class="column set-width bg-color full-height"
|
class="column set-width bg-color full-height"
|
||||||
style="padding: 12px"
|
style="padding: 12px"
|
||||||
>
|
>
|
||||||
({{ ThaiBahtText(summaryPrice.finalPrice) }})
|
({{ ThaiBahtText(summaryPrice.finalPrice) || 'ศูนย์บาทถ้วน' }})
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="row text-right border-5 items-center"
|
class="row text-right border-5 items-center"
|
||||||
|
|
@ -415,7 +422,34 @@ function print() {
|
||||||
}"
|
}"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<article style="height: 5.8in"></article>
|
<span
|
||||||
|
class="q-mb-sm q-mt-md"
|
||||||
|
style="
|
||||||
|
font-weight: 800;
|
||||||
|
font-size: 16px;
|
||||||
|
color: var(--main);
|
||||||
|
display: block;
|
||||||
|
border-bottom: 2px solid var(--main);
|
||||||
|
"
|
||||||
|
>
|
||||||
|
{{ $t('general.remark') }}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="border-5 surface-0 detail-note q-mb-md"
|
||||||
|
style="width: 100%; padding: 8px 16px; white-space: pre-wrap"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-html="
|
||||||
|
convertTemplate(data?.remark || '', {
|
||||||
|
'order-detail': {
|
||||||
|
items: taskListGroup,
|
||||||
|
itemsDiscount: data.taskProduct || [],
|
||||||
|
},
|
||||||
|
}) || '-'
|
||||||
|
"
|
||||||
|
></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<ViewFooter
|
<ViewFooter
|
||||||
:data="{
|
:data="{
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ export const useTaskOrderForm = defineStore('task-order-form', () => {
|
||||||
contactTel: '',
|
contactTel: '',
|
||||||
contactName: '',
|
contactName: '',
|
||||||
taskName: '',
|
taskName: '',
|
||||||
|
remark: '#[order-detail]',
|
||||||
};
|
};
|
||||||
|
|
||||||
const state = ref<{
|
const state = ref<{
|
||||||
|
|
@ -103,7 +104,10 @@ export const useTaskOrderForm = defineStore('task-order-form', () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state.value.mode === 'edit' && !!currentFormData.value.id) {
|
if (state.value.mode === 'edit' && !!currentFormData.value.id) {
|
||||||
const res = await taskOrderStore.editTaskOrder(currentFormData.value);
|
const res = await taskOrderStore.editTaskOrder({
|
||||||
|
...currentFormData.value,
|
||||||
|
taskProduct: opt?.taskProduct,
|
||||||
|
});
|
||||||
if (res) {
|
if (res) {
|
||||||
succeed = true;
|
succeed = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ import {
|
||||||
MainButton,
|
MainButton,
|
||||||
EditButton,
|
EditButton,
|
||||||
UndoButton,
|
UndoButton,
|
||||||
|
CancelButton,
|
||||||
} from 'src/components/button';
|
} from 'src/components/button';
|
||||||
import FormGroupHead from 'src/pages/08_request-list/FormGroupHead.vue';
|
import FormGroupHead from 'src/pages/08_request-list/FormGroupHead.vue';
|
||||||
import FailRemarkDialog from '../receive_view/FailRemarkDialog.vue';
|
import FailRemarkDialog from '../receive_view/FailRemarkDialog.vue';
|
||||||
|
|
@ -75,6 +76,20 @@ const taskStatusRecords = ref<
|
||||||
failedType?: string;
|
failedType?: string;
|
||||||
}[]
|
}[]
|
||||||
>([]);
|
>([]);
|
||||||
|
const tempGroupEdit = ref<
|
||||||
|
{
|
||||||
|
product: RequestWork['productService']['product'];
|
||||||
|
list: (RequestWork & {
|
||||||
|
_template?: {
|
||||||
|
id: string;
|
||||||
|
templateName: string;
|
||||||
|
templateStepName: string;
|
||||||
|
step: number;
|
||||||
|
responsibleInstitution: (string | { group: string })[];
|
||||||
|
} | null;
|
||||||
|
})[];
|
||||||
|
}[]
|
||||||
|
>([]);
|
||||||
|
|
||||||
const pageState = reactive({
|
const pageState = reactive({
|
||||||
productDialog: false,
|
productDialog: false,
|
||||||
|
|
@ -856,7 +871,7 @@ watch([currentFormData.value.taskStatus], () => {
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<DocumentExpansion
|
<DocumentExpansion
|
||||||
:readonly="state.mode !== 'create'"
|
:readonly="!['create', 'edit'].includes(state.mode || '')"
|
||||||
v-model:registered-branch-id="currentFormData.registeredBranchId"
|
v-model:registered-branch-id="currentFormData.registeredBranchId"
|
||||||
v-model:institution-id="currentFormData.institutionId"
|
v-model:institution-id="currentFormData.institutionId"
|
||||||
v-model:task-name="currentFormData.taskName"
|
v-model:task-name="currentFormData.taskName"
|
||||||
|
|
@ -891,11 +906,11 @@ watch([currentFormData.value.taskStatus], () => {
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<AdditionalFileExpansion
|
<AdditionalFileExpansion
|
||||||
|
:readonly="!['create', 'edit'].includes(state.mode || '')"
|
||||||
v-if="
|
v-if="
|
||||||
view === TaskOrderStatus.Pending ||
|
view === TaskOrderStatus.Pending ||
|
||||||
view === TaskOrderStatus.Complete
|
view === TaskOrderStatus.Complete
|
||||||
"
|
"
|
||||||
:readonly="!['create', 'edit'].includes(state.mode || '')"
|
|
||||||
v-model:file-data="fileData"
|
v-model:file-data="fileData"
|
||||||
:transform-url="
|
:transform-url="
|
||||||
async (url: string) => {
|
async (url: string) => {
|
||||||
|
|
@ -916,28 +931,34 @@ watch([currentFormData.value.taskStatus], () => {
|
||||||
@upload="
|
@upload="
|
||||||
async (f) => {
|
async (f) => {
|
||||||
fileList = f;
|
fileList = f;
|
||||||
fileData = [];
|
|
||||||
|
|
||||||
Array.from(f).forEach((el) => {
|
if (!currentFormData.id) {
|
||||||
fileData.push({
|
fileData = [];
|
||||||
name: el.name,
|
|
||||||
progress: 1,
|
Array.from(f).forEach((el) => {
|
||||||
loaded: 0,
|
fileData.push({
|
||||||
total: el.size,
|
name: el.name,
|
||||||
placeholder: true,
|
progress: 1,
|
||||||
url: fileToUrl(el),
|
loaded: 0,
|
||||||
|
total: el.size,
|
||||||
|
placeholder: true,
|
||||||
|
url: fileToUrl(el),
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
} else {
|
||||||
|
await uploadFile(currentFormData.id, f);
|
||||||
if (!currentFormData.id) return;
|
}
|
||||||
|
|
||||||
await uploadFile(currentFormData.id, f);
|
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
@remove="
|
@remove="
|
||||||
async (n) => {
|
async (n) => {
|
||||||
if (!currentFormData.id) return;
|
if (!currentFormData.id) {
|
||||||
await remove(currentFormData.id, n);
|
const attIndex = fileData.findIndex((v) => v.name === n);
|
||||||
|
|
||||||
|
fileData.splice(attIndex, 1);
|
||||||
|
} else {
|
||||||
|
await remove(currentFormData.id, n);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
|
|
@ -947,7 +968,8 @@ watch([currentFormData.value.taskStatus], () => {
|
||||||
view === TaskOrderStatus.Pending ||
|
view === TaskOrderStatus.Pending ||
|
||||||
view === TaskOrderStatus.Complete
|
view === TaskOrderStatus.Complete
|
||||||
"
|
"
|
||||||
:readonly="false"
|
v-model:remark="currentFormData.remark"
|
||||||
|
:readonly="!['create', 'edit'].includes(state.mode || '')"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<template
|
<template
|
||||||
|
|
@ -1185,7 +1207,11 @@ watch([currentFormData.value.taskStatus], () => {
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<SaveButton
|
<SaveButton
|
||||||
v-if="state.mode !== 'create' && view === TaskOrderStatus.Validate"
|
v-if="
|
||||||
|
state.mode !== 'create' &&
|
||||||
|
view === TaskOrderStatus.Validate &&
|
||||||
|
fullTaskOrder?.taskOrderStatus !== TaskOrderStatus.Pending
|
||||||
|
"
|
||||||
:disabled="
|
:disabled="
|
||||||
!fullTaskOrder?.taskList.some((t) =>
|
!fullTaskOrder?.taskList.some((t) =>
|
||||||
[
|
[
|
||||||
|
|
@ -1228,9 +1254,11 @@ watch([currentFormData.value.taskStatus], () => {
|
||||||
|
|
||||||
<!-- SEC: Dialog -->
|
<!-- SEC: Dialog -->
|
||||||
<SelectReadyRequestWork
|
<SelectReadyRequestWork
|
||||||
|
:task-list-group="taskListGroup"
|
||||||
:fetch-params="{ readyToTask: true }"
|
:fetch-params="{ readyToTask: true }"
|
||||||
v-model:open="pageState.productDialog"
|
v-model:open="pageState.productDialog"
|
||||||
v-model:task-list="currentFormData.taskList"
|
v-model:task-list="currentFormData.taskList"
|
||||||
|
v-model:temp-group-edit="tempGroupEdit"
|
||||||
@after-submit="
|
@after-submit="
|
||||||
() => {
|
() => {
|
||||||
taskProduct = [];
|
taskProduct = [];
|
||||||
|
|
|
||||||
|
|
@ -674,32 +674,36 @@ onMounted(async () => {
|
||||||
@upload="
|
@upload="
|
||||||
async (f) => {
|
async (f) => {
|
||||||
attachmentList = f;
|
attachmentList = f;
|
||||||
attachmentData = [];
|
|
||||||
|
|
||||||
Array.from(f).forEach((el) => {
|
if (!creditNoteData) {
|
||||||
attachmentData.push({
|
attachmentData = [];
|
||||||
name: el.name,
|
|
||||||
progress: 1,
|
Array.from(f).forEach((el) => {
|
||||||
loaded: 0,
|
attachmentData.push({
|
||||||
total: el.size,
|
name: el.name,
|
||||||
placeholder: true,
|
progress: 1,
|
||||||
url: fileToUrl(el),
|
loaded: 0,
|
||||||
|
total: el.size,
|
||||||
|
placeholder: true,
|
||||||
|
url: fileToUrl(el),
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
} else {
|
||||||
|
await uploadFile(creditNoteData.id, f);
|
||||||
if (!creditNoteData) return;
|
}
|
||||||
|
|
||||||
await uploadFile(creditNoteData.id, f);
|
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
@remove="
|
@remove="
|
||||||
async (n) => {
|
async (n) => {
|
||||||
const attIndex = attachmentData.findIndex((v) => v.name === n);
|
if (!creditNoteData) {
|
||||||
|
const attIndex = attachmentData.findIndex(
|
||||||
|
(v) => v.name === n,
|
||||||
|
);
|
||||||
|
|
||||||
attachmentData.splice(attIndex, 1);
|
attachmentData.splice(attIndex, 1);
|
||||||
|
} else {
|
||||||
if (!creditNoteData) return;
|
await remove(creditNoteData.id, n);
|
||||||
await remove(creditNoteData.id, n);
|
}
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,10 @@ export const useTaskOrderStore = defineStore('taskorder-store', () => {
|
||||||
|
|
||||||
async function editTaskOrder(body: TaskOrderPayload) {
|
async function editTaskOrder(body: TaskOrderPayload) {
|
||||||
const res = await api.put<TaskOrder>(`/task-order/${body.id}`, {
|
const res = await api.put<TaskOrder>(`/task-order/${body.id}`, {
|
||||||
|
taskProduct: body.taskProduct?.map((v) => ({
|
||||||
|
productId: v.productId,
|
||||||
|
discount: v.discount,
|
||||||
|
})),
|
||||||
taskList: body.taskList.map((v) => ({
|
taskList: body.taskList.map((v) => ({
|
||||||
step: v.step,
|
step: v.step,
|
||||||
requestWorkId: v.requestWorkId,
|
requestWorkId: v.requestWorkId,
|
||||||
|
|
@ -113,6 +117,7 @@ export const useTaskOrderStore = defineStore('taskorder-store', () => {
|
||||||
contactName: body.contactName,
|
contactName: body.contactName,
|
||||||
taskStatus: body.taskStatus,
|
taskStatus: body.taskStatus,
|
||||||
taskName: body.taskName,
|
taskName: body.taskName,
|
||||||
|
remark: body.remark,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (res.status < 400) {
|
if (res.status < 400) {
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ export interface TaskOrder {
|
||||||
code: string;
|
code: string;
|
||||||
id: string;
|
id: string;
|
||||||
userTask: UserTask[];
|
userTask: UserTask[];
|
||||||
|
remark?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UserTask {
|
export interface UserTask {
|
||||||
|
|
@ -176,6 +177,7 @@ export interface TaskOrderPayload {
|
||||||
registeredBranchId?: string;
|
registeredBranchId?: string;
|
||||||
id?: string;
|
id?: string;
|
||||||
code?: string;
|
code?: string;
|
||||||
|
remark?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ProductService {
|
export interface ProductService {
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { RequestWork } from 'src/stores/request-list';
|
||||||
import { formatNumberDecimal } from 'src/stores/utils';
|
import { formatNumberDecimal } from 'src/stores/utils';
|
||||||
|
|
||||||
const templates = {
|
const templates = {
|
||||||
|
|
@ -40,6 +41,40 @@ const templates = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'order-detail': {
|
||||||
|
converter: (context?: {
|
||||||
|
items: {
|
||||||
|
product: RequestWork['productService']['product'];
|
||||||
|
list: RequestWork[];
|
||||||
|
}[];
|
||||||
|
itemsDiscount?: {
|
||||||
|
productId: string;
|
||||||
|
discount?: number;
|
||||||
|
}[];
|
||||||
|
}) => {
|
||||||
|
return context?.items.flatMap((item) => {
|
||||||
|
const price = formatNumberDecimal(
|
||||||
|
item.product.serviceCharge -
|
||||||
|
(context.itemsDiscount?.find((v) => v.productId === item.product.id)
|
||||||
|
?.discount || 0),
|
||||||
|
);
|
||||||
|
|
||||||
|
const list = item.list.map((v, i) => {
|
||||||
|
const employee = v.request.employee;
|
||||||
|
const branch = v.request.quotation.customerBranch;
|
||||||
|
return (
|
||||||
|
`${i + 1}. ` +
|
||||||
|
`${employee.namePrefix}. ${employee.firstNameEN} ${employee.lastNameEN} `.toUpperCase() +
|
||||||
|
`(${branch.customer.customerType === 'PERS' ? `นายจ้าง ${branch.namePrefix}. ${branch.firstNameEN} ${branch.lastNameEN} `.toUpperCase() : branch.registerName})`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
return [`- ${item.product.name} ราคา ${price} บาท`, '', ...list].join(
|
||||||
|
'<br />',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
type Template = typeof templates;
|
type Template = typeof templates;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue