update action button
This commit is contained in:
@@ -53,13 +53,8 @@
|
||||
<div v-if="!visibleEventList.length" class="empty-block" v-text="emptyText" />
|
||||
<div v-if="visibleEventList.length" class="load-state" v-text="isNoMore ? '已经到底了' : '上拉加载更多'" />
|
||||
</t-pull-down-refresh>
|
||||
<t-button v-can="permissionCodes.event.create" class="create" theme="primary" @click="toCreate">
|
||||
<template #icon>
|
||||
<t-icon name="add" />
|
||||
</template>
|
||||
新增登记事件
|
||||
</t-button>
|
||||
</div>
|
||||
<nav-bar-action-menu v-if="canShowActionMenu" :actions="actionList" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
@@ -70,6 +65,7 @@ import ManagedUserAPI from "@/api/ManagedUserAPI";
|
||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||
import { useNavBarStore } from "@/store/navBarStore";
|
||||
import type { EventItem, EventLimitType, EventStatus } from "@/types/EventItem";
|
||||
import type { NavBarAction } from "@/types/NavBarAction";
|
||||
import { getEventValueUnitText } from "@/utils/eventValue";
|
||||
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
||||
|
||||
@@ -84,6 +80,31 @@ const currentStoreStore = useCurrentStoreStore();
|
||||
|
||||
const isGlobalManager = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
|
||||
const eventListOptions = computed(() => ({ storeId: currentStoreStore.currentStoreId }));
|
||||
const canCreateEvent = computed(() => userStore.hasPermissions(permissionCodes.event.create));
|
||||
const canUpdateEventItem = computed(() => userStore.hasPermissions(permissionCodes.event.update));
|
||||
const canShowActionMenu = computed(() => canCreateEvent.value || canUpdateEventItem.value);
|
||||
|
||||
const actionList = computed<NavBarAction[]>(() => {
|
||||
const list: NavBarAction[] = [];
|
||||
if (canCreateEvent.value) {
|
||||
list.push({
|
||||
action: toCreate,
|
||||
theme: "primary",
|
||||
icon: "add",
|
||||
key: "create",
|
||||
text: "新增登记事件"
|
||||
});
|
||||
}
|
||||
if (canUpdateEventItem.value) {
|
||||
list.push({
|
||||
action: toSort,
|
||||
icon: "order",
|
||||
key: "sort",
|
||||
text: "排序"
|
||||
});
|
||||
}
|
||||
return list;
|
||||
});
|
||||
|
||||
// ---------- 列表数据 ----------
|
||||
|
||||
@@ -104,7 +125,6 @@ const pageResult = reactive<PageResult<EventItem>>({
|
||||
total: 0,
|
||||
list: []
|
||||
});
|
||||
const canUpdateEventItem = computed(() => userStore.hasPermissions(permissionCodes.event.update));
|
||||
const visibleEventList = computed(() => pageResult.list);
|
||||
const emptyText = computed(() => {
|
||||
if (isLoading.value) {
|
||||
@@ -249,13 +269,13 @@ async function toCreate(): Promise<void> {
|
||||
});
|
||||
}
|
||||
|
||||
async function toSort(): Promise<void> {
|
||||
await router.push("/management/registration-events/sort");
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
navBarStore.clearRight();
|
||||
if (canUpdateEventItem.value) {
|
||||
navBarStore.setRightText("排序", "var(--td-brand-color)", () => {
|
||||
router.push("/management/registration-events/sort");
|
||||
});
|
||||
}
|
||||
navBarStore.setCustomRightVisible(canShowActionMenu.value);
|
||||
try {
|
||||
await loadData();
|
||||
} catch {
|
||||
@@ -270,7 +290,7 @@ onUnmounted(() => {
|
||||
|
||||
<style scoped lang="less">
|
||||
.registration-event-list {
|
||||
padding: calc(var(--app-nav-height) + 1rem) 0 6rem 0;
|
||||
padding: calc(var(--app-nav-height) + 1rem) 0 1rem 0;
|
||||
|
||||
.item {
|
||||
|
||||
@@ -308,12 +328,6 @@ onUnmounted(() => {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.create {
|
||||
left: 1rem;
|
||||
right: 1rem;
|
||||
bottom: calc(.75rem + env(safe-area-inset-bottom, 0));
|
||||
position: fixed;
|
||||
}
|
||||
}
|
||||
|
||||
:global(html.theme-dark) {
|
||||
|
||||
Reference in New Issue
Block a user