delete in detail
This commit is contained in:
@@ -74,6 +74,16 @@
|
||||
title="登记照片"
|
||||
/>
|
||||
</div>
|
||||
<t-button
|
||||
v-if="record && canDeleteRecord"
|
||||
class="delete-button cell-button"
|
||||
theme="danger"
|
||||
:loading="isDeleting"
|
||||
:disabled="isDeleting"
|
||||
@click="confirmRemoveRecord"
|
||||
v-entrance-transition="420"
|
||||
content="删除登记记录"
|
||||
/>
|
||||
<t-empty v-if="!record" :description="isLoading ? '正在加载登记事件记录' : '登记事件记录不存在'" />
|
||||
</div>
|
||||
<event-record-verify-dialog
|
||||
@@ -86,6 +96,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { DialogPlugin } from "tdesign-mobile-vue";
|
||||
import { PassTimeLabel, Text } from "timi-web";
|
||||
import { useUserStore, type Attachment } from "timi-web-api";
|
||||
import EventRecordAPI from "@/api/EventRecordAPI";
|
||||
@@ -100,7 +111,9 @@ import type { PhotoItem } from "@/types/Photo";
|
||||
import type { PointLedgerChangeType } from "@/types/Point";
|
||||
import { getAttachmentReadURL } from "@/utils/attachment";
|
||||
import { buildEventOptionSelectionMap } from "@/utils/eventOption";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { formatEventNumberValue } from "@/utils/eventValue";
|
||||
import { Message } from "@/utils/message";
|
||||
import { permissionCodes } from "@/utils/permission";
|
||||
|
||||
defineOptions({
|
||||
@@ -117,10 +130,12 @@ const userStore = useUserStore();
|
||||
const record = ref<EventRecord>();
|
||||
const isLoading = ref(false);
|
||||
const isVerifying = ref(false);
|
||||
const isDeleting = ref(false);
|
||||
const verifyDialogVisible = ref(false);
|
||||
|
||||
const canUpdateRecord = computed(() => userStore.hasPermissions(permissionCodes.eventRecord.update));
|
||||
const canVerifyRecord = computed(() => userStore.hasPermissions(permissionCodes.eventRecord.verify));
|
||||
const canDeleteRecord = computed(() => userStore.hasPermissions(permissionCodes.eventRecord.delete));
|
||||
const canReadEvent = computed(() => userStore.hasPermissions(permissionCodes.event.read));
|
||||
const recordPhotoItemList = computed(() => (record.value?.attachmentList || [])
|
||||
.filter(item => !!item.id)
|
||||
@@ -271,6 +286,54 @@ async function handleVerifySuccess(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- 删除 ----------
|
||||
|
||||
function confirmRemoveRecord(): void {
|
||||
const currentRecord = record.value;
|
||||
if (!currentRecord?.id || !canDeleteRecord.value || isDeleting.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
const customerName = currentRecord.customer?.name || "未知客户";
|
||||
const eventName = currentRecord.event?.name || "未知事件";
|
||||
const recordId = currentRecord.id;
|
||||
const dialog = DialogPlugin.confirm({
|
||||
title: "删除登记记录",
|
||||
content: `确定删除 ${customerName} 的 ${eventName} 记录吗?删除后无法恢复。`,
|
||||
cancelBtn: "取消",
|
||||
confirmBtn: "删除",
|
||||
onCancel() {
|
||||
dialog.destroy();
|
||||
},
|
||||
async onConfirm() {
|
||||
dialog.destroy();
|
||||
await removeRecord(recordId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function removeRecord(id: string): Promise<void> {
|
||||
if (isDeleting.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
isDeleting.value = true;
|
||||
try {
|
||||
await EventRecordAPI.remove(id);
|
||||
Message.success("登记记录已删除");
|
||||
await router.replace({ name: "EventRecordList" });
|
||||
} catch (error) {
|
||||
const message = getErrorMessage(error, "登记记录删除失败");
|
||||
if (message.includes("积分余额不足") || message.includes("余额不足")) {
|
||||
Message.warning("积分余额不足,请先人工调整积分后再删除登记记录");
|
||||
return;
|
||||
}
|
||||
Message.error(message);
|
||||
} finally {
|
||||
isDeleting.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- 导航 ----------
|
||||
|
||||
async function toEdit(): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user