refactor: function get index
This commit is contained in:
parent
9d61ab8946
commit
7816634c36
2 changed files with 22 additions and 42 deletions
|
|
@ -467,6 +467,7 @@ async function toggleStatusCustomer(id: string, status: boolean) {
|
|||
async function deleteEmployeeById(opts: {
|
||||
id?: string;
|
||||
type?: 'passport' | 'visa' | 'healthCheck' | 'work';
|
||||
index?: number;
|
||||
}) {
|
||||
dialog({
|
||||
color: 'negative',
|
||||
|
|
@ -476,20 +477,20 @@ async function deleteEmployeeById(opts: {
|
|||
persistent: true,
|
||||
message: t('dialog.message.confirmDelete'),
|
||||
action: async () => {
|
||||
if (opts.type === 'passport') {
|
||||
await employeeFormStore.deletePassport();
|
||||
if (opts.type === 'passport' && opts.index !== undefined) {
|
||||
await employeeFormStore.deletePassport(opts.index);
|
||||
}
|
||||
|
||||
if (opts.type === 'visa') {
|
||||
await employeeFormStore.deleteVisa();
|
||||
if (opts.type === 'visa' && opts.index !== undefined) {
|
||||
await employeeFormStore.deleteVisa(opts.index);
|
||||
}
|
||||
|
||||
if (opts.type === 'healthCheck') {
|
||||
await employeeFormStore.deleteHealthCheck();
|
||||
if (opts.type === 'healthCheck' && opts.index !== undefined) {
|
||||
await employeeFormStore.deleteHealthCheck(opts.index);
|
||||
}
|
||||
|
||||
if (opts.type === 'work') {
|
||||
await employeeFormStore.deleteWorkHistory();
|
||||
if (opts.type === 'work' && opts.index !== undefined) {
|
||||
await employeeFormStore.deleteWorkHistory(opts.index);
|
||||
} else {
|
||||
if (!!opts.id) {
|
||||
const result = await employeeStore.deleteById(opts.id);
|
||||
|
|
@ -4962,8 +4963,7 @@ const emptyCreateDialog = ref(false);
|
|||
icon-only
|
||||
@click.stop="
|
||||
() => {
|
||||
employeeFormState.currentIndexPassport = index;
|
||||
deleteEmployeeById({ type: 'passport' });
|
||||
deleteEmployeeById({ type: 'passport', index });
|
||||
}
|
||||
"
|
||||
type="button"
|
||||
|
|
@ -5081,8 +5081,7 @@ const emptyCreateDialog = ref(false);
|
|||
icon-only
|
||||
@click.stop="
|
||||
() => {
|
||||
employeeFormState.currentIndexVisa = index;
|
||||
deleteEmployeeById({ type: 'visa' });
|
||||
deleteEmployeeById({ type: 'visa', index });
|
||||
}
|
||||
"
|
||||
type="button"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue