refactor: use dialogCheckData
This commit is contained in:
parent
27aee89e3a
commit
f136eda56e
1 changed files with 44 additions and 37 deletions
|
|
@ -12,7 +12,7 @@ import {
|
|||
ref,
|
||||
watch,
|
||||
} from 'vue';
|
||||
import { dialog } from 'stores/utils';
|
||||
import { dialog, dialogCheckData } from 'stores/utils';
|
||||
import { quotationProductTree } from './utils';
|
||||
|
||||
// NOTE: Import stores
|
||||
|
|
@ -229,30 +229,6 @@ const productServiceList = ref<
|
|||
Required<QuotationPayload['productServiceList'][number]>[]
|
||||
>([]);
|
||||
|
||||
async function dialogWarning(
|
||||
callback: () => void,
|
||||
check: () => void | boolean,
|
||||
) {
|
||||
const status = check();
|
||||
|
||||
if (status) {
|
||||
dialog({
|
||||
color: 'warning',
|
||||
icon: 'mdi-alert',
|
||||
title: t('form.warning.title'),
|
||||
actionText: t('general.ok'),
|
||||
persistent: true,
|
||||
message: t('form.warning.message'),
|
||||
action: async () => {
|
||||
callback();
|
||||
},
|
||||
cancel: () => {},
|
||||
});
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
||||
async function assignToProductServiceList() {
|
||||
const ret = await productServiceStore.fetchListProductService({
|
||||
page: 1,
|
||||
|
|
@ -1152,26 +1128,57 @@ watch(
|
|||
async (group, allMeta) => {
|
||||
if (allMeta === undefined) return;
|
||||
|
||||
console.log(allMeta);
|
||||
|
||||
if (group === 'passport') {
|
||||
const fullName = allMeta['full_name'].split(' ');
|
||||
let tempValue: {
|
||||
oldData: { filName: string; value: string }[];
|
||||
newData: { filName: string; value: string }[];
|
||||
} = { oldData: [], newData: [] };
|
||||
|
||||
await dialogWarning(
|
||||
() => {
|
||||
if (formDataEmployee.firstName !== '') {
|
||||
tempValue.oldData.push({
|
||||
filName: $t('personnel.form.firstName'),
|
||||
value: formDataEmployee.firstName,
|
||||
});
|
||||
tempValue.newData.push({
|
||||
filName: $t('personnel.form.firstName'),
|
||||
value: fullName[0],
|
||||
});
|
||||
}
|
||||
|
||||
if (formDataEmployee.lastName !== '') {
|
||||
tempValue.oldData.push({
|
||||
filName: $t('personnel.form.lastName'),
|
||||
value: formDataEmployee.lastName,
|
||||
});
|
||||
tempValue.newData.push({
|
||||
filName: $t('personnel.form.lastName'),
|
||||
value: fullName[1],
|
||||
});
|
||||
}
|
||||
|
||||
if (formDataEmployee.passportNo !== '') {
|
||||
tempValue.oldData.push({
|
||||
filName: $t('customerEmployee.form.passportNo'),
|
||||
value: formDataEmployee.passportNo || '',
|
||||
});
|
||||
tempValue.newData.push({
|
||||
filName: $t('customerEmployee.form.passportNo'),
|
||||
value: allMeta['doc_number'],
|
||||
});
|
||||
}
|
||||
|
||||
dialogCheckData({
|
||||
action: async () => {
|
||||
formDataEmployee.firstName = fullName[0];
|
||||
formDataEmployee.lastName = fullName[1];
|
||||
formDataEmployee.passportNo = allMeta['doc_number'];
|
||||
},
|
||||
() => {
|
||||
let status = false;
|
||||
if (formDataEmployee.firstName !== '') status = true;
|
||||
if (formDataEmployee.lastName !== '') status = true;
|
||||
if (formDataEmployee.passportNo !== '') status = true;
|
||||
|
||||
return status;
|
||||
checkData: () => {
|
||||
return tempValue;
|
||||
},
|
||||
);
|
||||
cancel: () => {},
|
||||
});
|
||||
}
|
||||
}
|
||||
"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue