add NavbarActions.vue

This commit is contained in:
Timi
2026-10-22 14:55:33 +08:00
parent 2e91964a5d
commit bba4a2d4d6
12 changed files with 160 additions and 941 deletions
+113
View File
@@ -0,0 +1,113 @@
<template>
<div v-if="props.visible && visibleActionList.length" class="nav-actions">
<t-popover
v-model:visible="menuVisible"
placement="bottom-right"
:show-arrow="false"
theme="light"
>
<t-button
class="trigger"
variant="text"
:aria-label="props.triggerLabel"
type="button"
>
<template #icon>
<t-icon :name="props.triggerIcon" />
</template>
<span v-if="props.triggerText" v-text="props.triggerText" />
</t-button>
<template #content>
<div class="menu">
<t-button
v-for="action in visibleActionList"
:key="action.key"
class="menu-item"
variant="text"
type="button"
:theme="action.theme"
:loading="action.loading"
:disabled="action.disabled || action.loading"
@click="handleAction(action)"
>
<template v-if="action.icon" #icon>
<t-icon :name="action.icon" />
</template>
<span v-text="action.text" />
</t-button>
</div>
</template>
</t-popover>
</div>
</template>
<script setup lang="ts">
import type { NavbarAction } from "@/types/NavbarAction.ts";
interface Props {
actions: NavbarAction[];
triggerIcon?: string;
triggerLabel?: string;
triggerText?: string;
visible?: boolean;
}
const props = withDefaults(defineProps<Props>(), {
triggerIcon: "ellipsis",
triggerLabel: "更多操作",
triggerText: "",
visible: true
});
const menuVisible = ref(false);
const visibleActionList = computed(() => props.actions.filter(action => action.visible !== false));
async function handleAction(action: NavbarAction): Promise<void> {
menuVisible.value = false;
await action.action();
}
</script>
<style scoped lang="less">
.nav-actions {
--td-popover-padding: 0 .5rem;
width: 6rem;
height: 100%;
display: flex;
align-items: center;
justify-content: flex-end;
:deep(.t-popover__content) { border-radius: .875rem; }
.trigger { padding: 0; }
.menu {
gap: .25rem;
display: grid;
padding: .5rem 0;
min-width: 9rem;
.menu-item {
--td-button-medium-height: 32px;
--td-button-medium-padding-horizontal: 10px;
gap: .25rem;
width: 100%;
font-weight: unset;
justify-content: flex-start;
}
}
}
:global(html.theme-dark) {
.nav-actions {
:deep(.t-popover__content) {
color: #e2e8f0;
background: rgba(30, 41, 59, .98);
}
.menu-item { color: #e2e8f0; }
}
}
</style>
+4 -94
View File
@@ -8,48 +8,7 @@
@left-click="$router.back()"
>
<template #right>
<div
class="nav-actions"
v-if="(canShowActionMenu) && pageNavBarActionList.length"
>
<t-popover
v-model:visible="pageNavBarActionVisible"
placement="bottom-right"
:show-arrow="false"
theme="light"
>
<t-button
class="trigger"
variant="text"
:aria-label="'更多操作'"
type="button"
>
<template #icon>
<t-icon name="ellipsis" />
</template>
</t-button>
<template #content>
<div class="menu">
<t-button
v-for="action in pageNavBarActionList"
:key="action.key"
class="menu-item"
variant="text"
type="button"
:theme="action.theme"
:loading="action.loading"
:disabled="action.disabled || action.loading"
@click="handlePageNavBarAction(action)"
>
<template v-if="action.icon" #icon>
<t-icon :name="action.icon" />
</template>
<span v-text="action.text" />
</t-button>
</div>
</template>
</t-popover>
</div>
<navbar-actions :actions="actionList" :visible="canShowActionMenu" />
</template>
</t-navbar>
<main v-can="permissionCodes.customer.read" class="page-content scroll list">
@@ -208,7 +167,7 @@
</template>
<script setup lang="ts">
import type { NavBarAction } from "@/types/NavBarAction";
import type { NavbarAction } from "@/types/NavbarAction.ts";
import type { DropdownValue } from "tdesign-mobile-vue";
import { Message } from "@/utils/message";
import { Time, Toolkit, WebToolkit } from "timi-web";
@@ -223,14 +182,6 @@ import type { Tag } from "@/types/Tag";
import { buildPresetDateRange, parseDateTime } from "@/utils/date";
import { corePermissionCodes, gaoRoleCodes, permissionCodes } from "@/utils/permission";
const pageNavBarActionVisible = ref(false);
const pageNavBarActionList = computed<NavBarAction[]>(() => (unref(actionList) as NavBarAction[]).filter(action => action.visible !== false));
async function handlePageNavBarAction(action: NavBarAction): Promise<void> {
pageNavBarActionVisible.value = false;
await action.action();
}
import { useSettingStore } from "@/store/settingStore";
defineOptions({
@@ -309,8 +260,8 @@ function handleScanStatusChange(value: string): void {
scanStatus.value = value;
}
const actionList = computed<NavBarAction[]>(() => {
const list: NavBarAction[] = [];
const actionList = computed<NavbarAction[]>(() => {
const list: NavbarAction[] = [];
if (canCreateCustomer.value) {
list.push({
action: toCreate,
@@ -662,45 +613,4 @@ function buildCreatedAtRange(): [number | undefined, number | undefined] {
}
}
.nav-actions {
--td-popover-padding: 0 .5rem;
width: 6rem;
height: 100%;
display: flex;
align-items: center;
justify-content: flex-end;
:deep(.t-popover__content) { border-radius: .875rem; }
.trigger { padding: 0; }
.menu {
gap: .25rem;
display: grid;
padding: .5rem 0;
min-width: 9rem;
.menu-item {
--td-button-medium-height: 32px;
--td-button-medium-padding-horizontal: 10px;
gap: .25rem;
width: 100%;
font-weight: unset;
justify-content: flex-start;
}
}
}
:global(html.theme-dark) {
.nav-actions {
:deep(.t-popover__content) {
color: #e2e8f0;
background: rgba(30, 41, 59, .98);
}
.menu-item { color: #e2e8f0; }
}
}
</style>
+5 -94
View File
@@ -8,48 +8,7 @@
@left-click="$router.back()"
>
<template #right>
<div
class="nav-actions"
v-if="(canShowActionMenu) && pageNavBarActionList.length"
>
<t-popover
v-model:visible="pageNavBarActionVisible"
placement="bottom-right"
:show-arrow="false"
theme="light"
>
<t-button
class="trigger"
variant="text"
:aria-label="'更多操作'"
type="button"
>
<template #icon>
<t-icon name="ellipsis" />
</template>
</t-button>
<template #content>
<div class="menu">
<t-button
v-for="action in pageNavBarActionList"
:key="action.key"
class="menu-item"
variant="text"
type="button"
:theme="action.theme"
:loading="action.loading"
:disabled="action.disabled || action.loading"
@click="handlePageNavBarAction(action)"
>
<template v-if="action.icon" #icon>
<t-icon :name="action.icon" />
</template>
<span v-text="action.text" />
</t-button>
</div>
</template>
</t-popover>
</div>
<navbar-actions :actions="actionList" :visible="canShowActionMenu" />
</template>
</t-navbar>
<main
@@ -138,7 +97,7 @@
</template>
<script setup lang="ts">
import type { NavBarAction } from "@/types/NavBarAction";
import type { NavbarAction } from "@/types/NavbarAction.ts";
import { Message } from "@/utils/message";
import { type Page, type PageResult, type Role, useUserStore } from "timi-web-api";
import EventAPI from "@/api/EventAPI";
@@ -149,15 +108,8 @@ import { getEventBizTypeText, isRetiredEvent } from "@/utils/event";
import { getEventValueUnitText } from "@/utils/eventValue";
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
const pageNavBarActionVisible = ref(false);
const pageNavBarActionList = computed<NavBarAction[]>(() => (unref(actionList) as NavBarAction[]).filter(action => action.visible !== false));
async function handlePageNavBarAction(action: NavBarAction): Promise<void> {
pageNavBarActionVisible.value = false;
await action.action();
}
import type { EventItem, EventLimitType, EventStatus } from "@/types/EventItem";
import NavbarActions from "@/components/NavbarActions.vue";
defineOptions({
name: "eventList"
@@ -174,8 +126,8 @@ const canUpdateEventItem = computed(() => userStore.hasPermissions(permissionCod
const canDeleteEvent = computed(() => userStore.hasPermissions(permissionCodes.event.delete));
const canShowActionMenu = computed(() => canCreateEvent.value || canUpdateEventItem.value);
const actionList = computed<NavBarAction[]>(() => {
const list: NavBarAction[] = [];
const actionList = computed<NavbarAction[]>(() => {
const list: NavbarAction[] = [];
if (canCreateEvent.value) {
list.push({
action: toCreate,
@@ -469,45 +421,4 @@ onUnmounted(() => {
}
}
.nav-actions {
--td-popover-padding: 0 .5rem;
width: 6rem;
height: 100%;
display: flex;
align-items: center;
justify-content: flex-end;
:deep(.t-popover__content) { border-radius: .875rem; }
.trigger { padding: 0; }
.menu {
gap: .25rem;
display: grid;
padding: .5rem 0;
min-width: 9rem;
.menu-item {
--td-button-medium-height: 32px;
--td-button-medium-padding-horizontal: 10px;
gap: .25rem;
width: 100%;
font-weight: unset;
justify-content: flex-start;
}
}
}
:global(html.theme-dark) {
.nav-actions {
:deep(.t-popover__content) {
color: #e2e8f0;
background: rgba(30, 41, 59, .98);
}
.menu-item { color: #e2e8f0; }
}
}
</style>
+4 -94
View File
@@ -8,48 +8,7 @@
@left-click="$router.back()"
>
<template #right>
<div
class="nav-actions"
v-if="(canShowActionMenu) && pageNavBarActionList.length"
>
<t-popover
v-model:visible="pageNavBarActionVisible"
placement="bottom-right"
:show-arrow="false"
theme="light"
>
<t-button
class="trigger"
variant="text"
:aria-label="'更多操作'"
type="button"
>
<template #icon>
<t-icon name="ellipsis" />
</template>
</t-button>
<template #content>
<div class="menu">
<t-button
v-for="action in pageNavBarActionList"
:key="action.key"
class="menu-item"
variant="text"
type="button"
:theme="action.theme"
:loading="action.loading"
:disabled="action.disabled || action.loading"
@click="handlePageNavBarAction(action)"
>
<template v-if="action.icon" #icon>
<t-icon :name="action.icon" />
</template>
<span v-text="action.text" />
</t-button>
</div>
</template>
</t-popover>
</div>
<navbar-actions :actions="actionList" :visible="canShowActionMenu" />
</template>
</t-navbar>
<main v-can="permissionCodes.eventRecord.read" class="page-content scroll list">
@@ -200,7 +159,7 @@
</template>
<script setup lang="ts">
import type { NavBarAction } from "@/types/NavBarAction";
import type { NavbarAction } from "@/types/NavbarAction.ts";
import { CenterTips, Time, Text, WebToolkit } from "timi-web";
import { useUserStore } from "timi-web-api";
import EventAPI from "@/api/EventAPI";
@@ -214,14 +173,6 @@ import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/util
import { permissionCodes } from "@/utils/permission";
import { Message } from "@/utils/message.ts";
const pageNavBarActionVisible = ref(false);
const pageNavBarActionList = computed<NavBarAction[]>(() => (unref(actionList) as NavBarAction[]).filter(action => action.visible !== false));
async function handlePageNavBarAction(action: NavBarAction): Promise<void> {
pageNavBarActionVisible.value = false;
await action.action();
}
import type { EventItem, EventStatus } from "@/types/EventItem";
type DateFilterType = "today" | "yesterday" | "thisWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
@@ -337,8 +288,8 @@ const hasSelectedOption = computed(() => !!selectedOptionEvent.value);
const canExportRecord = computed(() => userStore.hasPermissions(permissionCodes.eventRecord.export));
const canShowActionMenu = computed(() => canCreateRecord.value || canExportRecord.value);
const actionList = computed<NavBarAction[]>(() => {
const list: NavBarAction[] = [];
const actionList = computed<NavbarAction[]>(() => {
const list: NavbarAction[] = [];
if (canCreateRecord.value) {
list.push({
action: toCreate,
@@ -814,45 +765,4 @@ onUnmounted(() => {
}
}
.nav-actions {
--td-popover-padding: 0 .5rem;
width: 6rem;
height: 100%;
display: flex;
align-items: center;
justify-content: flex-end;
:deep(.t-popover__content) { border-radius: .875rem; }
.trigger { padding: 0; }
.menu {
gap: .25rem;
display: grid;
padding: .5rem 0;
min-width: 9rem;
.menu-item {
--td-button-medium-height: 32px;
--td-button-medium-padding-horizontal: 10px;
gap: .25rem;
width: 100%;
font-weight: unset;
justify-content: flex-start;
}
}
}
:global(html.theme-dark) {
.nav-actions {
:deep(.t-popover__content) {
color: #e2e8f0;
background: rgba(30, 41, 59, .98);
}
.menu-item { color: #e2e8f0; }
}
}
</style>
+3 -93
View File
@@ -8,48 +8,7 @@
@left-click="$router.back()"
>
<template #right>
<div
class="nav-actions"
v-if="(canCreate) && pageNavBarActionList.length"
>
<t-popover
v-model:visible="pageNavBarActionVisible"
placement="bottom-right"
:show-arrow="false"
theme="light"
>
<t-button
class="trigger"
variant="text"
:aria-label="'更多操作'"
type="button"
>
<template #icon>
<t-icon name="ellipsis" />
</template>
</t-button>
<template #content>
<div class="menu">
<t-button
v-for="action in pageNavBarActionList"
:key="action.key"
class="menu-item"
variant="text"
type="button"
:theme="action.theme"
:loading="action.loading"
:disabled="action.disabled || action.loading"
@click="handlePageNavBarAction(action)"
>
<template v-if="action.icon" #icon>
<t-icon :name="action.icon" />
</template>
<span v-text="action.text" />
</t-button>
</div>
</template>
</t-popover>
</div>
<navbar-actions :actions="actions" :visible="canCreate" />
</template>
</t-navbar>
<main v-can="permissionCodes.orderFulfillment.read" class="page-content scroll list">
@@ -211,7 +170,7 @@
</template>
<script setup lang="ts">
import type { NavBarAction } from "@/types/NavBarAction";
import type { NavbarAction } from "@/types/NavbarAction.ts";
import { type DropdownValue } from "tdesign-mobile-vue";
import { Time } from "timi-web";
import { useUserStore } from "timi-web-api";
@@ -228,14 +187,6 @@ import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission";
import { getSalesOrderStatusText, getSalesOrderTypeText, getStatusTheme } from "@/utils/salesOrder";
const pageNavBarActionVisible = ref(false);
const pageNavBarActionList = computed<NavBarAction[]>(() => (unref(actions) as NavBarAction[]).filter(action => action.visible !== false));
async function handlePageNavBarAction(action: NavBarAction): Promise<void> {
pageNavBarActionVisible.value = false;
await action.action();
}
import OrderFulfillmentListCell from "@/pages/fulfillment/components/OrderFulfillmentListCell.vue";
import type { GaoFulfillmentStatus, OrderFulfillment } from "@/types/Fulfillment";
@@ -246,7 +197,7 @@ const router = useRouter();
const filterMenuRef = ref<{ collapseMenu: () => void }>();
const userStore = useUserStore();
const canCreate = computed(() => userStore.hasPermissions(permissionCodes.orderFulfillment.create));
const actions = computed<NavBarAction[]>(() => [
const actions = computed<NavbarAction[]>(() => [
{
key: "quick-fulfillment",
text: "快速履约",
@@ -695,45 +646,4 @@ onMounted(async () => {
}
}
.nav-actions {
--td-popover-padding: 0 .5rem;
width: 6rem;
height: 100%;
display: flex;
align-items: center;
justify-content: flex-end;
:deep(.t-popover__content) { border-radius: .875rem; }
.trigger { padding: 0; }
.menu {
gap: .25rem;
display: grid;
padding: .5rem 0;
min-width: 9rem;
.menu-item {
--td-button-medium-height: 32px;
--td-button-medium-padding-horizontal: 10px;
gap: .25rem;
width: 100%;
font-weight: unset;
justify-content: flex-start;
}
}
}
:global(html.theme-dark) {
.nav-actions {
:deep(.t-popover__content) {
color: #e2e8f0;
background: rgba(30, 41, 59, .98);
}
.menu-item { color: #e2e8f0; }
}
}
</style>
+4 -94
View File
@@ -8,48 +8,7 @@
@left-click="$router.back()"
>
<template #right>
<div
class="nav-actions"
v-if="(canShowActionMenu) && pageNavBarActionList.length"
>
<t-popover
v-model:visible="pageNavBarActionVisible"
placement="bottom-right"
:show-arrow="false"
theme="light"
>
<t-button
class="trigger"
variant="text"
:aria-label="'更多操作'"
type="button"
>
<template #icon>
<t-icon name="ellipsis" />
</template>
</t-button>
<template #content>
<div class="menu">
<t-button
v-for="action in pageNavBarActionList"
:key="action.key"
class="menu-item"
variant="text"
type="button"
:theme="action.theme"
:loading="action.loading"
:disabled="action.disabled || action.loading"
@click="handlePageNavBarAction(action)"
>
<template v-if="action.icon" #icon>
<t-icon :name="action.icon" />
</template>
<span v-text="action.text" />
</t-button>
</div>
</template>
</t-popover>
</div>
<navbar-actions :actions="actionList" :visible="canShowActionMenu" />
</template>
</t-navbar>
<main v-can="permissionCodes.pointRule.read" class="page-content scroll list">
@@ -124,7 +83,7 @@
</template>
<script setup lang="ts">
import type { NavBarAction } from "@/types/NavBarAction";
import type { NavbarAction } from "@/types/NavbarAction.ts";
import { type DropdownValue } from "tdesign-mobile-vue";
import { Toolkit } from "timi-web";
import EventAPI from "@/api/EventAPI";
@@ -136,14 +95,6 @@ import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
import { type Page, type PageResult, useUserStore } from "timi-web-api";
import { Message } from "@/utils/message.ts";
const pageNavBarActionVisible = ref(false);
const pageNavBarActionList = computed<NavBarAction[]>(() => (unref(actionList) as NavBarAction[]).filter(action => action.visible !== false));
async function handlePageNavBarAction(action: NavBarAction): Promise<void> {
pageNavBarActionVisible.value = false;
await action.action();
}
import type { EventItem } from "@/types/EventItem";
defineOptions({
@@ -161,8 +112,8 @@ const canCreate = computed(() => userStore.hasPermissions(permissionCodes.pointR
const canUpdate = computed(() => userStore.hasPermissions(permissionCodes.pointRule.update));
const canShowActionMenu = computed(() => canCreate.value || canUpdate.value);
const actionList = computed<NavBarAction[]>(() => {
const list: NavBarAction[] = [];
const actionList = computed<NavbarAction[]>(() => {
const list: NavbarAction[] = [];
if (canCreate.value) {
list.push({
action: toCreate,
@@ -464,45 +415,4 @@ onUnmounted(() => {
}
}
.nav-actions {
--td-popover-padding: 0 .5rem;
width: 6rem;
height: 100%;
display: flex;
align-items: center;
justify-content: flex-end;
:deep(.t-popover__content) { border-radius: .875rem; }
.trigger { padding: 0; }
.menu {
gap: .25rem;
display: grid;
padding: .5rem 0;
min-width: 9rem;
.menu-item {
--td-button-medium-height: 32px;
--td-button-medium-padding-horizontal: 10px;
gap: .25rem;
width: 100%;
font-weight: unset;
justify-content: flex-start;
}
}
}
:global(html.theme-dark) {
.nav-actions {
:deep(.t-popover__content) {
color: #e2e8f0;
background: rgba(30, 41, 59, .98);
}
.menu-item { color: #e2e8f0; }
}
}
</style>
+4 -94
View File
@@ -8,48 +8,7 @@
@left-click="$router.back()"
>
<template #right>
<div
class="nav-actions"
v-if="(canShowActionMenu) && pageNavBarActionList.length"
>
<t-popover
v-model:visible="pageNavBarActionVisible"
placement="bottom-right"
:show-arrow="false"
theme="light"
>
<t-button
class="trigger"
variant="text"
:aria-label="'更多操作'"
type="button"
>
<template #icon>
<t-icon name="ellipsis" />
</template>
</t-button>
<template #content>
<div class="menu">
<t-button
v-for="action in pageNavBarActionList"
:key="action.key"
class="menu-item"
variant="text"
type="button"
:theme="action.theme"
:loading="action.loading"
:disabled="action.disabled || action.loading"
@click="handlePageNavBarAction(action)"
>
<template v-if="action.icon" #icon>
<t-icon :name="action.icon" />
</template>
<span v-text="action.text" />
</t-button>
</div>
</template>
</t-popover>
</div>
<navbar-actions :actions="actionList" :visible="canShowActionMenu" />
</template>
</t-navbar>
<main v-can="permissionCodes.productCategory.read" class="page-content scroll list">
@@ -129,7 +88,7 @@
</template>
<script setup lang="ts">
import type { NavBarAction } from "@/types/NavBarAction";
import type { NavbarAction } from "@/types/NavbarAction.ts";
import { DialogPlugin, type DropdownValue } from "tdesign-mobile-vue";
import { useUserStore } from "timi-web-api";
import ProductAPI from "@/api/ProductAPI";
@@ -138,14 +97,6 @@ import { getProductCategoryStatusText, getProductCategoryStatusTheme } from "@/u
import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission";
const pageNavBarActionVisible = ref(false);
const pageNavBarActionList = computed<NavBarAction[]>(() => (unref(actionList) as NavBarAction[]).filter(action => action.visible !== false));
async function handlePageNavBarAction(action: NavBarAction): Promise<void> {
pageNavBarActionVisible.value = false;
await action.action();
}
import { getErrorMessage } from "@/utils/error";
defineOptions({ name: "ProductCategoryList" });
@@ -155,8 +106,8 @@ const userStore = useUserStore();
const canCreate = computed(() => userStore.hasPermissions(permissionCodes.productCategory.create));
const canUpdate = computed(() => userStore.hasPermissions(permissionCodes.productCategory.update));
const canShowActionMenu = computed(() => canCreate.value || canUpdate.value);
const actionList = computed<NavBarAction[]>(() => {
const list: NavBarAction[] = [];
const actionList = computed<NavbarAction[]>(() => {
const list: NavbarAction[] = [];
if (canCreate.value) {
list.push({
key: "create",
@@ -448,45 +399,4 @@ onUnmounted(() => {
padding: 0;
}
.nav-actions {
--td-popover-padding: 0 .5rem;
width: 6rem;
height: 100%;
display: flex;
align-items: center;
justify-content: flex-end;
:deep(.t-popover__content) { border-radius: .875rem; }
.trigger { padding: 0; }
.menu {
gap: .25rem;
display: grid;
padding: .5rem 0;
min-width: 9rem;
.menu-item {
--td-button-medium-height: 32px;
--td-button-medium-padding-horizontal: 10px;
gap: .25rem;
width: 100%;
font-weight: unset;
justify-content: flex-start;
}
}
}
:global(html.theme-dark) {
.nav-actions {
:deep(.t-popover__content) {
color: #e2e8f0;
background: rgba(30, 41, 59, .98);
}
.menu-item { color: #e2e8f0; }
}
}
</style>
+4 -94
View File
@@ -7,48 +7,7 @@
@left-click="$router.back()"
>
<template #right>
<div
class="nav-actions"
v-if="(actionList.length) && pageNavBarActionList.length"
>
<t-popover
v-model:visible="pageNavBarActionVisible"
placement="bottom-right"
:show-arrow="false"
theme="light"
>
<t-button
class="trigger"
variant="text"
:aria-label="'更多操作'"
type="button"
>
<template #icon>
<t-icon name="ellipsis" />
</template>
</t-button>
<template #content>
<div class="menu">
<t-button
v-for="action in pageNavBarActionList"
:key="action.key"
class="menu-item"
variant="text"
type="button"
:theme="action.theme"
:loading="action.loading"
:disabled="action.disabled || action.loading"
@click="handlePageNavBarAction(action)"
>
<template v-if="action.icon" #icon>
<t-icon :name="action.icon" />
</template>
<span v-text="action.text" />
</t-button>
</div>
</template>
</t-popover>
</div>
<navbar-actions :actions="actionList" />
</template>
</t-navbar>
<div v-can="permissionCodes.product.read" class="product-detail">
@@ -168,7 +127,7 @@
</template>
<script setup lang="ts">
import type { NavBarAction } from "@/types/NavBarAction";
import type { NavbarAction } from "@/types/NavbarAction.ts";
import { DialogPlugin } from "tdesign-mobile-vue";
import { BottomPopup } from "timi-tdesign-mobile";
import { useUserStore } from "timi-web-api";
@@ -189,14 +148,6 @@ import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission";
import { Text } from "timi-web";
const pageNavBarActionVisible = ref(false);
const pageNavBarActionList = computed<NavBarAction[]>(() => (unref(actionList) as NavBarAction[]).filter(action => action.visible !== false));
async function handlePageNavBarAction(action: NavBarAction): Promise<void> {
pageNavBarActionVisible.value = false;
await action.action();
}
import AttachmentSelector from "@/components/attachmentSelector/AttachmentSelector.vue";
defineOptions({ name: "ProductDetail" });
@@ -225,8 +176,8 @@ const skuPhotoItemList = computed<PhotoItem[]>(() => (selectedSku.value?.attachm
previewUrl: getAttachmentReadURL(item.id || ""),
url: getAttachmentReadURL(item.id || "", 90)
})));
const actionList = computed<NavBarAction[]>(() => {
const list: NavBarAction[] = [];
const actionList = computed<NavbarAction[]>(() => {
const list: NavbarAction[] = [];
if (userStore.hasPermissions(permissionCodes.product.update)) {
list.push({ key: "edit", text: "编辑产品", icon: "edit-1", theme: "primary", action: edit });
if (product.value?.status === "ACTIVE") {
@@ -441,45 +392,4 @@ onMounted(async () => {
}
}
.nav-actions {
--td-popover-padding: 0 .5rem;
width: 6rem;
height: 100%;
display: flex;
align-items: center;
justify-content: flex-end;
:deep(.t-popover__content) { border-radius: .875rem; }
.trigger { padding: 0; }
.menu {
gap: .25rem;
display: grid;
padding: .5rem 0;
min-width: 9rem;
.menu-item {
--td-button-medium-height: 32px;
--td-button-medium-padding-horizontal: 10px;
gap: .25rem;
width: 100%;
font-weight: unset;
justify-content: flex-start;
}
}
}
:global(html.theme-dark) {
.nav-actions {
:deep(.t-popover__content) {
color: #e2e8f0;
background: rgba(30, 41, 59, .98);
}
.menu-item { color: #e2e8f0; }
}
}
</style>
+2 -92
View File
@@ -2,48 +2,7 @@
<div class="page-layout navbar sales-order-list">
<t-navbar fixed :z-index="20" title="销售订单" left-arrow @left-click="$router.back()">
<template #right>
<div
class="nav-actions"
v-if="(route.name === 'SalesOrderList' && actions.length) && pageNavBarActionList.length"
>
<t-popover
v-model:visible="pageNavBarActionVisible"
placement="bottom-right"
:show-arrow="false"
theme="light"
>
<t-button
class="trigger"
variant="text"
:aria-label="'更多操作'"
type="button"
>
<template #icon>
<t-icon name="ellipsis" />
</template>
</t-button>
<template #content>
<div class="menu">
<t-button
v-for="action in pageNavBarActionList"
:key="action.key"
class="menu-item"
variant="text"
type="button"
:theme="action.theme"
:loading="action.loading"
:disabled="action.disabled || action.loading"
@click="handlePageNavBarAction(action)"
>
<template v-if="action.icon" #icon>
<t-icon :name="action.icon" />
</template>
<span v-text="action.text" />
</t-button>
</div>
</template>
</t-popover>
</div>
<navbar-actions :actions="actions" :visible="route.name === 'SalesOrderList'" />
</template>
</t-navbar>
<main ref="salesOrderListRef" v-can="permissionCodes.salesOrder.read" class="page-content scroll list">
@@ -149,7 +108,7 @@
</template>
<script setup lang="ts">
import type { NavBarAction } from "@/types/NavBarAction";
import type { NavbarAction } from "@/types/NavbarAction.ts";
import { Toolkit } from "timi-web";
import { useUserStore } from "timi-web-api";
import { onBeforeRouteLeave } from "vue-router";
@@ -183,14 +142,6 @@ import { events, isCurrentStoreEvent, listDataEventKeys, type ListDataChangedPay
import { Message } from "@/utils/message";
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
const pageNavBarActionVisible = ref(false);
const pageNavBarActionList = computed<NavBarAction[]>(() => (unref(actions) as NavBarAction[]).filter(action => action.visible !== false));
async function handlePageNavBarAction(action: NavBarAction): Promise<void> {
pageNavBarActionVisible.value = false;
await action.action();
}
import SalesOrderFilterPopup from "@/pages/salesOrder/components/SalesOrderFilterPopup.vue";
import type { Customer } from "@/types/Customer";
@@ -853,45 +804,4 @@ onUnmounted(() => {
}
}
.nav-actions {
--td-popover-padding: 0 .5rem;
width: 6rem;
height: 100%;
display: flex;
align-items: center;
justify-content: flex-end;
:deep(.t-popover__content) { border-radius: .875rem; }
.trigger { padding: 0; }
.menu {
gap: .25rem;
display: grid;
padding: .5rem 0;
min-width: 9rem;
.menu-item {
--td-button-medium-height: 32px;
--td-button-medium-padding-horizontal: 10px;
gap: .25rem;
width: 100%;
font-weight: unset;
justify-content: flex-start;
}
}
}
:global(html.theme-dark) {
.nav-actions {
:deep(.t-popover__content) {
color: #e2e8f0;
background: rgba(30, 41, 59, .98);
}
.menu-item { color: #e2e8f0; }
}
}
</style>
+5 -98
View File
@@ -8,48 +8,7 @@
@left-click="$router.back()"
>
<template #right>
<div
class="nav-actions"
v-if="(canShowActionMenu) && pageNavBarActionList.length"
>
<t-popover
v-model:visible="pageNavBarActionVisible"
placement="bottom-right"
:show-arrow="false"
theme="light"
>
<t-button
class="trigger"
variant="text"
:aria-label="'更多操作'"
type="button"
>
<template #icon>
<t-icon name="ellipsis" />
</template>
</t-button>
<template #content>
<div class="menu">
<t-button
v-for="action in pageNavBarActionList"
:key="action.key"
class="menu-item"
variant="text"
type="button"
:theme="action.theme"
:loading="action.loading"
:disabled="action.disabled || action.loading"
@click="handlePageNavBarAction(action)"
>
<template v-if="action.icon" #icon>
<t-icon :name="action.icon" />
</template>
<span v-text="action.text" />
</t-button>
</div>
</template>
</t-popover>
</div>
<navbar-actions :actions="actionList" :visible="canShowActionMenu" />
</template>
</t-navbar>
<main v-can="permissionCodes.store.read" class="page-content column scroll list">
@@ -112,7 +71,7 @@
</template>
<script setup lang="ts">
import type { NavBarAction } from "@/types/NavBarAction";
import type { NavbarAction } from "@/types/NavbarAction.ts";
import { Message } from "@/utils/message";
import { Time, WebToolkit } from "timi-web";
import { type Page, type PageResult, useUserStore } from "timi-web-api";
@@ -121,14 +80,7 @@ import StoreRemoveDialog from "@/components/StoreRemoveDialog.vue";
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
import { getStoreStatusText, getStoreStatusTheme } from "@/utils/store";
import type { Store } from "@/types/Store";
const pageNavBarActionVisible = ref(false);
const pageNavBarActionList = computed<NavBarAction[]>(() => (unref(actionList) as NavBarAction[]).filter(action => action.visible !== false));
async function handlePageNavBarAction(action: NavBarAction): Promise<void> {
pageNavBarActionVisible.value = false;
await action.action();
}
import NavbarActions from "@/components/NavbarActions.vue";
defineOptions({
name: "StoreList"
@@ -148,8 +100,8 @@ const removeDialogVisible = ref(false);
const removeTarget = ref<Store>();
const removingStoreId = ref("");
const actionList = computed<NavBarAction[]>(() => {
const list: NavBarAction[] = [];
const actionList = computed<NavbarAction[]>(() => {
const list: NavbarAction[] = [];
if (canCreateStore.value) {
list.push({
action: toCreate,
@@ -345,49 +297,4 @@ onUnmounted(() => {
}
}
.nav-actions {
--td-popover-padding: 0 .5rem;
width: 6rem;
height: 100%;
display: flex;
align-items: center;
justify-content: flex-end;
:deep(.t-popover__content) {
border-radius: .875rem;
}
.trigger {
padding: 0;
}
.menu {
gap: .25rem;
display: grid;
padding: .5rem 0;
min-width: 9rem;
.menu-item {
--td-button-medium-height: 32px;
--td-button-medium-padding-horizontal: 10px;
gap: .25rem;
width: 100%;
font-weight: unset;
justify-content: flex-start;
}
}
}
:global(html.theme-dark) {
.nav-actions {
:deep(.t-popover__content) {
color: #e2e8f0;
background: rgba(30, 41, 59, .98);
}
.menu-item { color: #e2e8f0; }
}
}
</style>
+11 -93
View File
@@ -8,47 +8,13 @@
@left-click="$router.back()"
>
<template #right>
<div
class="nav-actions"
v-if="(canCreateUser) && pageNavBarActionList.length"
>
<t-popover
v-model:visible="pageNavBarActionVisible"
placement="bottom-right"
:show-arrow="false"
theme="light"
>
<t-button
class="trigger"
variant="text"
:aria-label="'新增'"
type="button"
>
<template #icon><t-icon name="add" /></template>
<span v-text="'新增'" />
</t-button>
<template #content>
<div class="menu">
<t-button
v-for="action in pageNavBarActionList"
:key="action.key"
class="menu-item"
variant="text"
type="button"
:theme="action.theme"
:loading="action.loading"
:disabled="action.disabled || action.loading"
@click="handlePageNavBarAction(action)"
>
<template v-if="action.icon" #icon>
<t-icon :name="action.icon" />
</template>
<span v-text="action.text" />
</t-button>
</div>
</template>
</t-popover>
</div>
<navbar-actions
:actions="actionList"
:visible="canCreateUser"
trigger-icon="add"
trigger-label="新增"
trigger-text="新增"
/>
</template>
</t-navbar>
<main
@@ -105,9 +71,9 @@
</template>
<script setup lang="ts">
import type { NavBarAction } from "@/types/NavBarAction";
import type { NavbarAction } from "@/types/NavbarAction.ts";
import { Message } from "@/utils/message";
import { type Page, type PageResult, UserAPI, type User, useUserStore } from "timi-web-api";
import { type Page, type PageResult, type User, UserAPI, useUserStore } from "timi-web-api";
import ManagedUserAPI from "@/api/ManagedUserAPI";
import { useCurrentStoreStore } from "@/store/currentStoreStore";
import { usePermissionSettingsStore } from "@/store/permissionSettingsStore";
@@ -116,15 +82,8 @@ import { getManagedUserRoleList, getRoleDisplayName } from "@/utils/role";
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
import UserInvite from "@/pages/user/component/UserInvite.vue";
const pageNavBarActionVisible = ref(false);
const pageNavBarActionList = computed<NavBarAction[]>(() => (unref(actionList) as NavBarAction[]).filter(action => action.visible !== false));
async function handlePageNavBarAction(action: NavBarAction): Promise<void> {
pageNavBarActionVisible.value = false;
await action.action();
}
import type { ManagedUser } from "@/types/ManagedUser";
import NavbarActions from "@/components/NavbarActions.vue";
defineOptions({
name: "UserList"
@@ -139,7 +98,7 @@ const inviteVisible = ref(false);
const isGlobalManager = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
const canCreateUser = computed(() => userStore.hasPermissions(permissionCodes.user.create));
const actionList: NavBarAction[] = [
const actionList: NavbarAction[] = [
{
action: toCreate,
icon: "add",
@@ -337,45 +296,4 @@ onMounted(async () => {
}
}
.nav-actions {
--td-popover-padding: 0 .5rem;
width: 6rem;
height: 100%;
display: flex;
align-items: center;
justify-content: flex-end;
:deep(.t-popover__content) { border-radius: .875rem; }
.trigger { padding: 0; }
.menu {
gap: .25rem;
display: grid;
padding: .5rem 0;
min-width: 9rem;
.menu-item {
--td-button-medium-height: 32px;
--td-button-medium-padding-horizontal: 10px;
gap: .25rem;
width: 100%;
font-weight: unset;
justify-content: flex-start;
}
}
}
:global(html.theme-dark) {
.nav-actions {
:deep(.t-popover__content) {
color: #e2e8f0;
background: rgba(30, 41, 59, .98);
}
.menu-item { color: #e2e8f0; }
}
}
</style>
@@ -3,7 +3,7 @@ import type { ButtonProps } from "tdesign-mobile-vue";
/**
* 顶部导航右侧菜单项。
*/
export type NavBarAction = {
export type NavbarAction = {
action: () => void | Promise<unknown>;
disabled?: boolean;
icon?: string;