Compare commits

...

2 commits

Author SHA1 Message Date
Thanaphon Frappet
1d38dbc6cf refactor: copy now
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 7s
2025-04-24 14:10:11 +07:00
Thanaphon Frappet
a4a101712c fix: incorrectly swapped data 2025-04-24 14:09:17 +07:00
2 changed files with 61 additions and 67 deletions

View file

@ -78,6 +78,12 @@ onMounted(async () => {
await fetchProvince(); await fetchProvince();
}); });
const visaIssueCountryOptions = ref<Record<string, unknown>[]>([]);
let visaIssueCountryFilter: (
value: string,
update: (callbackFn: () => void, afterFn?: (ref: QSelect) => void) => void,
) => void;
const visaTypeOptions = ref<Record<string, unknown>[]>([]); const visaTypeOptions = ref<Record<string, unknown>[]>([]);
let visaTypeFilter: ( let visaTypeFilter: (
value: string, value: string,
@ -97,6 +103,12 @@ onMounted(() => {
'label', 'label',
); );
visaIssueCountryFilter = selectFilterOptionRefMod(
ref(optionStore.globalOption?.nationality),
visaIssueCountryOptions,
'label',
);
workerTypeFilter = selectFilterOptionRefMod( workerTypeFilter = selectFilterOptionRefMod(
ref(optionStore.globalOption?.workerType), ref(optionStore.globalOption?.workerType),
workerTypeOptions, workerTypeOptions,
@ -107,8 +119,14 @@ onMounted(() => {
watch( watch(
() => optionStore.globalOption, () => optionStore.globalOption,
() => { () => {
visaIssueCountryFilter = selectFilterOptionRefMod(
ref(optionStore.globalOption?.nationality),
visaIssueCountryOptions,
'label',
);
visaTypeFilter = selectFilterOptionRefMod( visaTypeFilter = selectFilterOptionRefMod(
optionStore.globalOption.nationality, optionStore.globalOption.visaType,
visaTypeOptions, visaTypeOptions,
'label', 'label',
); );
@ -422,11 +440,11 @@ watch(
class="col-md-4 col-6" class="col-md-4 col-6"
:dense="dense" :dense="dense"
:readonly="readonly" :readonly="readonly"
:options="visaTypeOptions" :options="visaIssueCountryOptions"
:hide-dropdown-icon="readonly" :hide-dropdown-icon="readonly"
:for="`${prefixId}-select-issue-country`" :for="`${prefixId}-select-issue-country`"
:label="$t('customerEmployee.form.issueCountry')" :label="$t('customerEmployee.form.issueCountry')"
@filter="visaTypeFilter" @filter="visaIssueCountryFilter"
:model-value="readonly ? issueCountry || '-' : issueCountry" :model-value="readonly ? issueCountry || '-' : issueCountry"
@update:model-value=" @update:model-value="
(v) => (typeof v === 'string' ? (issueCountry = v) : '') (v) => (typeof v === 'string' ? (issueCountry = v) : '')

View file

@ -104,10 +104,6 @@ const {
importProduct, importProduct,
} = productServiceStore; } = productServiceStore;
const currentCopy = ref<{
id: string | undefined;
type: 'service' | 'product';
}>();
const { workNameItems } = storeToRefs(productServiceStore); const { workNameItems } = storeToRefs(productServiceStore);
const allStat = ref<{ mode: string; count: number }[]>([]); const allStat = ref<{ mode: string; count: number }[]>([]);
@ -1848,65 +1844,49 @@ function handleSubmitSameWorkflow() {
); );
} }
async function paste() { async function copy(id: string) {
if ( {
!!currentCopy.value && const res = await fetchListServiceById(id);
currentCopy.value.type === 'service' && if (res) {
!!currentCopy.value.id formService.value = {
) code: res.code,
dialogWarningClose(t, { name: res.name,
message: t('dialog.message.warningPaste'), detail: res.detail,
action: async () => { attributes: res.attributes,
const res = await fetchListServiceById(currentCopy.value.id); work: res.work.map((v) => ({
if (res) { id: v.id,
formService.value = { name: v.name,
code: res.code, attributes: v.attributes,
name: res.name, product: v.productOnWork.map((productOnWorkItem) => ({
detail: res.detail, id: productOnWorkItem.product.id,
attributes: res.attributes, installmentNo: productOnWorkItem.installmentNo,
work: res.work.map((v) => ({ stepCount: productOnWorkItem.stepCount,
id: v.id, })),
name: v.name, })),
attributes: v.attributes, status: res.status,
product: v.productOnWork.map((productOnWorkItem) => ({ productGroupId: res.productGroupId,
id: productOnWorkItem.product.id, selectedImage: res.selectedImage,
installmentNo: productOnWorkItem.installmentNo, installments: res.installments,
stepCount: productOnWorkItem.stepCount, };
})),
})),
status: res.status,
productGroupId: res.productGroupId,
selectedImage: res.selectedImage,
installments: res.installments,
};
workItems.value = res.work.map((item) => { workItems.value = res.work.map((item) => {
return {
id: item.id,
name: item.name,
attributes: item.attributes,
product: item.productOnWork.map((productOnWorkItem) => {
return { return {
id: item.id, ...productOnWorkItem.product,
name: item.name, nameEn: productOnWorkItem.product.name,
attributes: item.attributes, installmentNo: productOnWorkItem.installmentNo,
product: item.productOnWork.map((productOnWorkItem) => {
return {
...productOnWorkItem.product,
nameEn: productOnWorkItem.product.name,
installmentNo: productOnWorkItem.installmentNo,
};
}),
}; };
}); }),
} };
}, });
}); }
else {
dialog({
color: 'warning',
icon: 'mdi-alert',
title: t('form.warning.title'),
actionText: t('dialog.action.ok'),
message: t('dialog.message.warningCopyEmpty'),
action: async () => {},
});
} }
dialogService.value = true;
} }
watch( watch(
@ -3278,11 +3258,7 @@ watch(
:id-name="props.row.name" :id-name="props.row.name"
@copy=" @copy="
() => { () => {
notify('create', $t('dialog.message.copy')); copy(props.row.id);
currentCopy = {
id: props.row.id,
type: productAndServiceTab,
};
} }
" "
@view=" @view="