diff --git a/src/assets/styles/global.less b/src/assets/styles/global.less index 4111873..d1362f8 100644 --- a/src/assets/styles/global.less +++ b/src/assets/styles/global.less @@ -330,3 +330,35 @@ html.theme-dark body { opacity: 1; transform: translate3d(0, 0, 0); } + +.nav-action { + font: inherit; + color: var(--td-brand-color); + border: 0; + cursor: pointer; + padding: 0; + background: transparent; + + &.nav-action-icon { + color: var(--td-text-color-primary, #333); + display: inline-flex; + align-items: center; + justify-content: center; + } + + &.danger { + color: var(--td-error-color); + } + + &.nav-action-prominent { + color: var(--td-brand-color, #0052d9); + padding: .25rem .5rem; + font-size: .95rem; + font-weight: 600; + } + + &:disabled { + color: var(--td-text-color-disabled); + cursor: not-allowed; + } +} diff --git a/src/pages/customer/CustomerDetail.vue b/src/pages/customer/CustomerDetail.vue index 5cc7d2c..2e5ef61 100644 --- a/src/pages/customer/CustomerDetail.vue +++ b/src/pages/customer/CustomerDetail.vue @@ -7,41 +7,14 @@ @left-click="$router.back()" >
void | Promise) | undefined -}); -function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise): void { - pageNavBarRight.text = value || ""; - pageNavBarRight.textColor = color || ""; - pageNavBarRight.disabled = false; - pageNavBarRight.action = action; - if (value) { - pageNavBarRight.badge = undefined; - pageNavBarRight.icon = ""; - } -} -function clearPageNavBarRight(): void { - Object.assign(pageNavBarRight, { icon: "", badge: undefined, text: "", textColor: "", disabled: false, action: undefined }); -} -async function handlePageNavBarRightAction(): Promise { - if (pageNavBarRight.disabled || !pageNavBarRight.action) { - return; - } - await pageNavBarRight.action(); -} import type { BodyAreaValue, Customer } from "@/types/Customer"; @@ -613,19 +559,11 @@ async function toCustomerDataCharts(): Promise { await router.push(`/management/customers/${customer.value.id}/data-charts`); } -function updateNavBar(): void { - clearPageNavBarRight(); - if (userStore.hasPermissions(permissionCodes.customer.update)) { - setPageNavBarRightText("编辑", "var(--td-brand-color)", toEdit); - } -} onMounted(async () => { await loadCustomer(); - updateNavBar(); }); watch(() => route.params.id, loadCustomer); -onUnmounted(() => clearPageNavBarRight()); diff --git a/src/pages/customer/CustomerEdit.vue b/src/pages/customer/CustomerEdit.vue index e208431..e0ec3b8 100644 --- a/src/pages/customer/CustomerEdit.vue +++ b/src/pages/customer/CustomerEdit.vue @@ -7,41 +7,15 @@ @left-click="$router.back()" >
@@ -273,41 +247,6 @@ import { normalizeBodyAreaValue } from "@/utils/customer"; import { corePermissionCodes, gaoRoleCodes, permissionCodes } from "@/utils/permission"; import { compressUploadImageList } from "@/utils/imageCompression"; -const pageNavBarRight = reactive({ - icon: "", - badge: undefined as number | undefined, - text: "", - textColor: "", - disabled: false, - action: undefined as (() => void | Promise) | undefined -}); - -function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise): void { - pageNavBarRight.text = value || ""; - pageNavBarRight.textColor = color || ""; - pageNavBarRight.disabled = false; - pageNavBarRight.action = action; - if (value) { - pageNavBarRight.badge = undefined; - pageNavBarRight.icon = ""; - } -} - -function setPageNavBarRightDisabled(value: boolean): void { - pageNavBarRight.disabled = value; -} - -function clearPageNavBarRight(): void { - Object.assign(pageNavBarRight, { icon: "", badge: undefined, text: "", textColor: "", disabled: false, action: undefined }); -} - -async function handlePageNavBarRightAction(): Promise { - if (pageNavBarRight.disabled || !pageNavBarRight.action) { - return; - } - await pageNavBarRight.action(); -} - import { useSettingStore } from "@/store/settingStore"; defineOptions({ @@ -545,7 +484,6 @@ function handlePointCardCapture(capturePhoto: () => void): void { } watch(isCustomerBound, (value) => { - setPageNavBarRightDisabled(value); if (!value) { return; } @@ -600,14 +538,6 @@ async function loadDetail() { } onMounted(loadDetail); -onMounted(() => { - clearPageNavBarRight(); - if (userStore.hasPermissions(savePermissionCode.value)) { - setPageNavBarRightText("保存", "var(--td-brand-color)", doSubmit); - setPageNavBarRightDisabled(isCustomerBound.value); - } -}); - watch(() => route.fullPath, loadDetail); // ---------- 年龄 ---------- @@ -767,10 +697,6 @@ async function toBoundCustomerEdit(): Promise { await router.push(`/management/customers/${customerId}/edit`); } -onUnmounted(() => { - clearPageNavBarRight(); -}); - function buildAttachmentList(): Attachment[] { return photoItemList.value.flatMap(item => { if (item.attachment) { @@ -892,45 +818,5 @@ function buildAttachmentList(): Attachment[] { } } -.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; } - } -} diff --git a/src/pages/customer/CustomerInviteRelation.vue b/src/pages/customer/CustomerInviteRelation.vue index 29231a4..7c9ff3b 100644 --- a/src/pages/customer/CustomerInviteRelation.vue +++ b/src/pages/customer/CustomerInviteRelation.vue @@ -7,41 +7,13 @@ @left-click="$router.back()" >
void | Promise) | undefined -}); -function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise): void { - pageNavBarRight.text = value || ""; - pageNavBarRight.textColor = color || ""; - pageNavBarRight.disabled = false; - pageNavBarRight.action = action; - if (value) { - pageNavBarRight.badge = undefined; - pageNavBarRight.icon = ""; - } -} -function clearPageNavBarRight(): void { - Object.assign(pageNavBarRight, { icon: "", badge: undefined, text: "", textColor: "", disabled: false, action: undefined }); -} -async function handlePageNavBarRightAction(): Promise { - if (pageNavBarRight.disabled || !pageNavBarRight.action) { - return; - } - await pageNavBarRight.action(); -} import type { Customer } from "@/types/Customer"; @@ -272,7 +217,6 @@ async function toInviteRank(): Promise { // ---------- 生命周期 ---------- onMounted(async () => { - setPageNavBarRightText("排行", "var(--td-brand-color)", toInviteRank); await loadCustomers(); }); @@ -281,7 +225,6 @@ watch(searchKeyword, () => { }); onBeforeUnmount(() => { - clearPageNavBarRight(); }); @@ -375,44 +318,4 @@ onBeforeUnmount(() => { } } -.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; } - } -} diff --git a/src/pages/event/EventDetail.vue b/src/pages/event/EventDetail.vue index bae44df..10033d1 100644 --- a/src/pages/event/EventDetail.vue +++ b/src/pages/event/EventDetail.vue @@ -7,41 +7,14 @@ @left-click="$router.back()" >
void | Promise) | undefined -}); -function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise): void { - pageNavBarRight.text = value || ""; - pageNavBarRight.textColor = color || ""; - pageNavBarRight.disabled = false; - pageNavBarRight.action = action; - if (value) { - pageNavBarRight.badge = undefined; - pageNavBarRight.icon = ""; - } -} -function clearPageNavBarRight(): void { - Object.assign(pageNavBarRight, { icon: "", badge: undefined, text: "", textColor: "", disabled: false, action: undefined }); -} -async function handlePageNavBarRightAction(): Promise { - if (pageNavBarRight.disabled || !pageNavBarRight.action) { - return; - } - await pageNavBarRight.action(); -} import type { EventItem, EventLimitType, EventOptionSelectionMap, EventStatus, EventValueType, EventValueUnit } from "@/types/EventItem"; @@ -440,22 +386,11 @@ watch(() => route.params.id, async () => { }, { immediate: true }); onMounted(() => { - clearPageNavBarRight(); if (canUpdate.value) { - setPageNavBarRightText("编辑", "var(--td-brand-color)", toEdit); } }); -watch(canUpdate, value => { - clearPageNavBarRight(); - if (value) { - setPageNavBarRightText("编辑", "var(--td-brand-color)", toEdit); - } -}); -onUnmounted(() => { - clearPageNavBarRight(); -}); diff --git a/src/pages/event/EventEdit.vue b/src/pages/event/EventEdit.vue index ab115cd..79b42fa 100644 --- a/src/pages/event/EventEdit.vue +++ b/src/pages/event/EventEdit.vue @@ -7,41 +7,14 @@ @left-click="$router.back()" >
@@ -283,37 +256,6 @@ import { getEventBizTypeText } from "@/utils/event"; import { gaoRoleCodes, permissionCodes } from "@/utils/permission"; import { Message } from "@/utils/message"; -const pageNavBarRight = reactive({ - icon: "", - badge: undefined as number | undefined, - text: "", - textColor: "", - disabled: false, - action: undefined as (() => void | Promise) | undefined -}); - -function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise): void { - pageNavBarRight.text = value || ""; - pageNavBarRight.textColor = color || ""; - pageNavBarRight.disabled = false; - pageNavBarRight.action = action; - if (value) { - pageNavBarRight.badge = undefined; - pageNavBarRight.icon = ""; - } -} - -function clearPageNavBarRight(): void { - Object.assign(pageNavBarRight, { icon: "", badge: undefined, text: "", textColor: "", disabled: false, action: undefined }); -} - -async function handlePageNavBarRightAction(): Promise { - if (pageNavBarRight.disabled || !pageNavBarRight.action) { - return; - } - await pageNavBarRight.action(); -} - import type { EventBizType, EventItem, EventLimitType, EventOptionGroup, EventStatus, EventValueType, EventValueUnit } from "@/types/EventItem"; type PickerValue = string | number; @@ -810,18 +752,12 @@ async function fillForm(): Promise { } onMounted(async () => { - clearPageNavBarRight(); - if (userStore.hasPermissions(savePermissionCode.value)) { - setPageNavBarRightText("保存", "var(--td-brand-color)", saveEventItem); - } try { await fillForm(); } catch { Message.error("登记事件加载失败"); } }); - -onUnmounted(() => clearPageNavBarRight()); diff --git a/src/pages/event/EventRecordDetail.vue b/src/pages/event/EventRecordDetail.vue index 3a447cc..08e274d 100644 --- a/src/pages/event/EventRecordDetail.vue +++ b/src/pages/event/EventRecordDetail.vue @@ -7,41 +7,14 @@ @left-click="$router.back()" >
@@ -167,36 +140,9 @@ import { formatEventNumberValue } from "@/utils/eventValue"; import { Message } from "@/utils/message"; import { permissionCodes } from "@/utils/permission"; -const pageNavBarRight = reactive({ - icon: "", - badge: undefined as number | undefined, - text: "", - textColor: "", - disabled: false, - action: undefined as (() => void | Promise) | undefined -}); -function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise): void { - pageNavBarRight.text = value || ""; - pageNavBarRight.textColor = color || ""; - pageNavBarRight.disabled = false; - pageNavBarRight.action = action; - if (value) { - pageNavBarRight.badge = undefined; - pageNavBarRight.icon = ""; - } -} -function clearPageNavBarRight(): void { - Object.assign(pageNavBarRight, { icon: "", badge: undefined, text: "", textColor: "", disabled: false, action: undefined }); -} -async function handlePageNavBarRightAction(): Promise { - if (pageNavBarRight.disabled || !pageNavBarRight.action) { - return; - } - await pageNavBarRight.action(); -} import type { EventRecord } from "@/types/EventRecord"; @@ -492,18 +438,8 @@ watch(() => route.params.id, async () => { await loadRecord(); }, { immediate: true }); -function updateNavBarAction(): void { - clearPageNavBarRight(); - if (canUpdateRecord.value) { - setPageNavBarRightText("编辑", "var(--td-brand-color)", toEdit); - } -} -watch(canUpdateRecord, updateNavBarAction, { immediate: true }); -onUnmounted(() => { - clearPageNavBarRight(); -}); diff --git a/src/pages/event/EventRecordEdit.vue b/src/pages/event/EventRecordEdit.vue index 5b3851e..dc675fc 100644 --- a/src/pages/event/EventRecordEdit.vue +++ b/src/pages/event/EventRecordEdit.vue @@ -7,41 +7,13 @@ @left-click="$router.back()" >
@@ -248,36 +220,9 @@ import { getEventRecordPhotoURL, hasPhotoAttachment } from "@/utils/eventRecord" import { getEventNumberValuePlaceholder, resolveEventNumberValue } from "@/utils/eventValue"; import { permissionCodes } from "@/utils/permission"; -const pageNavBarRight = reactive({ - icon: "", - badge: undefined as number | undefined, - text: "", - textColor: "", - disabled: false, - action: undefined as (() => void | Promise) | undefined -}); -function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise): void { - pageNavBarRight.text = value || ""; - pageNavBarRight.textColor = color || ""; - pageNavBarRight.disabled = false; - pageNavBarRight.action = action; - if (value) { - pageNavBarRight.badge = undefined; - pageNavBarRight.icon = ""; - } -} -function clearPageNavBarRight(): void { - Object.assign(pageNavBarRight, { icon: "", badge: undefined, text: "", textColor: "", disabled: false, action: undefined }); -} -async function handlePageNavBarRightAction(): Promise { - if (pageNavBarRight.disabled || !pageNavBarRight.action) { - return; - } - await pageNavBarRight.action(); -} import { useSettingStore } from "@/store/settingStore"; @@ -765,15 +710,10 @@ async function loadRecordForEdit(): Promise { onMounted(loadPageData); onMounted(() => { - clearPageNavBarRight(); if (userStore.hasPermissions(pageAccess.value)) { - setPageNavBarRightText(saveButtonText.value, "var(--td-brand-color)", submitRecord); } }); -onUnmounted(() => { - clearPageNavBarRight(); -}); watch(customerCode, async (value) => { if (!value) { @@ -929,44 +869,4 @@ watch(customerCode, async (value) => { } } -.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; } - } -} diff --git a/src/pages/event/EventSort.vue b/src/pages/event/EventSort.vue index 319340e..50d682f 100644 --- a/src/pages/event/EventSort.vue +++ b/src/pages/event/EventSort.vue @@ -7,41 +7,7 @@ @left-click="$router.back()" >
@@ -98,40 +64,8 @@ import { type TagProps } from "tdesign-mobile-vue"; import { VueDraggableNext } from "vue-draggable-next"; import EventAPI from "@/api/EventAPI"; import { permissionCodes } from "@/utils/permission"; -import { Message } from "@/utils/message.ts"; - -const pageNavBarRight = reactive({ - icon: "", - badge: undefined as number | undefined, - text: "", - textColor: "", - disabled: false, - action: undefined as (() => void | Promise) | undefined -}); - -function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise): void { - pageNavBarRight.text = value || ""; - pageNavBarRight.textColor = color || ""; - pageNavBarRight.disabled = false; - pageNavBarRight.action = action; - if (value) { - pageNavBarRight.badge = undefined; - pageNavBarRight.icon = ""; - } -} - -function clearPageNavBarRight(): void { - Object.assign(pageNavBarRight, { icon: "", badge: undefined, text: "", textColor: "", disabled: false, action: undefined }); -} - -async function handlePageNavBarRightAction(): Promise { - if (pageNavBarRight.disabled || !pageNavBarRight.action) { - return; - } - await pageNavBarRight.action(); -} - import type { EventItem, EventStatus } from "@/types/EventItem"; +import { Message } from "@/utils/message.ts"; defineOptions({ name: "EventSort" @@ -221,18 +155,12 @@ async function loadData(): Promise { } onMounted(async () => { - clearPageNavBarRight(); - setPageNavBarRightText("保存", "var(--td-brand-color)", saveSort); try { await loadData(); } catch { Message.error("登记事件加载失败"); } }); - -onUnmounted(() => { - clearPageNavBarRight(); -}); diff --git a/src/pages/followUpReminder/FollowUpReminderDetail.vue b/src/pages/followUpReminder/FollowUpReminderDetail.vue index edd2b8c..9256e5b 100644 --- a/src/pages/followUpReminder/FollowUpReminderDetail.vue +++ b/src/pages/followUpReminder/FollowUpReminderDetail.vue @@ -7,41 +7,14 @@ @left-click="$router.back()" >