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();
|
flowStore.rotate();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteEmployeeById(id: string) {
|
async function deleteEmployeeById(opts: {
|
||||||
if (!id) return;
|
id?: string;
|
||||||
|
type?: 'healthCheck' | 'work';
|
||||||
|
}) {
|
||||||
dialog({
|
dialog({
|
||||||
color: 'negative',
|
color: 'negative',
|
||||||
icon: 'mdi-alert',
|
icon: 'mdi-alert',
|
||||||
|
|
@ -408,7 +410,18 @@ async function deleteEmployeeById(id: string) {
|
||||||
persistent: true,
|
persistent: true,
|
||||||
message: t('deleteConfirmMessage'),
|
message: t('deleteConfirmMessage'),
|
||||||
action: async () => {
|
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();
|
const resultList = await employeeStore.fetchList();
|
||||||
if (resultList) listEmployee.value = resultList.result;
|
if (resultList) listEmployee.value = resultList.result;
|
||||||
flowStore.rotate();
|
flowStore.rotate();
|
||||||
|
|
@ -1588,7 +1601,9 @@ watch(
|
||||||
props.row.status !== 'CREATED',
|
props.row.status !== 'CREATED',
|
||||||
}"
|
}"
|
||||||
style="white-space: nowrap"
|
style="white-space: nowrap"
|
||||||
@click="deleteEmployeeById(props.row.id)"
|
@click="
|
||||||
|
deleteEmployeeById({ id: props.row.id })
|
||||||
|
"
|
||||||
>
|
>
|
||||||
<q-icon
|
<q-icon
|
||||||
name="mdi-trash-can-outline"
|
name="mdi-trash-can-outline"
|
||||||
|
|
@ -1680,7 +1695,9 @@ watch(
|
||||||
@history="openHistory(props.row.id)"
|
@history="openHistory(props.row.id)"
|
||||||
@update-card="console.log('update emp')"
|
@update-card="console.log('update emp')"
|
||||||
@enter-card="console.log('enter-emp')"
|
@enter-card="console.log('enter-emp')"
|
||||||
@delete-card="deleteEmployeeById(props.row.id)"
|
@delete-card="
|
||||||
|
deleteEmployeeById({ id: props.row.id })
|
||||||
|
"
|
||||||
@toggle-status="
|
@toggle-status="
|
||||||
triggerChangeStatus(props.row.id, props.row.status)
|
triggerChangeStatus(props.row.id, props.row.status)
|
||||||
"
|
"
|
||||||
|
|
@ -2311,6 +2328,12 @@ watch(
|
||||||
v-model:insuranceCompanyOption="
|
v-model:insuranceCompanyOption="
|
||||||
optionStore.globalOption.insurancePlace
|
optionStore.globalOption.insurancePlace
|
||||||
"
|
"
|
||||||
|
@delete="
|
||||||
|
(index) => {
|
||||||
|
employeeFormState.currentIndex = index;
|
||||||
|
deleteEmployeeById({ type: 'healthCheck' });
|
||||||
|
}
|
||||||
|
"
|
||||||
@save="
|
@save="
|
||||||
(index) => {
|
(index) => {
|
||||||
employeeFormState.currentIndex = index;
|
employeeFormState.currentIndex = index;
|
||||||
|
|
@ -2346,6 +2369,12 @@ watch(
|
||||||
v-model:position-name-option="optionStore.globalOption.position"
|
v-model:position-name-option="optionStore.globalOption.position"
|
||||||
v-model:job-type-option="optionStore.globalOption.businessType"
|
v-model:job-type-option="optionStore.globalOption.businessType"
|
||||||
v-model:workplace-option="optionStore.globalOption.area"
|
v-model:workplace-option="optionStore.globalOption.area"
|
||||||
|
@delete="
|
||||||
|
(index) => {
|
||||||
|
employeeFormState.currentIndex = index;
|
||||||
|
deleteEmployeeById({ type: 'work' });
|
||||||
|
}
|
||||||
|
"
|
||||||
@save="
|
@save="
|
||||||
(index) => {
|
(index) => {
|
||||||
employeeFormState.currentIndex = index;
|
employeeFormState.currentIndex = index;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue