update action button

This commit is contained in:
Timi
2026-08-22 17:50:31 +08:00
parent 6b5badfb23
commit cfa6364d93
4 changed files with 81 additions and 65 deletions
+34 -19
View File
@@ -52,13 +52,8 @@
</t-cell-group>
<div class="load-state" v-text="loadStateText" />
</t-pull-down-refresh>
<t-button v-can="permissionCodes.pointRule.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">
@@ -68,6 +63,7 @@ import PointAPI from "@/api/PointAPI";
import { useCurrentStoreStore } from "@/store/currentStoreStore";
import { useNavBarStore } from "@/store/navBarStore";
import type { EventItem } from "@/types/EventItem";
import type { NavBarAction } from "@/types/NavBarAction";
import type { PointRule, PointRuleStatus } from "@/types/Point";
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
import { type Page, type PageResult, useUserStore } from "timi-web";
@@ -85,7 +81,32 @@ const currentStoreStore = useCurrentStoreStore();
// ---------- 筛选 ----------
const isGlobalManager = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
const canCreate = computed(() => userStore.hasPermissions(permissionCodes.pointRule.create));
const canUpdate = computed(() => userStore.hasPermissions(permissionCodes.pointRule.update));
const canShowActionMenu = computed(() => canCreate.value || canUpdate.value);
const actionList = computed<NavBarAction[]>(() => {
const list: NavBarAction[] = [];
if (canCreate.value) {
list.push({
action: toCreate,
theme: "primary",
icon: "add",
key: "create",
text: "新增积分规则"
});
}
if (canUpdate.value) {
list.push({
action: toSort,
icon: "order",
key: "sort",
text: "排序"
});
}
return list;
});
const statusFilter = ref("ALL");
const statusOptions = [
{ label: "全部状态", value: "ALL" },
@@ -248,6 +269,10 @@ async function toCreate(): Promise<void> {
});
}
async function toSort(): Promise<void> {
await router.push("/management/points/rules/sort");
}
async function toEdit(rule: PointRule): Promise<void> {
if (!canUpdate.value || !rule.id) {
return;
@@ -267,11 +292,7 @@ async function preparePage(): Promise<void> {
onMounted(async () => {
navBarStore.clearRight();
if (userStore.hasPermissions(permissionCodes.pointRule.update)) {
navBarStore.setRightText("排序", "var(--td-brand-color)", () => {
router.push("/management/points/rules/sort");
});
}
navBarStore.setCustomRightVisible(canShowActionMenu.value);
try {
await preparePage();
} catch {
@@ -284,13 +305,13 @@ onUnmounted(() => navBarStore.clearRight());
<style scoped lang="less">
.point-rule-list {
padding: calc(var(--app-nav-height) + 4rem) 0 6rem;
padding: calc(var(--app-nav-height) + 4rem) 0 1rem;
.filter-menu {
top: var(--app-nav-height);
left: 0;
right: 0;
z-index: 20;
z-index: 10;
position: fixed;
background: var(--td-bg-color-container);
}
@@ -332,12 +353,6 @@ onUnmounted(() => navBarStore.clearRight());
}
}
.create {
left: 1rem;
right: 1rem;
bottom: calc(.75rem + env(safe-area-inset-bottom, 0));
position: fixed;
}
}
:global(html.theme-dark) {