feat: incomplete form warning (employee)
This commit is contained in:
parent
34cb58fbfd
commit
e284a7bd4c
1 changed files with 69 additions and 17 deletions
|
|
@ -390,6 +390,19 @@ async function openDialogInputForm(
|
||||||
if (selectorLabel.value === 'EMPLOYEE') {
|
if (selectorLabel.value === 'EMPLOYEE') {
|
||||||
if (!id) return;
|
if (!id) return;
|
||||||
await assignFormDataEmployee(id);
|
await assignFormDataEmployee(id);
|
||||||
|
const code = currentEmployee.value?.code.split('-')[0];
|
||||||
|
|
||||||
|
const result = await fetchListBranch({
|
||||||
|
includeCustomer: true,
|
||||||
|
query: code,
|
||||||
|
pageSize: 30,
|
||||||
|
});
|
||||||
|
if (result) {
|
||||||
|
employeeStore.ownerOption = result.result.map((i) => ({
|
||||||
|
label: i.code,
|
||||||
|
value: i.id,
|
||||||
|
}));
|
||||||
|
}
|
||||||
dialogEmployee.value = true;
|
dialogEmployee.value = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -587,17 +600,20 @@ async function onSubmit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectorLabel.value === 'EMPLOYEE') {
|
if (selectorLabel.value === 'EMPLOYEE') {
|
||||||
await employeeStore.create({
|
const isOk = await checkEmployeeForm();
|
||||||
...formDataEmployee.value,
|
if (isOk) {
|
||||||
image: profileSubmit.value ? profileFile.value ?? null : null,
|
await employeeStore.create({
|
||||||
});
|
...formDataEmployee.value,
|
||||||
const resultList = await employeeStore.fetchList();
|
image: profileSubmit.value ? profileFile.value ?? null : null,
|
||||||
if (resultList) listEmployee.value = resultList.result;
|
});
|
||||||
|
const resultList = await employeeStore.fetchList();
|
||||||
|
if (resultList) listEmployee.value = resultList.result;
|
||||||
|
|
||||||
const resultStatsEmployee = await employeeStore.getStatsEmployee();
|
const resultStatsEmployee = await employeeStore.getStatsEmployee();
|
||||||
if (resultStatsEmployee) statsEmployee.value = resultStatsEmployee;
|
if (resultStatsEmployee) statsEmployee.value = resultStatsEmployee;
|
||||||
|
|
||||||
clearFormEmployee();
|
clearFormEmployee();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -670,17 +686,20 @@ async function onSubmitEdit(id: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectorLabel.value === 'EMPLOYEE') {
|
if (selectorLabel.value === 'EMPLOYEE') {
|
||||||
if (!formDataEmployee.value) return;
|
const isOk = await checkEmployeeForm();
|
||||||
|
if (isOk) {
|
||||||
|
if (!formDataEmployee.value) return;
|
||||||
|
|
||||||
await employeeStore.editById(id, {
|
await employeeStore.editById(id, {
|
||||||
...formDataEmployee.value,
|
...formDataEmployee.value,
|
||||||
image: profileSubmit.value ? profileFile.value ?? null : null,
|
image: profileSubmit.value ? profileFile.value ?? null : null,
|
||||||
});
|
});
|
||||||
|
|
||||||
const resultList = await employeeStore.fetchList();
|
const resultList = await employeeStore.fetchList();
|
||||||
if (resultList) listEmployee.value = resultList.result;
|
if (resultList) listEmployee.value = resultList.result;
|
||||||
|
|
||||||
clearFormEmployee();
|
clearFormEmployee();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -893,6 +912,39 @@ async function assignFormDataEmployee(id: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function checkEmployeeForm() {
|
||||||
|
const formData = formDataEmployee.value;
|
||||||
|
let forget = false;
|
||||||
|
|
||||||
|
for (const [key, val] of Object.entries(formData)) {
|
||||||
|
if (key === 'workerStatus') continue;
|
||||||
|
if (key === 'image') continue;
|
||||||
|
|
||||||
|
if (val === '' || val === null) {
|
||||||
|
forget = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (forget) {
|
||||||
|
return await new Promise((resolve) => {
|
||||||
|
dialog({
|
||||||
|
color: 'warning',
|
||||||
|
icon: 'mdi-alert',
|
||||||
|
title: t('warning'),
|
||||||
|
actionText: t('ok'),
|
||||||
|
persistent: true,
|
||||||
|
message: t('warningForgetInput'),
|
||||||
|
action: () => {
|
||||||
|
resolve(true);
|
||||||
|
},
|
||||||
|
cancel: () => {
|
||||||
|
resolve(false);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else return true;
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
const resultStats = await getStatsCustomer();
|
const resultStats = await getStatsCustomer();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue