fix: change status dialog
This commit is contained in:
parent
305d1f2e2b
commit
f9eeb7f529
4 changed files with 152 additions and 84 deletions
|
|
@ -493,6 +493,26 @@ async function toggleStatus(id: string) {
|
|||
if (res) record.status = res.status;
|
||||
}
|
||||
|
||||
async function triggerChangeStatus(id: string, status: string) {
|
||||
return await new Promise((resolve, reject) => {
|
||||
dialog({
|
||||
color: status !== 'INACTIVE' ? 'warning' : 'info',
|
||||
icon: status !== 'INACTIVE' ? 'mdi-alert' : 'mdi-comment-alert',
|
||||
title: t('confirmChangeStatusTitle'),
|
||||
actionText:
|
||||
status !== 'INACTIVE' ? t('switchOffLabel') : t('switchOnLabel'),
|
||||
message:
|
||||
status !== 'INACTIVE'
|
||||
? t('confirmChangeStatusOffMessage')
|
||||
: t('confirmChangeStatusOnMessage'),
|
||||
action: async () => {
|
||||
await toggleStatus(id).then(resolve).catch(reject);
|
||||
},
|
||||
cancel: () => {},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function assignFormData(idEdit: string) {
|
||||
if (!userData.value) return;
|
||||
const foundUser = userData.value.result.find((user) => user.id === idEdit);
|
||||
|
|
@ -1248,7 +1268,10 @@ watch(
|
|||
"
|
||||
@click="
|
||||
async () => {
|
||||
toggleStatus(props.row.id);
|
||||
triggerChangeStatus(
|
||||
props.row.id,
|
||||
props.row.status,
|
||||
);
|
||||
}
|
||||
"
|
||||
:model-value="props.row.status !== 'INACTIVE'"
|
||||
|
|
@ -1305,7 +1328,9 @@ watch(
|
|||
@update-card="(a, b) => openDialog(a, props.row.id, b)"
|
||||
@delete-card="onDelete(props.row.id)"
|
||||
@enter-card="(a) => openDialog(a, props.row.id)"
|
||||
@toggle-status="toggleStatus(props.row.id)"
|
||||
@toggle-status="
|
||||
triggerChangeStatus(props.row.id, props.row.status)
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue