remove in customer list

This commit is contained in:
Timi
2026-08-29 00:35:10 +08:00
parent 498d0f4b87
commit 147808adda
3 changed files with 235 additions and 117 deletions
+10 -106
View File
@@ -105,52 +105,12 @@
>
<body-area-selector :model-value="selectedAreas" readonly />
</bottom-popup>
<t-dialog
class="remove-dialog"
<customer-remove-dialog
v-model:visible="removeDialogVisible"
title="删除客户"
>
<div class="content">
<div class="warning">删除后无法恢复,将同时清除以下关联数据:</div>
<ul class="items">
<li>登记事件记录及其附件,并撤销这些登记产生的积分</li>
<li>客户积分账户、标签和客户附件</li>
<li>解除该客户与其被邀请客户之间的邀请关系,被邀请客户不会被删除</li>
<li>减少该客户原介绍人的邀请客户计数</li>
<li>客户档案本身</li>
</ul>
<div class="hint">
请输入客户姓名
<span class="name red" v-text="removeCustomerName" />
以确认删除
</div>
<t-input
class="confirm-input"
v-model.trim="removeConfirmName"
size="small"
borderless
clearable
placeholder="请输入客户姓名"
/>
</div>
<template #cancelBtn>
<t-button
theme="default"
content="取消"
block
@click="closeRemoveDialog"
/>
</template>
<template #confirmBtn>
<t-button
theme="danger"
content="删除"
block
:disabled="!canConfirmRemove"
@click="removeConfirmedCustomer"
/>
</template>
</t-dialog>
:customer="removeTarget"
:loading="isRemoving"
@confirm="removeConfirmedCustomer"
/>
</div>
</template>
@@ -163,6 +123,7 @@ import CustomerAPI from "@/api/CustomerAPI";
import PointAPI from "@/api/PointAPI";
import TagAPI from "@/api/TagAPI";
import BodyAreaSelector from "@/components/BodyAreaSelector.vue";
import CustomerRemoveDialog from "@/components/CustomerRemoveDialog.vue";
import CustomerProfileCard from "@/components/CustomerProfileCard.vue";
import PhotoScroller from "@/components/PhotoScroller.vue";
import TagSelector from "@/components/TagSelector.vue";
@@ -190,15 +151,12 @@ const userStore = useUserStore();
const isRemoving = ref(false);
const removeDialogVisible = ref(false);
const removeTarget = ref<Customer>();
const removeConfirmName = ref("");
const canReadStat = computed(() => userStore.hasPermissions(permissionCodes.stat.read));
const canReadPointAccount = computed(() => userStore.hasPermissions(permissionCodes.point.accountRead));
const canReadTag = computed(() => userStore.hasPermissions(corePermissionCodes.tag.read));
const canApplyTag = computed(() => userStore.hasPermissions(corePermissionCodes.tag.apply));
const canUpdateCustomer = computed(() => userStore.hasPermissions(permissionCodes.customer.update));
const removeCustomerName = computed(() => removeTarget.value?.name || "");
const canConfirmRemove = computed(() => !!removeCustomerName.value && removeConfirmName.value === removeCustomerName.value);
// ---------- 资料 ----------
@@ -375,25 +333,21 @@ async function confirmRemoveCustomer(): Promise<void> {
}
removeTarget.value = currentCustomer;
removeConfirmName.value = "";
removeDialogVisible.value = true;
}
function closeRemoveDialog(): void {
removeDialogVisible.value = false;
removeTarget.value = undefined;
removeConfirmName.value = "";
}
async function removeConfirmedCustomer(): Promise<void> {
const customerId = removeTarget.value?.id;
if (!customerId || !canConfirmRemove.value || isRemoving.value) {
async function removeConfirmedCustomer(target: Customer): Promise<void> {
const customerId = target.id;
if (!customerId || isRemoving.value) {
return;
}
removeDialogVisible.value = false;
removeTarget.value = undefined;
removeConfirmName.value = "";
closeRemoveDialog();
await removeCustomer(customerId);
}
@@ -531,45 +485,6 @@ onUnmounted(() => navBarStore.clearRight());
}
}
.remove-dialog {
:deep(.t-dialog__footer) {
gap: 1rem;
}
.content {
text-align: left;
.warning {
color: #b42318;
font-weight: 700;
}
.items {
gap: .5rem;
height: 9rem;
margin: .75rem 0 1rem;
display: flex;
overflow-y: auto;
line-height: 1.2;
padding-left: 1.25rem;
flex-direction: column;
}
.name {
font-weight: 700;
}
.confirm-input {
--td-input-vertical-padding: 10px;
border: 1px solid var(--td-component-border);
margin-top: .5rem;
border-radius: .75rem;
}
}
}
:global(html.theme-dark) {
.customer-detail {
@@ -581,17 +496,6 @@ onUnmounted(() => navBarStore.clearRight());
color: #94a3b8;
}
.remove-dialog {
.warning {
color: #fda29b;
}
.confirm-input {
background: rgba(15, 23, 42, .72);
border-color: rgba(148, 163, 184, .16);
}
}
}
}
</style>