|
@@ -26,8 +26,8 @@
|
|
|
<template #body-cell-status="{ row }">
|
|
<template #body-cell-status="{ row }">
|
|
|
<q-td align="center">
|
|
<q-td align="center">
|
|
|
<q-badge
|
|
<q-badge
|
|
|
- :color="row.status === 'active' ? 'positive' : 'warning'"
|
|
|
|
|
- :label="row.status === 'active' ? 'Ativo' : 'Inativo'"
|
|
|
|
|
|
|
+ :color="statusColor(row.status)"
|
|
|
|
|
+ :label="statusLabel(row.status)"
|
|
|
/>
|
|
/>
|
|
|
</q-td>
|
|
</q-td>
|
|
|
</template>
|
|
</template>
|
|
@@ -64,6 +64,13 @@
|
|
|
>
|
|
>
|
|
|
<q-item-section>Visualizar arquivo</q-item-section>
|
|
<q-item-section>Visualizar arquivo</q-item-section>
|
|
|
</q-item>
|
|
</q-item>
|
|
|
|
|
+ <q-item
|
|
|
|
|
+ v-close-popup
|
|
|
|
|
+ clickable
|
|
|
|
|
+ @click="handleContractActions(row)"
|
|
|
|
|
+ >
|
|
|
|
|
+ <q-item-section>Ações do Contrato</q-item-section>
|
|
|
|
|
+ </q-item>
|
|
|
</q-list>
|
|
</q-list>
|
|
|
</q-menu>
|
|
</q-menu>
|
|
|
</q-btn>
|
|
</q-btn>
|
|
@@ -79,7 +86,13 @@ import { ref, onMounted } from "vue";
|
|
|
import { useQuasar } from "quasar";
|
|
import { useQuasar } from "quasar";
|
|
|
import DefaultTable from "src/components/defaults/DefaultTable.vue";
|
|
import DefaultTable from "src/components/defaults/DefaultTable.vue";
|
|
|
import CreateContractDialog from "src/pages/students/components/CreateContractDialog.vue";
|
|
import CreateContractDialog from "src/pages/students/components/CreateContractDialog.vue";
|
|
|
-import { getStudentContracts, attachContractFile } from "src/api/studentContract";
|
|
|
|
|
|
|
+import ContractActionsDialog from "src/pages/students/components/ContractActionsDialog.vue";
|
|
|
|
|
+import ContractActionConfirmDialog from "src/pages/students/components/ContractActionConfirmDialog.vue";
|
|
|
|
|
+import {
|
|
|
|
|
+ getStudentContracts,
|
|
|
|
|
+ attachContractFile,
|
|
|
|
|
+ updateContractStatus,
|
|
|
|
|
+} from "src/api/studentContract";
|
|
|
|
|
|
|
|
const props = defineProps({
|
|
const props = defineProps({
|
|
|
student: {
|
|
student: {
|
|
@@ -145,9 +158,65 @@ function openFile(url) {
|
|
|
window.open(url, "_blank");
|
|
window.open(url, "_blank");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+const actionLabels = {
|
|
|
|
|
+ frozen: {
|
|
|
|
|
+ title: "Congelar Contrato",
|
|
|
|
|
+ message:
|
|
|
|
|
+ "Você tem certeza que deseja CONGELAR este contrato? isso irá gerar multas e cancelamento da cobrança recorrente.",
|
|
|
|
|
+ },
|
|
|
|
|
+ cancelled: {
|
|
|
|
|
+ title: "Cancelar Contrato",
|
|
|
|
|
+ message:
|
|
|
|
|
+ "Você tem certeza que deseja CANCELAR este contrato? isso irá gerar multas e cancelamento da cobrança recorrente.",
|
|
|
|
|
+ },
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+function handleContractActions(contract) {
|
|
|
|
|
+ $q.dialog({
|
|
|
|
|
+ component: ContractActionsDialog,
|
|
|
|
|
+ }).onOk((status) => {
|
|
|
|
|
+ const { title, message } = actionLabels[status];
|
|
|
|
|
+ $q.dialog({
|
|
|
|
|
+ component: ContractActionConfirmDialog,
|
|
|
|
|
+ componentProps: { title, message },
|
|
|
|
|
+ }).onOk(async () => {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const updated = await updateContractStatus(contract.id, status);
|
|
|
|
|
+ const idx = rows.value.findIndex((r) => r.id === contract.id);
|
|
|
|
|
+ if (idx !== -1) rows.value[idx] = updated;
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ console.error(e);
|
|
|
|
|
+ $q.notify({
|
|
|
|
|
+ type: "negative",
|
|
|
|
|
+ message: "Erro ao atualizar status do contrato.",
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function statusColor(status) {
|
|
|
|
|
+ if (status === "active") return "positive";
|
|
|
|
|
+ if (status === "frozen") return "info";
|
|
|
|
|
+ if (status === "cancelled") return "negative";
|
|
|
|
|
+ return "warning";
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function statusLabel(status) {
|
|
|
|
|
+ if (status === "active") return "Ativo";
|
|
|
|
|
+ if (status === "frozen") return "Congelado";
|
|
|
|
|
+ if (status === "cancelled") return "Cancelado";
|
|
|
|
|
+ return "Inativo";
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
const columns = ref([
|
|
const columns = ref([
|
|
|
{ name: "contract", label: "Contrato", field: "protocol", align: "left" },
|
|
{ name: "contract", label: "Contrato", field: "protocol", align: "left" },
|
|
|
- { name: "period", label: "Data Assinatura - Encerramento", field: null, align: "left" },
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ name: "period",
|
|
|
|
|
+ label: "Data Assinatura - Encerramento",
|
|
|
|
|
+ field: null,
|
|
|
|
|
+ align: "left",
|
|
|
|
|
+ },
|
|
|
{ name: "status", label: "Status", field: "status", align: "center" },
|
|
{ name: "status", label: "Status", field: "status", align: "center" },
|
|
|
{ name: "actions", label: "Ações", field: null, align: "center" },
|
|
{ name: "actions", label: "Ações", field: null, align: "center" },
|
|
|
]);
|
|
]);
|