|
@@ -45,7 +45,7 @@
|
|
|
icon="mdi-trash-can-outline"
|
|
icon="mdi-trash-can-outline"
|
|
|
style="width: 36px"
|
|
style="width: 36px"
|
|
|
class="q-mr-sm"
|
|
class="q-mr-sm"
|
|
|
- @click.prevent.stop="() => {}"
|
|
|
|
|
|
|
+ @click.prevent.stop="onDeleteStudent(row)"
|
|
|
/>
|
|
/>
|
|
|
</q-item-section>
|
|
</q-item-section>
|
|
|
</q-td>
|
|
</q-td>
|
|
@@ -60,7 +60,7 @@ import { defineAsyncComponent, ref, onMounted } from "vue";
|
|
|
import { useQuasar } from "quasar";
|
|
import { useQuasar } from "quasar";
|
|
|
import DefaultHeaderPage from "src/components/layout/DefaultHeaderPage.vue";
|
|
import DefaultHeaderPage from "src/components/layout/DefaultHeaderPage.vue";
|
|
|
import DefaultTable from "src/components/defaults/DefaultTable.vue";
|
|
import DefaultTable from "src/components/defaults/DefaultTable.vue";
|
|
|
-import { getStudents } from "src/api/student";
|
|
|
|
|
|
|
+import { getStudents, deleteStudent } from "src/api/student";
|
|
|
|
|
|
|
|
const AddEditStudentDialog = defineAsyncComponent(
|
|
const AddEditStudentDialog = defineAsyncComponent(
|
|
|
() => import("src/pages/students/components/AddEditStudentDialog.vue"),
|
|
() => import("src/pages/students/components/AddEditStudentDialog.vue"),
|
|
@@ -130,5 +130,22 @@ function onEditStudent(student) {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+function onDeleteStudent(student) {
|
|
|
|
|
+ $q.dialog({
|
|
|
|
|
+ title: "Excluir Aluno",
|
|
|
|
|
+ message: `Deseja excluir o aluno "${student.name}"?`,
|
|
|
|
|
+ cancel: true,
|
|
|
|
|
+ persistent: true,
|
|
|
|
|
+ }).onOk(async () => {
|
|
|
|
|
+ try {
|
|
|
|
|
+ await deleteStudent(student.id);
|
|
|
|
|
+ rows.value = rows.value.filter((r) => r.id !== student.id);
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ console.error(e);
|
|
|
|
|
+ $q.notify({ type: "negative", message: "Erro ao excluir aluno." });
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
onMounted(loadStudents);
|
|
onMounted(loadStudents);
|
|
|
</script>
|
|
</script>
|