refactor: handle work name

This commit is contained in:
Thanaphon Frappet 2025-01-28 10:30:05 +07:00
parent 0750d77b98
commit 90cbe69ba7

View file

@ -1236,6 +1236,38 @@ function getInvoice() {
}
}
function handleWorkName() {
const validService = productService.value.find(
(item) => 'service' in item && item.service !== null,
);
if (!validService || validService?.service === null) return;
const workName = validService?.service.name;
if (
!!quotationFormData.value.workName &&
!(quotationFormData.value.workName === workName)
) {
dialogCheckData({
action: () => {
quotationFormData.value.workName = workName;
},
checkData: () => {
return {
oldData: [
{ nameField: 'workName', value: quotationFormData.value.workName },
],
newData: [{ nameField: 'workName', value: workName }],
};
},
cancel: () => {},
});
} else {
quotationFormData.value.workName = workName;
}
}
watch(
[
() => quotationFormState.value.statusFilterRequest,
@ -1266,6 +1298,7 @@ async function formDownload() {
</script>
<template>
{{ console.log(productService) }}
<ImportWorker
v-model:open="pageState.importWorker"
v-model:data="importWorkerCriteria"
@ -2350,7 +2383,12 @@ async function formDownload() {
v-model:service-list="serviceList"
v-model:selected-product-group="selectedProductGroup"
:agent-price="agentPrice"
@submit="convertToTable"
@submit="
(node) => {
convertToTable(node);
handleWorkName();
}
"
@select-group="
async (id) => {
await getAllService(id);