add event remove dialog
This commit is contained in:
@@ -98,15 +98,21 @@
|
||||
/>
|
||||
</div>
|
||||
</bottom-popup>
|
||||
<event-remove-dialog
|
||||
v-model:visible="removeDialogVisible"
|
||||
:event="removeTarget"
|
||||
:loading="isRemoving"
|
||||
@confirm="removeEvent"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { DialogPlugin } from "tdesign-mobile-vue";
|
||||
import { BottomPopup } from "timi-tdesign-mobile";
|
||||
import { Time, Text } from "timi-web";
|
||||
import { type ModuleCode, type Role, RoleAPI, useUserStore } from "timi-web-api";
|
||||
import EventAPI from "@/api/EventAPI";
|
||||
import EventOptionSelector from "@/components/EventOptionSelector.vue";
|
||||
import EventRemoveDialog from "@/pages/event/component/EventRemoveDialog.vue";
|
||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||
import { useNavBarStore } from "@/store/navBarStore";
|
||||
import type { EventItem, EventLimitType, EventOptionSelectionMap, EventStatus, EventValueType, EventValueUnit } from "@/types/EventItem";
|
||||
@@ -147,6 +153,8 @@ const event = ref<EventItem>();
|
||||
const roleOptions = ref<Role[]>([]);
|
||||
const isLoading = ref(false);
|
||||
const isRemoving = ref(false);
|
||||
const removeDialogVisible = ref(false);
|
||||
const removeTarget = ref<EventItem>();
|
||||
const optionPopupVisible = ref(false);
|
||||
const optionSelectionMap = reactive<EventOptionSelectionMap>({});
|
||||
|
||||
@@ -263,34 +271,28 @@ function closeOptionPopup(): void {
|
||||
|
||||
// ---------- 删除 ----------
|
||||
|
||||
async function confirmRemoveEvent(): Promise<void> {
|
||||
const eventId = String(route.params.id || "");
|
||||
if (!eventId || !canDeleteEvent.value || isRemoving.value) {
|
||||
function confirmRemoveEvent(): void {
|
||||
const currentEvent = event.value;
|
||||
if (!currentEvent?.id || !canDeleteEvent.value || isRemoving.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
const eventName = event.value?.name || "未命名事件";
|
||||
const dialog = DialogPlugin.confirm({
|
||||
title: "删除登记事件",
|
||||
content: `确定删除登记事件 ${eventName} 吗?删除后无法恢复。`,
|
||||
cancelBtn: "取消",
|
||||
confirmBtn: "删除",
|
||||
onCancel() {
|
||||
dialog.destroy();
|
||||
},
|
||||
async onConfirm() {
|
||||
dialog.destroy();
|
||||
await removeEvent(eventId);
|
||||
}
|
||||
});
|
||||
removeTarget.value = currentEvent;
|
||||
removeDialogVisible.value = true;
|
||||
}
|
||||
|
||||
async function removeEvent(eventId: string): Promise<void> {
|
||||
async function removeEvent(eventItem: EventItem): Promise<void> {
|
||||
const eventId = eventItem.id;
|
||||
if (!eventId) {
|
||||
return;
|
||||
}
|
||||
if (isRemoving.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
isRemoving.value = true;
|
||||
removeDialogVisible.value = false;
|
||||
removeTarget.value = undefined;
|
||||
try {
|
||||
await EventAPI.remove(eventId);
|
||||
Message.success("登记事件已删除");
|
||||
|
||||
Reference in New Issue
Block a user