|
@@ -77,6 +77,7 @@
|
|
|
size="sm"
|
|
size="sm"
|
|
|
:unelevated="props.row.status === 'confirmado'"
|
|
:unelevated="props.row.status === 'confirmado'"
|
|
|
:outline="props.row.status !== 'confirmado'"
|
|
:outline="props.row.status !== 'confirmado'"
|
|
|
|
|
+ :disable="!canApprove(props.row)"
|
|
|
:loading="actionId === props.row.id && actionType === 'approve'"
|
|
:loading="actionId === props.row.id && actionType === 'approve'"
|
|
|
@click.prevent.stop="onApprove(props.row)"
|
|
@click.prevent.stop="onApprove(props.row)"
|
|
|
/>
|
|
/>
|
|
@@ -88,6 +89,7 @@
|
|
|
size="sm"
|
|
size="sm"
|
|
|
:unelevated="props.row.status === 'recusado' || props.row.status === 'cancelado'"
|
|
:unelevated="props.row.status === 'recusado' || props.row.status === 'cancelado'"
|
|
|
:outline="props.row.status !== 'recusado' && props.row.status !== 'cancelado'"
|
|
:outline="props.row.status !== 'recusado' && props.row.status !== 'cancelado'"
|
|
|
|
|
+ :disable="!canReject(props.row)"
|
|
|
:loading="actionId === props.row.id && actionType === 'reject'"
|
|
:loading="actionId === props.row.id && actionType === 'reject'"
|
|
|
@click.prevent.stop="onReject(props.row)"
|
|
@click.prevent.stop="onReject(props.row)"
|
|
|
/>
|
|
/>
|
|
@@ -184,8 +186,20 @@ const formatDateTime = (date, time) => {
|
|
|
return time ? `${dateStr} ${time}` : dateStr;
|
|
return time ? `${dateStr} ${time}` : dateStr;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+const isFutureDateTime = (row) => {
|
|
|
|
|
+ if (!row.date) return false;
|
|
|
|
|
+ const dt = new Date(`${row.date}T${row.time || "00:00"}`);
|
|
|
|
|
+ if (isNaN(dt)) return false;
|
|
|
|
|
+ return dt.getTime() > Date.now();
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+const canApprove = (row) => row.status === "pendente";
|
|
|
|
|
+
|
|
|
|
|
+const canReject = (row) =>
|
|
|
|
|
+ row.status === "pendente" || (row.status === "confirmado" && isFutureDateTime(row));
|
|
|
|
|
+
|
|
|
const onApprove = (row) => {
|
|
const onApprove = (row) => {
|
|
|
- if (row.status !== "pendente") return;
|
|
|
|
|
|
|
+ if (!canApprove(row)) return;
|
|
|
$q.dialog({ component: ApproveAppointmentDialog }).onOk(async ({ date, time }) => {
|
|
$q.dialog({ component: ApproveAppointmentDialog }).onOk(async ({ date, time }) => {
|
|
|
actionId.value = row.id;
|
|
actionId.value = row.id;
|
|
|
actionType.value = "approve";
|
|
actionType.value = "approve";
|
|
@@ -203,7 +217,7 @@ const onApprove = (row) => {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const onReject = (row) => {
|
|
const onReject = (row) => {
|
|
|
- if (row.status !== "pendente") return;
|
|
|
|
|
|
|
+ if (!canReject(row)) return;
|
|
|
$q.dialog({
|
|
$q.dialog({
|
|
|
title: t("common.ui.messages.confirm_action"),
|
|
title: t("common.ui.messages.confirm_action"),
|
|
|
message: t("agendamento.confirm_reject"),
|
|
message: t("agendamento.confirm_reject"),
|