94 lines
2.5 KiB
Vue
94 lines
2.5 KiB
Vue
<script setup>
|
|
import { ref, computed } from 'vue';
|
|
import { useRoute, useRouter } from 'vue-router';
|
|
import { useI18n } from 'vue-i18n';
|
|
import { useState } from 'src/composables/useState';
|
|
import CardDescriptor from 'components/ui/CardDescriptor.vue';
|
|
import VnLv from 'src/components/ui/VnLv.vue';
|
|
import useCardDescription from 'src/composables/useCardDescription';
|
|
import { useQuasar } from 'quasar';
|
|
|
|
import axios from 'axios';
|
|
import useNotify from 'src/composables/useNotify.js';
|
|
const $props = defineProps({
|
|
id: {
|
|
type: Number,
|
|
required: false,
|
|
default: null,
|
|
},
|
|
});
|
|
|
|
const route = useRoute();
|
|
|
|
const quasar = useQuasar();
|
|
const router = useRouter();
|
|
|
|
const { notify } = useNotify();
|
|
const { t } = useI18n();
|
|
const entityId = computed(() => {
|
|
return $props.id || route.params.id;
|
|
});
|
|
const data = ref(useCardDescription());
|
|
const setData = (entity) => (data.value = useCardDescription(entity.name, entity.id));
|
|
const filter = {
|
|
where: { id: entityId },
|
|
};
|
|
const removeRole = () => {
|
|
quasar
|
|
.dialog({
|
|
title: 'Are you sure you want to delete it?',
|
|
message: 'Delete department',
|
|
ok: {
|
|
push: true,
|
|
color: 'primary',
|
|
},
|
|
cancel: true,
|
|
})
|
|
.onOk(async () => {
|
|
try {
|
|
await axios.post(
|
|
`/Departments/${entityId.value}/removeChild`,
|
|
entityId.value
|
|
);
|
|
router.push({ name: 'WorkerDepartment' });
|
|
notify('department.departmentRemoved', 'positive');
|
|
} catch (err) {
|
|
console.error('Error removing department');
|
|
}
|
|
});
|
|
};
|
|
</script>
|
|
|
|
<template>
|
|
<CardDescriptor
|
|
ref="descriptor"
|
|
:url="`VnRoles`"
|
|
:filter="filter"
|
|
module="Account"
|
|
@on-fetch="setData"
|
|
data-key="accountData"
|
|
:title="data.title"
|
|
:subtitle="data.subtitle"
|
|
>
|
|
<template #menu>
|
|
<QItem v-ripple clickable @click="removeRole()">
|
|
<QItemSection>{{ t('Delete') }}</QItemSection>
|
|
</QItem>
|
|
</template>
|
|
<template #body="{ entity }">
|
|
<VnLv :label="t('role.card.description')" :value="entity.description" />
|
|
</template>
|
|
</CardDescriptor>
|
|
</template>
|
|
<style scoped>
|
|
.q-item__label {
|
|
margin-top: 0;
|
|
}
|
|
</style>
|
|
<i18n>
|
|
en:
|
|
accountRate: Claming rate
|
|
es:
|
|
accountRate: Ratio de reclamación
|
|
</i18n>
|