refactor: add delete
This commit is contained in:
parent
fad5043f6c
commit
1899522328
1 changed files with 34 additions and 5 deletions
|
|
@ -398,8 +398,10 @@ async function toggleStatusCustomer(id: string, status: boolean) {
|
|||
flowStore.rotate();
|
||||
}
|
||||
|
||||
async function deleteEmployeeById(id: string) {
|
||||
if (!id) return;
|
||||
async function deleteEmployeeById(opts: {
|
||||
id?: string;
|
||||
type?: 'healthCheck' | 'work';
|
||||
}) {
|
||||
dialog({
|
||||
color: 'negative',
|
||||
icon: 'mdi-alert',
|
||||
|
|
@ -408,7 +410,18 @@ async function deleteEmployeeById(id: string) {
|
|||
persistent: true,
|
||||
message: t('deleteConfirmMessage'),
|
||||
action: async () => {
|
||||
await employeeStore.deleteById(id);
|
||||
if (opts.type === 'healthCheck') {
|
||||
await employeeFormStore.deleteHealthCheck();
|
||||
}
|
||||
|
||||
if (opts.type === 'work') {
|
||||
await employeeFormStore.deleteWorkHistory();
|
||||
} else {
|
||||
if (!!opts.id) {
|
||||
await employeeStore.deleteById(opts.id);
|
||||
}
|
||||
}
|
||||
|
||||
const resultList = await employeeStore.fetchList();
|
||||
if (resultList) listEmployee.value = resultList.result;
|
||||
flowStore.rotate();
|
||||
|
|
@ -1588,7 +1601,9 @@ watch(
|
|||
props.row.status !== 'CREATED',
|
||||
}"
|
||||
style="white-space: nowrap"
|
||||
@click="deleteEmployeeById(props.row.id)"
|
||||
@click="
|
||||
deleteEmployeeById({ id: props.row.id })
|
||||
"
|
||||
>
|
||||
<q-icon
|
||||
name="mdi-trash-can-outline"
|
||||
|
|
@ -1680,7 +1695,9 @@ watch(
|
|||
@history="openHistory(props.row.id)"
|
||||
@update-card="console.log('update emp')"
|
||||
@enter-card="console.log('enter-emp')"
|
||||
@delete-card="deleteEmployeeById(props.row.id)"
|
||||
@delete-card="
|
||||
deleteEmployeeById({ id: props.row.id })
|
||||
"
|
||||
@toggle-status="
|
||||
triggerChangeStatus(props.row.id, props.row.status)
|
||||
"
|
||||
|
|
@ -2311,6 +2328,12 @@ watch(
|
|||
v-model:insuranceCompanyOption="
|
||||
optionStore.globalOption.insurancePlace
|
||||
"
|
||||
@delete="
|
||||
(index) => {
|
||||
employeeFormState.currentIndex = index;
|
||||
deleteEmployeeById({ type: 'healthCheck' });
|
||||
}
|
||||
"
|
||||
@save="
|
||||
(index) => {
|
||||
employeeFormState.currentIndex = index;
|
||||
|
|
@ -2346,6 +2369,12 @@ watch(
|
|||
v-model:position-name-option="optionStore.globalOption.position"
|
||||
v-model:job-type-option="optionStore.globalOption.businessType"
|
||||
v-model:workplace-option="optionStore.globalOption.area"
|
||||
@delete="
|
||||
(index) => {
|
||||
employeeFormState.currentIndex = index;
|
||||
deleteEmployeeById({ type: 'work' });
|
||||
}
|
||||
"
|
||||
@save="
|
||||
(index) => {
|
||||
employeeFormState.currentIndex = index;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue