add NavbarActions.vue
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user