增加预约终态操作二次确认
This commit is contained in:
@@ -49,18 +49,36 @@
|
|||||||
|
|
||||||
<div v-if="showBottomActions" class="fixed-bottom">
|
<div v-if="showBottomActions" class="fixed-bottom">
|
||||||
<div class="fixed-bottom__inner button-row">
|
<div class="fixed-bottom__inner button-row">
|
||||||
<button v-if="canEditAppointment" class="primary-btn" type="button" :disabled="saving" @click="updateStatus(2)">完成</button>
|
<button v-if="canEditAppointment" class="primary-btn" type="button" :disabled="saving" @click="requestStatusUpdate(2)">完成</button>
|
||||||
<button v-if="canCancelAppointment" class="danger-btn" type="button" :disabled="saving" @click="updateStatus(3)">取消</button>
|
<button v-if="canCancelAppointment" class="danger-btn" type="button" :disabled="saving" @click="requestStatusUpdate(3)">取消</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<BaseModal
|
||||||
|
:model-value="statusConfirmVisible"
|
||||||
|
:title="statusConfirmTitle"
|
||||||
|
:close-disabled="saving"
|
||||||
|
@update:model-value="updateStatusConfirmVisible"
|
||||||
|
>
|
||||||
|
<div class="status-confirm">
|
||||||
|
<p>{{ statusConfirmMessage }}</p>
|
||||||
|
</div>
|
||||||
|
<template #footer>
|
||||||
|
<button class="secondary-btn" type="button" :disabled="saving" @click="closeStatusConfirm">再想想</button>
|
||||||
|
<button :class="statusConfirmButtonClass" type="button" :disabled="saving" @click="confirmStatusUpdate">
|
||||||
|
{{ saving ? '处理中...' : statusConfirmButtonText }}
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
|
</BaseModal>
|
||||||
</MobileShell>
|
</MobileShell>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted, ref } from 'vue'
|
import { computed, onMounted, ref } from 'vue'
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
|
import BaseModal from '@/components/BaseModal.vue'
|
||||||
import EmptyState from '@/components/EmptyState.vue'
|
import EmptyState from '@/components/EmptyState.vue'
|
||||||
import LoadingState from '@/components/LoadingState.vue'
|
import LoadingState from '@/components/LoadingState.vue'
|
||||||
import MobileShell from '@/components/MobileShell.vue'
|
import MobileShell from '@/components/MobileShell.vue'
|
||||||
@@ -78,6 +96,8 @@ const appointment = ref<Appointment | null>(null)
|
|||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const saving = ref(false)
|
const saving = ref(false)
|
||||||
const loadError = ref('')
|
const loadError = ref('')
|
||||||
|
const statusConfirmVisible = ref(false)
|
||||||
|
const pendingStatus = ref<number | null>(null)
|
||||||
|
|
||||||
const appointmentId = computed(() => String(route.params.id || ''))
|
const appointmentId = computed(() => String(route.params.id || ''))
|
||||||
const avatarText = computed(() => String(appointment.value?.customerName || '客').slice(0, 1))
|
const avatarText = computed(() => String(appointment.value?.customerName || '客').slice(0, 1))
|
||||||
@@ -107,6 +127,15 @@ const timeText = computed(() => {
|
|||||||
}
|
}
|
||||||
return `${start || '-'} - ${end || '-'}`
|
return `${start || '-'} - ${end || '-'}`
|
||||||
})
|
})
|
||||||
|
const statusConfirmTitle = computed(() => (pendingStatus.value === 3 ? '确认取消订单' : '确认完成订单'))
|
||||||
|
const statusConfirmMessage = computed(() => {
|
||||||
|
if (pendingStatus.value === 3) {
|
||||||
|
return '点击取消后订单会结束并且不可更改,确定取消吗?'
|
||||||
|
}
|
||||||
|
return '点击完成后订单会结束并且不可更改,确定完成吗?'
|
||||||
|
})
|
||||||
|
const statusConfirmButtonText = computed(() => (pendingStatus.value === 3 ? '确认取消' : '确认完成'))
|
||||||
|
const statusConfirmButtonClass = computed(() => (pendingStatus.value === 3 ? 'danger-btn' : 'primary-btn'))
|
||||||
|
|
||||||
const loadDetail = async (): Promise<void> => {
|
const loadDetail = async (): Promise<void> => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
@@ -121,6 +150,33 @@ const loadDetail = async (): Promise<void> => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const updateStatusConfirmVisible = (value: boolean): void => {
|
||||||
|
if (saving.value) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
statusConfirmVisible.value = value
|
||||||
|
if (!value) {
|
||||||
|
pendingStatus.value = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const closeStatusConfirm = (): void => {
|
||||||
|
updateStatusConfirmVisible(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
const requestStatusUpdate = (status: number): void => {
|
||||||
|
if (status === 2 && !canEditAppointment.value) {
|
||||||
|
toast.error('已完成或已取消的订单只可查看')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (status === 3 && !canCancelAppointment.value) {
|
||||||
|
toast.error('当前预约不能取消')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
pendingStatus.value = status
|
||||||
|
statusConfirmVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
const updateStatus = async (status: number): Promise<void> => {
|
const updateStatus = async (status: number): Promise<void> => {
|
||||||
if (isReadonlyAppointment.value) {
|
if (isReadonlyAppointment.value) {
|
||||||
toast.error('已完成或已取消的订单只可查看')
|
toast.error('已完成或已取消的订单只可查看')
|
||||||
@@ -144,6 +200,14 @@ const updateStatus = async (status: number): Promise<void> => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const confirmStatusUpdate = async (): Promise<void> => {
|
||||||
|
if (pendingStatus.value === null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
await updateStatus(pendingStatus.value)
|
||||||
|
closeStatusConfirm()
|
||||||
|
}
|
||||||
|
|
||||||
const goEdit = async (): Promise<void> => {
|
const goEdit = async (): Promise<void> => {
|
||||||
if (!canEditAppointment.value) {
|
if (!canEditAppointment.value) {
|
||||||
toast.error('已完成或已取消的订单只可查看')
|
toast.error('已完成或已取消的订单只可查看')
|
||||||
@@ -247,4 +311,11 @@ onMounted(loadDetail)
|
|||||||
color: #4d4840;
|
color: #4d4840;
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.status-confirm {
|
||||||
|
padding: 4px 0 12px;
|
||||||
|
color: #4d4840;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 1.7;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user