diff --git a/src/assets/styles/global.less b/src/assets/styles/global.less index 3388585..4111873 100644 --- a/src/assets/styles/global.less +++ b/src/assets/styles/global.less @@ -105,7 +105,8 @@ html.theme-dark body { --td-button-border-radius: 99rem; border: 1px solid var(--td-component-border); - padding: .25rem .25rem .25rem .5rem; + height: 2.25rem; + padding: .25rem .25rem .25rem .75rem; z-index: 2; position: relative; border-radius: 1rem; diff --git a/src/pages/customer/component/CustomerTagCard.vue b/src/pages/customer/component/CustomerTagCard.vue index 63de3e6..f9d5d52 100644 --- a/src/pages/customer/component/CustomerTagCard.vue +++ b/src/pages/customer/component/CustomerTagCard.vue @@ -38,7 +38,7 @@ const emit = defineEmits<{ edit: []; }>(); -const maxRowCount = 3; +const maxRowCount = 2; const tagRowList = computed(() => { const rowCount = Math.min(maxRowCount, props.tagList.length); const rowList = Array.from({ length: rowCount }, () => [] as Tag[]); diff --git a/src/pages/tag/TagDetail.vue b/src/pages/tag/TagDetail.vue index ea17bde..fe8a4ec 100644 --- a/src/pages/tag/TagDetail.vue +++ b/src/pages/tag/TagDetail.vue @@ -6,7 +6,19 @@ title="标签详情" left-arrow @left-click="$router.back()" - /> + > + + + + - - - 标签名称 - - - 保存 - - - - - - - - - - - 添加客户 - - + - - - - - - - - 移除 - - - - - - - - + > + + + 添加客户 + + + + + + + + + + + + + + + + + + + + + + + + + 移除 + + + + + + + + + + + + + 请输入标签名 + + 以确认删除 + + + + + + + + + + @@ -126,14 +180,21 @@ const tag = ref(); const tagName = ref(""); const isTagLoading = ref(false); const isSaving = ref(false); +const isDeletingTag = ref(false); +const deleteDialogVisible = ref(false); +const deleteConfirmName = ref(""); let tagRequestToken = 0; const canUpdateTag = computed(() => userStore.hasPermissions(corePermissionCodes.tag.update)); +const canDeleteTag = computed(() => userStore.hasPermissions(corePermissionCodes.tag.delete)); const canApplyTag = computed(() => userStore.hasPermissions(corePermissionCodes.tag.apply)); const canReadCustomer = computed(() => userStore.hasPermissions(permissionCodes.customer.read)); const canManageTagCustomers = computed(() => canApplyTag.value && canReadCustomer.value); const isNameChanged = computed(() => !!tag.value && !!tagName.value.trim() && tagName.value.trim() !== getTagName(tag.value)); -const tagUsageText = computed(() => `共 ${tag.value?.useCount ?? 0} 位客户使用`); +const canConfirmTagDeletion = computed(() => { + const currentTag = tag.value; + return canDeleteTag.value && !!currentTag?.id && deleteConfirmName.value === getTagName(currentTag) && !isDeletingTag.value; +}); function getTagName(value: Tag): string { return value.name || value.zhCN || "未命名标签"; @@ -190,6 +251,49 @@ async function saveTag(): Promise { } } +function openDeleteDialog(): void { + if (!canDeleteTag.value || !tag.value?.id || isDeletingTag.value) { + return; + } + deleteConfirmName.value = ""; + deleteDialogVisible.value = true; +} + +function closeDeleteDialog(): void { + if (isDeletingTag.value) { + return; + } + deleteDialogVisible.value = false; + deleteConfirmName.value = ""; +} + +async function removeTag(): Promise { + const id = tagId.value; + if (!id || !canConfirmTagDeletion.value || isDeletingTag.value) { + return; + } + + isDeletingTag.value = true; + try { + await TagAPI.remove(id); + } catch { + Message.error("标签删除失败"); + return; + } finally { + isDeletingTag.value = false; + } + + deleteDialogVisible.value = false; + Message.success("标签已删除"); + await router.replace({ name: "TagList" }); +} + +watch(deleteDialogVisible, visible => { + if (!visible) { + deleteConfirmName.value = ""; + } +}); + // ---------- 客户列表 ---------- const pageSize = 20; @@ -283,7 +387,11 @@ async function openCustomer(customer: Customer): Promise { if (!customer.id) { return; } - await router.push({ name: "CustomerDetail", params: { id: customer.id } }); + await router.push({ + name: "CustomerDetail", + params: { id: customer.id }, + query: { transitionDepth: String(Number(route.meta.depth ?? 0) + 1) } + }); } // ---------- 客户标签维护 ---------- @@ -396,6 +504,12 @@ onUnmounted(() => { .tag-detail { padding: var(--app-nav-height) 0 1rem; + .list-wrap { + gap: 1rem; + display: flex; + flex-direction: column; + } + .tag-card, .customer-section { margin: 0 1rem 1rem; @@ -462,4 +576,21 @@ onUnmounted(() => { } } } + +.delete-dialog-content { + .hint { + color: var(--td-text-color-secondary); + margin-bottom: .5rem; + } + + .name { + color: var(--td-error-color); + font-weight: 600; + } + + .confirm-input { + border: 1px solid var(--td-component-border); + border-radius: .75rem; + } +} diff --git a/src/pages/tag/TagList.vue b/src/pages/tag/TagList.vue index cbc8ff8..bb64622 100644 --- a/src/pages/tag/TagList.vue +++ b/src/pages/tag/TagList.vue @@ -8,41 +8,14 @@ @left-click="$router.back()" > - - - - - - - - - - - + @@ -59,30 +32,30 @@ class="search" type="search" borderless - placeholder="搜索标签" + placeholder="搜索标签名称(拼音)" /> - - - - + + + + + - - - + + + + + + + - - @@ -342,46 +254,13 @@ onUnmounted(() => { .tag-list { padding: var(--app-nav-height) 0 1rem 0; - .tag-panel { - gap: .75rem; + .list-wrap { + gap: 1rem; display: flex; - padding: 0 1rem 1rem 1rem; - flex-wrap: wrap; - align-items: flex-start; + flex-direction: column; - .item { - flex: 1 1 auto; - color: var(--td-brand-color); - width: fit-content; - border: 1px solid var(--td-brand-color); - cursor: pointer; - margin: 0; - display: flex; - padding: .25rem .5rem; - min-width: 0; - font-size: 1rem; - align-items: center; - border-radius: .5rem; - justify-content: center; - - .name { - flex: 1; - min-width: 0; - line-height: 1; - text-align: center; - overflow-wrap: anywhere; - } - - .close { - color: inherit; - flex: 0 0 auto; - border: 0; - padding: 0; - display: flex; - background: transparent; - margin-left: .5rem; - align-items: center; - } + .title { + color: color-mix(in srgb, hsl(var(--tag-hue), 72%, 44%) 68%, var(--td-text-color-primary)); } } } @@ -397,44 +276,4 @@ onUnmounted(() => { } } -.nav-right-slot { - width: 6rem; - height: 100%; - display: flex; - align-items: center; - justify-content: flex-end; - - .badge { - :deep(.t-badge__content) { - display: flex; - align-items: center; - } - } - - .button, - .nav-text { - color: var(--td-text-color-primary, #333); - border: none; - padding: 0; - display: inline-flex; - background: transparent; - align-items: center; - justify-content: center; - } - - .button { - &:disabled { - color: var(--td-text-color-disabled); - cursor: not-allowed; - } - } - - .nav-text { - font: inherit; - cursor: default; - - &.clickable { cursor: pointer; } - &.disabled { cursor: not-allowed; } - } -}