simple navbar action

This commit is contained in:
Timi
2026-10-22 16:17:22 +08:00
parent de8374db0b
commit 1eef8c6ea1
52 changed files with 358 additions and 5516 deletions
+32
View File
@@ -330,3 +330,35 @@ html.theme-dark body {
opacity: 1; opacity: 1;
transform: translate3d(0, 0, 0); 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;
}
}
+7 -109
View File
@@ -7,41 +7,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" v-if="customer?.id && userStore.hasPermissions(permissionCodes.customer.update)"
class="nav-right-slot" class="nav-action"
type="button"
@click="toEdit"
> >
<t-badge 编辑
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div <div
@@ -213,36 +186,9 @@ import { normalizeBodyAreaValue } from "@/utils/customer";
import { corePermissionCodes, permissionCodes } from "@/utils/permission"; import { corePermissionCodes, permissionCodes } from "@/utils/permission";
import { LunarCalendar } from "@/utils/LunarCalendar"; import { LunarCalendar } from "@/utils/LunarCalendar";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import type { BodyAreaValue, Customer } from "@/types/Customer"; import type { BodyAreaValue, Customer } from "@/types/Customer";
@@ -613,19 +559,11 @@ async function toCustomerDataCharts(): Promise<void> {
await router.push(`/management/customers/${customer.value.id}/data-charts`); 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 () => { onMounted(async () => {
await loadCustomer(); await loadCustomer();
updateNavBar();
}); });
watch(() => route.params.id, loadCustomer); watch(() => route.params.id, loadCustomer);
onUnmounted(() => clearPageNavBarRight());
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -683,44 +621,4 @@ onUnmounted(() => clearPageNavBarRight());
} }
} }
.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; }
}
}
</style> </style>
+8 -122
View File
@@ -7,41 +7,15 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" v-if="userStore.hasPermissions(savePermissionCode)"
class="nav-right-slot" class="nav-action"
type="button"
:disabled="isCustomerBound"
@click="doSubmit"
> >
<t-badge 保存
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div v-can="savePermissionCode" class="customer-edit"> <div v-can="savePermissionCode" class="customer-edit">
@@ -273,41 +247,6 @@ import { normalizeBodyAreaValue } from "@/utils/customer";
import { corePermissionCodes, gaoRoleCodes, permissionCodes } from "@/utils/permission"; import { corePermissionCodes, gaoRoleCodes, permissionCodes } from "@/utils/permission";
import { compressUploadImageList } from "@/utils/imageCompression"; import { compressUploadImageList } from "@/utils/imageCompression";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import { useSettingStore } from "@/store/settingStore"; import { useSettingStore } from "@/store/settingStore";
defineOptions({ defineOptions({
@@ -545,7 +484,6 @@ function handlePointCardCapture(capturePhoto: () => void): void {
} }
watch(isCustomerBound, (value) => { watch(isCustomerBound, (value) => {
setPageNavBarRightDisabled(value);
if (!value) { if (!value) {
return; return;
} }
@@ -600,14 +538,6 @@ async function loadDetail() {
} }
onMounted(loadDetail); onMounted(loadDetail);
onMounted(() => {
clearPageNavBarRight();
if (userStore.hasPermissions(savePermissionCode.value)) {
setPageNavBarRightText("保存", "var(--td-brand-color)", doSubmit);
setPageNavBarRightDisabled(isCustomerBound.value);
}
});
watch(() => route.fullPath, loadDetail); watch(() => route.fullPath, loadDetail);
// ---------- 年龄 ---------- // ---------- 年龄 ----------
@@ -767,10 +697,6 @@ async function toBoundCustomerEdit(): Promise<void> {
await router.push(`/management/customers/${customerId}/edit`); await router.push(`/management/customers/${customerId}/edit`);
} }
onUnmounted(() => {
clearPageNavBarRight();
});
function buildAttachmentList(): Attachment[] { function buildAttachmentList(): Attachment[] {
return photoItemList.value.flatMap(item => { return photoItemList.value.flatMap(item => {
if (item.attachment) { 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; }
}
}
</style> </style>
+6 -103
View File
@@ -7,41 +7,13 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" class="nav-action"
class="nav-right-slot" type="button"
@click="toInviteRank"
> >
<t-badge 排行
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div <div
@@ -101,36 +73,9 @@ import { getErrorMessage } from "@/utils/error";
import { Message } from "@/utils/message"; import { Message } from "@/utils/message";
import { gaoRoleCodes, permissionCodes } from "@/utils/permission"; import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import type { Customer } from "@/types/Customer"; import type { Customer } from "@/types/Customer";
@@ -272,7 +217,6 @@ async function toInviteRank(): Promise<void> {
// ---------- 生命周期 ---------- // ---------- 生命周期 ----------
onMounted(async () => { onMounted(async () => {
setPageNavBarRightText("排行", "var(--td-brand-color)", toInviteRank);
await loadCustomers(); await loadCustomers();
}); });
@@ -281,7 +225,6 @@ watch(searchKeyword, () => {
}); });
onBeforeUnmount(() => { onBeforeUnmount(() => {
clearPageNavBarRight();
}); });
</script> </script>
@@ -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; }
}
}
</style> </style>
+7 -112
View File
@@ -7,41 +7,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" v-if="canUpdate"
class="nav-right-slot" class="nav-action"
type="button"
@click="toEdit"
> >
<t-badge 编辑
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div <div
@@ -178,36 +151,9 @@ import { formatPackageAmount, getPackageConfigStatusText } from "@/utils/package
import { gaoRoleCodes, permissionCodes } from "@/utils/permission"; import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
import { Message } from "@/utils/message"; import { Message } from "@/utils/message";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import type { EventItem, EventLimitType, EventOptionSelectionMap, EventStatus, EventValueType, EventValueUnit } from "@/types/EventItem"; import type { EventItem, EventLimitType, EventOptionSelectionMap, EventStatus, EventValueType, EventValueUnit } from "@/types/EventItem";
@@ -440,22 +386,11 @@ watch(() => route.params.id, async () => {
}, { immediate: true }); }, { immediate: true });
onMounted(() => { onMounted(() => {
clearPageNavBarRight();
if (canUpdate.value) { if (canUpdate.value) {
setPageNavBarRightText("编辑", "var(--td-brand-color)", toEdit);
} }
}); });
watch(canUpdate, value => {
clearPageNavBarRight();
if (value) {
setPageNavBarRightText("编辑", "var(--td-brand-color)", toEdit);
}
});
onUnmounted(() => {
clearPageNavBarRight();
});
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -543,44 +478,4 @@ onUnmounted(() => {
padding: 1rem; padding: 1rem;
} }
.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; }
}
}
</style> </style>
+7 -111
View File
@@ -7,41 +7,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" v-if="userStore.hasPermissions(savePermissionCode)"
class="nav-right-slot" class="nav-action"
type="button"
@click="saveEventItem"
> >
<t-badge 保存
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div v-can="pageAccess" class="event-edit"> <div v-can="pageAccess" class="event-edit">
@@ -283,37 +256,6 @@ import { getEventBizTypeText } from "@/utils/event";
import { gaoRoleCodes, permissionCodes } from "@/utils/permission"; import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
import { Message } from "@/utils/message"; import { Message } from "@/utils/message";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import type { EventBizType, EventItem, EventLimitType, EventOptionGroup, EventStatus, EventValueType, EventValueUnit } from "@/types/EventItem"; import type { EventBizType, EventItem, EventLimitType, EventOptionGroup, EventStatus, EventValueType, EventValueUnit } from "@/types/EventItem";
type PickerValue = string | number; type PickerValue = string | number;
@@ -810,18 +752,12 @@ async function fillForm(): Promise<void> {
} }
onMounted(async () => { onMounted(async () => {
clearPageNavBarRight();
if (userStore.hasPermissions(savePermissionCode.value)) {
setPageNavBarRightText("保存", "var(--td-brand-color)", saveEventItem);
}
try { try {
await fillForm(); await fillForm();
} catch { } catch {
Message.error("登记事件加载失败"); Message.error("登记事件加载失败");
} }
}); });
onUnmounted(() => clearPageNavBarRight());
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -990,44 +926,4 @@ onUnmounted(() => clearPageNavBarRight());
} }
} }
.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; }
}
}
</style> </style>
+7 -111
View File
@@ -7,41 +7,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" v-if="canUpdateRecord"
class="nav-right-slot" class="nav-action"
type="button"
@click="toEdit"
> >
<t-badge 编辑
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div v-can="permissionCodes.eventRecord.read" class="event-record-detail"> <div v-can="permissionCodes.eventRecord.read" class="event-record-detail">
@@ -167,36 +140,9 @@ import { formatEventNumberValue } from "@/utils/eventValue";
import { Message } from "@/utils/message"; import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission"; import { permissionCodes } from "@/utils/permission";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import type { EventRecord } from "@/types/EventRecord"; import type { EventRecord } from "@/types/EventRecord";
@@ -492,18 +438,8 @@ watch(() => route.params.id, async () => {
await loadRecord(); await loadRecord();
}, { immediate: true }); }, { immediate: true });
function updateNavBarAction(): void {
clearPageNavBarRight();
if (canUpdateRecord.value) {
setPageNavBarRightText("编辑", "var(--td-brand-color)", toEdit);
}
}
watch(canUpdateRecord, updateNavBarAction, { immediate: true });
onUnmounted(() => {
clearPageNavBarRight();
});
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -546,45 +482,5 @@ 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; }
}
}
</style> </style>
+7 -107
View File
@@ -7,41 +7,13 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" v-if="userStore.hasPermissions(pageAccess)"
class="nav-right-slot" class="nav-action"
> type="button"
<t-badge @click="submitRecord"
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" v-text="saveButtonText"
class="badge" ></button>
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div v-can="pageAccess" class="registration-record-edit"> <div v-can="pageAccess" class="registration-record-edit">
@@ -248,36 +220,9 @@ import { getEventRecordPhotoURL, hasPhotoAttachment } from "@/utils/eventRecord"
import { getEventNumberValuePlaceholder, resolveEventNumberValue } from "@/utils/eventValue"; import { getEventNumberValuePlaceholder, resolveEventNumberValue } from "@/utils/eventValue";
import { permissionCodes } from "@/utils/permission"; import { permissionCodes } from "@/utils/permission";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import { useSettingStore } from "@/store/settingStore"; import { useSettingStore } from "@/store/settingStore";
@@ -765,15 +710,10 @@ async function loadRecordForEdit(): Promise<void> {
onMounted(loadPageData); onMounted(loadPageData);
onMounted(() => { onMounted(() => {
clearPageNavBarRight();
if (userStore.hasPermissions(pageAccess.value)) { if (userStore.hasPermissions(pageAccess.value)) {
setPageNavBarRightText(saveButtonText.value, "var(--td-brand-color)", submitRecord);
} }
}); });
onUnmounted(() => {
clearPageNavBarRight();
});
watch(customerCode, async (value) => { watch(customerCode, async (value) => {
if (!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; }
}
}
</style> </style>
+2 -114
View File
@@ -7,41 +7,7 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button class="nav-action" type="button" @click="saveSort">保存</button>
v-if="pageNavBarRight.icon || pageNavBarRight.text"
class="nav-right-slot"
>
<t-badge
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined"
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div v-can="permissionCodes.event.update" class="registration-event-sort"> <div v-can="permissionCodes.event.update" class="registration-event-sort">
@@ -98,40 +64,8 @@ import { type TagProps } from "tdesign-mobile-vue";
import { VueDraggableNext } from "vue-draggable-next"; import { VueDraggableNext } from "vue-draggable-next";
import EventAPI from "@/api/EventAPI"; import EventAPI from "@/api/EventAPI";
import { permissionCodes } from "@/utils/permission"; 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<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import type { EventItem, EventStatus } from "@/types/EventItem"; import type { EventItem, EventStatus } from "@/types/EventItem";
import { Message } from "@/utils/message.ts";
defineOptions({ defineOptions({
name: "EventSort" name: "EventSort"
@@ -221,18 +155,12 @@ async function loadData(): Promise<void> {
} }
onMounted(async () => { onMounted(async () => {
clearPageNavBarRight();
setPageNavBarRightText("保存", "var(--td-brand-color)", saveSort);
try { try {
await loadData(); await loadData();
} catch { } catch {
Message.error("登记事件加载失败"); Message.error("登记事件加载失败");
} }
}); });
onUnmounted(() => {
clearPageNavBarRight();
});
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -306,44 +234,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; }
}
}
</style> </style>
@@ -7,41 +7,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" v-if="canUpdate"
class="nav-right-slot" class="nav-action"
type="button"
@click="toEdit"
> >
<t-badge 编辑
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div v-can="permissionCodes.customerFollowUpReminder.read" class="follow-up-reminder-detail"> <div v-can="permissionCodes.customerFollowUpReminder.read" class="follow-up-reminder-detail">
@@ -134,36 +107,9 @@ import type { PhotoItem } from "@/types/Photo";
import { getAttachmentReadURL } from "@/utils/attachment"; import { getAttachmentReadURL } from "@/utils/attachment";
import { corePermissionCodes, permissionCodes } from "@/utils/permission"; import { corePermissionCodes, permissionCodes } from "@/utils/permission";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import type { FollowUpReminder, FollowUpReminderNotifyChannel, FollowUpReminderStatus } from "@/types/FollowUpReminder"; import type { FollowUpReminder, FollowUpReminderNotifyChannel, FollowUpReminderStatus } from "@/types/FollowUpReminder";
@@ -251,7 +197,6 @@ async function loadDetail(): Promise<void> {
loadToken = token; loadToken = token;
detail.value = undefined; detail.value = undefined;
internalNotifyStatus.value = undefined; internalNotifyStatus.value = undefined;
clearPageNavBarRight();
const id = String(route.params.id || ""); const id = String(route.params.id || "");
if (!id) { if (!id) {
return; return;
@@ -264,7 +209,6 @@ async function loadDetail(): Promise<void> {
return; return;
} }
detail.value = result; detail.value = result;
setEditAction();
await loadInternalNotifyStatus(result, token); await loadInternalNotifyStatus(result, token);
} catch (error) { } catch (error) {
Message.error(getErrorMessage(error, "跟进提醒详情加载失败")); Message.error(getErrorMessage(error, "跟进提醒详情加载失败"));
@@ -275,11 +219,6 @@ async function loadDetail(): Promise<void> {
} }
} }
function setEditAction(): void {
if (canUpdate.value) {
setPageNavBarRightText("编辑", "var(--td-brand-color)", toEdit);
}
}
async function loadInternalNotifyStatus(item: FollowUpReminder, token: number): Promise<void> { async function loadInternalNotifyStatus(item: FollowUpReminder, token: number): Promise<void> {
if (!item.internalNotifyDetailId || !userStore.hasPermissions(corePermissionCodes.notify.read)) { if (!item.internalNotifyDetailId || !userStore.hasPermissions(corePermissionCodes.notify.read)) {
@@ -375,14 +314,12 @@ function confirmDelete(): void {
async function remove(id: string): Promise<void> { async function remove(id: string): Promise<void> {
isDeleting.value = true; isDeleting.value = true;
clearPageNavBarRight();
try { try {
await FollowUpReminderAPI.remove(id); await FollowUpReminderAPI.remove(id);
Message.success("跟进提醒已删除"); Message.success("跟进提醒已删除");
await router.replace({ name: "CustomerFollowUpReminderList" }); await router.replace({ name: "CustomerFollowUpReminderList" });
} catch (error) { } catch (error) {
Message.error(getErrorMessage(error, "跟进提醒删除失败")); Message.error(getErrorMessage(error, "跟进提醒删除失败"));
setEditAction();
} finally { } finally {
isDeleting.value = false; isDeleting.value = false;
} }
@@ -392,7 +329,6 @@ watch(() => route.params.id, async () => {
await loadDetail(); await loadDetail();
}, { immediate: true }); }, { immediate: true });
onUnmounted(() => clearPageNavBarRight());
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -445,44 +381,4 @@ onUnmounted(() => clearPageNavBarRight());
} }
} }
.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; }
}
}
</style> </style>
@@ -7,41 +7,12 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" class="nav-action"
class="nav-right-slot" type="button"
> @click="save"
<t-badge v-text="isEditMode ? '保存' : '提交'"
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" ></button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div v-can="pageAccess" class="follow-up-reminder-edit"> <div v-can="pageAccess" class="follow-up-reminder-edit">
@@ -174,36 +145,9 @@ import { getAttachmentReadURL } from "@/utils/attachment";
import { parseDateTime } from "@/utils/date"; import { parseDateTime } from "@/utils/date";
import { gaoRoleCodes, permissionCodes } from "@/utils/permission"; import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import type { Customer } from "@/types/Customer"; import type { Customer } from "@/types/Customer";
@@ -648,7 +592,6 @@ async function save(): Promise<void> {
} }
onMounted(async () => { onMounted(async () => {
setPageNavBarRightText(isEditMode.value ? "保存" : "提交", "var(--td-brand-color)", save);
try { try {
await loadForm(); await loadForm();
} catch (error) { } catch (error) {
@@ -656,7 +599,6 @@ onMounted(async () => {
} }
}); });
onUnmounted(() => clearPageNavBarRight());
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -724,44 +666,4 @@ onUnmounted(() => clearPageNavBarRight());
} }
} }
.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; }
}
}
</style> </style>
@@ -7,41 +7,13 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" class="nav-action"
class="nav-right-slot" type="button"
@click="save"
> >
<t-badge 提交
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div v-can="permissionCodes.orderFulfillment.create" class="fulfillment-create"> <div v-can="permissionCodes.orderFulfillment.create" class="fulfillment-create">
@@ -219,36 +191,9 @@ import {
import { uploadPhotoList } from "@/utils/photo"; import { uploadPhotoList } from "@/utils/photo";
import { getProductPhotoURL, getProductQuantityStep } from "@/utils/product"; import { getProductPhotoURL, getProductQuantityStep } from "@/utils/product";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import type { Attachment } from "timi-web-api"; import type { Attachment } from "timi-web-api";
@@ -687,12 +632,10 @@ async function save(): Promise<void> {
} }
onMounted(async () => { onMounted(async () => {
setPageNavBarRightText("提交", "var(--td-brand-color)", save);
await loadData(); await loadData();
}); });
onUnmounted(() => { onUnmounted(() => {
window.clearTimeout(stockPreviewTimer); window.clearTimeout(stockPreviewTimer);
clearPageNavBarRight();
}); });
</script> </script>
@@ -823,44 +766,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; }
}
}
</style> </style>
@@ -8,7 +8,7 @@
@left-click="handleBack" @left-click="handleBack"
> >
<template #right> <template #right>
<button class="nav-action" type="button" :disabled="isSaving || isStockChecking || sourceOrderLoading" @click="save"> <button class="nav-action nav-action-prominent" type="button" :disabled="isSaving || isStockChecking || sourceOrderLoading" @click="save">
<span v-text="isSaving ? '提交中' : '提交'" /> <span v-text="isSaving ? '提交中' : '提交'" />
</button> </button>
</template> </template>
@@ -455,18 +455,6 @@ onUnmounted(() => {
padding: calc(var(--app-nav-height) + .75rem) 0 2rem; padding: calc(var(--app-nav-height) + .75rem) 0 2rem;
} }
.nav-action {
color: var(--td-brand-color, #0052d9);
border: 0;
padding: .25rem .5rem;
font-size: .95rem;
background: transparent;
font-weight: 600;
&:disabled {
color: var(--td-text-color-disabled, #bbb);
}
}
.customer-profile { .customer-profile {
margin: .75rem 1rem; margin: .75rem 1rem;
+6 -109
View File
@@ -7,41 +7,12 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" class="nav-action"
class="nav-right-slot" type="button"
> @click="saveNotification"
<t-badge v-text="scheduleAtText ? '提交' : '发送'"
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" ></button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div v-can="corePermissionCodes.notify.create" class="notify-management-create"> <div v-can="corePermissionCodes.notify.create" class="notify-management-create">
@@ -128,36 +99,9 @@ import NotifyRecipientPicker, {
} from "@/pages/notify/component/NotifyRecipientPicker.vue"; } from "@/pages/notify/component/NotifyRecipientPicker.vue";
import { corePermissionCodes, coreRoleCodes, gaoRoleCodes, permissionCodes } from "@/utils/permission"; import { corePermissionCodes, coreRoleCodes, gaoRoleCodes, permissionCodes } from "@/utils/permission";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import { useCurrentStoreStore } from "@/store/currentStoreStore"; import { useCurrentStoreStore } from "@/store/currentStoreStore";
@@ -266,11 +210,7 @@ const scheduleAtText = ref("");
const scheduleDraftText = ref(""); const scheduleDraftText = ref("");
const minimumScheduleText = computed(() => Time.toDateTime(new Date(Time.now() + Time.M))); const minimumScheduleText = computed(() => Time.toDateTime(new Date(Time.now() + Time.M)));
function updateNavActionText(): void {
setPageNavBarRightText(scheduleAtText.value ? "提交" : "发送", "var(--td-brand-color)", saveNotification);
}
watch(scheduleAtText, updateNavActionText);
function getContentText(content: string): string { function getContentText(content: string): string {
const parser = new DOMParser(); const parser = new DOMParser();
@@ -431,7 +371,6 @@ async function loadRecipients(): Promise<void> {
// ---------- 生命周期 ---------- // ---------- 生命周期 ----------
onMounted(async () => { onMounted(async () => {
clearPageNavBarRight();
if (!canCreate.value) { if (!canCreate.value) {
return; return;
} }
@@ -441,11 +380,9 @@ onMounted(async () => {
const loginStore = await currentStoreStore.loadLoginStore(); const loginStore = await currentStoreStore.loadLoginStore();
recipientStoreId.value = loginStore?.id || currentStoreStore.currentStoreId || ""; recipientStoreId.value = loginStore?.id || currentStoreStore.currentStoreId || "";
} }
updateNavActionText();
await loadRecipients(); await loadRecipients();
}); });
onUnmounted(() => clearPageNavBarRight());
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -524,44 +461,4 @@ onUnmounted(() => clearPageNavBarRight());
} }
} }
.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; }
}
}
</style> </style>
+7 -112
View File
@@ -7,41 +7,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" v-if="detail?.id && canDeleteNotify"
class="nav-right-slot" class="nav-action danger"
type="button"
@click="confirmDelete"
> >
<t-badge 删除
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div v-can="corePermissionCodes.notify.read" class="notify-detail"> <div v-can="corePermissionCodes.notify.read" class="notify-detail">
@@ -91,36 +64,9 @@ import { getErrorMessage } from "@/utils/error";
import { getAttachmentReadURL } from "@/utils/attachment"; import { getAttachmentReadURL } from "@/utils/attachment";
import NotifyContent from "@/pages/notify/component/NotifyContent.vue"; import NotifyContent from "@/pages/notify/component/NotifyContent.vue";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import { corePermissionCodes } from "@/utils/permission"; import { corePermissionCodes } from "@/utils/permission";
@@ -183,7 +129,6 @@ async function loadDetail(): Promise<void> {
const requestToken = loadToken + 1; const requestToken = loadToken + 1;
loadToken = requestToken; loadToken = requestToken;
detail.value = undefined; detail.value = undefined;
clearPageNavBarRight();
const notifyId = String(route.params.id || ""); const notifyId = String(route.params.id || "");
if (!notifyId) { if (!notifyId) {
return; return;
@@ -196,7 +141,6 @@ async function loadDetail(): Promise<void> {
return; return;
} }
detail.value = result; detail.value = result;
setRightAction();
} catch (error) { } catch (error) {
Message.error(getErrorMessage(error, "通知详情加载失败")); Message.error(getErrorMessage(error, "通知详情加载失败"));
} finally { } finally {
@@ -206,11 +150,6 @@ async function loadDetail(): Promise<void> {
} }
} }
function setRightAction(): void {
if (detail.value?.id && canDeleteNotify.value) {
setPageNavBarRightText("删除", "var(--td-error-color)", confirmDelete);
}
}
// ---------- 通知操作 ---------- // ---------- 通知操作 ----------
@@ -263,14 +202,12 @@ async function confirmDelete(): Promise<void> {
async onConfirm() { async onConfirm() {
dialog.destroy(); dialog.destroy();
isDeleting.value = true; isDeleting.value = true;
clearPageNavBarRight();
try { try {
await NotifyAPI.managementDelete(notifyId); await NotifyAPI.managementDelete(notifyId);
Message.success("通知已删除"); Message.success("通知已删除");
await router.replace({ name: "NotifyList" }); await router.replace({ name: "NotifyList" });
} catch (error) { } catch (error) {
Message.error(getErrorMessage(error, "通知删除失败")); Message.error(getErrorMessage(error, "通知删除失败"));
setRightAction();
} finally { } finally {
isDeleting.value = false; isDeleting.value = false;
} }
@@ -332,8 +269,6 @@ watch(() => route.params.id, async () => {
await loadDetail(); await loadDetail();
}, { immediate: true }); }, { immediate: true });
onMounted(() => clearPageNavBarRight());
onUnmounted(() => clearPageNavBarRight());
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -357,44 +292,4 @@ onUnmounted(() => clearPageNavBarRight());
} }
} }
.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; }
}
}
</style> </style>
+1 -105
View File
@@ -8,41 +8,7 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button v-if="canReadNotify && canCreateNotify" class="nav-action" type="button" @click="toCreate">新建</button>
v-if="pageNavBarRight.icon || pageNavBarRight.text"
class="nav-right-slot"
>
<t-badge
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined"
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<main v-can="corePermissionCodes.notify.read" class="page-content scroll list"> <main v-can="corePermissionCodes.notify.read" class="page-content scroll list">
@@ -113,36 +79,9 @@ import { DialogPlugin } from "tdesign-mobile-vue";
import { Message } from "@/utils/message"; import { Message } from "@/utils/message";
import { getErrorMessage } from "@/utils/error"; import { getErrorMessage } from "@/utils/error";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import { corePermissionCodes } from "@/utils/permission"; import { corePermissionCodes } from "@/utils/permission";
@@ -333,17 +272,14 @@ async function confirmDelete(item: NotifyManagementItem): Promise<void> {
// ---------- 生命周期 ---------- // ---------- 生命周期 ----------
onMounted(async () => { onMounted(async () => {
clearPageNavBarRight();
if (!canReadNotify.value) { if (!canReadNotify.value) {
return; return;
} }
if (canCreateNotify.value) { if (canCreateNotify.value) {
setPageNavBarRightText("新建", "var(--td-brand-color)", toCreate);
} }
await reloadList(); await reloadList();
}); });
onUnmounted(() => clearPageNavBarRight());
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -413,44 +349,4 @@ onUnmounted(() => clearPageNavBarRight());
} }
} }
.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; }
}
}
</style> </style>
+7 -116
View File
@@ -7,41 +7,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" v-if="detail?.id"
class="nav-right-slot" class="nav-action danger"
type="button"
@click="confirmDelete"
> >
<t-badge 删除
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div v-can="corePermissionCodes.notify.read" class="notify-detail"> <div v-can="corePermissionCodes.notify.read" class="notify-detail">
@@ -67,36 +40,9 @@ import { corePermissionCodes } from "@/utils/permission";
import { Message } from "@/utils/message.ts"; import { Message } from "@/utils/message.ts";
import NotifyContent from "@/pages/notify/component/NotifyContent.vue"; import NotifyContent from "@/pages/notify/component/NotifyContent.vue";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import { getErrorMessage } from "@/utils/error"; import { getErrorMessage } from "@/utils/error";
@@ -117,7 +63,6 @@ let loadToken = 0;
async function loadDetail(): Promise<void> { async function loadDetail(): Promise<void> {
const requestToken = loadToken + 1; const requestToken = loadToken + 1;
loadToken = requestToken; loadToken = requestToken;
clearPageNavBarRight();
const detailId = String(route.params.id || ""); const detailId = String(route.params.id || "");
if (!detailId) { if (!detailId) {
detail.value = undefined; detail.value = undefined;
@@ -133,7 +78,6 @@ async function loadDetail(): Promise<void> {
} }
detail.value = result; detail.value = result;
setDeleteAction();
await markRead(result, requestToken); await markRead(result, requestToken);
} catch (error) { } catch (error) {
console.warn("通知详情加载失败", error); console.warn("通知详情加载失败", error);
@@ -145,11 +89,6 @@ async function loadDetail(): Promise<void> {
} }
} }
function setDeleteAction(): void {
if (detail.value?.id) {
setPageNavBarRightText("删除", "var(--td-error-color)", confirmDelete);
}
}
async function confirmDelete(): Promise<void> { async function confirmDelete(): Promise<void> {
const detailId = detail.value?.id; const detailId = detail.value?.id;
@@ -178,14 +117,12 @@ async function deleteDetail(detailId: string): Promise<void> {
} }
isDeleting.value = true; isDeleting.value = true;
clearPageNavBarRight();
try { try {
await NotifyAPI.deleteInternal(detailId); await NotifyAPI.deleteInternal(detailId);
Message.success("通知已删除"); Message.success("通知已删除");
await router.replace({ name: "UserNotifyList" }); await router.replace({ name: "UserNotifyList" });
} catch (error) { } catch (error) {
Message.error(getErrorMessage(error, "通知删除失败")); Message.error(getErrorMessage(error, "通知删除失败"));
setDeleteAction();
} finally { } finally {
isDeleting.value = false; isDeleting.value = false;
} }
@@ -224,13 +161,7 @@ watch(() => route.params.id, async () => {
await loadDetail(); await loadDetail();
}, { immediate: true }); }, { immediate: true });
onMounted(() => {
clearPageNavBarRight();
});
onUnmounted(() => {
clearPageNavBarRight();
});
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -238,44 +169,4 @@ onUnmounted(() => {
padding: var(--app-nav-height) 0 1rem 0; padding: var(--app-nav-height) 0 1rem 0;
} }
.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; }
}
}
</style> </style>
+7 -118
View File
@@ -8,41 +8,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" v-if="canReadNotify && 0 < unreadCount"
class="nav-right-slot" class="nav-action"
type="button"
@click="markAllRead"
> >
<t-badge 全部已读
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<main v-can="corePermissionCodes.notify.read" class="page-content scroll list"> <main v-can="corePermissionCodes.notify.read" class="page-content scroll list">
@@ -120,36 +93,9 @@ import { DialogPlugin } from "tdesign-mobile-vue";
import { Message } from "@/utils/message"; import { Message } from "@/utils/message";
import { corePermissionCodes } from "@/utils/permission"; import { corePermissionCodes } from "@/utils/permission";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import { getErrorMessage } from "@/utils/error"; import { getErrorMessage } from "@/utils/error";
@@ -189,7 +135,6 @@ const pageResult = reactive<PageResult<NotifyDetail>>({
}); });
let loadToken = 0; let loadToken = 0;
let loadingPromise: Promise<void> | undefined; let loadingPromise: Promise<void> | undefined;
let isPageActive = true;
const loadStateText = computed(() => { const loadStateText = computed(() => {
if (isLoading.value) { if (isLoading.value) {
@@ -279,7 +224,6 @@ async function loadUnreadCount(): Promise<void> {
unreadCount.value = 0; unreadCount.value = 0;
console.warn("未读通知数量加载失败", error); console.warn("未读通知数量加载失败", error);
} finally { } finally {
updateNavBarAction();
} }
} }
@@ -307,7 +251,6 @@ async function markAllRead(): Promise<void> {
Message.error("全部标记已读失败"); Message.error("全部标记已读失败");
} finally { } finally {
isMarkingAllRead.value = false; isMarkingAllRead.value = false;
updateNavBarAction();
} }
} }
@@ -350,15 +293,6 @@ async function deleteNotification(detailId: string): Promise<void> {
} }
} }
function updateNavBarAction(): void {
if (!isPageActive) {
return;
}
clearPageNavBarRight();
if (0 < unreadCount.value) {
setPageNavBarRightText("全部已读", "var(--td-brand-color)", markAllRead);
}
}
// ---------- 展示和导航 ---------- // ---------- 展示和导航 ----------
@@ -383,7 +317,6 @@ async function toDetail(item: NotifyDetail): Promise<void> {
// ---------- 生命周期 ---------- // ---------- 生命周期 ----------
onMounted(async () => { onMounted(async () => {
clearPageNavBarRight();
if (!canReadNotify.value) { if (!canReadNotify.value) {
return; return;
} }
@@ -396,10 +329,6 @@ onMounted(async () => {
} }
}); });
onUnmounted(() => {
isPageActive = false;
clearPageNavBarRight();
});
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -486,44 +415,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; }
}
}
</style> </style>
+7 -110
View File
@@ -7,41 +7,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" v-if="canUpdate"
class="nav-right-slot" class="nav-action"
type="button"
@click="toEdit"
> >
<t-badge 编辑
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div v-can="permissionCodes.packageConfig.read" class="package-config-detail"> <div v-can="permissionCodes.packageConfig.read" class="package-config-detail">
@@ -143,36 +116,9 @@ import { Message } from "@/utils/message";
import { gaoRoleCodes, permissionCodes } from "@/utils/permission"; import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
import { getProductPhotoURL as getProductPhotoUrl } from "@/utils/product"; import { getProductPhotoURL as getProductPhotoUrl } from "@/utils/product";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import type { GaoPackageConfig, PackageConfigItem, PackageConfigStatus } from "@/types/Package"; import type { GaoPackageConfig, PackageConfigItem, PackageConfigStatus } from "@/types/Package";
@@ -272,20 +218,11 @@ function removeConfig(): void {
onMounted(async () => { onMounted(async () => {
await loadData(); await loadData();
clearPageNavBarRight();
if (canUpdate.value) { if (canUpdate.value) {
setPageNavBarRightText("编辑", "var(--td-brand-color)", toEdit);
} }
}); });
watch(canUpdate, value => {
clearPageNavBarRight();
if (value) {
setPageNavBarRightText("编辑", "var(--td-brand-color)", toEdit);
}
});
onUnmounted(() => clearPageNavBarRight());
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -428,44 +365,4 @@ onUnmounted(() => clearPageNavBarRight());
} }
} }
.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; }
}
}
</style> </style>
+7 -110
View File
@@ -7,41 +7,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" v-if="userStore.hasPermissions(savePermissionCode)"
class="nav-right-slot" class="nav-action"
type="button"
@click="save"
> >
<t-badge 保存
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div v-can="savePermissionCode" class="package-config-edit"> <div v-can="savePermissionCode" class="package-config-edit">
@@ -176,37 +149,6 @@ import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
import { getProductQuantityStep } from "@/utils/product"; import { getProductQuantityStep } from "@/utils/product";
import type { GaoPackageConfig, PackageConfigItem, PackageConfigStatus } from "@/types/Package"; import type { GaoPackageConfig, PackageConfigItem, PackageConfigStatus } from "@/types/Package";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
type PackageConfigFormItem = Partial<PackageConfigItem> & { clientKey: string }; type PackageConfigFormItem = Partial<PackageConfigItem> & { clientKey: string };
defineOptions({ name: "PackageConfigEdit" }); defineOptions({ name: "PackageConfigEdit" });
@@ -523,17 +465,12 @@ async function loadData(): Promise<void> {
} }
onMounted(async () => { onMounted(async () => {
if (userStore.hasPermissions(savePermissionCode.value)) {
setPageNavBarRightText("保存", "var(--td-brand-color)", save);
}
try { try {
await loadData(); await loadData();
} catch (error) { } catch (error) {
Message.error(getErrorMessage(error, "套餐配置加载失败")); Message.error(getErrorMessage(error, "套餐配置加载失败"));
} }
}); });
onUnmounted(() => clearPageNavBarRight());
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -638,44 +575,4 @@ onUnmounted(() => clearPageNavBarRight());
} }
} }
.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; }
}
}
</style> </style>
+7 -104
View File
@@ -7,41 +7,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" v-if="userStore.hasPermissions(permissionCodes.customerPackage.create)"
class="nav-right-slot" class="nav-action"
type="button"
@click="submitRecord"
> >
<t-badge 提交
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div v-can="permissionCodes.customerPackage.create" class="package-purchase"> <div v-can="permissionCodes.customerPackage.create" class="package-purchase">
@@ -403,36 +376,9 @@ import type { ProductStockPreviewItem } from "@/utils/productStock";
import { uploadPhotoList } from "@/utils/photo"; import { uploadPhotoList } from "@/utils/photo";
import { getProductPhotoURL, getProductSkuSnapshotText } from "@/utils/product"; import { getProductPhotoURL, getProductSkuSnapshotText } from "@/utils/product";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import { useSettingStore } from "@/store/settingStore"; import { useSettingStore } from "@/store/settingStore";
@@ -1015,9 +961,7 @@ async function selectConfig(item: GaoPackageConfig): Promise<void> {
} }
onMounted(async () => { onMounted(async () => {
clearPageNavBarRight();
if (userStore.hasPermissions(permissionCodes.customerPackage.create)) { if (userStore.hasPermissions(permissionCodes.customerPackage.create)) {
setPageNavBarRightText("提交", "var(--td-brand-color)", submitRecord);
} }
try { try {
await loadPageData(); await loadPageData();
@@ -1026,7 +970,6 @@ onMounted(async () => {
} }
}); });
onUnmounted(() => clearPageNavBarRight());
watch(config, value => { watch(config, value => {
if (value) { if (value) {
@@ -1277,44 +1220,4 @@ watch(config, 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; }
}
}
</style> </style>
@@ -7,41 +7,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" v-if="canEditActiveRole && canUpdateRolePermission"
class="nav-right-slot" class="nav-action"
type="button"
@click="savePermissionList"
> >
<t-badge 保存
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div <div
@@ -93,37 +66,6 @@ import { type Permission, useUserStore } from "timi-web-api";
import { getErrorMessage } from "@/utils/error"; import { getErrorMessage } from "@/utils/error";
import { corePermissionCodes, coreRoleCodes } from "@/utils/permission"; import { corePermissionCodes, coreRoleCodes } from "@/utils/permission";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import { type Role, usePermissionSettingsStore } from "@/store/permissionSettingsStore"; import { type Role, usePermissionSettingsStore } from "@/store/permissionSettingsStore";
defineOptions({ defineOptions({
@@ -220,16 +162,6 @@ async function savePermissionList(): Promise<void> {
} }
} }
function updateNavBar(): void {
clearPageNavBarRight();
if (canEditActiveRole.value && canUpdateRolePermission.value) {
setPageNavBarRightText("保存", "var(--td-brand-color)", savePermissionList);
}
}
watch([canEditActiveRole, canUpdateRolePermission], updateNavBar, { immediate: true });
onMounted(updateNavBar);
// ---------- 权限勾选 ---------- // ---------- 权限勾选 ----------
function isPermissionChecked(permissionId: string): boolean { function isPermissionChecked(permissionId: string): boolean {
@@ -333,44 +265,4 @@ onMounted(async () => {
} }
} }
.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; }
}
}
</style> </style>
+8 -124
View File
@@ -7,41 +7,15 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" v-if="hasSavePermission"
class="nav-right-slot" class="nav-action"
type="button"
:disabled="!canSaveBaseInfo"
@click="saveBaseInfo"
> >
<t-badge 保存
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div v-can="pageAccess" class="role-edit"> <div v-can="pageAccess" class="role-edit">
@@ -152,41 +126,6 @@ import { corePermissionCodes, coreRoleCodes } from "@/utils/permission";
import PermissionCell from "@/pages/permission/component/PermissionCell.vue"; import PermissionCell from "@/pages/permission/component/PermissionCell.vue";
import PermissionLegend from "@/pages/permission/component/PermissionLegend.vue"; import PermissionLegend from "@/pages/permission/component/PermissionLegend.vue";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import { import {
moduleCode, moduleCode,
type Permission, type Permission,
@@ -556,24 +495,9 @@ async function getCurrentStoreId(): Promise<string> {
return storeId; return storeId;
} }
function updateNavBar(): void {
clearPageNavBarRight();
if (!hasSavePermission.value) {
return;
}
setPageNavBarRightText("保存", "var(--td-brand-color)", saveBaseInfo);
setPageNavBarRightDisabled(!canSaveBaseInfo.value);
}
watch([hasSavePermission, canSaveBaseInfo], updateNavBar, { immediate: true });
onMounted(async () => { onMounted(async () => {
await fillForm(); await fillForm();
updateNavBar();
}); });
onUnmounted(() => clearPageNavBarRight());
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -636,44 +560,4 @@ onUnmounted(() => clearPageNavBarRight());
} }
} }
.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; }
}
}
</style> </style>
+7 -106
View File
@@ -8,41 +8,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" v-if="canCreateRole"
class="nav-right-slot" class="nav-action"
type="button"
@click="toCreate"
> >
<t-badge 添加
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<main v-can="{ value: [corePermissionCodes.role.read, corePermissionCodes.permission.read], mode: 'and' }" class="page-content scroll list"> <main v-can="{ value: [corePermissionCodes.role.read, corePermissionCodes.permission.read], mode: 'and' }" class="page-content scroll list">
@@ -88,36 +61,9 @@ import type { Role } from "@/store/permissionSettingsStore";
import { getErrorMessage } from "@/utils/error"; import { getErrorMessage } from "@/utils/error";
import { corePermissionCodes, coreRoleCodes } from "@/utils/permission"; import { corePermissionCodes, coreRoleCodes } from "@/utils/permission";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import { usePermissionSettingsStore } from "@/store/permissionSettingsStore"; import { usePermissionSettingsStore } from "@/store/permissionSettingsStore";
@@ -190,9 +136,7 @@ async function refresh(): Promise<void> {
} }
onMounted(async () => { onMounted(async () => {
clearPageNavBarRight();
if (canCreateRole.value) { if (canCreateRole.value) {
setPageNavBarRightText("添加", "var(--td-brand-color)", toCreate);
} }
await permissionStore.loadAll(); await permissionStore.loadAll();
await refreshAuthorizationScope(); await refreshAuthorizationScope();
@@ -201,9 +145,6 @@ onMounted(async () => {
} }
}); });
onUnmounted(() => {
clearPageNavBarRight();
});
function getDisplayRoleList(): Role[] { function getDisplayRoleList(): Role[] {
return userStore.hasRoles(coreRoleCodes.admin) ? permissionStore.roleList : permissionStore.manageableRoleList; return userStore.hasRoles(coreRoleCodes.admin) ? permissionStore.roleList : permissionStore.manageableRoleList;
@@ -266,44 +207,4 @@ async function refreshAuthorizationScope(): Promise<void> {
} }
.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; }
}
}
</style> </style>
+7 -119
View File
@@ -7,41 +7,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" v-if="canEditActiveRole && canUpdateRolePermission"
class="nav-right-slot" class="nav-action"
type="button"
@click="savePermissionList"
> >
<t-badge 保存
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div <div
@@ -100,37 +73,6 @@ import { type Permission, useUserStore } from "timi-web-api";
import { getErrorMessage } from "@/utils/error"; import { getErrorMessage } from "@/utils/error";
import { corePermissionCodes, coreRoleCodes } from "@/utils/permission"; import { corePermissionCodes, coreRoleCodes } from "@/utils/permission";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import { type Role, usePermissionSettingsStore } from "@/store/permissionSettingsStore"; import { type Role, usePermissionSettingsStore } from "@/store/permissionSettingsStore";
defineOptions({ defineOptions({
@@ -239,20 +181,6 @@ async function savePermissionList(): Promise<void> {
} }
} }
function updateNavBar(): void {
clearPageNavBarRight();
if (canEditActiveRole.value && canUpdateRolePermission.value) {
setPageNavBarRightText("保存", "var(--td-brand-color)", savePermissionList);
}
}
watch([canEditActiveRole, canUpdateRolePermission], updateNavBar, { immediate: true });
onMounted(updateNavBar);
onUnmounted(() => {
clearPageNavBarRight();
});
// ---------- 权限勾选 ---------- // ---------- 权限勾选 ----------
function isPermissionChecked(permissionId: string): boolean { function isPermissionChecked(permissionId: string): boolean {
@@ -395,44 +323,4 @@ onMounted(async () => {
} }
} }
.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; }
}
}
</style> </style>
+6 -108
View File
@@ -7,41 +7,13 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" class="nav-action"
class="nav-right-slot" type="button"
@click="save"
> >
<t-badge 保存
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div v-can="permissionCodes.pointRedeemSku.manage" class="redeem-sku-edit"> <div v-can="permissionCodes.pointRedeemSku.manage" class="redeem-sku-edit">
@@ -109,37 +81,6 @@ import { Message } from "@/utils/message";
import { normalizePackageQuantity } from "@/utils/package"; import { normalizePackageQuantity } from "@/utils/package";
import { permissionCodes } from "@/utils/permission"; import { permissionCodes } from "@/utils/permission";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import type { PointRedeemSku, PointRedeemSkuStatus } from "@/types/Point"; import type { PointRedeemSku, PointRedeemSkuStatus } from "@/types/Point";
defineOptions({ name: "PointRedeemSkuEdit" }); defineOptions({ name: "PointRedeemSkuEdit" });
@@ -274,15 +215,12 @@ async function remove(): Promise<void> {
} }
onMounted(async () => { onMounted(async () => {
setPageNavBarRightText("保存", "var(--td-brand-color)", save);
try { try {
await load(); await load();
} catch (error) { } catch (error) {
Message.error(getErrorMessage(error, "兑换配置加载失败")); Message.error(getErrorMessage(error, "兑换配置加载失败"));
} }
}); });
onUnmounted(() => clearPageNavBarRight());
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -297,44 +235,4 @@ onUnmounted(() => clearPageNavBarRight());
} }
} }
.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; }
}
}
</style> </style>
+6 -103
View File
@@ -7,41 +7,13 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" class="nav-action"
class="nav-right-slot" type="button"
@click="save"
> >
<t-badge 兑换
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div v-can="permissionCodes.pointRedemption.create" class="redemption-create"> <div v-can="permissionCodes.pointRedemption.create" class="redemption-create">
@@ -189,36 +161,9 @@ import { getProductPhotoURL, getProductQuantityStep } from "@/utils/product";
import { uploadPhotoList } from "@/utils/photo"; import { uploadPhotoList } from "@/utils/photo";
import { permissionCodes } from "@/utils/permission"; import { permissionCodes } from "@/utils/permission";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import { useSettingStore } from "@/store/settingStore"; import { useSettingStore } from "@/store/settingStore";
@@ -404,7 +349,6 @@ function formatPoint(value?: number): string {
} }
onMounted(async () => { onMounted(async () => {
setPageNavBarRightText("兑换", "var(--td-brand-color)", save);
try { try {
await loadSkuList(); await loadSkuList();
} catch (error) { } catch (error) {
@@ -412,7 +356,6 @@ onMounted(async () => {
} }
}); });
onUnmounted(() => clearPageNavBarRight());
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -485,44 +428,4 @@ onUnmounted(() => clearPageNavBarRight());
} }
} }
.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; }
}
}
</style> </style>
+7 -115
View File
@@ -7,41 +7,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" v-if="rule?.id && canUpdate"
class="nav-right-slot" class="nav-action"
type="button"
@click="toEdit"
> >
<t-badge 编辑
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div v-can="permissionCodes.pointRule.read" class="point-rule-detail"> <div v-can="permissionCodes.pointRule.read" class="point-rule-detail">
@@ -147,36 +120,9 @@ import { Message } from "@/utils/message";
import { formatWanInteger } from "@/utils/money"; import { formatWanInteger } from "@/utils/money";
import { gaoRoleCodes, permissionCodes } from "@/utils/permission"; import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import type { EventItem } from "@/types/EventItem"; import type { EventItem } from "@/types/EventItem";
@@ -332,14 +278,12 @@ async function removeRule(): Promise<void> {
} }
isDeleting.value = true; isDeleting.value = true;
clearPageNavBarRight();
try { try {
await PointAPI.ruleRemove(ruleId); await PointAPI.ruleRemove(ruleId);
Message.success("积分规则已删除"); Message.success("积分规则已删除");
await router.replace("/management/points/rules"); await router.replace("/management/points/rules");
} catch (error) { } catch (error) {
Message.error(getErrorMessage(error, "积分规则删除失败")); Message.error(getErrorMessage(error, "积分规则删除失败"));
setEditAction();
} finally { } finally {
isDeleting.value = false; isDeleting.value = false;
} }
@@ -347,11 +291,6 @@ async function removeRule(): Promise<void> {
// ---------- 导航 ---------- // ---------- 导航 ----------
function setEditAction(): void {
if (canUpdate.value) {
setPageNavBarRightText("编辑", "var(--td-brand-color)", toEdit);
}
}
async function toEdit(): Promise<void> { async function toEdit(): Promise<void> {
const ruleId = String(route.params.id || ""); const ruleId = String(route.params.id || "");
@@ -380,14 +319,7 @@ watch(() => route.params.id, async () => {
await loadRule(); await loadRule();
}, { immediate: true }); }, { immediate: true });
onMounted(() => {
clearPageNavBarRight();
setEditAction();
});
onUnmounted(() => {
clearPageNavBarRight();
});
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -467,44 +399,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; }
}
}
</style> </style>
+7 -110
View File
@@ -7,41 +7,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" v-if="userStore.hasPermissions(savePermissionCode)"
class="nav-right-slot" class="nav-action"
type="button"
@click="saveRule"
> >
<t-badge 保存
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div v-can="pageAccess" class="point-rule-edit"> <div v-can="pageAccess" class="point-rule-edit">
@@ -202,37 +175,6 @@ import { getErrorMessage } from "@/utils/error";
import { gaoRoleCodes, permissionCodes } from "@/utils/permission"; import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
import { Message } from "@/utils/message"; import { Message } from "@/utils/message";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import type { EventItem } from "@/types/EventItem"; import type { EventItem } from "@/types/EventItem";
type PickerValue = string | number; type PickerValue = string | number;
@@ -622,17 +564,12 @@ async function fillForm(): Promise<void> {
} }
onMounted(async () => { onMounted(async () => {
if (userStore.hasPermissions(savePermissionCode.value)) {
setPageNavBarRightText("保存", "var(--td-brand-color)", saveRule);
}
try { try {
await fillForm(); await fillForm();
} catch (error) { } catch (error) {
Message.error(getErrorMessage(error, "积分规则加载失败")); Message.error(getErrorMessage(error, "积分规则加载失败"));
} }
}); });
onUnmounted(() => clearPageNavBarRight());
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -689,44 +626,4 @@ onUnmounted(() => clearPageNavBarRight());
} }
} }
.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; }
}
}
</style> </style>
+2 -112
View File
@@ -7,41 +7,7 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button class="nav-action" type="button" @click="saveSort">保存</button>
v-if="pageNavBarRight.icon || pageNavBarRight.text"
class="nav-right-slot"
>
<t-badge
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined"
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div v-can="permissionCodes.pointRule.update" class="point-rule-sort"> <div v-can="permissionCodes.pointRule.update" class="point-rule-sort">
@@ -95,42 +61,10 @@ import { VueDraggableNext } from "vue-draggable-next";
import EventAPI from "@/api/EventAPI"; import EventAPI from "@/api/EventAPI";
import PointAPI from "@/api/PointAPI"; import PointAPI from "@/api/PointAPI";
import type { PointRule } from "@/types/Point"; import type { PointRule } from "@/types/Point";
import type { EventItem } from "@/types/EventItem";
import { formatWanInteger } from "@/utils/money"; import { formatWanInteger } from "@/utils/money";
import { permissionCodes } from "@/utils/permission"; import { permissionCodes } from "@/utils/permission";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import type { EventItem } from "@/types/EventItem";
defineOptions({ name: "PointRuleSort" }); defineOptions({ name: "PointRuleSort" });
const router = useRouter(); const router = useRouter();
const ruleList = ref<PointRule[]>([]); const ruleList = ref<PointRule[]>([]);
@@ -185,16 +119,12 @@ async function saveSort(): Promise<void> {
} }
onMounted(async () => { onMounted(async () => {
clearPageNavBarRight();
setPageNavBarRightText("保存", "var(--td-brand-color)", saveSort);
try { try {
await loadData(); await loadData();
} catch { } catch {
Message.error("启用积分规则加载失败"); Message.error("启用积分规则加载失败");
} }
}); });
onUnmounted(() => clearPageNavBarRight());
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -232,44 +162,4 @@ onUnmounted(() => clearPageNavBarRight());
} }
} }
.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; }
}
}
</style> </style>
+7 -105
View File
@@ -7,41 +7,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" class="nav-action nav-action-icon"
class="nav-right-slot" type="button"
aria-label="刷新"
@click="reload"
> >
<t-badge <t-icon name="refresh" size="1.25rem" />
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div v-can="permissionCodes.stat.read" class="gao-chart-page order-data-charts"> <div v-can="permissionCodes.stat.read" class="gao-chart-page order-data-charts">
@@ -123,36 +96,9 @@ import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission"; import { permissionCodes } from "@/utils/permission";
import { buildDateTextList, formatMoney, formatQuantity, toUnixRange } from "@/pages/product/component/chartUtils"; import { buildDateTextList, formatMoney, formatQuantity, toUnixRange } from "@/pages/product/component/chartUtils";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightIcon(value?: string, action?: () => void | Promise<void>): void {
pageNavBarRight.icon = value || "";
pageNavBarRight.badge = undefined;
pageNavBarRight.disabled = false;
pageNavBarRight.action = action;
if (value) {
pageNavBarRight.text = "";
pageNavBarRight.textColor = "";
}
}
function clearPageNavBarRight(): void {
Object.assign(pageNavBarRight, { icon: "", badge: undefined, text: "", textColor: "", disabled: false, action: undefined });
}
async function handlePageNavBarRightAction(): Promise<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import { getCurrentStoreId } from "@/utils/store"; import { getCurrentStoreId } from "@/utils/store";
@@ -206,15 +152,11 @@ watch(storeId, async () => {
}, { immediate: true }); }, { immediate: true });
onMounted(async () => { onMounted(async () => {
setPageNavBarRightIcon("refresh", reload);
if (!currentStoreStore.currentStoreId) { if (!currentStoreStore.currentStoreId) {
await currentStoreStore.loadLoginStore(); await currentStoreStore.loadLoginStore();
} }
}); });
onUnmounted(() => {
clearPageNavBarRight();
});
async function reload(): Promise<void> { async function reload(): Promise<void> {
clearStoreChartCache(); clearStoreChartCache();
@@ -410,44 +352,4 @@ function pad(value: number): string {
} }
} }
.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; }
}
}
</style> </style>
+1 -115
View File
@@ -7,41 +7,7 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button v-if="userStore.hasPermissions(permissionCodes.productCategory.update)" class="nav-action" type="button" @click="saveSort">保存</button>
v-if="pageNavBarRight.icon || pageNavBarRight.text"
class="nav-right-slot"
>
<t-badge
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined"
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div v-can="permissionCodes.productCategory.update" class="product-category-rank"> <div v-can="permissionCodes.productCategory.update" class="product-category-rank">
@@ -93,38 +59,6 @@ import { getErrorMessage } from "@/utils/error";
import { Message } from "@/utils/message"; import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission"; import { permissionCodes } from "@/utils/permission";
import { useUserStore } from "timi-web-api"; import { useUserStore } from "timi-web-api";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import type { ProductCategory, ProductCategoryStatus } from "@/types/Product"; import type { ProductCategory, ProductCategoryStatus } from "@/types/Product";
defineOptions({ name: "ProductCategoryRank" }); defineOptions({ name: "ProductCategoryRank" });
@@ -183,20 +117,12 @@ async function loadData(): Promise<void> {
} }
onMounted(async () => { onMounted(async () => {
clearPageNavBarRight();
if (userStore.hasPermissions(permissionCodes.productCategory.update)) {
setPageNavBarRightText("保存", "var(--td-brand-color)", saveSort);
}
try { try {
await loadData(); await loadData();
} catch (error) { } catch (error) {
Message.error(getErrorMessage(error, "产品分类加载失败")); Message.error(getErrorMessage(error, "产品分类加载失败"));
} }
}); });
onUnmounted(() => {
clearPageNavBarRight();
});
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -254,44 +180,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; }
}
}
</style> </style>
+7 -105
View File
@@ -7,41 +7,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" class="nav-action nav-action-icon"
class="nav-right-slot" type="button"
aria-label="刷新"
@click="reload"
> >
<t-badge <t-icon name="refresh" size="1.25rem" />
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div v-can="permissionCodes.stat.read" class="gao-chart-page product-data-charts"> <div v-can="permissionCodes.stat.read" class="gao-chart-page product-data-charts">
@@ -127,36 +100,9 @@ import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission"; import { permissionCodes } from "@/utils/permission";
import { buildDateTextList, formatMoney, formatQuantity, sumNumber, toUnixRange } from "@/pages/product/component/chartUtils"; import { buildDateTextList, formatMoney, formatQuantity, sumNumber, toUnixRange } from "@/pages/product/component/chartUtils";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightIcon(value?: string, action?: () => void | Promise<void>): void {
pageNavBarRight.icon = value || "";
pageNavBarRight.badge = undefined;
pageNavBarRight.disabled = false;
pageNavBarRight.action = action;
if (value) {
pageNavBarRight.text = "";
pageNavBarRight.textColor = "";
}
}
function clearPageNavBarRight(): void {
Object.assign(pageNavBarRight, { icon: "", badge: undefined, text: "", textColor: "", disabled: false, action: undefined });
}
async function handlePageNavBarRightAction(): Promise<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import { getCurrentStoreId } from "@/utils/store"; import { getCurrentStoreId } from "@/utils/store";
@@ -211,15 +157,11 @@ watch(storeId, async () => {
}, { immediate: true }); }, { immediate: true });
onMounted(async () => { onMounted(async () => {
setPageNavBarRightIcon("refresh", reload);
if (!currentStoreStore.currentStoreId) { if (!currentStoreStore.currentStoreId) {
await currentStoreStore.loadLoginStore(); await currentStoreStore.loadLoginStore();
} }
}); });
onUnmounted(() => {
clearPageNavBarRight();
});
async function reload(): Promise<void> { async function reload(): Promise<void> {
clearStoreChartCache(); clearStoreChartCache();
@@ -428,44 +370,4 @@ function pad(value: number): string {
} }
} }
.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; }
}
}
</style> </style>
+7 -111
View File
@@ -7,41 +7,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" v-if="userStore.hasPermissions(savePermissionCode)"
class="nav-right-slot" class="nav-action"
type="button"
@click="save"
> >
<t-badge 保存
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div v-can="savePermissionCode" class="product-edit"> <div v-can="savePermissionCode" class="product-edit">
@@ -261,37 +234,6 @@ import { formatProductAmount, getProductStatusText, getProductTypeText, normaliz
import { Message } from "@/utils/message"; import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission"; import { permissionCodes } from "@/utils/permission";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import type { PhotoItem } from "@/types/Photo"; import type { PhotoItem } from "@/types/Photo";
type PickerValue = string | number; type PickerValue = string | number;
@@ -1177,18 +1119,12 @@ async function load(): Promise<void> {
} }
onMounted(async () => { onMounted(async () => {
clearPageNavBarRight();
if (userStore.hasPermissions(savePermissionCode.value)) {
setPageNavBarRightText("保存", "var(--td-brand-color)", save);
}
try { try {
await load(); await load();
} catch (error) { } catch (error) {
Message.error(getErrorMessage(error, "产品加载失败")); Message.error(getErrorMessage(error, "产品加载失败"));
} }
}); });
onUnmounted(() => clearPageNavBarRight());
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -1303,44 +1239,4 @@ onUnmounted(() => clearPageNavBarRight());
} }
} }
.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; }
}
}
</style> </style>
@@ -7,41 +7,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" v-if="userStore.hasPermissions(permissionCodes.productStock.create)"
class="nav-right-slot" class="nav-action"
> type="button"
<t-badge :disabled="!canSubmit"
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" @click="submit"
class="badge" v-text="isSaving ? '提交中' : '提交'"
:count="pageNavBarRight.badge" ></button>
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div v-can="permissionCodes.productStock.create" class="product-stock-batch-configure"> <div v-can="permissionCodes.productStock.create" class="product-stock-batch-configure">
@@ -176,7 +149,6 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { onBeforeRouteLeave } from "vue-router";
import { useUserStore } from "timi-web-api"; import { useUserStore } from "timi-web-api";
import { useCurrentStoreStore } from "@/store/currentStoreStore"; import { useCurrentStoreStore } from "@/store/currentStoreStore";
import AttachmentSelector from "@/components/attachmentSelector/AttachmentSelector.vue"; import AttachmentSelector from "@/components/attachmentSelector/AttachmentSelector.vue";
@@ -191,40 +163,10 @@ import { permissionCodes } from "@/utils/permission";
import { getCurrentStoreId } from "@/utils/store"; import { getCurrentStoreId } from "@/utils/store";
import { uploadPhotoList } from "@/utils/photo"; import { uploadPhotoList } from "@/utils/photo";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import { type ProductStockBatchSelection, useProductStockBatchStore } from "@/store/productStockBatchStore"; import { type ProductStockBatchSelection, useProductStockBatchStore } from "@/store/productStockBatchStore";
@@ -331,14 +273,6 @@ function isItemValid(item: ProductStockBatchSelection): boolean {
&& 0 < (itemAttachmentList.length || globalAttachmentList.length); && 0 < (itemAttachmentList.length || globalAttachmentList.length);
} }
function updateNavBar(): void {
clearPageNavBarRight();
if (!userStore.hasPermissions(permissionCodes.productStock.create)) {
return;
}
setPageNavBarRightText(isSaving.value ? "提交中" : "提交", "var(--td-brand-color)", submit);
setPageNavBarRightDisabled(!canSubmit.value);
}
function selectUnit(item: ProductStockBatchSelection, unit: ProductSkuUnit): void { function selectUnit(item: ProductStockBatchSelection, unit: ProductSkuUnit): void {
if (isSaving.value) { if (isSaving.value) {
@@ -466,7 +400,6 @@ async function submit(): Promise<void> {
return; return;
} }
isSaving.value = true; isSaving.value = true;
updateNavBar();
try { try {
await ProductAPI.manualInBatch(buildRequest()); await ProductAPI.manualInBatch(buildRequest());
emitListDataChanged(listDataEventKeys.productStockChanged); emitListDataChanged(listDataEventKeys.productStockChanged);
@@ -480,11 +413,9 @@ async function submit(): Promise<void> {
Message.error(getErrorMessage(error, "批量入库失败,请确认请求号后重试")); Message.error(getErrorMessage(error, "批量入库失败,请确认请求号后重试"));
} finally { } finally {
isSaving.value = false; isSaving.value = false;
updateNavBar();
} }
} }
watch([canSubmit, isSaving], updateNavBar);
onMounted(() => { onMounted(() => {
const storeId = currentStoreStore.currentStoreId || getCurrentStoreId(); const storeId = currentStoreStore.currentStoreId || getCurrentStoreId();
@@ -493,7 +424,6 @@ onMounted(() => {
if (!productStockBatchStore.selectedItemList.length) { if (!productStockBatchStore.selectedItemList.length) {
void router.replace({ name: "ProductStockBatchSelect" }); void router.replace({ name: "ProductStockBatchSelect" });
} }
updateNavBar();
}); });
onActivated(() => { onActivated(() => {
@@ -505,12 +435,9 @@ onActivated(() => {
return; return;
} }
activeStoreId.value = storeId; activeStoreId.value = storeId;
updateNavBar();
}); });
onBeforeRouteLeave(() => clearPageNavBarRight());
onUnmounted(() => clearPageNavBarRight());
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -612,44 +539,4 @@ onUnmounted(() => clearPageNavBarRight());
} }
.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; }
}
}
</style> </style>
+8 -117
View File
@@ -8,41 +8,15 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" v-if="canReadAndCreate"
class="nav-right-slot" class="nav-action"
type="button"
:disabled="!canContinue"
@click="toConfigure"
> >
<t-badge 下一步
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<main v-can="permissionCodes.productStock.create" class="page-content scroll list"> <main v-can="permissionCodes.productStock.create" class="page-content scroll list">
@@ -82,7 +56,6 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { onBeforeRouteLeave } from "vue-router";
import { useUserStore } from "timi-web-api"; import { useUserStore } from "timi-web-api";
import ProductAPI from "@/api/ProductAPI"; import ProductAPI from "@/api/ProductAPI";
import { useCurrentStoreStore } from "@/store/currentStoreStore"; import { useCurrentStoreStore } from "@/store/currentStoreStore";
@@ -94,40 +67,10 @@ import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission"; import { permissionCodes } from "@/utils/permission";
import { getCurrentStoreId } from "@/utils/store"; import { getCurrentStoreId } from "@/utils/store";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import { useProductStockBatchStore } from "@/store/productStockBatchStore"; import { useProductStockBatchStore } from "@/store/productStockBatchStore";
@@ -213,13 +156,6 @@ function getCurrentRouteDepth(): number {
return Number(route.meta.depth ?? 0); return Number(route.meta.depth ?? 0);
} }
function updateNavBar(): void {
clearPageNavBarRight();
if (canReadAndCreate.value) {
setPageNavBarRightText("下一步", "var(--td-brand-color)", toConfigure);
setPageNavBarRightDisabled(!canContinue.value);
}
}
function getProduct(productId: string): Product | undefined { function getProduct(productId: string): Product | undefined {
return productDetailMap.value[productId]; return productDetailMap.value[productId];
@@ -400,7 +336,6 @@ async function loadMore(): Promise<void> {
} }
} }
watch(canContinue, updateNavBar);
watch(keyword, () => { watch(keyword, () => {
window.clearTimeout(keywordTimer); window.clearTimeout(keywordTimer);
keywordTimer = window.setTimeout(async () => { keywordTimer = window.setTimeout(async () => {
@@ -416,7 +351,6 @@ onMounted(async () => {
const storeId = currentStoreStore.currentStoreId || getCurrentStoreId(); const storeId = currentStoreStore.currentStoreId || getCurrentStoreId();
productStockBatchStore.ensureStore(storeId); productStockBatchStore.ensureStore(storeId);
activeStoreId = storeId; activeStoreId = storeId;
updateNavBar();
if (!canReadAndCreate.value) { if (!canReadAndCreate.value) {
return; return;
} }
@@ -439,13 +373,10 @@ onActivated(async () => {
} }
} }
activeStoreId = storeId; activeStoreId = storeId;
updateNavBar();
}); });
onBeforeRouteLeave(() => clearPageNavBarRight());
onUnmounted(() => { onUnmounted(() => {
clearPageNavBarRight();
window.clearTimeout(keywordTimer); window.clearTimeout(keywordTimer);
requestToken += 1; requestToken += 1;
productDetailToken += 1; productDetailToken += 1;
@@ -465,44 +396,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; }
}
}
</style> </style>
+7 -111
View File
@@ -8,41 +8,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" v-if="canBatchIn"
class="nav-right-slot" class="nav-action"
type="button"
@click="openBatchIn"
> >
<t-badge 批量入库
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<main ref="productStockListRef" v-can="permissionCodes.productStock.read" class="page-content scroll list"> <main ref="productStockListRef" v-can="permissionCodes.productStock.read" class="page-content scroll list">
@@ -121,36 +94,9 @@ import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission"; import { permissionCodes } from "@/utils/permission";
import { getCurrentStoreId } from "@/utils/store"; import { getCurrentStoreId } from "@/utils/store";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import { useProductStockBatchStore } from "@/store/productStockBatchStore"; import { useProductStockBatchStore } from "@/store/productStockBatchStore";
@@ -217,12 +163,6 @@ function getCurrentRouteDepth(): number {
return Number(route.meta.depth ?? 0); return Number(route.meta.depth ?? 0);
} }
function updateNavBar(): void {
clearPageNavBarRight();
if (canBatchIn.value) {
setPageNavBarRightText("批量入库", "var(--td-brand-color)", openBatchIn);
}
}
async function openBatchIn(): Promise<void> { async function openBatchIn(): Promise<void> {
const storeId = currentStoreStore.currentStoreId || getCurrentStoreId(); const storeId = currentStoreStore.currentStoreId || getCurrentStoreId();
@@ -378,7 +318,6 @@ async function toSkuList(item: ProductStockProduct): Promise<void> {
onMounted(async () => { onMounted(async () => {
unregisterProductStockListEvent = events.register(listDataEventKeys.productStockChanged, (payload: ListDataChangedPayload) => requestEventRefresh(payload)); unregisterProductStockListEvent = events.register(listDataEventKeys.productStockChanged, (payload: ListDataChangedPayload) => requestEventRefresh(payload));
updateNavBar();
if (!userStore.hasPermissions(permissionCodes.productStock.read)) { if (!userStore.hasPermissions(permissionCodes.productStock.read)) {
return; return;
} }
@@ -391,7 +330,6 @@ onMounted(async () => {
onActivated(() => { onActivated(() => {
restorePageScrollPosition(); restorePageScrollPosition();
updateNavBar();
}); });
onDeactivated(() => { onDeactivated(() => {
@@ -411,14 +349,12 @@ watch(keyword, () => {
onBeforeRouteLeave(() => { onBeforeRouteLeave(() => {
savePageScrollPosition(); savePageScrollPosition();
clearPageNavBarRight();
}); });
onUnmounted(() => { onUnmounted(() => {
isDisposed = true; isDisposed = true;
unregisterProductStockListEvent?.(); unregisterProductStockListEvent?.();
unregisterProductStockListEvent = undefined; unregisterProductStockListEvent = undefined;
clearPageNavBarRight();
window.clearTimeout(keywordTimer); window.clearTimeout(keywordTimer);
requestToken += 1; requestToken += 1;
}); });
@@ -491,44 +427,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; }
}
}
</style> </style>
+7 -103
View File
@@ -7,41 +7,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" v-if="userStore.hasPermissions(permissionCodes.fund.revoke)"
class="nav-right-slot" class="nav-action danger"
type="button"
@click="save"
> >
<t-badge 提交
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div v-can="permissionCodes.fund.revoke" class="package-operation-edit"> <div v-can="permissionCodes.fund.revoke" class="package-operation-edit">
@@ -158,36 +131,9 @@ import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission"; import { permissionCodes } from "@/utils/permission";
import { uploadPhotoList } from "@/utils/photo"; import { uploadPhotoList } from "@/utils/photo";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import type { FundRecord } from "@/types/SalesOrder"; import type { FundRecord } from "@/types/SalesOrder";
@@ -353,12 +299,10 @@ async function save(): Promise<void> {
onMounted(async () => { onMounted(async () => {
if (userStore.hasPermissions(permissionCodes.fund.revoke)) { if (userStore.hasPermissions(permissionCodes.fund.revoke)) {
setPageNavBarRightText("提交", "var(--td-error-color)", save);
} }
await loadData(); await loadData();
}); });
onUnmounted(() => clearPageNavBarRight());
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -392,44 +336,4 @@ onUnmounted(() => clearPageNavBarRight());
} }
} }
.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; }
}
}
</style> </style>
+7 -103
View File
@@ -7,41 +7,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" v-if="userStore.hasPermissions(permissionCodes.salesOrder.cancel)"
class="nav-right-slot" class="nav-action danger"
type="button"
@click="save"
> >
<t-badge 确认
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div v-can="permissionCodes.salesOrder.cancel" class="sales-order-operation"> <div v-can="permissionCodes.salesOrder.cancel" class="sales-order-operation">
@@ -108,36 +81,9 @@ import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission"; import { permissionCodes } from "@/utils/permission";
import { getSalesOrderStatusText } from "@/utils/salesOrder"; import { getSalesOrderStatusText } from "@/utils/salesOrder";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import type { SalesOrder } from "@/types/SalesOrder"; import type { SalesOrder } from "@/types/SalesOrder";
@@ -219,10 +165,8 @@ async function save(): Promise<void> {
onMounted(async () => { onMounted(async () => {
if (!userStore.hasPermissions(permissionCodes.salesOrder.cancel)) return; if (!userStore.hasPermissions(permissionCodes.salesOrder.cancel)) return;
setPageNavBarRightText("确认", "var(--td-error-color)", save);
await loadData(); await loadData();
}); });
onUnmounted(() => clearPageNavBarRight());
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -241,44 +185,4 @@ onUnmounted(() => clearPageNavBarRight());
} }
} }
.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; }
}
}
</style> </style>
+7 -103
View File
@@ -7,41 +7,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" v-if="userStore.hasPermissions(permissionCodes.fund.refund)"
class="nav-right-slot" class="nav-action"
type="button"
@click="save"
> >
<t-badge 确认提交
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div v-can="permissionCodes.fund.refund" class="sales-order-operation"> <div v-can="permissionCodes.fund.refund" class="sales-order-operation">
@@ -61,36 +34,9 @@ import { emitListDataChanged, listDataEventKeys } from "@/utils/listDataEvents";
import { Message } from "@/utils/message"; import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission"; import { permissionCodes } from "@/utils/permission";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import type { SalesOrder } from "@/types/SalesOrder"; import type { SalesOrder } from "@/types/SalesOrder";
@@ -118,10 +64,8 @@ async function save(): Promise<void> {
} }
onMounted(async () => { onMounted(async () => {
if (!userStore.hasPermissions(permissionCodes.fund.refund)) return; if (!userStore.hasPermissions(permissionCodes.fund.refund)) return;
setPageNavBarRightText("确认提交", "var(--td-brand-color)", save);
await loadData(); await loadData();
}); });
onUnmounted(() => clearPageNavBarRight());
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -129,44 +73,4 @@ onUnmounted(() => clearPageNavBarRight());
.form { padding: 0 .5rem; background: var(--td-bg-color-container); box-shadow: var(--td-shadow-1); border-radius: 1rem; overflow: hidden; } .form { padding: 0 .5rem; background: var(--td-bg-color-container); box-shadow: var(--td-shadow-1); border-radius: 1rem; overflow: hidden; }
} }
.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; }
}
}
</style> </style>
+7 -103
View File
@@ -7,41 +7,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" v-if="userStore.hasPermissions(permissionCodes.fundReceive.create)"
class="nav-right-slot" class="nav-action"
type="button"
@click="save"
> >
<t-badge 提交
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div v-can="permissionCodes.fundReceive.create" class="sales-order-operation"> <div v-can="permissionCodes.fundReceive.create" class="sales-order-operation">
@@ -147,36 +120,9 @@ import { Message } from "@/utils/message";
import { gaoRoleCodes, permissionCodes } from "@/utils/permission"; import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
import { uploadPhotoList } from "@/utils/photo"; import { uploadPhotoList } from "@/utils/photo";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import type { SalesOrder } from "@/types/SalesOrder"; import type { SalesOrder } from "@/types/SalesOrder";
@@ -288,10 +234,8 @@ async function save(): Promise<void> {
onMounted(async () => { onMounted(async () => {
if (!userStore.hasPermissions(permissionCodes.fundReceive.create)) return; if (!userStore.hasPermissions(permissionCodes.fundReceive.create)) return;
setPageNavBarRightText("提交", "var(--td-brand-color)", save);
await loadData(); await loadData();
}); });
onUnmounted(() => clearPageNavBarRight());
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -318,44 +262,4 @@ onUnmounted(() => clearPageNavBarRight());
} }
} }
.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; }
}
}
</style> </style>
+7 -103
View File
@@ -7,41 +7,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" v-if="userStore.hasPermissions(permissionCodes.fund.refund)"
class="nav-right-slot" class="nav-action danger"
type="button"
@click="save"
> >
<t-badge 提交
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div v-can="permissionCodes.fund.refund" class="sales-order-operation"> <div v-can="permissionCodes.fund.refund" class="sales-order-operation">
@@ -169,36 +142,9 @@ import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission"; import { permissionCodes } from "@/utils/permission";
import { uploadPhotoList } from "@/utils/photo"; import { uploadPhotoList } from "@/utils/photo";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import type { SalesOrder } from "@/types/SalesOrder"; import type { SalesOrder } from "@/types/SalesOrder";
@@ -324,10 +270,8 @@ async function save(): Promise<void> {
onMounted(async () => { onMounted(async () => {
if (!userStore.hasPermissions(permissionCodes.fund.refund)) return; if (!userStore.hasPermissions(permissionCodes.fund.refund)) return;
setPageNavBarRightText("提交", "var(--td-error-color)", save);
await loadData(); await loadData();
}); });
onUnmounted(() => clearPageNavBarRight());
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -363,44 +307,4 @@ onUnmounted(() => clearPageNavBarRight());
} }
} }
.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; }
}
}
</style> </style>
+7 -113
View File
@@ -7,41 +7,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" v-if="article?.id && canUpdate && !isDeleting"
class="nav-right-slot" class="nav-action"
type="button"
@click="toEdit"
> >
<t-badge 编辑
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div v-can="permissionCodes.storeDiary.read" class="store-diary-detail"> <div v-can="permissionCodes.storeDiary.read" class="store-diary-detail">
@@ -120,36 +93,9 @@ import { getErrorMessage } from "@/utils/error";
import { Message } from "@/utils/message"; import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission"; import { permissionCodes } from "@/utils/permission";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import type { StoreDiary } from "@/types/StoreDiary"; import type { StoreDiary } from "@/types/StoreDiary";
@@ -196,19 +142,11 @@ async function prepareStoreScope(): Promise<void> {
await currentStoreStore.loadLoginStore(); await currentStoreStore.loadLoginStore();
} }
function setRightAction(): void {
if (article.value?.id && canUpdate.value) {
setPageNavBarRightText("编辑", "var(--td-brand-color)", toEdit);
return;
}
clearPageNavBarRight();
}
async function loadArticle(): Promise<void> { async function loadArticle(): Promise<void> {
const requestToken = loadToken + 1; const requestToken = loadToken + 1;
loadToken = requestToken; loadToken = requestToken;
article.value = undefined; article.value = undefined;
clearPageNavBarRight();
const id = String(route.params.id || ""); const id = String(route.params.id || "");
if (!id) { if (!id) {
return; return;
@@ -222,7 +160,6 @@ async function loadArticle(): Promise<void> {
return; return;
} }
article.value = result; article.value = result;
setRightAction();
} catch (error) { } catch (error) {
Message.error(getErrorMessage(error, "门店日记加载失败")); Message.error(getErrorMessage(error, "门店日记加载失败"));
} finally { } finally {
@@ -261,14 +198,12 @@ async function confirmDelete(): Promise<void> {
async onConfirm() { async onConfirm() {
dialog.destroy(); dialog.destroy();
isDeleting.value = true; isDeleting.value = true;
clearPageNavBarRight();
try { try {
await StoreDiaryAPI.remove(diaryId); await StoreDiaryAPI.remove(diaryId);
Message.success("门店日记已删除"); Message.success("门店日记已删除");
await router.replace({ name: "StoreDiaryList" }); await router.replace({ name: "StoreDiaryList" });
} catch (error) { } catch (error) {
Message.error(getErrorMessage(error, "门店日记删除失败")); Message.error(getErrorMessage(error, "门店日记删除失败"));
setRightAction();
} finally { } finally {
isDeleting.value = false; isDeleting.value = false;
} }
@@ -278,7 +213,6 @@ async function confirmDelete(): Promise<void> {
onMounted(loadArticle); onMounted(loadArticle);
onUnmounted(() => clearPageNavBarRight());
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -366,44 +300,4 @@ onUnmounted(() => clearPageNavBarRight());
} }
} }
.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; }
}
}
</style> </style>
+7 -110
View File
@@ -7,41 +7,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" v-if="userStore.hasPermissions(savePermissionCode)"
class="nav-right-slot" class="nav-action"
type="button"
@click="save"
> >
<t-badge 保存
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div v-can="pageAccess" class="store-diary-edit"> <div v-can="pageAccess" class="store-diary-edit">
@@ -105,37 +78,6 @@ import { getAttachmentReadURL } from "@/utils/attachment";
import { Message } from "@/utils/message"; import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission"; import { permissionCodes } from "@/utils/permission";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import type { StoreDiary } from "@/types/StoreDiary"; import type { StoreDiary } from "@/types/StoreDiary";
defineOptions({ defineOptions({
@@ -411,17 +353,12 @@ async function loadArticle(): Promise<void> {
} }
onMounted(async () => { onMounted(async () => {
if (userStore.hasPermissions(savePermissionCode.value)) {
setPageNavBarRightText("保存", "var(--td-brand-color)", save);
}
try { try {
await loadArticle(); await loadArticle();
} catch (error) { } catch (error) {
Message.error(getErrorMessage(error, "门店日记加载失败")); Message.error(getErrorMessage(error, "门店日记加载失败"));
} }
}); });
onUnmounted(() => clearPageNavBarRight());
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -496,44 +433,4 @@ onUnmounted(() => clearPageNavBarRight());
} }
} }
.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; }
}
}
</style> </style>
+7 -110
View File
@@ -7,41 +7,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" v-if="userStore.hasPermissions(savePermissionCode)"
class="nav-right-slot" class="nav-action"
type="button"
@click="doSave"
> >
<t-badge 保存
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div v-can="savePermissionCode" class="store-edit"> <div v-can="savePermissionCode" class="store-edit">
@@ -108,37 +81,6 @@ import { useCurrentStoreStore } from "@/store/currentStoreStore";
import { gaoRoleCodes, permissionCodes } from "@/utils/permission"; import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
import { Message } from "@/utils/message.ts"; import { Message } from "@/utils/message.ts";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import type { Store, StoreStatus } from "@/types/Store"; import type { Store, StoreStatus } from "@/types/Store";
defineOptions({ defineOptions({
@@ -229,9 +171,6 @@ function validateForm(): boolean {
} }
onMounted(async () => { onMounted(async () => {
if (userStore.hasPermissions(savePermissionCode.value)) {
setPageNavBarRightText("保存", "var(--td-brand-color)", doSave);
}
try { try {
if (!routeId.value) { if (!routeId.value) {
return; return;
@@ -243,8 +182,6 @@ onMounted(async () => {
} }
}); });
onUnmounted(() => clearPageNavBarRight());
// ---------- 删除 ---------- // ---------- 删除 ----------
async function confirmRemoveStore(): Promise<void> { async function confirmRemoveStore(): Promise<void> {
@@ -303,44 +240,4 @@ async function removeStore(id: string): Promise<void> {
} }
.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; }
}
}
</style> </style>
+1 -114
View File
@@ -7,41 +7,7 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button class="nav-action" type="button" @click="saveSort">保存</button>
v-if="pageNavBarRight.icon || pageNavBarRight.text"
class="nav-right-slot"
>
<t-badge
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined"
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div v-can="permissionCodes.store.update" class="store-sort"> <div v-can="permissionCodes.store.update" class="store-sort">
@@ -96,38 +62,6 @@ import { VueDraggableNext } from "vue-draggable-next";
import StoreAPI from "@/api/StoreAPI"; import StoreAPI from "@/api/StoreAPI";
import { Message } from "@/utils/message"; import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission"; import { permissionCodes } from "@/utils/permission";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import type { Store, StoreStatus } from "@/types/Store"; import type { Store, StoreStatus } from "@/types/Store";
defineOptions({ defineOptions({
@@ -205,18 +139,12 @@ async function loadData(): Promise<void> {
} }
onMounted(async () => { onMounted(async () => {
clearPageNavBarRight();
setPageNavBarRightText("保存", "var(--td-brand-color)", saveSort);
try { try {
await loadData(); await loadData();
} catch { } catch {
Message.error("门店加载失败"); Message.error("门店加载失败");
} }
}); });
onUnmounted(() => {
clearPageNavBarRight();
});
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -274,45 +202,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; }
}
}
</style> </style>
+13 -112
View File
@@ -5,41 +5,17 @@
title="客户" title="客户"
> >
<template #right> <template #right>
<div <t-badge
v-if="pageNavBarRight.icon || pageNavBarRight.text" v-if="canReadNotify"
class="nav-right-slot" class="notification-badge"
:count="unreadNotifyCount"
:max-count="99"
:show-zero="false"
> >
<t-badge <button class="nav-action nav-action-icon" type="button" aria-label="通知" @click="router.push('/notify')">
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" <t-icon name="notification" size="1.25rem" />
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button> </button>
<button </t-badge>
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<main class="page-content scroll column home-tab"> <main class="page-content scroll column home-tab">
@@ -101,40 +77,10 @@
<script setup lang="ts"> <script setup lang="ts">
import { NotifyAPI, useUserStore } from "timi-web-api"; import { NotifyAPI, useUserStore } from "timi-web-api";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightIcon(value?: string, action?: () => void | Promise<void>): void {
pageNavBarRight.icon = value || "";
pageNavBarRight.badge = undefined;
pageNavBarRight.disabled = false;
pageNavBarRight.action = action;
if (value) {
pageNavBarRight.text = "";
pageNavBarRight.textColor = "";
}
}
function setPageNavBarRightBadge(value?: number): void {
pageNavBarRight.badge = value === undefined ? undefined : Math.max(0, value);
}
function clearPageNavBarRight(): void {
Object.assign(pageNavBarRight, { icon: "", badge: undefined, text: "", textColor: "", disabled: false, action: undefined });
}
async function handlePageNavBarRightAction(): Promise<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import { corePermissionCodes, gaoRoleCodes, permissionCodes } from "@/utils/permission"; import { corePermissionCodes, gaoRoleCodes, permissionCodes } from "@/utils/permission";
@@ -145,7 +91,6 @@ defineOptions({
const router = useRouter(); const router = useRouter();
const userStore = useUserStore(); const userStore = useUserStore();
const unreadNotifyCount = ref(0); const unreadNotifyCount = ref(0);
let isPageActive = true;
interface HomeEntry { interface HomeEntry {
path: string; path: string;
@@ -242,26 +187,15 @@ async function loadUnreadNotifyCount(): Promise<void> {
unreadNotifyCount.value = 0; unreadNotifyCount.value = 0;
console.warn("未读通知数量加载失败", error); console.warn("未读通知数量加载失败", error);
} }
if (isPageActive) {
setPageNavBarRightBadge(unreadNotifyCount.value);
}
} }
onMounted(async () => { onMounted(async () => {
clearPageNavBarRight();
if (canReadNotify.value) { if (canReadNotify.value) {
setPageNavBarRightIcon("notification", async () => {
await router.push("/notify");
});
setPageNavBarRightBadge(0);
await loadUnreadNotifyCount(); await loadUnreadNotifyCount();
} }
}); });
onUnmounted(() => {
isPageActive = false;
clearPageNavBarRight();
});
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -368,44 +302,11 @@ onUnmounted(() => {
} }
} }
.nav-right-slot {
width: 6rem;
height: 100%;
display: flex;
align-items: center;
justify-content: flex-end;
.badge { .notification-badge {
:deep(.t-badge__content) { :deep(.t-badge__content) {
display: flex; 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; 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; }
} }
} }
</style> </style>
+7 -105
View File
@@ -1,41 +1,14 @@
<template> <template>
<t-navbar fixed :z-index="20" title="门店"> <t-navbar fixed :z-index="20" title="门店">
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" class="nav-action nav-action-icon"
class="nav-right-slot" type="button"
aria-label="刷新"
@click="refreshCharts"
> >
<t-badge <t-icon name="refresh" size="1.25rem" />
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<main class="page-content scroll column store-tab"> <main class="page-content scroll column store-tab">
@@ -109,36 +82,9 @@ import { useUserStore } from "timi-web-api";
import { useCurrentStoreStore } from "@/store/currentStoreStore"; import { useCurrentStoreStore } from "@/store/currentStoreStore";
import { clearStoreChartCache } from "@/utils/storeChartCache"; import { clearStoreChartCache } from "@/utils/storeChartCache";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightIcon(value?: string, action?: () => void | Promise<void>): void {
pageNavBarRight.icon = value || "";
pageNavBarRight.badge = undefined;
pageNavBarRight.disabled = false;
pageNavBarRight.action = action;
if (value) {
pageNavBarRight.text = "";
pageNavBarRight.textColor = "";
}
}
function clearPageNavBarRight(): void {
Object.assign(pageNavBarRight, { icon: "", badge: undefined, text: "", textColor: "", disabled: false, action: undefined });
}
async function handlePageNavBarRightAction(): Promise<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import { gaoRoleCodes, gaoStoreScopePermissionCodes, permissionCodes } from "@/utils/permission"; import { gaoRoleCodes, gaoStoreScopePermissionCodes, permissionCodes } from "@/utils/permission";
@@ -239,7 +185,6 @@ async function goStoreDiaryManagement(): Promise<void> {
} }
onMounted(async () => { onMounted(async () => {
setPageNavBarRightIcon("refresh", refreshCharts);
if (canSelectStore.value) { if (canSelectStore.value) {
await currentStoreStore.loadStoreList(); await currentStoreStore.loadStoreList();
} else if (canLoadLoginStore.value) { } else if (canLoadLoginStore.value) {
@@ -247,9 +192,6 @@ onMounted(async () => {
} }
}); });
onUnmounted(() => {
clearPageNavBarRight();
});
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -279,44 +221,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; }
}
}
</style> </style>
+7 -103
View File
@@ -7,41 +7,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" v-if="currentUser && userStore.hasPermissions(permissionCodes.user.update)"
class="nav-right-slot" class="nav-action"
type="button"
@click="toEdit"
> >
<t-badge 编辑
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div <div
@@ -111,36 +84,9 @@ import { usePermissionSettingsStore } from "@/store/permissionSettingsStore";
import { buildEffectiveRoleCodeSet, getManagedUserRoleList, getRoleDisplayName } from "@/utils/role"; import { buildEffectiveRoleCodeSet, getManagedUserRoleList, getRoleDisplayName } from "@/utils/role";
import { permissionCodes } from "@/utils/permission"; import { permissionCodes } from "@/utils/permission";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import { buildFallbackAvatar } from "@/utils/avatar"; import { buildFallbackAvatar } from "@/utils/avatar";
@@ -255,14 +201,12 @@ onMounted(async () => {
try { try {
await loadData(); await loadData();
if (userStore.hasPermissions(permissionCodes.user.update)) { if (userStore.hasPermissions(permissionCodes.user.update)) {
setPageNavBarRightText("编辑", "var(--td-brand-color)", toEdit);
} }
} catch { } catch {
Message.error("用户详情加载失败"); Message.error("用户详情加载失败");
} }
}); });
onUnmounted(() => clearPageNavBarRight());
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -298,44 +242,4 @@ onUnmounted(() => clearPageNavBarRight());
} }
} }
.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; }
}
}
</style> </style>
+7 -110
View File
@@ -7,41 +7,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" v-if="userStore.hasPermissions(savePermissionCode)"
class="nav-right-slot" class="nav-action"
type="button"
@click="saveUser"
> >
<t-badge 保存
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div v-can="savePermissionCode" class="user-edit"> <div v-can="savePermissionCode" class="user-edit">
@@ -78,37 +51,6 @@ import ManagedUserAPI from "@/api/ManagedUserAPI";
import { useCurrentStoreStore } from "@/store/currentStoreStore"; import { useCurrentStoreStore } from "@/store/currentStoreStore";
import { gaoRoleCodes, permissionCodes } from "@/utils/permission"; import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import type { ManagedUser } from "@/types/ManagedUser"; import type { ManagedUser } from "@/types/ManagedUser";
type PickerValue = string | number; type PickerValue = string | number;
@@ -292,17 +234,12 @@ function validateForm(): boolean {
} }
onMounted(async () => { onMounted(async () => {
if (userStore.hasPermissions(savePermissionCode.value)) {
setPageNavBarRightText("保存", "var(--td-brand-color)", saveUser);
}
try { try {
await fillForm(); await fillForm();
} catch { } catch {
Message.error("用户数据加载失败"); Message.error("用户数据加载失败");
} }
}); });
onUnmounted(() => clearPageNavBarRight());
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -327,45 +264,5 @@ onUnmounted(() => clearPageNavBarRight());
} }
} }
.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; }
}
}
</style> </style>
+6 -110
View File
@@ -7,41 +7,13 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" class="nav-action"
class="nav-right-slot" type="button"
@click="saveProfile"
> >
<t-badge 保存
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div class="profile-page"> <div class="profile-page">
@@ -104,37 +76,6 @@ import PhotoField from "@/components/PhotoField.vue";
import { compressUploadImage } from "@/utils/imageCompression"; import { compressUploadImage } from "@/utils/imageCompression";
import { Message } from "@/utils/message"; import { Message } from "@/utils/message";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import { buildFallbackAvatar } from "@/utils/avatar"; import { buildFallbackAvatar } from "@/utils/avatar";
type UserAvatarSource = NonNullable<Parameters<typeof UserAPI.getAvatarURL>[0]> & { type UserAvatarSource = NonNullable<Parameters<typeof UserAPI.getAvatarURL>[0]> & {
@@ -292,13 +233,8 @@ function buildUserAvatar(user?: UserAvatarSource): string {
} }
onMounted(() => { onMounted(() => {
setPageNavBarRightText("保存", "var(--td-brand-color)", saveProfile);
fillForm(); fillForm();
}); });
onUnmounted(() => {
clearPageNavBarRight();
});
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -339,44 +275,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; }
}
}
</style> </style>
+7 -113
View File
@@ -7,41 +7,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <button
v-if="pageNavBarRight.icon || pageNavBarRight.text" v-if="userStore.hasPermissions(corePermissionCodes.userRole.create) && userStore.hasPermissions(corePermissionCodes.userRole.delete)"
class="nav-right-slot" class="nav-action"
type="button"
@click="saveRoleList"
> >
<t-badge 保存
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined" </button>
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template> </template>
</t-navbar> </t-navbar>
<div v-can="corePermissionCodes.userRole.read" class="user-role-assign"> <div v-can="corePermissionCodes.userRole.read" class="user-role-assign">
@@ -93,37 +66,6 @@ import type { ManagedUser } from "@/types/ManagedUser";
import { getErrorMessage } from "@/utils/error"; import { getErrorMessage } from "@/utils/error";
import { corePermissionCodes, gaoRoleCodes } from "@/utils/permission"; import { corePermissionCodes, gaoRoleCodes } from "@/utils/permission";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): 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<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import type { Role } from "@/store/permissionSettingsStore"; import type { Role } from "@/store/permissionSettingsStore";
defineOptions({ defineOptions({
@@ -363,20 +305,12 @@ function setRoleChecked(roleId: string, value: boolean): void {
} }
onMounted(async () => { onMounted(async () => {
if (
userStore.hasPermissions(corePermissionCodes.userRole.create)
&& userStore.hasPermissions(corePermissionCodes.userRole.delete)
) {
setPageNavBarRightText("保存", "var(--td-brand-color)", saveRoleList);
}
try { try {
await loadData(); await loadData();
} catch { } catch {
Message.error("用户角色加载失败"); Message.error("用户角色加载失败");
} }
}); });
onUnmounted(() => clearPageNavBarRight());
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@@ -405,45 +339,5 @@ onUnmounted(() => clearPageNavBarRight());
} }
} }
.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; }
}
}
</style> </style>