refactor layout

This commit is contained in:
Timi
2026-10-17 12:01:28 +08:00
parent fe467e8781
commit 469c595a7c
134 changed files with 11493 additions and 4437 deletions
+37
View File
@@ -1,6 +1,26 @@
<template>
<t-navbar
fixed
:z-index="20"
title="AI 小糕"
left-arrow
@left-click="$router.back()"
>
<template #right>
<button
v-if="canUseAi"
class="nav-history"
type="button"
:disabled="aiChatPanelRef?.isBusy"
@click="aiChatPanelRef?.openConversationList()"
>
历史
</button>
</template>
</t-navbar>
<div v-if="canUseAi" class="ai-chat-page">
<ai-chat-panel
ref="aiChatPanel"
:store-name="currentStoreStore.currentStoreName"
:session-key="sessionKey"
:store-id="aiStoreId"
@@ -26,6 +46,11 @@ const sessionKey = computed(() => `${userStore.loginUser.user?.id || userStore.l
const canUseAi = computed(() => userStore.hasRoles(gaoRoleCodes.storeManager));
const isGlobalManager = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
const aiStoreId = computed(() => canUseAi.value && isGlobalManager.value ? currentStoreStore.currentStoreId : undefined);
type AiChatPanelExpose = {
isBusy: boolean;
openConversationList: () => void;
};
const aiChatPanelRef = useTemplateRef<AiChatPanelExpose>("aiChatPanel");
function startNewConversation(): void {
conversationResetToken.value += 1;
@@ -33,6 +58,18 @@ function startNewConversation(): void {
</script>
<style scoped lang="less">
.nav-history {
color: var(--td-brand-color);
border: none;
padding: 0;
background: transparent;
}
.nav-history:disabled {
color: var(--td-text-color-disabled);
cursor: not-allowed;
}
.ai-chat-page {
height: 100%;
overflow: hidden;
+7 -8
View File
@@ -88,11 +88,11 @@ import {
} from "@/api/GaoAiAPI";
import AiConversationList from "@/pages/ai/components/AiConversationList.vue";
import { aiQuickQuestionList, loadAiQuickQuestions, refreshAiQuickQuestions } from "@/pages/ai/aiChatQuestions";
import { useNavBarStore } from "@/store/navBarStore";
import { getErrorMessage } from "@/utils/error";
import { Message } from "@/utils/message";
import { useUserStore } from "timi-web-api/store";
import { getErrorMessage } from "@/utils/error";
defineOptions({
name: "AiChatPanel"
});
@@ -108,7 +108,6 @@ const emit = defineEmits<{
"new-conversation": [];
}>();
const userStore = useUserStore();
const navBarStore = useNavBarStore();
type MessageListExpose = {
scrollToBottom: () => Promise<void>;
};
@@ -174,6 +173,11 @@ function openConversationList(): void {
}
}
defineExpose({
isBusy,
openConversationList
});
async function selectConversation(conversation: GaoAiConversation): Promise<void> {
if (isBusy.value || !conversation.id) {
return;
@@ -330,14 +334,9 @@ function isFailedConversationMessage(message: GaoAiConversationMessage): boolean
}
onMounted(async () => {
navBarStore.clearRight();
navBarStore.setRightText("历史", "var(--td-brand-color)", openConversationList);
await loadAiQuickQuestions();
});
watch(isBusy, value => navBarStore.setRightDisabled(value));
onUnmounted(() => navBarStore.clearRight());
</script>
<style scoped lang="less">
+18
View File
@@ -1,4 +1,11 @@
<template>
<t-navbar
fixed
:z-index="20"
:title="routeNavBarTitle"
left-arrow
@left-click="$router.back()"
/>
<div v-can="permissionCodes.stat.read" class="customer-data-charts-page">
<div class="filters glass">
<t-input
@@ -95,6 +102,17 @@ defineOptions({
});
const route = useRoute();
const routeNavBarTitle = computed(() => {
switch (route.name) {
case "CustomerDataCharts":
return "客户数据";
case "CustomerDataChartsFromCustomer":
return "客户数据图表";
default:
return "";
}
});
const router = useRouter();
// ---------- 路由 ----------
+122 -6
View File
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
title="客户详情"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div
v-if="customer"
v-can="permissionCodes.customer.read"
@@ -149,8 +194,6 @@ import CustomerProfileCard from "@/components/CustomerProfileCard.vue";
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
import TagSelector from "@/components/TagSelector.vue";
import CustomerTagCard from "@/pages/customer/component/CustomerTagCard.vue";
import { useNavBarStore } from "@/store/navBarStore";
import type { BodyAreaValue, Customer } from "@/types/Customer";
import type { PointAccount } from "@/types/Point";
import type { PhotoItem } from "@/types/Photo";
import type { GaoSalesOrderType } from "@/types/SalesOrder";
@@ -161,13 +204,45 @@ import { normalizeBodyAreaValue } from "@/utils/customer";
import { corePermissionCodes, permissionCodes } from "@/utils/permission";
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";
defineOptions({
name: "CustomerDetail"
});
const route = useRoute();
const router = useRouter();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const isRemoving = ref(false);
@@ -501,9 +576,9 @@ async function toCustomerDataCharts(): Promise<void> {
}
function updateNavBar(): void {
navBarStore.clearRight();
clearPageNavBarRight();
if (userStore.hasPermissions(permissionCodes.customer.update)) {
navBarStore.setRightText("编辑", "var(--td-brand-color)", toEdit);
setPageNavBarRightText("编辑", "var(--td-brand-color)", toEdit);
}
}
@@ -512,7 +587,7 @@ onMounted(async () => {
updateNavBar();
});
watch(() => route.params.id, loadCustomer);
onUnmounted(() => navBarStore.clearRight());
onUnmounted(() => clearPageNavBarRight());
</script>
<style scoped lang="less">
@@ -570,4 +645,45 @@ onUnmounted(() => navBarStore.clearRight());
}
}
.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>
+139 -8
View File
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
:title="routeNavBarTitle"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div v-can="savePermissionCode" class="customer-edit">
<t-form class="form" label-align="left" label-width="5rem" :disabled="isCustomerBound" v-entrance-transition>
<t-form-item label="客户编码">
@@ -236,8 +281,6 @@ import type { MediaSelectorAddAction } from "@/components/mediaSelector/types";
import TagSelector from "@/components/TagSelector.vue";
import CustomerTagCard from "@/pages/customer/component/CustomerTagCard.vue";
import { useCurrentStoreStore } from "@/store/currentStoreStore";
import { useNavBarStore } from "@/store/navBarStore";
import { useSettingStore } from "@/store/settingStore";
import type { BodyAreaValue, Customer, CustomerAttachmentType, EditableCustomerPhoto } from "@/types/Customer";
import type { Tag } from "@/types/Tag";
import { bodyAreaLabelMap } from "@/utils/bodyArea";
@@ -247,16 +290,63 @@ import { corePermissionCodes, gaoRoleCodes, permissionCodes } from "@/utils/perm
import { compressUploadImage } from "@/utils/imageCompression";
import { saveCapturedFilesFromInput } from "@/utils/twaBridge";
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";
defineOptions({
name: "CustomerEdit"
});
const route = useRoute();
const routeNavBarTitle = computed(() => {
switch (route.name) {
case "CustomerCreate":
return "新增客户";
case "CustomerEdit":
return "编辑客户";
default:
return "";
}
});
const router = useRouter();
const userStore = useUserStore();
const settingStore = useSettingStore();
const currentStoreStore = useCurrentStoreStore();
const navBarStore = useNavBarStore();
const isCreateMode = computed(() => route.name === "CustomerCreate");
const savePermissionCode = computed(() => isCreateMode.value ? permissionCodes.customer.create : permissionCodes.customer.update);
const hasCustomerDeletePermission = computed(() => userStore.hasPermissions(permissionCodes.customer.delete));
@@ -497,7 +587,7 @@ function handlePhotoAction(action: MediaSelectorAddAction): void {
}
watch(isCustomerBound, (value) => {
navBarStore.setRightDisabled(value);
setPageNavBarRightDisabled(value);
if (!value) {
return;
}
@@ -553,10 +643,10 @@ async function loadDetail() {
onMounted(loadDetail);
onMounted(() => {
navBarStore.clearRight();
clearPageNavBarRight();
if (userStore.hasPermissions(savePermissionCode.value)) {
navBarStore.setRightText("保存", "var(--td-brand-color)", doSubmit);
navBarStore.setRightDisabled(isCustomerBound.value);
setPageNavBarRightText("保存", "var(--td-brand-color)", doSubmit);
setPageNavBarRightDisabled(isCustomerBound.value);
}
});
@@ -741,7 +831,7 @@ async function toBoundCustomerEdit(): Promise<void> {
}
onUnmounted(() => {
navBarStore.clearRight();
clearPageNavBarRight();
});
function buildAttachmentList(): Attachment[] {
@@ -862,5 +952,46 @@ 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>
+53 -44
View File
@@ -1,49 +1,58 @@
<template>
<div v-can="permissionCodes.customer.read" class="customer-invite-rank">
<t-pull-down-refresh
class="list-wrapper"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadRanks"
>
<t-cell-group v-if="rankedCustomerList.length" class="list" theme="card">
<customer-cell
v-for="(item, index) in rankedCustomerList"
:key="item.id || item.code || index"
v-entrance-transition="{ step: 30 }"
class="item"
:class="{ 'in-top3': index < 3 }"
:customer="item"
arrow
hover
@click="toCustomerDetail(item)"
>
<template #note>
<div
class="rank"
:class="{
top1: index === 0,
top2: index === 1,
top3: index === 2
}"
v-text="String(index + 1)"
/>
</template>
<template #description>
<div class="description">
<t-tag
theme="primary"
variant="light-outline"
:content="getInvitedCountText(item)"
<div class="page-layout navbar customer-invite-rank">
<t-navbar
fixed
:z-index="20"
title="客户邀请排行"
left-arrow
@left-click="$router.back()"
/>
<main v-can="permissionCodes.customer.read" class="page-content scroll list">
<t-pull-down-refresh
class="list-wrapper pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadRanks"
>
<t-cell-group v-if="rankedCustomerList.length" class="list" theme="card">
<customer-cell
v-for="(item, index) in rankedCustomerList"
:key="item.id || item.code || index"
v-entrance-transition="{ step: 30 }"
class="item"
:class="{ 'in-top3': index < 3 }"
:customer="item"
arrow
hover
@click="toCustomerDetail(item)"
>
<template #note>
<div
class="rank"
:class="{
top1: index === 0,
top2: index === 1,
top3: index === 2
}"
v-text="String(index + 1)"
/>
</div>
</template>
</customer-cell>
</t-cell-group>
<div v-else class="center-tips" v-text="emptyText" />
<div v-if="rankedCustomerList.length" class="center-tips" v-text="loadStateText" />
</t-pull-down-refresh>
</template>
<template #description>
<div class="description">
<t-tag
theme="primary"
variant="light-outline"
:content="getInvitedCountText(item)"
/>
</div>
</template>
</customer-cell>
</t-cell-group>
<div v-else class="center-tips" v-text="emptyText" />
<div v-if="rankedCustomerList.length" class="center-tips" v-text="loadStateText" />
</t-pull-down-refresh>
</main>
</div>
</template>
+121 -5
View File
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
title="客户邀请关系"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div
v-can="permissionCodes.customer.read"
class="customer-invite-relation"
@@ -52,12 +97,43 @@ import { type PageResult, useUserStore } from "timi-web-api";
import CustomerAPI, { type CustomerPage } from "@/api/CustomerAPI";
import CustomerInviteRelationChart from "@/pages/customer/component/CustomerInviteRelationChart.vue";
import { useCurrentStoreStore } from "@/store/currentStoreStore";
import { useNavBarStore } from "@/store/navBarStore";
import type { Customer } from "@/types/Customer";
import { getErrorMessage } from "@/utils/error";
import { Message } from "@/utils/message";
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";
type InviteColorLegendItem = {
color: string;
label: string;
@@ -69,7 +145,6 @@ defineOptions({
const userStore = useUserStore();
const currentStoreStore = useCurrentStoreStore();
const navBarStore = useNavBarStore();
const router = useRouter();
const chartComponent = ref<InstanceType<typeof CustomerInviteRelationChart>>();
const customerList = ref<Customer[]>([]);
@@ -197,7 +272,7 @@ async function toInviteRank(): Promise<void> {
// ---------- 生命周期 ----------
onMounted(async () => {
navBarStore.setRightText("排行", "var(--td-brand-color)", toInviteRank);
setPageNavBarRightText("排行", "var(--td-brand-color)", toInviteRank);
await loadCustomers();
});
@@ -206,7 +281,7 @@ watch(searchKeyword, () => {
});
onBeforeUnmount(() => {
navBarStore.clearRight();
clearPageNavBarRight();
});
</script>
@@ -299,4 +374,45 @@ 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>
@@ -1,4 +1,11 @@
<template>
<t-navbar
fixed
:z-index="20"
title="邀请客户"
left-arrow
@left-click="$router.back()"
/>
<div v-can="permissionCodes.customer.read" class="customer-invitee-list">
<customer-profile-card
v-if="customer"
+227 -127
View File
@@ -1,132 +1,186 @@
<template>
<div v-can="permissionCodes.customer.read" class="customer-list">
<div class="filters glass">
<t-input
v-model.trim="keyword"
class="search"
placeholder="搜索编码、姓名(拼音)、电话"
borderless
>
<template #suffix-icon>
<t-button
size="extra-small"
theme="primary"
variant="outline"
@click.stop="toggleScanner"
>
<template #icon>
<t-icon name="scan" />
</template>
<span v-text="scannerVisible ? '关闭扫码' : '扫码'" />
</t-button>
</template>
</t-input>
<t-dropdown-menu ref="filterMenu" class="menus">
<t-dropdown-item
v-model="dateFilterType"
:label="dateFilterLabel"
:options="dateOptions"
@change="selectDateFilter"
/>
<t-dropdown-item
v-if="canReadTag"
:label="tagFilterText"
@open="handleTagFilterOpen"
/>
</t-dropdown-menu>
</div>
<div v-if="scannerVisible" class="scanner-wrapper">
<code-scanner
:visible="scannerVisible"
:status-text="scanStatus"
active-text="正在识别客户编码,请将条码或二维码移入取景框"
@decode="handleDecodedText"
@status-change="handleScanStatusChange"
/>
</div>
<div v-if="canReadTag && selectedTagList.length" class="selected-tags bg-white">
<t-tag
v-for="item in selectedTagList"
:key="item.id"
theme="primary"
variant="light-outline"
:content="getTagName(item)"
/>
<t-button size="extra-small" variant="text" @click="clearTagFilter">清空</t-button>
</div>
<t-pull-down-refresh
class="fix-last-cell-line"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="fetch"
<div class="page-layout navbar customer-list">
<t-navbar
fixed
:z-index="20"
title="客户管理"
left-arrow
@left-click="$router.back()"
>
<div class="list-wrap">
<t-cell-group class="summary" theme="card">
<t-cell
v-if="dateFilterType !== 'all'"
title="开始时间"
:note="dateRange[0] || '-'"
arrow
@click="openStartTime"
/>
<t-cell
v-if="dateFilterType !== 'all'"
title="结束时间"
:note="dateRange[1] || '-'"
arrow
@click="openEndTime"
/>
<t-cell v-if="keyword" title="关键词" :note="keyword" />
<t-cell v-if="selectedTagList.length" title="标签" :note="tagFilterText" />
<t-cell title="客户总数" :note="`${pageResult.total} 位`" />
</t-cell-group>
<t-cell-group class="items" theme="card">
<t-swipe-cell
v-entrance-transition="{ step: 30 }"
v-for="(item, index) in pageResult.list"
:key="item.id || item.code || index"
class="item"
<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"
>
<customer-cell
class="cell"
:customer="item"
arrow
@click="toDetail(item)"
<t-button
class="trigger"
variant="text"
:aria-label="'更多操作'"
type="button"
>
<template #description>
<telephone-link :value="item.telephone" />
<template #icon>
<t-icon name="ellipsis" />
</template>
</customer-cell>
<template v-if="canDeleteCustomer" #right>
</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>
</template>
</t-navbar>
<main v-can="permissionCodes.customer.read" class="page-content scroll list">
<t-pull-down-refresh
class="pull-refresh fix-last-cell-line"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="fetch"
>
<div class="filters glass">
<t-input
v-model.trim="keyword"
class="search"
placeholder="搜索编码、姓名(拼音)、电话"
borderless
>
<template #suffix-icon>
<t-button
class="delete"
theme="danger"
:loading="isRemoving && removingCustomerId === item.id"
@click.stop="openRemoveDialog(item)"
size="extra-small"
theme="primary"
variant="outline"
@click.stop="toggleScanner"
>
删除
<template #icon>
<t-icon name="scan" />
</template>
<span v-text="scannerVisible ? '关闭扫码' : '扫码'" />
</t-button>
</template>
</t-swipe-cell>
</t-cell-group>
<div v-if="!pageResult.list.length" class="center-tips" v-text="isLoading ? '正在加载客户' : '暂无客户数据'" />
<div v-if="pageResult.list.length" class="center-tips" v-text="isLoading ? '正在加载更多' : isNoMore ? '已经到底了' : '上拉加载更多'" />
</div>
</t-pull-down-refresh>
<tag-selector
v-model="selectedTagIdList"
v-model:visible="tagSelectorVisible"
@change="handleTagFilterChanged"
/>
<customer-remove-dialog
v-model:visible="removeDialogVisible"
:customer="removeTarget"
:loading="isRemoving"
@confirm="removeCustomer"
/>
</t-input>
<t-dropdown-menu ref="filterMenu" class="menus">
<t-dropdown-item
v-model="dateFilterType"
:label="dateFilterLabel"
:options="dateOptions"
@change="selectDateFilter"
/>
<t-dropdown-item
v-if="canReadTag"
:label="tagFilterText"
@open="handleTagFilterOpen"
/>
</t-dropdown-menu>
</div>
<div v-if="scannerVisible" class="scanner-wrapper">
<code-scanner
:visible="scannerVisible"
:status-text="scanStatus"
active-text="正在识别客户编码,请将条码或二维码移入取景框"
@decode="handleDecodedText"
@status-change="handleScanStatusChange"
/>
</div>
<div v-if="canReadTag && selectedTagList.length" class="selected-tags bg-white">
<t-tag
v-for="item in selectedTagList"
:key="item.id"
theme="primary"
variant="light-outline"
:content="getTagName(item)"
/>
<t-button size="extra-small" variant="text" @click="clearTagFilter">清空</t-button>
</div>
<div class="list-wrap">
<t-cell-group class="summary" theme="card">
<t-cell
v-if="dateFilterType !== 'all'"
title="开始时间"
:note="dateRange[0] || '-'"
arrow
@click="openStartTime"
/>
<t-cell
v-if="dateFilterType !== 'all'"
title="结束时间"
:note="dateRange[1] || '-'"
arrow
@click="openEndTime"
/>
<t-cell v-if="keyword" title="关键词" :note="keyword" />
<t-cell v-if="selectedTagList.length" title="标签" :note="tagFilterText" />
<t-cell title="客户总数" :note="`${pageResult.total} 位`" />
</t-cell-group>
<t-cell-group class="items" theme="card">
<t-swipe-cell
v-entrance-transition="{ step: 30 }"
v-for="(item, index) in pageResult.list"
:key="item.id || item.code || index"
class="item"
>
<customer-cell
class="cell"
:customer="item"
arrow
@click="toDetail(item)"
>
<template #description>
<telephone-link :value="item.telephone" />
</template>
</customer-cell>
<template v-if="canDeleteCustomer" #right>
<t-button
class="delete"
theme="danger"
:loading="isRemoving && removingCustomerId === item.id"
@click.stop="openRemoveDialog(item)"
>
删除
</t-button>
</template>
</t-swipe-cell>
</t-cell-group>
<div v-if="!pageResult.list.length" class="center-tips" v-text="isLoading ? '正在加载客户' : '暂无客户数据'" />
<div v-if="pageResult.list.length" class="center-tips" v-text="isLoading ? '正在加载更多' : isNoMore ? '已经到底了' : '上拉加载更多'" />
</div>
</t-pull-down-refresh>
<tag-selector
v-model="selectedTagIdList"
v-model:visible="tagSelectorVisible"
@change="handleTagFilterChanged"
/>
<customer-remove-dialog
v-model:visible="removeDialogVisible"
:customer="removeTarget"
:loading="isRemoving"
@confirm="removeCustomer"
/>
</main>
</div>
<nav-bar-action-menu v-if="canShowActionMenu" :actions="actionList" />
<t-popup v-model="startVisible" placement="bottom">
<t-date-time-picker
v-if="startVisible"
@@ -154,6 +208,7 @@
</template>
<script setup lang="ts">
import type { NavBarAction } from "@/types/NavBarAction";
import type { DropdownValue } from "tdesign-mobile-vue";
import { Message } from "@/utils/message";
import { Time, Toolkit, WebToolkit } from "timi-web";
@@ -163,14 +218,21 @@ import CodeScanner from "@/components/CodeScanner.vue";
import CustomerRemoveDialog from "@/pages/customer/component/CustomerRemoveDialog.vue";
import TagSelector from "@/components/TagSelector.vue";
import { useCurrentStoreStore } from "@/store/currentStoreStore";
import { useNavBarStore } from "@/store/navBarStore";
import { useSettingStore } from "@/store/settingStore";
import type { Customer } from "@/types/Customer";
import type { NavBarAction } from "@/types/NavBarAction";
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({
name: "CustomerList"
});
@@ -181,7 +243,6 @@ const router = useRouter();
const userStore = useUserStore();
const currentStoreStore = useCurrentStoreStore();
const settingStore = useSettingStore();
const navBarStore = useNavBarStore();
const isRefreshing = ref(false);
const isExporting = ref(false);
const isRemoving = ref(false);
@@ -409,8 +470,7 @@ async function loadData(): Promise<void> {
onMounted(loadData);
onMounted(() => {
navBarStore.clearRight();
navBarStore.setCustomRightVisible(canShowActionMenu.value);
});
watch(keyword, async () => {
@@ -421,7 +481,6 @@ watch(keyword, async () => {
});
onUnmounted(() => {
navBarStore.clearRight();
window.clearTimeout(keywordTimer);
scannerVisible.value = false;
});
@@ -504,7 +563,6 @@ function buildCreatedAtRange(): [number | undefined, number | undefined] {
<style scoped lang="less">
.customer-list {
padding: var(--app-nav-height) 0 1rem 0;
.filters {
top: var(--app-nav-height);
@@ -641,4 +699,46 @@ 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>
+7
View File
@@ -1,4 +1,11 @@
<template>
<t-navbar
fixed
:z-index="20"
title="生成二维码"
left-arrow
@left-click="$router.back()"
/>
<div v-can="permissionCodes.qrCode.create" class="qr-page">
<t-form class="form" label-align="left" v-entrance-transition>
<t-form-item label="编码前缀">
+124 -8
View File
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
title="登记事件详情"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div
v-can="permissionCodes.event.read"
class="registration-event-detail"
@@ -128,20 +173,50 @@ import EventAPI from "@/api/EventAPI";
import EventOptionSelector from "@/components/EventOptionSelector.vue";
import EventRemoveDialog from "@/pages/event/component/EventRemoveDialog.vue";
import { useCurrentStoreStore } from "@/store/currentStoreStore";
import { useNavBarStore } from "@/store/navBarStore";
import type { EventItem, EventLimitType, EventOptionSelectionMap, EventStatus, EventValueType, EventValueUnit } from "@/types/EventItem";
import { getEventBizTypeText, isPackagePurchaseEvent } from "@/utils/event";
import { formatPackageAmount, getPackageConfigStatusText } from "@/utils/package";
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
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";
defineOptions({
name: "EventDetail"
});
const route = useRoute();
const router = useRouter();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const currentStoreStore = useCurrentStoreStore();
const moduleCode: ModuleCode = "GAO";
@@ -365,21 +440,21 @@ watch(() => route.params.id, async () => {
}, { immediate: true });
onMounted(() => {
navBarStore.clearRight();
clearPageNavBarRight();
if (canUpdate.value) {
navBarStore.setRightText("编辑", "var(--td-brand-color)", toEdit);
setPageNavBarRightText("编辑", "var(--td-brand-color)", toEdit);
}
});
watch(canUpdate, value => {
navBarStore.clearRight();
clearPageNavBarRight();
if (value) {
navBarStore.setRightText("编辑", "var(--td-brand-color)", toEdit);
setPageNavBarRightText("编辑", "var(--td-brand-color)", toEdit);
}
});
onUnmounted(() => {
navBarStore.clearRight();
clearPageNavBarRight();
});
</script>
@@ -467,4 +542,45 @@ onUnmounted(() => {
.option-popup {
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>
+133 -6
View File
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
:title="routeNavBarTitle"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div v-can="pageAccess" class="event-edit">
<t-form class="form" label-align="left" label-width="7rem" v-entrance-transition>
<t-form-item label="颜色">
@@ -232,14 +277,45 @@ import type { ColorObject } from "tdesign-mobile-vue";
import EventAPI from "@/api/EventAPI";
import EventOptionEditor from "@/pages/event/component/EventOptionEditor.vue";
import { useCurrentStoreStore } from "@/store/currentStoreStore";
import { useNavBarStore } from "@/store/navBarStore";
import type { EventBizType, EventItem, EventLimitType, EventOptionGroup, EventStatus, EventValueType, EventValueUnit } from "@/types/EventItem";
import { getErrorMessage } from "@/utils/error";
import { normalizeEventOptionGroupList, prepareEventOptionGroupList, validateEventOptionGroupList } from "@/utils/eventOption";
import { getEventBizTypeText } from "@/utils/event";
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
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";
type PickerValue = string | number;
type LimitOption = {
@@ -252,8 +328,18 @@ defineOptions({
});
const route = useRoute();
const routeNavBarTitle = computed(() => {
switch (route.name) {
case "EventCreate":
return "新增登记事件";
case "EventEdit":
return "编辑登记事件";
default:
return "";
}
});
const router = useRouter();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const currentStoreStore = useCurrentStoreStore();
const routeId = computed(() => String(route.params.id || ""));
@@ -724,9 +810,9 @@ async function fillForm(): Promise<void> {
}
onMounted(async () => {
navBarStore.clearRight();
clearPageNavBarRight();
if (userStore.hasPermissions(savePermissionCode.value)) {
navBarStore.setRightText("保存", "var(--td-brand-color)", saveEventItem);
setPageNavBarRightText("保存", "var(--td-brand-color)", saveEventItem);
}
try {
await fillForm();
@@ -735,7 +821,7 @@ onMounted(async () => {
}
});
onUnmounted(() => navBarStore.clearRight());
onUnmounted(() => clearPageNavBarRight());
</script>
<style scoped lang="less">
@@ -903,4 +989,45 @@ onUnmounted(() => navBarStore.clearRight());
}
}
}
.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>
+183 -81
View File
@@ -1,107 +1,169 @@
<template>
<div
v-can="{ value: [permissionCodes.event.read, permissionCodes.user.read], mode: 'and' }"
class="registration-event-list"
>
<t-pull-down-refresh
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="fetch"
<div class="page-layout navbar registration-event-list">
<t-navbar
fixed
:z-index="20"
title="登记事件管理"
left-arrow
@left-click="$router.back()"
>
<t-cell-group class="fix-last-cell-line" theme="card">
<t-swipe-cell
v-entrance-transition="{ step: 30 }"
v-for="item in visibleEventList"
:key="item.id"
class="item"
<template #right>
<div
class="nav-actions"
v-if="(canShowActionMenu) && pageNavBarActionList.length"
>
<t-cell
class="cell"
:arrow="!!item.id"
:hover="!!item.id"
@click="toEventItem(item)"
<t-popover
v-model:visible="pageNavBarActionVisible"
placement="bottom-right"
:show-arrow="false"
theme="light"
>
<template #title>
<div class="header">
<div class="color" :style="{ background: item.color || defaultColor }" />
<div class="title" v-text="item.name || '未命名事件'" />
<t-tag
class="status"
:theme="getStatusTag(item).theme"
variant="outline"
:content="getStatusTag(item).text"
/>
<t-tag v-if="item.requirePhoto" theme="warning" variant="outline">需拍照</t-tag>
<t-tag v-if="item.requireVerification" theme="warning" variant="outline">需核销</t-tag>
<t-tag v-if="item.bizType === 'PACKAGE_PURCHASE'" theme="primary" variant="outline">套餐购买</t-tag>
<t-tag v-if="item.bizType === 'LEGACY_CONSUMPTION'" theme="default" variant="outline">历史消费</t-tag>
</div>
</template>
<template #description>
<div class="description">
<div class="line">
<span>可登记角色</span>
<t-tag
v-for="roleCode in item.roleCodeList"
:key="roleCode"
theme="primary"
variant="light-outline"
:content="getRoleName(roleCode)"
/>
<span v-if="!(item.roleCodeList || []).length" class="muted" v-text="'未配置'" />
</div>
<div class="line" v-text="getLimitText(item)" />
<div class="line" v-text="`${getEventBizTypeText(item.bizType)}|${getValueDefinitionText(item)}`" />
<div v-if="item.bizType === 'PACKAGE_PURCHASE'" class="line" v-text="`绑定套餐:${item.packageConfig?.name || '未配置'}`" />
</div>
</template>
</t-cell>
<template v-if="canDeleteEvent && item.status !== 'DELETED'" #right>
<t-button
class="delete"
theme="danger"
:loading="isRemoving && removingEventId === item.id"
@click.stop="openRemoveDialog(item)"
class="trigger"
variant="text"
:aria-label="'更多操作'"
type="button"
>
删除
<template #icon>
<t-icon name="ellipsis" />
</template>
</t-button>
</template>
</t-swipe-cell>
</t-cell-group>
<div v-if="!visibleEventList.length" class="empty-block" v-text="emptyText" />
<div v-if="visibleEventList.length" class="center-tips" v-text="isNoMore ? '已经到底了' : '上拉加载更多'" />
</t-pull-down-refresh>
<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>
</template>
</t-navbar>
<main
v-can="{ value: [permissionCodes.event.read, permissionCodes.user.read], mode: 'and' }"
class="page-content scroll list"
>
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="fetch"
>
<t-cell-group class="fix-last-cell-line" theme="card">
<t-swipe-cell
v-entrance-transition="{ step: 30 }"
v-for="item in visibleEventList"
:key="item.id"
class="item"
>
<t-cell
class="cell"
:arrow="!!item.id"
:hover="!!item.id"
@click="toEventItem(item)"
>
<template #title>
<div class="header">
<div class="color" :style="{ background: item.color || defaultColor }" />
<div class="title" v-text="item.name || '未命名事件'" />
<t-tag
class="status"
:theme="getStatusTag(item).theme"
variant="outline"
:content="getStatusTag(item).text"
/>
<t-tag v-if="item.requirePhoto" theme="warning" variant="outline">需拍照</t-tag>
<t-tag v-if="item.requireVerification" theme="warning" variant="outline">需核销</t-tag>
<t-tag v-if="item.bizType === 'PACKAGE_PURCHASE'" theme="primary" variant="outline">套餐购买</t-tag>
<t-tag v-if="item.bizType === 'LEGACY_CONSUMPTION'" theme="default" variant="outline">历史消费</t-tag>
</div>
</template>
<template #description>
<div class="description">
<div class="line">
<span>可登记角色</span>
<t-tag
v-for="roleCode in item.roleCodeList"
:key="roleCode"
theme="primary"
variant="light-outline"
:content="getRoleName(roleCode)"
/>
<span v-if="!(item.roleCodeList || []).length" class="muted" v-text="'未配置'" />
</div>
<div class="line" v-text="getLimitText(item)" />
<div class="line" v-text="`${getEventBizTypeText(item.bizType)}|${getValueDefinitionText(item)}`" />
<div v-if="item.bizType === 'PACKAGE_PURCHASE'" class="line" v-text="`绑定套餐:${item.packageConfig?.name || '未配置'}`" />
</div>
</template>
</t-cell>
<template v-if="canDeleteEvent && item.status !== 'DELETED'" #right>
<t-button
class="delete"
theme="danger"
:loading="isRemoving && removingEventId === item.id"
@click.stop="openRemoveDialog(item)"
>
删除
</t-button>
</template>
</t-swipe-cell>
</t-cell-group>
<div v-if="!visibleEventList.length" class="empty-block" v-text="emptyText" />
<div v-if="visibleEventList.length" class="center-tips" v-text="isNoMore ? '已经到底了' : '上拉加载更多'" />
</t-pull-down-refresh>
</main>
<event-remove-dialog
v-model:visible="removeDialogVisible"
:event="removeTarget"
:loading="isRemoving"
@confirm="removeEvent"
/>
</div>
<nav-bar-action-menu v-if="canShowActionMenu" :actions="actionList" />
<event-remove-dialog
v-model:visible="removeDialogVisible"
:event="removeTarget"
:loading="isRemoving"
@confirm="removeEvent"
/>
</template>
<script setup lang="ts">
import type { NavBarAction } from "@/types/NavBarAction";
import { Message } from "@/utils/message";
import { type Page, type PageResult, type Role, useUserStore } from "timi-web-api";
import EventAPI from "@/api/EventAPI";
import EventRemoveDialog from "@/pages/event/component/EventRemoveDialog.vue";
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 { 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";
defineOptions({
name: "eventList"
});
const router = useRouter();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const currentStoreStore = useCurrentStoreStore();
@@ -336,8 +398,7 @@ async function toSort(): Promise<void> {
}
onMounted(async () => {
navBarStore.clearRight();
navBarStore.setCustomRightVisible(canShowActionMenu.value);
try {
await loadData();
} catch {
@@ -346,7 +407,6 @@ onMounted(async () => {
});
onUnmounted(() => {
navBarStore.clearRight();
});
</script>
@@ -418,4 +478,46 @@ 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>
+122 -6
View File
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
title="登记事件记录详情"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div v-can="permissionCodes.eventRecord.read" class="event-record-detail">
<customer-profile-card
v-entrance-transition
@@ -105,8 +150,6 @@ import CustomerProfileCard from "@/components/CustomerProfileCard.vue";
import EventOptionSelector from "@/components/EventOptionSelector.vue";
import EventRecordVerifyDialog from "@/components/EventRecordVerifyDialog.vue";
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
import { useNavBarStore } from "@/store/navBarStore";
import type { EventRecord } from "@/types/EventRecord";
import type { PhotoItem } from "@/types/Photo";
import type { PointLedgerChangeType } from "@/types/Point";
import { getAttachmentReadURL } from "@/utils/attachment";
@@ -117,13 +160,45 @@ import { formatEventNumberValue } from "@/utils/eventValue";
import { Message } from "@/utils/message";
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";
defineOptions({
name: "EventRecordDetail"
});
const route = useRoute();
const router = useRouter();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
// ---------- 记录数据 ----------
@@ -383,16 +458,16 @@ watch(() => route.params.id, async () => {
}, { immediate: true });
function updateNavBarAction(): void {
navBarStore.clearRight();
clearPageNavBarRight();
if (canUpdateRecord.value) {
navBarStore.setRightText("编辑", "var(--td-brand-color)", toEdit);
setPageNavBarRightText("编辑", "var(--td-brand-color)", toEdit);
}
}
watch(canUpdateRecord, updateNavBarAction, { immediate: true });
onUnmounted(() => {
navBarStore.clearRight();
clearPageNavBarRight();
});
</script>
@@ -435,5 +510,46 @@ 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>
+135 -6
View File
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
:title="routeNavBarTitle"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div v-can="pageAccess" class="registration-record-edit">
<t-form class="form" label-align="left" v-entrance-transition>
<t-form-item label="客户" required-mark>
@@ -222,8 +267,6 @@ import EventOptionSelector from "@/components/EventOptionSelector.vue";
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
import EventSelector from "@/components/EventSelector.vue";
import { useEventRecordPhoto } from "@/pages/event/component/useEventRecordPhoto";
import { useNavBarStore } from "@/store/navBarStore";
import { useSettingStore } from "@/store/settingStore";
import type { Customer } from "@/types/Customer";
import type { EventItem, EventOptionSelectionMap } from "@/types/EventItem";
import type { EventRecord } from "@/types/EventRecord";
@@ -233,15 +276,60 @@ import { getEventRecordPhotoURL, hasPhotoAttachment } from "@/utils/eventRecord"
import { getEventNumberValuePlaceholder, resolveEventNumberValue } from "@/utils/eventValue";
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";
defineOptions({
name: "EventRecordEdit"
});
const router = useRouter();
const route = useRoute();
const routeNavBarTitle = computed(() => {
switch (route.name) {
case "CustomerEventRecordCreate":
return "登记";
case "EventRecordCreate":
return "新增登记事件记录";
case "EventRecordEdit":
return "编辑登记事件记录";
default:
return "";
}
});
const settingStore = useSettingStore();
const userStore = useUserStore();
const navBarStore = useNavBarStore();
// ---------- 路由权限 ----------
@@ -712,14 +800,14 @@ async function loadRecordForEdit(): Promise<void> {
onMounted(loadPageData);
onMounted(() => {
navBarStore.clearRight();
clearPageNavBarRight();
if (userStore.hasPermissions(pageAccess.value)) {
navBarStore.setRightText(saveButtonText.value, "var(--td-brand-color)", submitRecord);
setPageNavBarRightText(saveButtonText.value, "var(--td-brand-color)", submitRecord);
}
});
onUnmounted(() => {
navBarStore.clearRight();
clearPageNavBarRight();
});
watch(customerCode, async (value) => {
@@ -889,4 +977,45 @@ 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>
+240 -138
View File
@@ -1,141 +1,197 @@
<template>
<div v-can="permissionCodes.eventRecord.read" class="registration-record-list">
<div class="filters glass">
<div class="search-date">
<t-input
v-model.trim="keyword"
class="search-input"
type="search"
borderless
placeholder="搜索客户、姓名拼音、编码、事件、备注、登记人"
>
<template #suffix-icon>
<t-button
size="extra-small"
theme="primary"
variant="outline"
content="选择客户"
@click.stop="customerSelectorVisible = true"
/>
</template>
</t-input>
<t-dropdown-menu class="date-filter">
<t-dropdown-item
v-model="dateFilterType"
:label="dateFilterLabel"
:options="dateOptions"
@change="selectDateFilter"
/>
</t-dropdown-menu>
</div>
<t-dropdown-menu class="filter-menu">
<t-dropdown-item
v-model="actionFilter"
:label="eventFilterLabel"
options-columns="2"
:options="actionOptions"
multiple
/>
<t-dropdown-item
v-model="verificationFilter"
:label="verificationFilterLabel"
:options="verificationOptions"
/>
<t-dropdown-item
v-model="optionFilter"
:label="optionFilterLabel"
:footer="!optionFilterOptions.length ? optionFilterUnavailableFooter : undefined"
options-columns="2"
:options="optionFilterOptions"
multiple
/>
</t-dropdown-menu>
</div>
<t-pull-down-refresh
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="reloadRecords"
@scrolltolower="loadRecords"
<div class="page-layout navbar registration-record-list">
<t-navbar
fixed
:z-index="20"
title="登记事件记录管理"
left-arrow
@left-click="$router.back()"
>
<div class="list-wrapper">
<t-cell-group v-entrance-transition class="summary" theme="card">
<t-cell
title="开始时间"
:note="dateRange[0] || '-'"
arrow
@click="openStartTime"
/>
<t-cell
title="结束时间"
:note="dateRange[1] || '-'"
arrow
@click="openEndTime"
/>
<t-cell title="事件" :note="eventFilterLabel" />
<t-cell v-if="optionFilterLabel !== '全部选项'" title="选项" :note="optionFilterLabel" />
<t-cell title="记录数" :note="Text.display(pageResult.total)" />
<t-cell title="客户数" :note="Text.display(pageResult.customerCount)" />
<t-cell v-if="summaryNumberValueText" title="数值合计" :note="summaryNumberValueText" />
</t-cell-group>
<t-cell-group v-if="hasSelectedOption && optionStatList.length" title="选项统计" class="option-stat" theme="card">
<t-cell
v-for="item in optionStatList"
:key="`${item.groupId}-${item.optionId}`"
:title="`${item.groupName || '选项组'}:${item.optionLabel || '未命名选项'}`"
:note="`${item.recordCount || 0} 条`"
/>
</t-cell-group>
<t-cell-group
v-if="pageResult.list.length"
class="record-list"
theme="card"
<template #right>
<div
class="nav-actions"
v-if="(canShowActionMenu) && pageNavBarActionList.length"
>
<event-record-cell
v-entrance-transition="{ step: 30 }"
v-for="item in pageResult.list"
:key="item.id"
:record="item"
@updated="reloadRecords"
/>
</t-cell-group>
<div v-else class="center-tips" v-text="isLoading ? '正在加载登记事件记录' : '暂无登记事件记录'" />
<div v-if="pageResult.list.length" class="center-tips" v-text="loadStateText" />
</div>
</t-pull-down-refresh>
<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>
</template>
</t-navbar>
<main v-can="permissionCodes.eventRecord.read" class="page-content scroll list">
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="reloadRecords"
@scrolltolower="loadRecords"
>
<div class="filters glass">
<div class="search-date">
<t-input
v-model.trim="keyword"
class="search-input"
type="search"
borderless
placeholder="搜索客户、姓名拼音、编码、事件、备注、登记人"
>
<template #suffix-icon>
<t-button
size="extra-small"
theme="primary"
variant="outline"
content="选择客户"
@click.stop="customerSelectorVisible = true"
/>
</template>
</t-input>
<t-dropdown-menu class="date-filter">
<t-dropdown-item
v-model="dateFilterType"
:label="dateFilterLabel"
:options="dateOptions"
@change="selectDateFilter"
/>
</t-dropdown-menu>
</div>
<t-dropdown-menu class="filter-menu">
<t-dropdown-item
v-model="actionFilter"
:label="eventFilterLabel"
options-columns="2"
:options="actionOptions"
multiple
/>
<t-dropdown-item
v-model="verificationFilter"
:label="verificationFilterLabel"
:options="verificationOptions"
/>
<t-dropdown-item
v-model="optionFilter"
:label="optionFilterLabel"
:footer="!optionFilterOptions.length ? optionFilterUnavailableFooter : undefined"
options-columns="2"
:options="optionFilterOptions"
multiple
/>
</t-dropdown-menu>
</div>
<div class="list-wrapper">
<t-cell-group v-entrance-transition class="summary" theme="card">
<t-cell
title="开始时间"
:note="dateRange[0] || '-'"
arrow
@click="openStartTime"
/>
<t-cell
title="结束时间"
:note="dateRange[1] || '-'"
arrow
@click="openEndTime"
/>
<t-cell title="事件" :note="eventFilterLabel" />
<t-cell v-if="optionFilterLabel !== '全部选项'" title="选项" :note="optionFilterLabel" />
<t-cell title="记录数" :note="Text.display(pageResult.total)" />
<t-cell title="客户数" :note="Text.display(pageResult.customerCount)" />
<t-cell v-if="summaryNumberValueText" title="数值合计" :note="summaryNumberValueText" />
</t-cell-group>
<t-cell-group v-if="hasSelectedOption && optionStatList.length" title="选项统计" class="option-stat" theme="card">
<t-cell
v-for="item in optionStatList"
:key="`${item.groupId}-${item.optionId}`"
:title="`${item.groupName || '选项组'}:${item.optionLabel || '未命名选项'}`"
:note="`${item.recordCount || 0} 条`"
/>
</t-cell-group>
<t-cell-group
v-if="pageResult.list.length"
class="record-list"
theme="card"
>
<event-record-cell
v-entrance-transition="{ step: 30 }"
v-for="item in pageResult.list"
:key="item.id"
:record="item"
@updated="reloadRecords"
/>
</t-cell-group>
<div v-else class="center-tips" v-text="isLoading ? '正在加载登记事件记录' : '暂无登记事件记录'" />
<div v-if="pageResult.list.length" class="center-tips" v-text="loadStateText" />
</div>
</t-pull-down-refresh>
</main>
<customer-selector
v-model="customerId"
v-model:visible="customerSelectorVisible"
@change="handleCustomerChange"
/>
<t-popup v-model="startVisible" placement="bottom">
<t-date-time-picker
v-if="startVisible"
v-model="startDraft"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="开始时间"
:default-value="dateRange[0]"
@cancel="cancelStartTime"
@confirm="confirmStartTime"
/>
</t-popup>
<t-popup v-model="endVisible" placement="bottom">
<t-date-time-picker
v-if="endVisible"
v-model="endDraft"
:mode="['date', 'minute']"
format="YYYY-MM-DD HH:mm"
title="结束时间"
:default-value="dateRange[1]"
@cancel="cancelEndTime"
@confirm="confirmEndTime"
/>
</t-popup>
</div>
<nav-bar-action-menu v-if="canShowActionMenu" :actions="actionList" />
<customer-selector
v-model="customerId"
v-model:visible="customerSelectorVisible"
@change="handleCustomerChange"
/>
<t-popup v-model="startVisible" placement="bottom">
<t-date-time-picker
v-if="startVisible"
v-model="startDraft"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="开始时间"
:default-value="dateRange[0]"
@cancel="cancelStartTime"
@confirm="confirmStartTime"
/>
</t-popup>
<t-popup v-model="endVisible" placement="bottom">
<t-date-time-picker
v-if="endVisible"
v-model="endDraft"
:mode="['date', 'minute']"
format="YYYY-MM-DD HH:mm"
title="结束时间"
:default-value="dateRange[1]"
@cancel="cancelEndTime"
@confirm="confirmEndTime"
/>
</t-popup>
</template>
<script setup lang="ts">
import type { NavBarAction } from "@/types/NavBarAction";
import type { DropdownValue } from "tdesign-mobile-vue";
import { Time, Text, WebToolkit } from "timi-web";
import { useUserStore } from "timi-web-api";
@@ -143,16 +199,23 @@ import EventAPI from "@/api/EventAPI";
import EventRecordAPI from "@/api/EventRecordAPI";
import CustomerSelector from "@/components/CustomerSelector.vue";
import EventRecordCell from "@/pages/event/component/EventRecordCell.vue";
import { useNavBarStore } from "@/store/navBarStore";
import type { EventItem, EventStatus } from "@/types/EventItem";
import type { EventOptionStat, EventRecordPage, EventRecordPageResult, VerificationStatus } from "@/types/EventRecord";
import type { NavBarAction } from "@/types/NavBarAction";
import { isRetiredEvent } from "@/utils/event";
import { formatEventNumberValue } from "@/utils/eventValue";
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
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";
type VerificationFilter = "ALL" | VerificationStatus;
@@ -163,7 +226,6 @@ defineOptions({
const pageSize = 20;
const route = useRoute();
const router = useRouter();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const dateOptions: Array<{ label: string; value: DateFilterType }> = [
{ label: "今天", value: "today" },
@@ -669,15 +731,13 @@ function buildUnixRange(): [number, number] {
}
onMounted(async () => {
navBarStore.clearRight();
navBarStore.setCustomRightVisible(canShowActionMenu.value);
await loadActions();
initialized = true;
await reloadRecords();
});
onUnmounted(() => {
navBarStore.clearRight();
window.clearTimeout(keywordTimer);
});
</script>
@@ -805,4 +865,46 @@ 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>
+129 -120
View File
@@ -1,127 +1,136 @@
<template>
<div v-can="permissionCodes.stat.read" class="event-record-rank">
<div class="filters">
<t-dropdown-menu class="filter-menu">
<t-dropdown-item
v-model="rankType"
:label="rankTypeLabel"
:options="rankTypeOptions"
@change="selectRankType"
/>
<t-dropdown-item
v-model="dateFilterType"
:label="dateFilterLabel"
:options="dateOptions"
@change="selectDateFilter"
/>
<t-dropdown-item
v-model="eventFilter"
:label="eventFilterLabel"
options-columns="2"
:options="eventOptions"
multiple
/>
</t-dropdown-menu>
</div>
<t-cell-group v-if="isCustomRange" class="time-range" theme="card">
<t-cell
title="开始时间"
:note="dateRange[0] || '-'"
@click="startVisible = true"
/>
<t-cell
title="结束时间"
:note="dateRange[1] || '-'"
@click="endVisible = true"
/>
</t-cell-group>
<t-pull-down-refresh
class="list-wrapper"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="reloadRanks"
@scrolltolower="loadRanks"
>
<t-cell-group
v-if="pageResult.list.length"
class="list"
theme="card"
<div class="page-layout navbar event-record-rank">
<t-navbar
fixed
:z-index="20"
title="登记记录排行"
left-arrow
@left-click="$router.back()"
/>
<main v-can="permissionCodes.stat.read" class="page-content scroll list">
<t-pull-down-refresh
class="list-wrapper pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="reloadRanks"
@scrolltolower="loadRanks"
>
<customer-cell
v-entrance-transition="{ step: 30 }"
v-for="(item, index) in pageResult.list"
:key="item.customerId"
class="item"
:class="{ 'in-top3': index < 3}"
arrow
@click="toCustomerDetail(item.customerId || '')"
:customer="item.customer"
>
<template #note>
<div
class="rank"
:class="{
top1: index === 0,
top2: index === 1,
top3: index === 2,
}"
v-text="index + 1"
/>
</template>
<template #description>
<div class="description">
<t-tag
v-if="rankType === 'TOTAL_DAYS'"
size="small"
variant="outline"
:content="`累计天数 ${item.totalEventDays || 0}`"
<div class="filters">
<t-dropdown-menu class="filter-menu">
<t-dropdown-item
v-model="rankType"
:label="rankTypeLabel"
:options="rankTypeOptions"
@change="selectRankType"
/>
<t-dropdown-item
v-model="dateFilterType"
:label="dateFilterLabel"
:options="dateOptions"
@change="selectDateFilter"
/>
<t-dropdown-item
v-model="eventFilter"
:label="eventFilterLabel"
options-columns="2"
:options="eventOptions"
multiple
/>
</t-dropdown-menu>
</div>
<t-cell-group v-if="isCustomRange" class="time-range" theme="card">
<t-cell
title="开始时间"
:note="dateRange[0] || '-'"
@click="startVisible = true"
/>
<t-cell
title="结束时间"
:note="dateRange[1] || '-'"
@click="endVisible = true"
/>
</t-cell-group>
<t-cell-group
v-if="pageResult.list.length"
class="list"
theme="card"
>
<customer-cell
v-entrance-transition="{ step: 30 }"
v-for="(item, index) in pageResult.list"
:key="item.customerId"
class="item"
:class="{ 'in-top3': index < 3}"
arrow
@click="toCustomerDetail(item.customerId || '')"
:customer="item.customer"
>
<template #note>
<div
class="rank"
:class="{
top1: index === 0,
top2: index === 1,
top3: index === 2,
}"
v-text="index + 1"
/>
<t-tag
v-else-if="rankType === 'TOTAL_COUNT'"
size="small"
variant="outline"
:content="`累计次数 ${item.totalEventCount || 0}`"
/>
<t-tag
v-else-if="rankType === 'CONTINUOUS_DAYS'"
size="small"
variant="outline"
:content="`连续天数 ${item.recentContinuousEventDays || 0}`"
/>
<t-tag
v-else
size="small"
variant="outline"
:content="`登记数值 ${getTotalNumberValueText(item)}`"
/>
</div>
</template>
</customer-cell>
</t-cell-group>
<div v-else class="center-tips" v-text="emptyStateText" />
<div v-if="pageResult.list.length" class="center-tips" v-text="loadStateText" />
</t-pull-down-refresh>
</template>
<template #description>
<div class="description">
<t-tag
v-if="rankType === 'TOTAL_DAYS'"
size="small"
variant="outline"
:content="`累计天数 ${item.totalEventDays || 0}`"
/>
<t-tag
v-else-if="rankType === 'TOTAL_COUNT'"
size="small"
variant="outline"
:content="`累计次数 ${item.totalEventCount || 0}`"
/>
<t-tag
v-else-if="rankType === 'CONTINUOUS_DAYS'"
size="small"
variant="outline"
:content="`连续天数 ${item.recentContinuousEventDays || 0}`"
/>
<t-tag
v-else
size="small"
variant="outline"
:content="`登记数值 ${getTotalNumberValueText(item)}`"
/>
</div>
</template>
</customer-cell>
</t-cell-group>
<div v-else class="center-tips" v-text="emptyStateText" />
<div v-if="pageResult.list.length" class="center-tips" v-text="loadStateText" />
</t-pull-down-refresh>
</main>
<t-popup v-model="startVisible" placement="bottom">
<t-date-time-picker
v-model="dateRange[0]"
:default-value="dateRange[0]"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="开始时间"
@confirm="startVisible = false"
/>
</t-popup>
<t-popup v-model="endVisible" placement="bottom">
<t-date-time-picker
v-model="dateRange[1]"
:default-value="dateRange[1]"
:mode="['date', 'minute']"
format="YYYY-MM-DD HH:mm"
title="结束时间"
@confirm="endVisible = false"
/>
</t-popup>
</div>
<t-popup v-model="startVisible" placement="bottom">
<t-date-time-picker
v-model="dateRange[0]"
:default-value="dateRange[0]"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="开始时间"
@confirm="startVisible = false"
/>
</t-popup>
<t-popup v-model="endVisible" placement="bottom">
<t-date-time-picker
v-model="dateRange[1]"
:default-value="dateRange[1]"
:mode="['date', 'minute']"
format="YYYY-MM-DD HH:mm"
title="结束时间"
@confirm="endVisible = false"
/>
</t-popup>
</template>
<script setup lang="ts">
+122 -7
View File
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
title="登记事件排序"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div v-can="permissionCodes.event.update" class="registration-event-sort">
<div class="tip" v-text="'按住右侧拖动手柄调整事件顺序,保存后生效'" v-entrance-transition />
<div class="items">
@@ -52,16 +97,45 @@
import { type TagProps } from "tdesign-mobile-vue";
import { VueDraggableNext } from "vue-draggable-next";
import EventAPI from "@/api/EventAPI";
import { useNavBarStore } from "@/store/navBarStore";
import type { EventItem, EventStatus } from "@/types/EventItem";
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";
defineOptions({
name: "EventSort"
});
const navBarStore = useNavBarStore();
const router = useRouter();
// ---------- 列表数据 ----------
@@ -147,8 +221,8 @@ async function loadData(): Promise<void> {
}
onMounted(async () => {
navBarStore.clearRight();
navBarStore.setRightText("保存", "var(--td-brand-color)", saveSort);
clearPageNavBarRight();
setPageNavBarRightText("保存", "var(--td-brand-color)", saveSort);
try {
await loadData();
} catch {
@@ -157,7 +231,7 @@ onMounted(async () => {
});
onUnmounted(() => {
navBarStore.clearRight();
clearPageNavBarRight();
});
</script>
@@ -238,4 +312,45 @@ 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>
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
title="跟进提醒详情"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div v-can="permissionCodes.customerFollowUpReminder.read" class="follow-up-reminder-detail">
<t-empty v-if="!detail" :description="isLoading ? '正在加载跟进提醒' : '跟进提醒不存在'" />
<template v-else>
@@ -89,12 +134,43 @@ import { getErrorMessage } from "@/utils/error";
import FollowUpReminderAPI from "@/api/FollowUpReminderAPI";
import CustomerProfileCard from "@/components/CustomerProfileCard.vue";
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
import { useNavBarStore } from "@/store/navBarStore";
import type { FollowUpReminder, FollowUpReminderNotifyChannel, FollowUpReminderStatus } from "@/types/FollowUpReminder";
import type { PhotoItem } from "@/types/Photo";
import { getAttachmentReadURL } from "@/utils/attachment";
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";
type NotifyTagTheme = "default" | "success" | "warning" | "primary" | "danger";
defineOptions({
@@ -103,7 +179,6 @@ defineOptions({
const route = useRoute();
const router = useRouter();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const detail = ref<FollowUpReminder>();
@@ -181,7 +256,7 @@ async function loadDetail(): Promise<void> {
loadToken = token;
detail.value = undefined;
internalNotifyStatus.value = undefined;
navBarStore.clearRight();
clearPageNavBarRight();
const id = String(route.params.id || "");
if (!id) {
return;
@@ -207,7 +282,7 @@ async function loadDetail(): Promise<void> {
function setEditAction(): void {
if (canUpdate.value) {
navBarStore.setRightText("编辑", "var(--td-brand-color)", toEdit);
setPageNavBarRightText("编辑", "var(--td-brand-color)", toEdit);
}
}
@@ -305,7 +380,7 @@ function confirmDelete(): void {
async function remove(id: string): Promise<void> {
isDeleting.value = true;
navBarStore.clearRight();
clearPageNavBarRight();
try {
await FollowUpReminderAPI.remove(id);
Message.success("跟进提醒已删除");
@@ -322,7 +397,7 @@ watch(() => route.params.id, async () => {
await loadDetail();
}, { immediate: true });
onUnmounted(() => navBarStore.clearRight());
onUnmounted(() => clearPageNavBarRight());
</script>
<style scoped lang="less">
@@ -374,4 +449,45 @@ onUnmounted(() => navBarStore.clearRight());
}
}
}
.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>
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
:title="routeNavBarTitle"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div v-can="pageAccess" class="follow-up-reminder-edit">
<t-form class="form" label-width="6rem">
<t-form-item label="客户" content-align="right" required-mark>
@@ -120,8 +165,6 @@ import CustomerSelector from "@/components/CustomerSelector.vue";
import ManagedUserSelector from "@/pages/followUpReminder/component/ManagedUserSelector.vue";
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
import { useCurrentStoreStore } from "@/store/currentStoreStore";
import { useNavBarStore } from "@/store/navBarStore";
import type { Customer } from "@/types/Customer";
import type { ManagedUser } from "@/types/ManagedUser";
import type {
FollowUpReminder,
@@ -135,15 +178,58 @@ import { getAttachmentReadURL } from "@/utils/attachment";
import { parseDateTime } from "@/utils/date";
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";
defineOptions({
name: "FollowUpReminderEdit"
});
const route = useRoute();
const routeNavBarTitle = computed(() => {
switch (route.name) {
case "CustomerFollowUpReminderCreate":
return "新增跟进提醒";
case "CustomerFollowUpReminderEdit":
return "编辑跟进提醒";
default:
return "";
}
});
const router = useRouter();
const userStore = useUserStore();
const currentStoreStore = useCurrentStoreStore();
const navBarStore = useNavBarStore();
const routeId = computed(() => String(route.params.id || ""));
const isEditMode = computed(() => !!routeId.value);
@@ -567,7 +653,7 @@ async function save(): Promise<void> {
}
onMounted(async () => {
navBarStore.setRightText(isEditMode.value ? "保存" : "提交", "var(--td-brand-color)", save);
setPageNavBarRightText(isEditMode.value ? "保存" : "提交", "var(--td-brand-color)", save);
try {
await loadForm();
} catch (error) {
@@ -575,7 +661,7 @@ onMounted(async () => {
}
});
onUnmounted(() => navBarStore.clearRight());
onUnmounted(() => clearPageNavBarRight());
</script>
<style scoped lang="less">
@@ -642,4 +728,45 @@ onUnmounted(() => navBarStore.clearRight());
}
}
}
.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>
@@ -1,180 +1,236 @@
<template>
<div v-can="permissionCodes.customerFollowUpReminder.read" class="follow-up-reminder-list">
<div class="filters glass">
<t-input
v-model="customerSearchKeyword"
class="customer"
type="search"
borderless
placeholder="输入客户编码、姓名或拼音"
@enter="applyCustomerSearch"
@clear="clearCustomer"
>
<template #suffix-icon>
<t-button
size="extra-small"
theme="primary"
variant="outline"
content="选择客户"
@click.stop="customerSelectorVisible = true"
/>
</template>
</t-input>
<t-dropdown-menu ref="dropdownMenuRef" class="menus">
<t-dropdown-item
v-model="dateFilterType"
:label="dateFilterLabel"
:options="dateOptions"
@change="handleDateFilterChange"
/>
<t-dropdown-item
v-model="statusFilter"
:label="statusFilterLabel"
:options="statusOptions"
@change="handleStatusChange"
/>
<t-dropdown-item
:label="selectedResponsibleName"
:options="[]"
@open="openResponsibleSelector"
/>
</t-dropdown-menu>
</div>
<t-pull-down-refresh
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="fetch"
<div class="page-layout navbar follow-up-reminder-list">
<t-navbar
fixed
:z-index="20"
title="客户跟进提醒"
left-arrow
@left-click="$router.back()"
>
<div class="list-wrap">
<customer-profile-card class="customer" :customer="selectedCustomer" />
<t-cell-group class="summary" theme="card">
<t-cell title="提醒数量" :note="`共 ${pageResult.total} 条`" />
<t-cell v-if="dateFilterType !== 'all'" title="提醒时间" :note="dateFilterLabel" />
<t-cell v-if="selectedResponsibleId" title="负责人" :note="selectedResponsibleName" />
</t-cell-group>
<t-cell-group v-if="pageResult.list.length" class="items fix-last-cell-line empty-cell-title-margin" theme="card">
<t-swipe-cell
v-for="(item, index) in pageResult.list"
:key="item.id || index"
class="item"
<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-cell
v-entrance-transition="{ step: 30 }"
class="cell"
arrow
@click="toDetail(item)"
<t-button
class="trigger"
variant="text"
:aria-label="'更多操作'"
type="button"
>
<template #leftIcon>
<t-image
v-if="getCustomerPhotoURL(item.customer, 64)"
:src="getCustomerPhotoURL(item.customer, 64)"
:alt="getCustomerName(item)"
fit="cover"
class="avatar"
/>
<div v-else class="avatar fallback" v-text="getCustomerName(item).slice(0, 1)" />
<template #icon>
<t-icon name="ellipsis" />
</template>
<template #title>
<div class="title">
<div class="name-channel">
<span class="text-bold" v-text="getCustomerName(item)" />
<t-tag
v-if="item.notifyChannelList?.includes('INTERNAL')"
size="small"
theme="primary"
variant="outline"
content="站内信"
/>
<t-tag
v-if="item.notifyChannelList?.includes('SMS')"
size="small"
theme="warning"
variant="outline"
content="短信"
/>
</div>
<t-tag size="small" :theme="getStatusTheme(item.status)" :content="getStatusText(item.status)" />
</div>
</template>
<template #description>
<div class="description">
<div class="content clip-text" v-text="getContentSummary(item.content)" />
<div class="time-responsible">
<span
class="remind-time"
:class="getReminderTimeClass(item)"
v-text="getReminderTimeText(item.remindAt)"
/>
<span v-text="`负责人:${getResponsibleName(item)}`" />
</div>
</div>
</template>
</t-cell>
<template #right>
<div class="swipe-actions">
</t-button>
<template #content>
<div class="menu">
<t-button
v-if="canComplete && item.status === 'PENDING'"
class="complete swipe-cell-button"
v-for="action in pageNavBarActionList"
:key="action.key"
class="menu-item"
variant="text"
:loading="operatingId === item.id && operatingType === 'complete'"
@click.stop="confirmComplete(item)"
>完成</t-button>
<t-button
v-if="canDelete"
class="delete swipe-cell-button"
variant="text"
:loading="operatingId === item.id && operatingType === 'delete'"
@click.stop="confirmDelete(item)"
>删除</t-button>
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-swipe-cell>
</t-cell-group>
<div class="center-tips" v-text="isLoading ? '正在加载提醒' : pageResult.list.length ? (isNoMore ? '已经到底了' : '上拉加载更多') : '暂无跟进提醒'" />
</div>
</t-pull-down-refresh>
<customer-selector
v-model="selectedCustomerId"
v-model:visible="customerSelectorVisible"
:initial-keyword="customerSearchKeyword"
:store-id="currentStoreStore.currentStoreId"
:enable-scan="true"
@change="handleCustomerSelected"
/>
<managed-user-selector
v-model="selectedResponsibleId"
v-model:visible="responsibleSelectorVisible"
:store-id="currentStoreStore.currentStoreId"
@change="handleResponsibleSelected"
/>
<t-popup v-model="startVisible" placement="bottom">
<t-date-time-picker
v-if="startVisible"
v-model="startDraft"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="提醒开始时间"
@cancel="startVisible = false"
@confirm="confirmStart"
</t-popover>
</div>
</template>
</t-navbar>
<main v-can="permissionCodes.customerFollowUpReminder.read" class="page-content scroll list">
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="fetch"
>
<div class="filters glass">
<t-input
v-model="customerSearchKeyword"
class="customer"
type="search"
borderless
placeholder="输入客户编码、姓名或拼音"
@enter="applyCustomerSearch"
@clear="clearCustomer"
>
<template #suffix-icon>
<t-button
size="extra-small"
theme="primary"
variant="outline"
content="选择客户"
@click.stop="customerSelectorVisible = true"
/>
</template>
</t-input>
<t-dropdown-menu ref="dropdownMenuRef" class="menus">
<t-dropdown-item
v-model="dateFilterType"
:label="dateFilterLabel"
:options="dateOptions"
@change="handleDateFilterChange"
/>
<t-dropdown-item
v-model="statusFilter"
:label="statusFilterLabel"
:options="statusOptions"
@change="handleStatusChange"
/>
<t-dropdown-item
:label="selectedResponsibleName"
:options="[]"
@open="openResponsibleSelector"
/>
</t-dropdown-menu>
</div>
<div class="list-wrap">
<customer-profile-card class="customer" :customer="selectedCustomer" />
<t-cell-group class="summary" theme="card">
<t-cell title="提醒数量" :note="`共 ${pageResult.total} 条`" />
<t-cell v-if="dateFilterType !== 'all'" title="提醒时间" :note="dateFilterLabel" />
<t-cell v-if="selectedResponsibleId" title="负责人" :note="selectedResponsibleName" />
</t-cell-group>
<t-cell-group v-if="pageResult.list.length" class="items fix-last-cell-line empty-cell-title-margin" theme="card">
<t-swipe-cell
v-for="(item, index) in pageResult.list"
:key="item.id || index"
class="item"
>
<t-cell
v-entrance-transition="{ step: 30 }"
class="cell"
arrow
@click="toDetail(item)"
>
<template #leftIcon>
<t-image
v-if="getCustomerPhotoURL(item.customer, 64)"
:src="getCustomerPhotoURL(item.customer, 64)"
:alt="getCustomerName(item)"
fit="cover"
class="avatar"
/>
<div v-else class="avatar fallback" v-text="getCustomerName(item).slice(0, 1)" />
</template>
<template #title>
<div class="title">
<div class="name-channel">
<span class="text-bold" v-text="getCustomerName(item)" />
<t-tag
v-if="item.notifyChannelList?.includes('INTERNAL')"
size="small"
theme="primary"
variant="outline"
content="站内信"
/>
<t-tag
v-if="item.notifyChannelList?.includes('SMS')"
size="small"
theme="warning"
variant="outline"
content="短信"
/>
</div>
<t-tag size="small" :theme="getStatusTheme(item.status)" :content="getStatusText(item.status)" />
</div>
</template>
<template #description>
<div class="description">
<div class="content clip-text" v-text="getContentSummary(item.content)" />
<div class="time-responsible">
<span
class="remind-time"
:class="getReminderTimeClass(item)"
v-text="getReminderTimeText(item.remindAt)"
/>
<span v-text="`负责人:${getResponsibleName(item)}`" />
</div>
</div>
</template>
</t-cell>
<template #right>
<div class="swipe-actions">
<t-button
v-if="canComplete && item.status === 'PENDING'"
class="complete swipe-cell-button"
variant="text"
:loading="operatingId === item.id && operatingType === 'complete'"
@click.stop="confirmComplete(item)"
>完成</t-button>
<t-button
v-if="canDelete"
class="delete swipe-cell-button"
variant="text"
:loading="operatingId === item.id && operatingType === 'delete'"
@click.stop="confirmDelete(item)"
>删除</t-button>
</div>
</template>
</t-swipe-cell>
</t-cell-group>
<div class="center-tips" v-text="isLoading ? '正在加载提醒' : pageResult.list.length ? (isNoMore ? '已经到底了' : '上拉加载更多') : '暂无跟进提醒'" />
</div>
</t-pull-down-refresh>
<customer-selector
v-model="selectedCustomerId"
v-model:visible="customerSelectorVisible"
:initial-keyword="customerSearchKeyword"
:store-id="currentStoreStore.currentStoreId"
:enable-scan="true"
@change="handleCustomerSelected"
/>
</t-popup>
<t-popup v-model="endVisible" placement="bottom">
<t-date-time-picker
v-if="endVisible"
v-model="endDraft"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="提醒结束时间"
@cancel="endVisible = false"
@confirm="confirmEnd"
<managed-user-selector
v-model="selectedResponsibleId"
v-model:visible="responsibleSelectorVisible"
:store-id="currentStoreStore.currentStoreId"
@change="handleResponsibleSelected"
/>
</t-popup>
<t-popup v-model="startVisible" placement="bottom">
<t-date-time-picker
v-if="startVisible"
v-model="startDraft"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="提醒开始时间"
@cancel="startVisible = false"
@confirm="confirmStart"
/>
</t-popup>
<t-popup v-model="endVisible" placement="bottom">
<t-date-time-picker
v-if="endVisible"
v-model="endDraft"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="提醒结束时间"
@cancel="endVisible = false"
@confirm="confirmEnd"
/>
</t-popup>
</main>
</div>
<nav-bar-action-menu v-if="canCreate" :actions="actionList" />
</template>
<script setup lang="ts">
import type { NavBarAction } from "@/types/NavBarAction";
import { DialogPlugin, type DropdownValue } from "tdesign-mobile-vue";
import { Time } from "timi-web";
import { type PageResult, useUserStore } from "timi-web-api";
@@ -185,14 +241,22 @@ import CustomerAPI from "@/api/CustomerAPI";
import CustomerSelector from "@/components/CustomerSelector.vue";
import ManagedUserSelector from "@/pages/followUpReminder/component/ManagedUserSelector.vue";
import { useCurrentStoreStore } from "@/store/currentStoreStore";
import { useNavBarStore } from "@/store/navBarStore";
import type { Customer } from "@/types/Customer";
import type { ManagedUser } from "@/types/ManagedUser";
import type { FollowUpReminder, FollowUpReminderPage, FollowUpReminderStatus } from "@/types/FollowUpReminder";
import { getCustomerPhotoURL } from "@/utils/customer";
import { parseDateTime } from "@/utils/date";
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 { Customer } from "@/types/Customer";
type DateFilterType = "all" | "today" | "next7" | "custom";
defineOptions({
@@ -203,7 +267,6 @@ const router = useRouter();
const route = useRoute();
const userStore = useUserStore();
const currentStoreStore = useCurrentStoreStore();
const navBarStore = useNavBarStore();
const isGlobalManager = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
const canCreate = computed(() => userStore.hasPermissions(permissionCodes.customerFollowUpReminder.create));
@@ -611,7 +674,7 @@ async function toDetail(item: FollowUpReminder): Promise<void> {
}
onMounted(async () => {
navBarStore.setCustomRightVisible(canCreate.value);
try {
await loadStoreScope();
const queryCustomerId = String(route.query.customerId || "");
@@ -637,7 +700,6 @@ watch(() => route.query.customerId, async value => {
await refresh();
});
onUnmounted(() => navBarStore.clearRight());
</script>
<style scoped lang="less">
@@ -833,4 +895,46 @@ onUnmounted(() => navBarStore.clearRight());
}
}
.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>
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
title="创建履约单"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div v-can="permissionCodes.orderFulfillment.create" class="fulfillment-create">
<t-cell-group title="履约来源" theme="card">
<t-cell title="销售订单" :note="order?.orderNo || order?.id || '未找到来源订单'" />
@@ -150,8 +195,6 @@ import { Time } from "timi-web";
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
import ProductSkuTags from "@/components/ProductSkuTags.vue";
import ProductStockPreview from "@/components/ProductStockPreview.vue";
import { useNavBarStore } from "@/store/navBarStore";
import type { Attachment } from "timi-web-api";
import { useUserStore } from "timi-web-api";
import type { GaoOrderFulfillmentItemRequest } from "@/types/Fulfillment";
import type { GaoSalesOrderItem, SalesOrder } from "@/types/SalesOrder";
@@ -178,10 +221,42 @@ import {
import { uploadPhotoList } from "@/utils/photo";
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";
defineOptions({ name: "OrderFulfillmentCreate" });
const route = useRoute();
const router = useRouter();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const order = ref<SalesOrder>();
const quantityMap = reactive<Record<string, string | number>>({});
@@ -615,12 +690,12 @@ async function save(): Promise<void> {
}
onMounted(async () => {
navBarStore.setRightText("提交", "var(--td-brand-color)", save);
setPageNavBarRightText("提交", "var(--td-brand-color)", save);
await loadData();
});
onUnmounted(() => {
window.clearTimeout(stockPreviewTimer);
navBarStore.clearRight();
clearPageNavBarRight();
});
</script>
@@ -750,4 +825,45 @@ 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>
@@ -1,4 +1,11 @@
<template>
<t-navbar
fixed
:z-index="20"
title="履约单详情"
left-arrow
@left-click="$router.back()"
/>
<div v-can="permissionCodes.orderFulfillment.read" class="fulfillment-detail">
<template v-if="fulfillment">
<t-cell-group title="履约单信息" theme="card" v-entrance-transition>
@@ -131,8 +138,6 @@ import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
import ProductSkuTags from "@/components/ProductSkuTags.vue";
import ProductStockPreview from "@/components/ProductStockPreview.vue";
import OrderFulfillmentRevoke from "@/pages/fulfillment/components/OrderFulfillmentRevoke.vue";
import { useNavBarStore } from "@/store/navBarStore";
import type { OrderFulfillment, OrderFulfillmentItem } from "@/types/Fulfillment";
import type { GaoSalesOrderItemType, SalesOrder } from "@/types/SalesOrder";
import type { PhotoItem } from "@/types/Photo";
import { addPackageQuantity, getPackageQuantityText } from "@/utils/package";
@@ -146,11 +151,12 @@ import { permissionCodes } from "@/utils/permission";
import type { ProductStockPreviewItem } from "@/utils/productStock";
import { buildProductStockPreview, mergeProductStockRequirements } from "@/utils/productStock";
import type { OrderFulfillment, OrderFulfillmentItem } from "@/types/Fulfillment";
type ReasonAction = "reject" | "cancel";
defineOptions({ name: "OrderFulfillmentDetail" });
const route = useRoute();
const router = useRouter();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const fulfillment = ref<OrderFulfillment>();
const order = ref<SalesOrder>();
@@ -341,7 +347,6 @@ async function submitReason(): Promise<void> {
finally { operating.value = false; }
}
onMounted(loadData);
onUnmounted(() => navBarStore.clearRight());
</script>
<style scoped lang="less">
+255 -154
View File
@@ -1,161 +1,217 @@
<template>
<div v-can="permissionCodes.orderFulfillment.read" class="fulfillment-list">
<div class="filters glass">
<t-input
class="customer"
:value="customerDisplayText"
readonly
borderless
placeholder="选择客户"
@click="customerSelectorVisible = true"
>
<template #suffix-icon>
<div class="actions">
<t-button
v-if="customerId"
shape="circle"
theme="danger"
variant="text"
size="extra-small"
aria-label="清除客户选择"
@click.stop="clearCustomer"
>
<t-icon name="close" size="1rem" />
</t-button>
<t-button
size="extra-small"
theme="primary"
variant="outline"
content="选择客户"
@click.stop="customerSelectorVisible = true"
/>
</div>
</template>
</t-input>
<t-dropdown-menu ref="filterMenuRef" class="menus">
<t-dropdown-item
v-model="dateFilterType"
:label="dateFilterLabel"
:options="dateOptions"
@change="selectDateFilter"
/>
<t-dropdown-item
:label="skuFilterLabel"
:options="[]"
@open="openSkuFilter"
/>
<t-dropdown-item
v-model="status"
label="履约状态"
:options="statusOptions"
@change="selectStatus"
/>
</t-dropdown-menu>
</div>
<t-pull-down-refresh
v-model="refreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
<div class="page-layout navbar fulfillment-list">
<t-navbar
fixed
:z-index="20"
title="履约记录"
left-arrow
@left-click="$router.back()"
>
<div class="list-wrap">
<t-cell-group v-if="salesOrder || selectedSkuOptionList.length" class="filter-info" theme="card">
<template v-if="salesOrder">
<t-cell title="订单号" :note="salesOrder.orderNo || salesOrder.id || '未知订单'" />
<t-cell title="订单类型" :note="getSalesOrderTypeText(salesOrder.orderType)" />
<t-cell title="订单状态">
<template #note>
<t-tag
:content="getSalesOrderStatusText(salesOrder.status)"
:theme="getStatusTheme(salesOrder.status)"
variant="light-outline"
/>
<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-cell>
</template>
<t-cell v-if="selectedSkuOptionList.length" class="sku-filter-cell" title="已筛选 SKU">
<template #note>
<div class="selected-sku-list">
<t-tag
v-for="sku in selectedSkuOptionList"
:key="sku.skuId"
size="small"
</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>
</template>
</t-navbar>
<main v-can="permissionCodes.orderFulfillment.read" class="page-content scroll list">
<t-pull-down-refresh
class="pull-refresh"
v-model="refreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
>
<div class="filters glass">
<t-input
class="customer"
:value="customerDisplayText"
readonly
borderless
placeholder="选择客户"
@click="customerSelectorVisible = true"
>
<template #suffix-icon>
<div class="actions">
<t-button
v-if="customerId"
shape="circle"
theme="danger"
variant="text"
size="extra-small"
aria-label="清除客户选择"
@click.stop="clearCustomer"
>
<t-icon name="close" size="1rem" />
</t-button>
<t-button
size="extra-small"
theme="primary"
variant="outline"
:content="formatSelectedSkuName(sku.productName, sku.skuName)"
content="选择客户"
@click.stop="customerSelectorVisible = true"
/>
</div>
</template>
</t-cell>
</t-cell-group>
<t-cell-group v-if="isCustomDate" class="date-summary" theme="card">
<t-cell
title="开始时间"
:note="dateRange[0] || '-'"
arrow
@click="openStartTime"
/>
<t-cell
title="结束时间"
:note="dateRange[1] || '-'"
arrow
@click="openEndTime"
/>
</t-cell-group>
<div v-if="list.length" class="items">
<order-fulfillment-list-cell
v-for="item in list"
:key="item.id"
class="item"
:fulfillment="item"
v-entrance-transition="{ step: 30 }"
@detail="toDetail(item)"
/>
</t-input>
<t-dropdown-menu ref="filterMenuRef" class="menus">
<t-dropdown-item
v-model="dateFilterType"
:label="dateFilterLabel"
:options="dateOptions"
@change="selectDateFilter"
/>
<t-dropdown-item
:label="skuFilterLabel"
:options="[]"
@open="openSkuFilter"
/>
<t-dropdown-item
v-model="status"
label="履约状态"
:options="statusOptions"
@change="selectStatus"
/>
</t-dropdown-menu>
</div>
<div v-else class="center-tips" v-text="loading ? '正在加载履约单' : '暂无履约单'" />
<div class="center-tips" v-text="loading ? '正在加载' : noMore ? '已经到底了' : '上拉加载更多'" />
</div>
</t-pull-down-refresh>
<div class="list-wrap">
<t-cell-group v-if="salesOrder || selectedSkuOptionList.length" class="filter-info" theme="card">
<template v-if="salesOrder">
<t-cell title="订单号" :note="salesOrder.orderNo || salesOrder.id || '未知订单'" />
<t-cell title="订单类型" :note="getSalesOrderTypeText(salesOrder.orderType)" />
<t-cell title="订单状态">
<template #note>
<t-tag
:content="getSalesOrderStatusText(salesOrder.status)"
:theme="getStatusTheme(salesOrder.status)"
variant="light-outline"
/>
</template>
</t-cell>
</template>
<t-cell v-if="selectedSkuOptionList.length" class="sku-filter-cell" title="已筛选 SKU">
<template #note>
<div class="selected-sku-list">
<t-tag
v-for="sku in selectedSkuOptionList"
:key="sku.skuId"
size="small"
theme="primary"
variant="outline"
:content="formatSelectedSkuName(sku.productName, sku.skuName)"
/>
</div>
</template>
</t-cell>
</t-cell-group>
<t-cell-group v-if="isCustomDate" class="date-summary" theme="card">
<t-cell
title="开始时间"
:note="dateRange[0] || '-'"
arrow
@click="openStartTime"
/>
<t-cell
title="结束时间"
:note="dateRange[1] || '-'"
arrow
@click="openEndTime"
/>
</t-cell-group>
<div v-if="list.length" class="items">
<order-fulfillment-list-cell
v-for="item in list"
:key="item.id"
class="item"
:fulfillment="item"
v-entrance-transition="{ step: 30 }"
@detail="toDetail(item)"
/>
</div>
<div v-else class="center-tips" v-text="loading ? '正在加载履约单' : '暂无履约单'" />
<div class="center-tips" v-text="loading ? '正在加载' : noMore ? '已经到底了' : '上拉加载更多'" />
</div>
</t-pull-down-refresh>
</main>
<sku-filter-popup
v-model="skuFilterVisible"
:sku-id-list="selectedSkuIdList"
@options-loaded="handleSkuFilterOptionsLoaded"
@confirm="confirmSkuFilter"
/>
<customer-selector
v-model="customerId"
v-model:visible="customerSelectorVisible"
@change="handleCustomerChange"
/>
<t-popup v-model="startVisible" placement="bottom">
<t-date-time-picker
v-if="startVisible"
v-model="startDraft"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="开始时间"
:default-value="dateRange[0]"
@cancel="cancelStartTime"
@confirm="confirmStartTime"
/>
</t-popup>
<t-popup v-model="endVisible" placement="bottom">
<t-date-time-picker
v-if="endVisible"
v-model="endDraft"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="结束时间"
:default-value="dateRange[1]"
@cancel="cancelEndTime"
@confirm="confirmEndTime"
/>
</t-popup>
</div>
<nav-bar-action-menu v-if="canCreate" :actions="actions" />
<sku-filter-popup
v-model="skuFilterVisible"
:sku-id-list="selectedSkuIdList"
@options-loaded="handleSkuFilterOptionsLoaded"
@confirm="confirmSkuFilter"
/>
<customer-selector
v-model="customerId"
v-model:visible="customerSelectorVisible"
@change="handleCustomerChange"
/>
<t-popup v-model="startVisible" placement="bottom">
<t-date-time-picker
v-if="startVisible"
v-model="startDraft"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="开始时间"
:default-value="dateRange[0]"
@cancel="cancelStartTime"
@confirm="confirmStartTime"
/>
</t-popup>
<t-popup v-model="endVisible" placement="bottom">
<t-date-time-picker
v-if="endVisible"
v-model="endDraft"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="结束时间"
:default-value="dateRange[1]"
@cancel="cancelEndTime"
@confirm="confirmEndTime"
/>
</t-popup>
</template>
<script setup lang="ts">
import type { NavBarAction } from "@/types/NavBarAction";
import { type DropdownValue } from "tdesign-mobile-vue";
import { Time } from "timi-web";
import { useUserStore } from "timi-web-api";
@@ -163,12 +219,7 @@ import CustomerAPI from "@/api/CustomerAPI";
import FulfillmentAPI from "@/api/FulfillmentAPI";
import SalesOrderAPI from "@/api/SalesOrderAPI";
import CustomerSelector from "@/components/CustomerSelector.vue";
import NavBarActionMenu from "@/components/NavBarActionMenu.vue";
import OrderFulfillmentListCell from "@/pages/fulfillment/components/OrderFulfillmentListCell.vue";
import SkuFilterPopup from "@/pages/fulfillment/components/SkuFilterPopup.vue";
import { useNavBarStore } from "@/store/navBarStore";
import type { GaoFulfillmentStatus, OrderFulfillment } from "@/types/Fulfillment";
import type { NavBarAction } from "@/types/NavBarAction";
import type { Customer } from "@/types/Customer";
import type { SalesOrder } from "@/types/SalesOrder";
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
@@ -177,12 +228,22 @@ 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";
defineOptions({ name: "OrderFulfillmentList" });
const route = useRoute();
const router = useRouter();
const filterMenuRef = ref<{ collapseMenu: () => void }>();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const canCreate = computed(() => userStore.hasPermissions(permissionCodes.orderFulfillment.create));
const actions = computed<NavBarAction[]>(() => [
@@ -531,8 +592,7 @@ function getCurrentRouteDepth(): number {
}
onMounted(async () => {
navBarStore.clearRight();
navBarStore.setCustomRightVisible(canCreate.value);
try {
await loadSalesOrder();
if (customerId.value) {
@@ -544,7 +604,6 @@ onMounted(async () => {
}
});
onUnmounted(() => navBarStore.clearRight());
</script>
<style scoped lang="less">
@@ -662,4 +721,46 @@ onUnmounted(() => navBarStore.clearRight());
}
}
}
.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
View File
@@ -1,4 +1,11 @@
<template>
<t-navbar
fixed
:z-index="20"
title="快速扫码登记"
left-arrow
@left-click="$router.back()"
/>
<div v-can="permissionCodes.eventRecord.create" class="quick-sign-in-page">
<t-cell-group v-if="!isEventLoading && !eventLoadFailed" theme="card">
<t-cell title="登记事件" arrow @click="eventPopupVisible = true">
+121 -5
View File
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
title="发送通知"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div v-can="corePermissionCodes.notify.create" class="notify-management-create">
<t-empty v-if="!canCreate" description="暂无发送通知权限" />
<t-form v-else class="form" label-align="left" label-width="5rem">
@@ -82,7 +127,38 @@ import NotifyRecipientPicker, {
type NotifyRecipientScopeOption
} from "@/pages/notify/component/NotifyRecipientPicker.vue";
import { corePermissionCodes, coreRoleCodes, gaoRoleCodes, permissionCodes } from "@/utils/permission";
import { useNavBarStore } from "@/store/navBarStore";
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";
defineOptions({
@@ -90,7 +166,6 @@ defineOptions({
});
const router = useRouter();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const currentStoreStore = useCurrentStoreStore();
const notifyEditorRef = ref<NotifyEditorExpose>();
@@ -192,7 +267,7 @@ const scheduleDraftText = ref("");
const minimumScheduleText = computed(() => Time.formatDateTime(new Date(Time.now() + Time.M)));
function updateNavActionText(): void {
navBarStore.setRightText(scheduleAtText.value ? "提交" : "发送", "var(--td-brand-color)", saveNotification);
setPageNavBarRightText(scheduleAtText.value ? "提交" : "发送", "var(--td-brand-color)", saveNotification);
}
watch(scheduleAtText, updateNavActionText);
@@ -356,7 +431,7 @@ async function loadRecipients(): Promise<void> {
// ---------- 生命周期 ----------
onMounted(async () => {
navBarStore.clearRight();
clearPageNavBarRight();
if (!canCreate.value) {
return;
}
@@ -370,7 +445,7 @@ onMounted(async () => {
await loadRecipients();
});
onUnmounted(() => navBarStore.clearRight());
onUnmounted(() => clearPageNavBarRight());
</script>
<style scoped lang="less">
@@ -448,4 +523,45 @@ onUnmounted(() => navBarStore.clearRight());
}
}
}
.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>
+124 -8
View File
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
title="通知详情"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div v-can="corePermissionCodes.notify.read" class="notify-detail">
<t-empty
v-if="!detail"
@@ -44,10 +89,41 @@ import { DialogPlugin } from "tdesign-mobile-vue";
import { Message } from "@/utils/message";
import { getErrorMessage } from "@/utils/error";
import { getAttachmentReadURL } from "@/utils/attachment";
import { useNavBarStore } from "@/store/navBarStore";
import { corePermissionCodes } from "@/utils/permission";
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";
type NotifyTagTheme = "default" | "success" | "warning" | "primary" | "danger";
type RecipientFilter = "all" | "unread" | "read";
@@ -57,7 +133,6 @@ defineOptions({
const route = useRoute();
const router = useRouter();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const canDeleteNotify = computed(() => userStore.hasPermissions(corePermissionCodes.notify.delete));
const canCancelNotify = computed(() => userStore.hasPermissions(corePermissionCodes.notify.cancel));
@@ -108,7 +183,7 @@ async function loadDetail(): Promise<void> {
const requestToken = loadToken + 1;
loadToken = requestToken;
detail.value = undefined;
navBarStore.clearRight();
clearPageNavBarRight();
const notifyId = String(route.params.id || "");
if (!notifyId) {
return;
@@ -133,7 +208,7 @@ async function loadDetail(): Promise<void> {
function setRightAction(): void {
if (detail.value?.id && canDeleteNotify.value) {
navBarStore.setRightText("删除", "var(--td-error-color)", confirmDelete);
setPageNavBarRightText("删除", "var(--td-error-color)", confirmDelete);
}
}
@@ -188,7 +263,7 @@ async function confirmDelete(): Promise<void> {
async onConfirm() {
dialog.destroy();
isDeleting.value = true;
navBarStore.clearRight();
clearPageNavBarRight();
try {
await NotifyAPI.managementDelete(notifyId);
Message.success("通知已删除");
@@ -257,8 +332,8 @@ watch(() => route.params.id, async () => {
await loadDetail();
}, { immediate: true });
onMounted(() => navBarStore.clearRight());
onUnmounted(() => navBarStore.clearRight());
onMounted(() => clearPageNavBarRight());
onUnmounted(() => clearPageNavBarRight());
</script>
<style scoped lang="less">
@@ -281,4 +356,45 @@ onUnmounted(() => navBarStore.clearRight());
background: #FFF;
}
}
.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>
+177 -58
View File
@@ -1,60 +1,108 @@
<template>
<div v-can="corePermissionCodes.notify.read" class="notify-management">
<t-pull-down-refresh
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
<div class="page-layout navbar notify-management">
<t-navbar
fixed
:z-index="20"
title="通知管理"
left-arrow
@left-click="$router.back()"
>
<t-cell-group
v-if="pageResult.list.length"
class="items fix-last-cell-line"
theme="card"
>
<t-swipe-cell
v-for="item in pageResult.list"
:key="item.id"
class="item"
v-entrance-transition="{ step: 30 }"
<template #right>
<div
v-if="pageNavBarRight.icon || pageNavBarRight.text"
class="nav-right-slot"
>
<t-cell arrow @click="toDetail(item)">
<template #leftIcon>
<div class="icon" :class="{ scheduled: isScheduled(item) }">
<t-icon :name="isScheduled(item) ? 'time' : 'notification'" size="1.25rem" />
</div>
<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>
</t-navbar>
<main v-can="corePermissionCodes.notify.read" class="page-content scroll list">
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
>
<t-cell-group
v-if="pageResult.list.length"
class="items fix-last-cell-line"
theme="card"
>
<t-swipe-cell
v-for="item in pageResult.list"
:key="item.id"
class="item"
v-entrance-transition="{ step: 30 }"
>
<t-cell arrow @click="toDetail(item)">
<template #leftIcon>
<div class="icon" :class="{ scheduled: isScheduled(item) }">
<t-icon :name="isScheduled(item) ? 'time' : 'notification'" size="1.25rem" />
</div>
</template>
<template #title>
<div class="title">
<span v-text="getSubject(item)" />
</div>
</template>
<template #description>
<span v-if="isScheduled(item)" v-text="`定时 ${Time.toDateTime(item.sendAt)}`" />
<pass-time-label v-else :timestamp="item.sendAt || item.createdAt" underline />
</template>
<template #note>
<t-tag size="small" :theme="getStatusTheme(item)" :content="getStatusText(item)" />
</template>
</t-cell>
<template #right>
<t-button
v-if="canCancel(item)"
class="cancel"
theme="primary"
@click.stop="confirmCancel(item)"
>取消</t-button>
<t-button
v-if="canDeleteNotify"
class="delete"
theme="danger"
@click.stop="confirmDelete(item)"
>删除</t-button>
</template>
<template #title>
<div class="title">
<span v-text="getSubject(item)" />
</div>
</template>
<template #description>
<span v-if="isScheduled(item)" v-text="`定时 ${Time.toDateTime(item.sendAt)}`" />
<pass-time-label v-else :timestamp="item.sendAt || item.createdAt" underline />
</template>
<template #note>
<t-tag size="small" :theme="getStatusTheme(item)" :content="getStatusText(item)" />
</template>
</t-cell>
<template #right>
<t-button
v-if="canCancel(item)"
class="cancel"
theme="primary"
@click.stop="confirmCancel(item)"
>取消</t-button>
<t-button
v-if="canDeleteNotify"
class="delete"
theme="danger"
@click.stop="confirmDelete(item)"
>删除</t-button>
</template>
</t-swipe-cell>
</t-cell-group>
<t-empty v-else-if="!isLoading" description="暂无已发送通知" />
<div class="center-tips" v-text="loadStateText" />
</t-pull-down-refresh>
</t-swipe-cell>
</t-cell-group>
<t-empty v-else-if="!isLoading" description="暂无已发送通知" />
<div class="center-tips" v-text="loadStateText" />
</t-pull-down-refresh>
</main>
</div>
</template>
@@ -64,7 +112,38 @@ import { NotifyAPI, type Notify, type NotifyManagementItem, type Page, type Page
import { DialogPlugin } from "tdesign-mobile-vue";
import { Message } from "@/utils/message";
import { getErrorMessage } from "@/utils/error";
import { useNavBarStore } from "@/store/navBarStore";
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";
type NotifyTagTheme = "default" | "success" | "warning" | "primary" | "danger";
@@ -75,7 +154,6 @@ defineOptions({
const pageSize = 20;
const router = useRouter();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const canReadNotify = computed(() => userStore.hasPermissions(corePermissionCodes.notify.read));
const canCreateNotify = computed(() => userStore.hasPermissions(corePermissionCodes.notify.create));
@@ -255,17 +333,17 @@ async function confirmDelete(item: NotifyManagementItem): Promise<void> {
// ---------- 生命周期 ----------
onMounted(async () => {
navBarStore.clearRight();
clearPageNavBarRight();
if (!canReadNotify.value) {
return;
}
if (canCreateNotify.value) {
navBarStore.setRightText("新建", "var(--td-brand-color)", toCreate);
setPageNavBarRightText("新建", "var(--td-brand-color)", toCreate);
}
await reloadList();
});
onUnmounted(() => navBarStore.clearRight());
onUnmounted(() => clearPageNavBarRight());
</script>
<style scoped lang="less">
@@ -334,4 +412,45 @@ onUnmounted(() => navBarStore.clearRight());
}
}
}
.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>
+8 -3
View File
@@ -1,4 +1,11 @@
<template>
<t-navbar
fixed
:z-index="20"
title="发送用户"
left-arrow
@left-click="$router.back()"
/>
<div v-can="corePermissionCodes.notify.read" class="notify-recipient-list">
<template v-if="detail">
<t-segmented
@@ -55,7 +62,7 @@ import { PassTimeLabel, Time } from "timi-web";
import { NotifyAPI, type Notify, type NotifyDetail } from "timi-web-api";
import { Message } from "@/utils/message";
import { getErrorMessage } from "@/utils/error";
import { useNavBarStore } from "@/store/navBarStore";
import { corePermissionCodes } from "@/utils/permission";
type RecipientFilter = "all" | "unread" | "read";
@@ -66,7 +73,6 @@ defineOptions({
});
const route = useRoute();
const navBarStore = useNavBarStore();
// ---------- 通知数据 ----------
@@ -164,7 +170,6 @@ watch(() => route.query.filter, () => {
recipientFilter.value = getRecipientFilterFromRoute();
});
onMounted(() => navBarStore.clearRight());
</script>
<style scoped lang="less">
+124 -8
View File
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
title="通知详情"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div v-can="corePermissionCodes.notify.read" class="notify-detail">
<notify-content
v-if="detail"
@@ -17,16 +62,46 @@
<script setup lang="ts">
import { NotifyAPI, type NotifyDetail } from "timi-web-api";
import { DialogPlugin } from "tdesign-mobile-vue";
import { useNavBarStore } from "@/store/navBarStore";
import { getErrorMessage } from "@/utils/error";
import { getAttachmentReadURL } from "@/utils/attachment";
import { corePermissionCodes } from "@/utils/permission";
import { Message } from "@/utils/message.ts";
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";
const route = useRoute();
const router = useRouter();
const navBarStore = useNavBarStore();
defineOptions({
name: "UserNotifyDetail"
@@ -42,7 +117,7 @@ let loadToken = 0;
async function loadDetail(): Promise<void> {
const requestToken = loadToken + 1;
loadToken = requestToken;
navBarStore.clearRight();
clearPageNavBarRight();
const detailId = String(route.params.id || "");
if (!detailId) {
detail.value = undefined;
@@ -72,7 +147,7 @@ async function loadDetail(): Promise<void> {
function setDeleteAction(): void {
if (detail.value?.id) {
navBarStore.setRightText("删除", "var(--td-error-color)", confirmDelete);
setPageNavBarRightText("删除", "var(--td-error-color)", confirmDelete);
}
}
@@ -103,7 +178,7 @@ async function deleteDetail(detailId: string): Promise<void> {
}
isDeleting.value = true;
navBarStore.clearRight();
clearPageNavBarRight();
try {
await NotifyAPI.deleteInternal(detailId);
Message.success("通知已删除");
@@ -150,11 +225,11 @@ watch(() => route.params.id, async () => {
}, { immediate: true });
onMounted(() => {
navBarStore.clearRight();
clearPageNavBarRight();
});
onUnmounted(() => {
navBarStore.clearRight();
clearPageNavBarRight();
});
</script>
@@ -162,4 +237,45 @@ onUnmounted(() => {
.notify-detail {
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>
+185 -66
View File
@@ -1,67 +1,115 @@
<template>
<div v-can="corePermissionCodes.notify.read" class="notify-list">
<t-segmented
v-model="filterMode"
class="filter"
block
:options="filterOptions"
@change="switchFilter"
v-entrance-transition
/>
<t-pull-down-refresh
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
<div class="page-layout navbar notify-list">
<t-navbar
fixed
:z-index="20"
title="站内通知"
left-arrow
@left-click="$router.back()"
>
<t-cell-group v-if="pageResult.list.length" class="items fix-last-cell-line" theme="card">
<t-swipe-cell
v-for="item in pageResult.list"
:key="item.id"
class="item"
v-entrance-transition="{ step: 30 }"
<template #right>
<div
v-if="pageNavBarRight.icon || pageNavBarRight.text"
class="nav-right-slot"
>
<t-cell arrow hover @click="toDetail(item)">
<template #leftIcon>
<div class="icon" :class="{ unread: isUnread(item) }">
<t-icon name="notification" size="1.25rem" />
</div>
</template>
<template #title>
<div class="title">
<span v-text="getSubject(item)" />
</div>
</template>
<template #description>
<pass-time-label :timestamp="item.sendAt" underline />
</template>
<template #note>
<t-tag
v-if="filterMode === 'all' && isUnread(item)"
class="unread-label"
<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>
</t-navbar>
<main v-can="corePermissionCodes.notify.read" class="page-content scroll list">
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
>
<t-segmented
v-model="filterMode"
class="filter"
block
:options="filterOptions"
@change="switchFilter"
v-entrance-transition
/>
<t-cell-group v-if="pageResult.list.length" class="items fix-last-cell-line" theme="card">
<t-swipe-cell
v-for="item in pageResult.list"
:key="item.id"
class="item"
v-entrance-transition="{ step: 30 }"
>
<t-cell arrow hover @click="toDetail(item)">
<template #leftIcon>
<div class="icon" :class="{ unread: isUnread(item) }">
<t-icon name="notification" size="1.25rem" />
</div>
</template>
<template #title>
<div class="title">
<span v-text="getSubject(item)" />
</div>
</template>
<template #description>
<pass-time-label :timestamp="item.sendAt" underline />
</template>
<template #note>
<t-tag
v-if="filterMode === 'all' && isUnread(item)"
class="unread-label"
theme="danger"
size="small"
>未读</t-tag>
</template>
</t-cell>
<template #right>
<t-button
class="delete"
theme="danger"
size="small"
>未读</t-tag>
:loading="deletingId === item.id"
@click.stop="confirmDelete(item)"
>
删除
</t-button>
</template>
</t-cell>
<template #right>
<t-button
class="delete"
theme="danger"
:loading="deletingId === item.id"
@click.stop="confirmDelete(item)"
>
删除
</t-button>
</template>
</t-swipe-cell>
</t-cell-group>
<t-empty
v-else-if="!isLoading"
description="暂无站内通知"
/>
<div class="center-tips" v-text="loadStateText" />
</t-pull-down-refresh>
</t-swipe-cell>
</t-cell-group>
<t-empty
v-else-if="!isLoading"
description="暂无站内通知"
/>
<div class="center-tips" v-text="loadStateText" />
</t-pull-down-refresh>
</main>
</div>
</template>
@@ -70,10 +118,41 @@ import { PassTimeLabel } from "timi-web";
import { NotifyAPI, type NotifyDetail, type Page, type PageResult, useUserStore } from "timi-web-api";
import { DialogPlugin } from "tdesign-mobile-vue";
import { Message } from "@/utils/message";
import { useNavBarStore } from "@/store/navBarStore";
import { getErrorMessage } from "@/utils/error";
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";
type NotifyFilter = "all" | "unread";
defineOptions({
@@ -82,7 +161,6 @@ defineOptions({
const pageSize = 20;
const router = useRouter();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const canReadNotify = computed(() => userStore.hasPermissions(corePermissionCodes.notify.read));
@@ -276,9 +354,9 @@ function updateNavBarAction(): void {
if (!isPageActive) {
return;
}
navBarStore.clearRight();
clearPageNavBarRight();
if (0 < unreadCount.value) {
navBarStore.setRightText("全部已读", "var(--td-brand-color)", markAllRead);
setPageNavBarRightText("全部已读", "var(--td-brand-color)", markAllRead);
}
}
@@ -305,7 +383,7 @@ async function toDetail(item: NotifyDetail): Promise<void> {
// ---------- 生命周期 ----------
onMounted(async () => {
navBarStore.clearRight();
clearPageNavBarRight();
if (!canReadNotify.value) {
return;
}
@@ -320,7 +398,7 @@ onMounted(async () => {
onUnmounted(() => {
isPageActive = false;
navBarStore.clearRight();
clearPageNavBarRight();
});
</script>
@@ -407,4 +485,45 @@ 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>
+124 -8
View File
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
title="套餐配置详情"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div v-can="permissionCodes.packageConfig.read" class="package-config-detail">
<template v-if="config">
<section class="hero" v-entrance-transition>
@@ -92,19 +137,49 @@ import { useUserStore } from "timi-web-api";
import PackageAPI from "@/api/PackageAPI";
import ProductSkuTags from "@/components/ProductSkuTags.vue";
import { useCurrentStoreStore } from "@/store/currentStoreStore";
import { useNavBarStore } from "@/store/navBarStore";
import type { GaoPackageConfig, PackageConfigItem, PackageConfigStatus } from "@/types/Package";
import { getErrorMessage } from "@/utils/error";
import { formatPackageAmount, getPackageConfigStatusText } from "@/utils/package";
import { Message } from "@/utils/message";
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
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";
defineOptions({ name: "PackageConfigDetail" });
const route = useRoute();
const router = useRouter();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const currentStoreStore = useCurrentStoreStore();
const config = ref<GaoPackageConfig>();
@@ -197,20 +272,20 @@ function removeConfig(): void {
onMounted(async () => {
await loadData();
navBarStore.clearRight();
clearPageNavBarRight();
if (canUpdate.value) {
navBarStore.setRightText("编辑", "var(--td-brand-color)", toEdit);
setPageNavBarRightText("编辑", "var(--td-brand-color)", toEdit);
}
});
watch(canUpdate, value => {
navBarStore.clearRight();
clearPageNavBarRight();
if (value) {
navBarStore.setRightText("编辑", "var(--td-brand-color)", toEdit);
setPageNavBarRightText("编辑", "var(--td-brand-color)", toEdit);
}
});
onUnmounted(() => navBarStore.clearRight());
onUnmounted(() => clearPageNavBarRight());
</script>
<style scoped lang="less">
@@ -352,4 +427,45 @@ onUnmounted(() => navBarStore.clearRight());
color: #fdba74;
}
}
.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>
+139 -8
View File
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
:title="routeNavBarTitle"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div v-can="savePermissionCode" class="package-config-edit">
<t-form class="form" label-align="left" label-width="6rem" v-entrance-transition>
<t-form-item label="套餐名称" required-mark>
@@ -112,29 +157,74 @@
</template>
<script setup lang="ts">
import { AnimatedAmount, AnimatedNumber, Time } from "timi-web";
import { AnimatedAmount, Time } from "timi-web";
import { useUserStore } from "timi-web-api";
import PackageAPI from "@/api/PackageAPI";
import ProductSelectFormItem from "@/components/productSelector/ProductSelectFormItem.vue";
import { useCurrentStoreStore } from "@/store/currentStoreStore";
import { useNavBarStore } from "@/store/navBarStore";
import type { GaoPackageConfig, PackageConfigItem, PackageConfigStatus } from "@/types/Package";
import ProductAPI from "@/api/ProductAPI";
import type { Product, ProductSelection, ProductSku, ProductSkuUnit } from "@/types/Product";
import { getErrorMessage } from "@/utils/error";
import { formatPackageAmountInput, getPackageConfigStatusText, normalizePackageQuantity, parsePackageAmount } from "@/utils/package";
import {
formatPackageAmountInput,
getPackageConfigStatusText,
normalizePackageQuantity,
parsePackageAmount
} from "@/utils/package";
import { Message } from "@/utils/message";
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
import { formatProductAmount, getProductQuantityStep } from "@/utils/product";
import { getProductQuantityStep } from "@/utils/product";
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 };
defineOptions({ name: "PackageConfigEdit" });
const route = useRoute();
const routeNavBarTitle = computed(() => {
switch (route.name) {
case "PackageConfigCreate":
return "新增套餐配置";
case "PackageConfigEdit":
return "编辑套餐配置";
default:
return "";
}
});
const router = useRouter();
const userStore = useUserStore();
const navBarStore = useNavBarStore();
const currentStoreStore = useCurrentStoreStore();
const routeId = computed(() => String(route.params.id || ""));
const isCreateMode = computed(() => !routeId.value);
@@ -434,7 +524,7 @@ async function loadData(): Promise<void> {
onMounted(async () => {
if (userStore.hasPermissions(savePermissionCode.value)) {
navBarStore.setRightText("保存", "var(--td-brand-color)", save);
setPageNavBarRightText("保存", "var(--td-brand-color)", save);
}
try {
await loadData();
@@ -443,7 +533,7 @@ onMounted(async () => {
}
});
onUnmounted(() => navBarStore.clearRight());
onUnmounted(() => clearPageNavBarRight());
</script>
<style scoped lang="less">
@@ -547,4 +637,45 @@ onUnmounted(() => navBarStore.clearRight());
}
}
}
.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>
+178 -77
View File
@@ -1,102 +1,163 @@
<template>
<div v-can="permissionCodes.packageConfig.read" class="package-config-list">
<div class="filters glass">
<t-input
v-model.trim="keyword"
class="keyword"
borderless
clearable
placeholder="搜索套餐名称或说明"
/>
<t-dropdown-menu class="status">
<t-dropdown-item
v-model="status"
label="状态"
:options="statusOptions"
@change="selectStatus"
/>
</t-dropdown-menu>
</div>
<t-pull-down-refresh
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="reload"
@scrolltolower="loadMore"
<div class="page-layout navbar package-config-list">
<t-navbar
fixed
:z-index="20"
title="套餐配置"
left-arrow
@left-click="$router.back()"
>
<t-cell-group
v-if="configList.length"
class="list fix-last-cell-line empty-cell-title-margin"
theme="card"
>
<t-cell
class="item"
v-for="item in configList"
:key="item.id"
v-entrance-transition="{ step: 30 }"
<template #right>
<div
class="nav-actions"
v-if="(canCreate) && pageNavBarActionList.length"
>
<template #title>
<div class="title">
<strong v-text="item.name || '未命名套餐'" />
<t-tag :content="getPackageConfigStatusText(item.status)" variant="light-outline" :theme="getStatusTheme(item.status)" />
</div>
</template>
<template #description>
<div class="description">
<div class="products">
<t-tag
v-for="productItem in item.itemList || []"
:key="productItem.id || `${productItem.skuId}-${productItem.skuUnitId}`"
:content="getProductRightText(productItem)"
theme="primary"
variant="light"
/>
<t-tag v-if="!item.itemList?.length" content="暂无产品权益" />
<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>
<div class="price-actions">
<div class="price">
<span class="red">¥</span>
<span class="value red" v-text="formatPackageAmount(item.standardAmount)" />
</div>
<div v-if="item.id" class="actions" @click.stop>
<t-button
class="detail"
</template>
</t-popover>
</div>
</template>
</t-navbar>
<main v-can="permissionCodes.packageConfig.read" class="page-content scroll list">
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="reload"
@scrolltolower="loadMore"
>
<div class="filters glass">
<t-input
v-model.trim="keyword"
class="keyword"
borderless
clearable
placeholder="搜索套餐名称或说明"
/>
<t-dropdown-menu class="status">
<t-dropdown-item
v-model="status"
label="状态"
:options="statusOptions"
@change="selectStatus"
/>
</t-dropdown-menu>
</div>
<t-cell-group
v-if="configList.length"
class="list fix-last-cell-line empty-cell-title-margin"
theme="card"
>
<t-cell
class="item"
v-for="item in configList"
:key="item.id"
v-entrance-transition="{ step: 30 }"
>
<template #title>
<div class="title">
<strong v-text="item.name || '未命名套餐'" />
<t-tag :content="getPackageConfigStatusText(item.status)" variant="light-outline" :theme="getStatusTheme(item.status)" />
</div>
</template>
<template #description>
<div class="description">
<div class="products">
<t-tag
v-for="productItem in item.itemList || []"
:key="productItem.id || `${productItem.skuId}-${productItem.skuUnitId}`"
:content="getProductRightText(productItem)"
theme="primary"
size="extra-small"
content="详情"
@click.stop="toDetail(item)"
variant="light"
/>
<t-tag v-if="!item.itemList?.length" content="暂无产品权益" />
</div>
<div class="price-actions">
<div class="price">
<span class="red">¥</span>
<span class="value red" v-text="formatPackageAmount(item.standardAmount)" />
</div>
<div v-if="item.id" class="actions" @click.stop>
<t-button
class="detail"
theme="primary"
size="extra-small"
content="详情"
@click.stop="toDetail(item)"
/>
</div>
</div>
</div>
</div>
</template>
</t-cell>
</t-cell-group>
<div v-else class="center-tips" v-text="loading ? '正在加载套餐配置' : '暂无套餐配置'" />
<div class="center-tips" v-text="loadStateText" />
</t-pull-down-refresh>
</template>
</t-cell>
</t-cell-group>
<div v-else class="center-tips" v-text="loading ? '正在加载套餐配置' : '暂无套餐配置'" />
<div class="center-tips" v-text="loadStateText" />
</t-pull-down-refresh>
</main>
</div>
<nav-bar-action-menu v-if="canCreate" :actions="actionList" />
</template>
<script setup lang="ts">
import type { NavBarAction } from "@/types/NavBarAction";
import { type DropdownValue } from "tdesign-mobile-vue";
import { Toolkit } from "timi-web";
import { useUserStore } from "timi-web-api";
import PackageAPI from "@/api/PackageAPI";
import type { GaoPackageConfig, PackageConfigItem, PackageConfigStatus } from "@/types/Package";
import type { NavBarAction } from "@/types/NavBarAction";
import NavBarActionMenu from "@/components/NavBarActionMenu.vue";
import { useNavBarStore } from "@/store/navBarStore";
import { getErrorMessage } from "@/utils/error";
import { formatPackageAmount, getPackageConfigStatusText, getPackageQuantityText } from "@/utils/package";
import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission";
import { getProductSkuSnapshotText } from "@/utils/product";
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: "PackageConfigList" });
const router = useRouter();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const canCreate = computed(() => userStore.hasPermissions(permissionCodes.packageConfig.create));
const actionList = computed<NavBarAction[]>(() => canCreate.value ? [{
@@ -197,8 +258,7 @@ function getProductRightText(item: PackageConfigItem): string {
}
onMounted(async () => {
navBarStore.clearRight();
navBarStore.setCustomRightVisible(canCreate.value);
try {
await reload();
} catch (error) {
@@ -207,7 +267,6 @@ onMounted(async () => {
});
onUnmounted(() => {
navBarStore.clearRight();
reloadByKeyword.cancel();
});
</script>
@@ -313,4 +372,46 @@ 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>
+74 -67
View File
@@ -1,70 +1,80 @@
<template>
<div v-can="permissionCodes.packageConfig.read" class="package-order-config-list">
<div class="filters glass">
<t-input
v-model.trim="keyword"
class="keyword"
borderless
clearable
placeholder="搜索套餐名称或说明"
/>
<t-dropdown-menu class="status">
<t-dropdown-item
v-model="status"
label="状态"
:options="statusOptions"
@change="selectStatus"
/>
</t-dropdown-menu>
</div>
<t-pull-down-refresh
v-model="refreshing"
:refresh-timeout="30000"
@refresh="reload"
@scrolltolower="loadMore"
>
<t-cell-group
v-if="configList.length"
class="list fix-last-cell-line empty-cell-title-margin"
theme="card"
<div class="page-layout navbar package-order-config-list">
<t-navbar
fixed
:z-index="20"
title="选择套餐"
left-arrow
@left-click="$router.back()"
/>
<main v-can="permissionCodes.packageConfig.read" class="page-content scroll list">
<t-pull-down-refresh
class="pull-refresh"
v-model="refreshing"
:refresh-timeout="30000"
@refresh="reload"
@scrolltolower="loadMore"
>
<t-cell
v-for="item in configList"
:key="item.id"
class="item"
arrow
v-entrance-transition="{ step: 30 }"
@click="selectConfig(item)"
<div class="filters glass">
<t-input
v-model.trim="keyword"
class="keyword"
borderless
clearable
placeholder="搜索套餐名称或说明"
/>
<t-dropdown-menu class="status">
<t-dropdown-item
v-model="status"
label="状态"
:options="statusOptions"
@change="selectStatus"
/>
</t-dropdown-menu>
</div>
<t-cell-group
v-if="configList.length"
class="list fix-last-cell-line empty-cell-title-margin"
theme="card"
>
<template #title>
<div class="title">
<strong class="name clip-text" v-text="item.name || '未命名套餐'" />
<t-tag :content="getPackageConfigStatusText(item.status)" variant="light-outline" :theme="getStatusTheme(item.status)" />
</div>
</template>
<template #description>
<div class="description">
<div class="products">
<t-tag
v-for="productItem in item.itemList || []"
:key="productItem.id || `${productItem.skuId}-${productItem.skuUnitId}`"
:content="getProductText(productItem)"
theme="primary"
variant="light"
/>
<t-tag v-if="!item.itemList?.length" content="暂无产品权益" />
<t-cell
v-for="item in configList"
:key="item.id"
class="item"
arrow
v-entrance-transition="{ step: 30 }"
@click="selectConfig(item)"
>
<template #title>
<div class="title">
<strong class="name clip-text" v-text="item.name || '未命名套餐'" />
<t-tag :content="getPackageConfigStatusText(item.status)" variant="light-outline" :theme="getStatusTheme(item.status)" />
</div>
<div class="price">
<span class="label gray">标准价:</span>
<span class="value red" v-text="formatPackageAmount(item.standardAmount)" />
</template>
<template #description>
<div class="description">
<div class="products">
<t-tag
v-for="productItem in item.itemList || []"
:key="productItem.id || `${productItem.skuId}-${productItem.skuUnitId}`"
:content="getProductText(productItem)"
theme="primary"
variant="light"
/>
<t-tag v-if="!item.itemList?.length" content="暂无产品权益" />
</div>
<div class="price">
<span class="label gray">标准价:</span>
<span class="value red" v-text="formatPackageAmount(item.standardAmount)" />
</div>
</div>
</div>
</template>
</t-cell>
</t-cell-group>
<div v-else class="center-tips" v-text="loading ? '正在加载套餐' : '暂无套餐'" />
<div class="center-tips" v-text="loadStateText" />
</t-pull-down-refresh>
</template>
</t-cell>
</t-cell-group>
<div v-else class="center-tips" v-text="loading ? '正在加载套餐' : '暂无套餐'" />
<div class="center-tips" v-text="loadStateText" />
</t-pull-down-refresh>
</main>
</div>
</template>
@@ -72,19 +82,18 @@
import { type DropdownValue } from "tdesign-mobile-vue";
import { Toolkit } from "timi-web";
import PackageAPI from "@/api/PackageAPI";
import { useNavBarStore } from "@/store/navBarStore";
import type { GaoPackageConfig, PackageConfigItem, PackageConfigStatus } from "@/types/Package";
import { getErrorMessage } from "@/utils/error";
import { Message } from "@/utils/message";
import { formatPackageAmount, getPackageConfigStatusText, getPackageQuantityText } from "@/utils/package";
import { permissionCodes } from "@/utils/permission";
import { getProductSkuSnapshotText } from "@/utils/product";
import type { GaoPackageConfig, PackageConfigItem, PackageConfigStatus } from "@/types/Package";
defineOptions({ name: "PackageOrderConfigList" });
const route = useRoute();
const router = useRouter();
const navBarStore = useNavBarStore();
const keyword = ref("");
const status = ref("ALL");
@@ -184,7 +193,6 @@ function getProductText(item: PackageConfigItem): string {
}
onMounted(async () => {
navBarStore.clearRight();
try {
await reload();
} catch (error) {
@@ -193,7 +201,6 @@ onMounted(async () => {
});
onUnmounted(() => {
navBarStore.clearRight();
reloadByKeyword.cancel();
});
</script>
+133 -6
View File
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
:title="routeNavBarTitle"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div v-can="permissionCodes.customerPackage.create" class="package-purchase">
<t-form class="form" label-align="left" v-entrance-transition>
<t-form-item label="客户" required-mark>
@@ -342,8 +387,6 @@ import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
import ProductSelectFormItem from "@/components/productSelector/ProductSelectFormItem.vue";
import ProductStockPreview from "@/components/ProductStockPreview.vue";
import { usePackagePurchase } from "@/pages/package/usePackagePurchase";
import { useNavBarStore } from "@/store/navBarStore";
import { useSettingStore } from "@/store/settingStore";
import type { Customer } from "@/types/Customer";
import type { PhotoItem } from "@/types/Photo";
import type { GaoPackageConfig, PackageAttachment, PackageConfigItem, PackagePurchaseItem } from "@/types/Package";
@@ -366,13 +409,56 @@ import type { ProductStockPreviewItem } from "@/utils/productStock";
import { uploadPhotoList } from "@/utils/photo";
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";
defineOptions({
name: "PackagePurchase"
});
const route = useRoute();
const routeNavBarTitle = computed(() => {
switch (route.name) {
case "PackagePurchase":
return "购买套餐";
case "CustomerPackageCreate":
return "创建客户套餐";
default:
return "";
}
});
const router = useRouter();
const navBarStore = useNavBarStore();
const settingStore = useSettingStore();
const userStore = useUserStore();
@@ -938,9 +1024,9 @@ async function selectConfig(item: GaoPackageConfig): Promise<void> {
}
onMounted(async () => {
navBarStore.clearRight();
clearPageNavBarRight();
if (userStore.hasPermissions(permissionCodes.customerPackage.create)) {
navBarStore.setRightText("提交", "var(--td-brand-color)", submitRecord);
setPageNavBarRightText("提交", "var(--td-brand-color)", submitRecord);
}
try {
await loadPageData();
@@ -949,7 +1035,7 @@ onMounted(async () => {
}
});
onUnmounted(() => navBarStore.clearRight());
onUnmounted(() => clearPageNavBarRight());
watch(config, value => {
if (value) {
@@ -1199,4 +1285,45 @@ 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>
+37 -28
View File
@@ -1,33 +1,42 @@
<template>
<div v-can="{ value: [corePermissionCodes.role.read, corePermissionCodes.permission.read], mode: 'and' }" class="permission-list">
<t-pull-down-refresh
class="list-wrapper"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
>
<div class="content">
<t-cell-group v-entrance-transition class="header" theme="card">
<t-cell title="当前账号角色聚合权限 P">
<template #description>
<div>你拥有以下权限,可执行权限对应的功能,这些权限来自上级角色直接授权或子角色继承。</div>
<permission-legend />
</template>
</t-cell>
<div class="page-layout navbar permission-list">
<t-navbar
fixed
:z-index="20"
title="权限管理"
left-arrow
@left-click="$router.back()"
/>
<main v-can="{ value: [corePermissionCodes.role.read, corePermissionCodes.permission.read], mode: 'and' }" class="page-content scroll list">
<t-pull-down-refresh
class="list-wrapper pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
>
<div class="content">
<t-cell-group v-entrance-transition class="header" theme="card">
<t-cell title="当前账号角色聚合权限 P">
<template #description>
<div>你拥有以下权限,可执行权限对应的功能,这些权限来自上级角色直接授权或子角色继承。</div>
<permission-legend />
</template>
</t-cell>
</t-cell-group>
<t-cell-group v-if="sortedPermissions.length" theme="card">
<t-swipe-cell
v-entrance-transition="{ step: 30 }"
v-for="item in sortedPermissions"
:key="item.id"
class="item"
>
<permission-cell :permission="item" :source="item.source" />
</t-swipe-cell>
</t-cell-group>
<t-cell-group v-if="sortedPermissions.length" theme="card">
<t-swipe-cell
v-entrance-transition="{ step: 30 }"
v-for="item in sortedPermissions"
:key="item.id"
class="item"
>
<permission-cell :permission="item" :source="item.source" />
</t-swipe-cell>
</t-cell-group>
<t-empty v-if="!permissionStore.loading && !isSourceLoading" description="暂无权限" />
</div>
</t-pull-down-refresh>
<t-empty v-if="!permissionStore.loading && !isSourceLoading" description="暂无权限" />
</div>
</t-pull-down-refresh>
</main>
</div>
</template>
@@ -1,4 +1,11 @@
<template>
<t-navbar
fixed
:z-index="20"
title="权限设置"
left-arrow
@left-click="$router.back()"
/>
<div
v-can="{ value: [corePermissionCodes.role.read, corePermissionCodes.permission.read], mode: 'and' }"
class="permission-settings"
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
title="角色可转授权限 D"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div
v-can="{ value: [corePermissionCodes.role.read, corePermissionCodes.permission.read, corePermissionCodes.rolePermission.read], mode: 'and' }"
class="role-delegation-permission-assign"
@@ -45,17 +90,47 @@
import type { DropdownOption, DropdownValue } from "tdesign-mobile-vue";
import { Message } from "@/utils/message";
import { type Permission, useUserStore } from "timi-web-api";
import { useNavBarStore } from "@/store/navBarStore";
import { type Role, usePermissionSettingsStore } from "@/store/permissionSettingsStore";
import { getErrorMessage } from "@/utils/error";
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";
defineOptions({
name: "RoleDelegationPermissionAssign"
});
const permissionStore = usePermissionSettingsStore();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const route = useRoute();
@@ -146,15 +221,14 @@ async function savePermissionList(): Promise<void> {
}
function updateNavBar(): void {
navBarStore.clearRight();
clearPageNavBarRight();
if (canEditActiveRole.value && canUpdateRolePermission.value) {
navBarStore.setRightText("保存", "var(--td-brand-color)", savePermissionList);
setPageNavBarRightText("保存", "var(--td-brand-color)", savePermissionList);
}
}
watch([canEditActiveRole, canUpdateRolePermission], updateNavBar, { immediate: true });
onMounted(updateNavBar);
onUnmounted(navBarStore.clearRight);
// ---------- 权限勾选 ----------
@@ -258,4 +332,45 @@ 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>
+141 -10
View File
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
:title="routeNavBarTitle"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div v-can="pageAccess" class="role-edit">
<t-form v-entrance-transition class="form" label-align="left">
<t-form-item label="名称">
@@ -102,7 +147,46 @@ import { BottomPopup } from "timi-tdesign-mobile";
import { Message } from "@/utils/message";
import { useUserStore } from "timi-web-api";
import { useCurrentStoreStore } from "@/store/currentStoreStore";
import { useNavBarStore } from "@/store/navBarStore";
import { getErrorMessage } from "@/utils/error";
import { corePermissionCodes, coreRoleCodes } from "@/utils/permission";
import PermissionCell from "@/pages/permission/component/PermissionCell.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 {
moduleCode,
type Permission,
@@ -110,18 +194,24 @@ import {
type RoleDraft,
usePermissionSettingsStore
} from "@/store/permissionSettingsStore";
import { getErrorMessage } from "@/utils/error";
import { corePermissionCodes, coreRoleCodes } from "@/utils/permission";
import PermissionCell from "@/pages/permission/component/PermissionCell.vue";
import PermissionLegend from "@/pages/permission/component/PermissionLegend.vue";
defineOptions({
name: "RoleEdit"
});
const route = useRoute();
const routeNavBarTitle = computed(() => {
switch (route.name) {
case "RoleCreate":
return "新增角色";
case "RoleEdit":
return "编辑角色";
default:
return "";
}
});
const router = useRouter();
const navBarStore = useNavBarStore();
const permissionStore = usePermissionSettingsStore();
const currentStoreStore = useCurrentStoreStore();
const userStore = useUserStore();
@@ -467,13 +557,13 @@ async function getCurrentStoreId(): Promise<string> {
}
function updateNavBar(): void {
navBarStore.clearRight();
clearPageNavBarRight();
if (!hasSavePermission.value) {
return;
}
navBarStore.setRightText("保存", "var(--td-brand-color)", saveBaseInfo);
navBarStore.setRightDisabled(!canSaveBaseInfo.value);
setPageNavBarRightText("保存", "var(--td-brand-color)", saveBaseInfo);
setPageNavBarRightDisabled(!canSaveBaseInfo.value);
}
watch([hasSavePermission, canSaveBaseInfo], updateNavBar, { immediate: true });
@@ -483,7 +573,7 @@ onMounted(async () => {
updateNavBar();
});
onUnmounted(() => navBarStore.clearRight());
onUnmounted(() => clearPageNavBarRight());
</script>
<style scoped lang="less">
@@ -545,4 +635,45 @@ onUnmounted(() => navBarStore.clearRight());
background: #0f172a;
}
}
.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>
+152 -34
View File
@@ -1,36 +1,83 @@
<template>
<div v-can="{ value: [corePermissionCodes.role.read, corePermissionCodes.permission.read], mode: 'and' }" class="role-list">
<t-pull-down-refresh
class="list-wrapper"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
<div class="page-layout navbar role-list">
<t-navbar
fixed
:z-index="20"
title="角色管理"
left-arrow
@left-click="$router.back()"
>
<t-cell-group v-if="sortedRoles.length" theme="card">
<t-swipe-cell
v-entrance-transition="{ step: 30 }"
v-for="item in sortedRoles"
:key="item.id"
class="item"
<template #right>
<div
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"
>
<t-cell
:title="item.name"
:note="`${item.code} · ${getRoleScopeLabel(item)}`"
arrow
hover
@click="router.push(`/management/permissions/roles/${item.id}`)"
<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>
</t-navbar>
<main v-can="{ value: [corePermissionCodes.role.read, corePermissionCodes.permission.read], mode: 'and' }" class="page-content scroll list">
<t-pull-down-refresh
class="list-wrapper pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
>
<t-cell-group v-if="sortedRoles.length" theme="card">
<t-swipe-cell
v-entrance-transition="{ step: 30 }"
v-for="item in sortedRoles"
:key="item.id"
class="item"
>
<template #title>
<div class="title" v-text="item.name" :style="{ paddingLeft: `${item.level * 1.25}rem` }" />
<t-cell
:title="item.name"
:note="`${item.code} · ${getRoleScopeLabel(item)}`"
arrow
hover
@click="router.push(`/management/permissions/roles/${item.id}`)"
>
<template #title>
<div class="title" v-text="item.name" :style="{ paddingLeft: `${item.level * 1.25}rem` }" />
</template>
</t-cell>
<template #right>
<t-button v-if="canDeleteRole(item)" v-can="corePermissionCodes.role.delete" class="delete" theme="danger" @click="removeRole(item.id)">删除</t-button>
</template>
</t-cell>
<template #right>
<t-button v-if="canDeleteRole(item)" v-can="corePermissionCodes.role.delete" class="delete" theme="danger" @click="removeRole(item.id)">删除</t-button>
</template>
</t-swipe-cell>
</t-cell-group>
<t-empty v-else-if="!permissionStore.loading" description="暂无角色" />
</t-pull-down-refresh>
</t-swipe-cell>
</t-cell-group>
<t-empty v-else-if="!permissionStore.loading" description="暂无角色" />
</t-pull-down-refresh>
</main>
</div>
</template>
@@ -38,17 +85,47 @@
import { Message } from "@/utils/message";
import { useUserStore } from "timi-web-api";
import type { Role } from "@/store/permissionSettingsStore";
import { useNavBarStore } from "@/store/navBarStore";
import { usePermissionSettingsStore } from "@/store/permissionSettingsStore";
import { getErrorMessage } from "@/utils/error";
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";
defineOptions({
name: "RoleList"
});
const router = useRouter();
const navBarStore = useNavBarStore();
const permissionStore = usePermissionSettingsStore();
const userStore = useUserStore();
const isRefreshing = ref(false);
@@ -113,9 +190,9 @@ async function refresh(): Promise<void> {
}
onMounted(async () => {
navBarStore.clearRight();
clearPageNavBarRight();
if (canCreateRole.value) {
navBarStore.setRightText("添加", "var(--td-brand-color)", toCreate);
setPageNavBarRightText("添加", "var(--td-brand-color)", toCreate);
}
await permissionStore.loadAll();
await refreshAuthorizationScope();
@@ -125,7 +202,7 @@ onMounted(async () => {
});
onUnmounted(() => {
navBarStore.clearRight();
clearPageNavBarRight();
});
function getDisplayRoleList(): Role[] {
@@ -188,4 +265,45 @@ 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>
+122 -6
View File
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
title="角色直接授权权限 P"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div
v-can="{ value: [corePermissionCodes.role.read, corePermissionCodes.permission.read, corePermissionCodes.rolePermission.read], mode: 'and' }"
class="role-permission-assign"
@@ -52,17 +97,47 @@
import type { DropdownOption, DropdownValue } from "tdesign-mobile-vue";
import { Message } from "@/utils/message";
import { type Permission, useUserStore } from "timi-web-api";
import { useNavBarStore } from "@/store/navBarStore";
import { type Role, usePermissionSettingsStore } from "@/store/permissionSettingsStore";
import { getErrorMessage } from "@/utils/error";
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";
defineOptions({
name: "RolePermissionAssign"
});
const permissionStore = usePermissionSettingsStore();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const route = useRoute();
@@ -165,9 +240,9 @@ async function savePermissionList(): Promise<void> {
}
function updateNavBar(): void {
navBarStore.clearRight();
clearPageNavBarRight();
if (canEditActiveRole.value && canUpdateRolePermission.value) {
navBarStore.setRightText("保存", "var(--td-brand-color)", savePermissionList);
setPageNavBarRightText("保存", "var(--td-brand-color)", savePermissionList);
}
}
@@ -175,7 +250,7 @@ watch([canEditActiveRole, canUpdateRolePermission], updateNavBar, { immediate: t
onMounted(updateNavBar);
onUnmounted(() => {
navBarStore.clearRight();
clearPageNavBarRight();
});
// ---------- 权限勾选 ----------
@@ -319,4 +394,45 @@ 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>
@@ -13,6 +13,7 @@
<script setup lang="ts">
</script>
<style scoped lang="less">
+7
View File
@@ -1,4 +1,11 @@
<template>
<t-navbar
fixed
:z-index="20"
title="积分账户详情"
left-arrow
@left-click="$router.back()"
/>
<div v-can="permissionCodes.point.accountRead" class="point-account-detail">
<card-container v-if="customer" v-entrance-transition>
<customer-profile-card :customer="customer" />
+63 -53
View File
@@ -1,58 +1,68 @@
<template>
<div v-can="permissionCodes.point.accountRead" class="point-account-list">
<div class="filters glass">
<t-input
v-model.trim="keyword"
class="customer"
placeholder="搜索客户编码、姓名(拼音)"
borderless
>
<template #suffix-icon>
<t-button
size="extra-small"
theme="primary"
variant="outline"
content="选择客户"
@click.stop="customerSelectorVisible = true"
/>
</template>
</t-input>
</div>
<t-pull-down-refresh
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="reload"
@scrolltolower="load"
>
<div class="list-wrap">
<t-cell-group v-if="pageResult.list.length" class="list" theme="card">
<customer-cell
v-entrance-transition="{ step: 30 }"
v-for="item in pageResult.list"
:key="item.id"
:customer="item.customer"
class="item"
arrow
hover
@click="toDetail(item)"
>
<template #description>
<span>余额:</span>
<span
class="balance"
:class="getBalanceTheme(item.balance)"
v-text="formatPoints(item.balance)" />
</template>
</customer-cell>
</t-cell-group>
<div class="center-tips" v-text="loadStateText" />
</div>
</t-pull-down-refresh>
<customer-selector
v-model="selectedCustomerId"
v-model:visible="customerSelectorVisible"
@change="handleCustomerChange"
<div class="page-layout navbar point-account-list">
<t-navbar
fixed
:z-index="20"
title="积分账户"
left-arrow
@left-click="$router.back()"
/>
<main v-can="permissionCodes.point.accountRead" class="page-content scroll list">
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="reload"
@scrolltolower="load"
>
<div class="filters glass">
<t-input
v-model.trim="keyword"
class="customer"
placeholder="搜索客户编码、姓名(拼音)"
borderless
>
<template #suffix-icon>
<t-button
size="extra-small"
theme="primary"
variant="outline"
content="选择客户"
@click.stop="customerSelectorVisible = true"
/>
</template>
</t-input>
</div>
<div class="list-wrap">
<t-cell-group v-if="pageResult.list.length" class="list" theme="card">
<customer-cell
v-entrance-transition="{ step: 30 }"
v-for="item in pageResult.list"
:key="item.id"
:customer="item.customer"
class="item"
arrow
hover
@click="toDetail(item)"
>
<template #description>
<span>余额:</span>
<span
class="balance"
:class="getBalanceTheme(item.balance)"
v-text="formatPoints(item.balance)" />
</template>
</customer-cell>
</t-cell-group>
<div class="center-tips" v-text="loadStateText" />
</div>
</t-pull-down-refresh>
<customer-selector
v-model="selectedCustomerId"
v-model:visible="customerSelectorVisible"
@change="handleCustomerChange"
/>
</main>
</div>
</template>
+7
View File
@@ -1,4 +1,11 @@
<template>
<t-navbar
fixed
:z-index="20"
title="人工调整积分"
left-arrow
@left-click="$router.back()"
/>
<div v-can="permissionCodes.point.adjust" class="point-adjust">
<t-notice-bar
theme="warning"
+7
View File
@@ -1,4 +1,11 @@
<template>
<t-navbar
fixed
:z-index="20"
title="积分流水详情"
left-arrow
@left-click="$router.back()"
/>
<div v-if="customer" v-can="permissionCodes.point.ledgerRead" class="point-ledger-detail">
<customer-profile-card
class="customer-profile"
+142 -132
View File
@@ -1,143 +1,153 @@
<template>
<div v-can="permissionCodes.point.ledgerRead" class="point-ledger-list">
<div class="filters glass">
<t-input
v-model="customerKeyword"
class="customer"
type="search"
borderless
placeholder="输入客户编码或姓名"
@clear="searchCustomer"
@enter="searchCustomer"
@input="searchCustomer"
<div class="page-layout navbar point-ledger-list">
<t-navbar
fixed
:z-index="20"
title="积分流水"
left-arrow
@left-click="$router.back()"
/>
<main v-can="permissionCodes.point.ledgerRead" class="page-content scroll list">
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="reload"
@scrolltolower="load"
>
<template #suffix-icon>
<t-button
size="extra-small"
theme="primary"
variant="outline"
content="选择客户"
@click.stop="selectorVisible = true"
/>
</template>
</t-input>
<t-dropdown-menu class="menus">
<t-dropdown-item
v-model="changeTypeFilter"
label="流水类型"
:options="changeTypeOptions"
@change="selectChangeType"
/>
<t-dropdown-item
v-model="dateFilter"
:label="dateFilterLabel"
:options="dateFilterOptions"
@change="selectDateFilter"
/>
</t-dropdown-menu>
</div>
<t-pull-down-refresh
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="reload"
@scrolltolower="load"
>
<div class="list-wrap">
<card-container v-if="customer" class="customer">
<customer-profile-card :customer="customer" />
</card-container>
<t-cell-group class="summary" theme="card">
<t-cell
title="开始时间"
:note="dateRange[0] || '-'"
arrow
@click="openStartDate"
/>
<t-cell
title="结束时间"
:note="dateRange[1] || '-'"
arrow
@click="openEndDate"
/>
</t-cell-group>
<t-cell-group v-if="pageResult.list.length" class="list" theme="card">
<t-cell
v-entrance-transition="{ step: 30 }"
v-for="item in pageResult.list"
:key="item.id"
class="item"
:arrow="!!item.id"
:hover="!!item.id"
@click="toDetail(item)"
<div class="filters glass">
<t-input
v-model="customerKeyword"
class="customer"
type="search"
borderless
placeholder="输入客户编码或姓名"
@clear="searchCustomer"
@enter="searchCustomer"
@input="searchCustomer"
>
<template #leftIcon>
<t-image
v-if="getCustomerPhotoURL(item.customer!, 64)"
:src="getCustomerPhotoURL(item.customer!, 64)"
fit="cover"
class="avatar"
<template #suffix-icon>
<t-button
size="extra-small"
theme="primary"
variant="outline"
content="选择客户"
@click.stop="selectorVisible = true"
/>
<div v-else class="avatar fallback" v-text="(item.customer?.name || item.customer?.code || '客').slice(0, 1)" />
</template>
<template #title>
<div class="title">
<t-tag
class="type-icon"
:theme="item.pointDelta && 0 < item.pointDelta ? 'success' : 'danger'"
:content="getLedgerShortType(item)"
variant="outline"
</t-input>
<t-dropdown-menu class="menus">
<t-dropdown-item
v-model="changeTypeFilter"
label="流水类型"
:options="changeTypeOptions"
@change="selectChangeType"
/>
<t-dropdown-item
v-model="dateFilter"
:label="dateFilterLabel"
:options="dateFilterOptions"
@change="selectDateFilter"
/>
</t-dropdown-menu>
</div>
<div class="list-wrap">
<card-container v-if="customer" class="customer">
<customer-profile-card :customer="customer" />
</card-container>
<t-cell-group class="summary" theme="card">
<t-cell
title="开始时间"
:note="dateRange[0] || '-'"
arrow
@click="openStartDate"
/>
<t-cell
title="结束时间"
:note="dateRange[1] || '-'"
arrow
@click="openEndDate"
/>
</t-cell-group>
<t-cell-group v-if="pageResult.list.length" class="list" theme="card">
<t-cell
v-entrance-transition="{ step: 30 }"
v-for="item in pageResult.list"
:key="item.id"
class="item"
:arrow="!!item.id"
:hover="!!item.id"
@click="toDetail(item)"
>
<template #leftIcon>
<t-image
v-if="getCustomerPhotoURL(item.customer!, 64)"
:src="getCustomerPhotoURL(item.customer!, 64)"
fit="cover"
class="avatar"
/>
<div class="name" v-text="item.customer?.name" />
</div>
</template>
<template #description>
<div class="description">
<div>
<span>时间:</span>
<pass-time-label :timestamp="item.occurredAt" underline />
<div v-else class="avatar fallback" v-text="(item.customer?.name || item.customer?.code || '客').slice(0, 1)" />
</template>
<template #title>
<div class="title">
<t-tag
class="type-icon"
:theme="item.pointDelta && 0 < item.pointDelta ? 'success' : 'danger'"
:content="getLedgerShortType(item)"
variant="outline"
/>
<div class="name" v-text="item.customer?.name" />
</div>
<div v-text="`余额:${formatPointValue(item.balanceBefore)} → ${formatPointValue(item.balanceAfter)}`" />
<div v-text="item.remark" />
</div>
</template>
<template #note>
<div class="delta keep-text" :class="getLedgerTheme(item)" v-text="getLedgerDelta(item)" />
</template>
</t-cell>
</t-cell-group>
<div class="center-tips" v-text="loadStateText" />
</div>
</t-pull-down-refresh>
</template>
<template #description>
<div class="description">
<div>
<span>时间:</span>
<pass-time-label :timestamp="item.occurredAt" underline />
</div>
<div v-text="`余额:${formatPointValue(item.balanceBefore)} → ${formatPointValue(item.balanceAfter)}`" />
<div v-text="item.remark" />
</div>
</template>
<template #note>
<div class="delta keep-text" :class="getLedgerTheme(item)" v-text="getLedgerDelta(item)" />
</template>
</t-cell>
</t-cell-group>
<div class="center-tips" v-text="loadStateText" />
</div>
</t-pull-down-refresh>
</main>
<customer-selector
v-model="selectedCustomerId"
v-model:visible="selectorVisible"
@change="handleCustomerChange"
/>
<t-popup v-model="startDateVisible" placement="bottom">
<t-date-time-picker
v-if="startDateVisible"
v-model="startDraft"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="开始时间"
:default-value="dateRange[0]"
@cancel="cancelStartDate"
@confirm="confirmStartDate"
/>
</t-popup>
<t-popup v-model="endDateVisible" placement="bottom">
<t-date-time-picker
v-if="endDateVisible"
v-model="endDraft"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="结束时间"
:default-value="dateRange[1]"
@cancel="cancelEndDate"
@confirm="confirmEndDate"
/>
</t-popup>
</div>
<customer-selector
v-model="selectedCustomerId"
v-model:visible="selectorVisible"
@change="handleCustomerChange"
/>
<t-popup v-model="startDateVisible" placement="bottom">
<t-date-time-picker
v-if="startDateVisible"
v-model="startDraft"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="开始时间"
:default-value="dateRange[0]"
@cancel="cancelStartDate"
@confirm="confirmStartDate"
/>
</t-popup>
<t-popup v-model="endDateVisible" placement="bottom">
<t-date-time-picker
v-if="endDateVisible"
v-model="endDraft"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="结束时间"
:default-value="dateRange[1]"
@cancel="cancelEndDate"
@confirm="confirmEndDate"
/>
</t-popup>
</template>
<script setup lang="ts">
+132 -5
View File
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
:title="routeNavBarTitle"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div v-can="permissionCodes.pointRedeemSku.manage" class="redeem-sku-edit">
<t-form class="form" v-entrance-transition>
<product-select-form-item
@@ -58,18 +103,59 @@
<script setup lang="ts">
import PointAPI from "@/api/PointAPI";
import ProductSelectFormItem from "@/components/productSelector/ProductSelectFormItem.vue";
import { useNavBarStore } from "@/store/navBarStore";
import type { PointRedeemSku, PointRedeemSkuStatus } from "@/types/Point";
import type { ProductSelection } from "@/types/Product";
import { getErrorMessage } from "@/utils/error";
import { Message } from "@/utils/message";
import { normalizePackageQuantity } from "@/utils/package";
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";
defineOptions({ name: "PointRedeemSkuEdit" });
const route = useRoute();
const routeNavBarTitle = computed(() => {
switch (route.name) {
case "PointRedeemSkuCreate":
return "新增兑换商品";
case "PointRedeemSkuEdit":
return "编辑兑换商品";
default:
return "";
}
});
const router = useRouter();
const navBarStore = useNavBarStore();
const selection = ref<{ skuId: string; skuUnitId: string }>();
const statusVisible = ref(false);
const statusDraft = ref<Array<string | number>>(["DRAFT"]);
@@ -188,7 +274,7 @@ async function remove(): Promise<void> {
}
onMounted(async () => {
navBarStore.setRightText("保存", "var(--td-brand-color)", save);
setPageNavBarRightText("保存", "var(--td-brand-color)", save);
try {
await load();
} catch (error) {
@@ -196,7 +282,7 @@ onMounted(async () => {
}
});
onUnmounted(() => navBarStore.clearRight());
onUnmounted(() => clearPageNavBarRight());
</script>
<style scoped lang="less">
@@ -210,4 +296,45 @@ onUnmounted(() => navBarStore.clearRight());
font-size: .875rem;
}
}
.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>
+173 -66
View File
@@ -1,85 +1,151 @@
<template>
<div v-can="permissionCodes.pointRedeemSku.manage" class="redeem-sku-list">
<div class="filters glass">
<t-input
v-model.trim="keyword"
class="keyword"
type="search"
borderless
clearable
placeholder="搜索产品名称、编码或 SKU"
/>
</div>
<t-pull-down-refresh v-model="isRefreshing" :refresh-timeout="30000" @refresh="reload" @scrolltolower="load">
<t-cell-group v-if="result.list.length" theme="card">
<t-cell
v-for="item in result.list"
:key="item.id"
class="item"
arrow
v-entrance-transition="{ step: 30 }"
@click="toEdit(item)"
<div class="page-layout navbar redeem-sku-list">
<t-navbar
fixed
:z-index="20"
title="兑换商品"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
class="nav-actions"
v-if="pageNavBarActionList.length"
v-can="permissionCodes.pointRedeemSku.manage"
>
<template #left-icon>
<t-image
v-if="getProductPhoto(item)"
:src="getProductPhoto(item)"
:alt="item.product?.name || item.sku?.name || '产品图片'"
fit="cover"
class="avatar"
/>
<div
v-else
class="avatar fallback"
v-text="(item.product?.name || item.sku?.name || '产').slice(0, 1)"
/>
</template>
<template #title>
<span class="clip-text" v-text="item.product?.name || item.sku?.name || '未命名产品'" />
</template>
<template #note>
<span class="orange keep-text" v-text="formatPoint(item.defaultPointCost)" />
</template>
<template #description>
<div class="description">
<t-tag
size="small"
:theme="item.status === 'ACTIVE' ? 'success' : 'default'"
:content="statusText(item.status)"
<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>
</template>
</t-navbar>
<main v-can="permissionCodes.pointRedeemSku.manage" class="page-content scroll list">
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="reload"
@scrolltolower="load"
>
<div class="filters glass">
<t-input
v-model.trim="keyword"
class="keyword"
type="search"
borderless
clearable
placeholder="搜索产品名称、编码或 SKU"
/>
</div>
<t-cell-group v-if="result.list.length" theme="card">
<t-cell
v-for="item in result.list"
:key="item.id"
class="item"
arrow
v-entrance-transition="{ step: 30 }"
@click="toEdit(item)"
>
<template #left-icon>
<t-image
v-if="getProductPhoto(item)"
:src="getProductPhoto(item)"
:alt="item.product?.name || item.sku?.name || '产品图片'"
fit="cover"
class="avatar"
/>
<product-sku-tags
:product-name="item.product?.name"
:fallback="item.sku?.specSummary || item.sku?.name || '默认 SKU'"
:unit="item.unit?.name"
<div
v-else
class="avatar fallback"
v-text="(item.product?.name || item.sku?.name || '产').slice(0, 1)"
/>
</div>
</template>
</t-cell>
</t-cell-group>
<t-empty v-else :description="isLoading ? '正在加载兑换配置' : '暂无兑换配置'" />
<div class="tips" v-text="isNoMore ? `共 ${result.total} 条配置` : '上拉加载更多'" />
</t-pull-down-refresh>
</template>
<template #title>
<span class="clip-text" v-text="item.product?.name || item.sku?.name || '未命名产品'" />
</template>
<template #note>
<span class="orange keep-text" v-text="formatPoint(item.defaultPointCost)" />
</template>
<template #description>
<div class="description">
<t-tag
size="small"
:theme="item.status === 'ACTIVE' ? 'success' : 'default'"
:content="statusText(item.status)"
/>
<product-sku-tags
:product-name="item.product?.name"
:fallback="item.sku?.specSummary || item.sku?.name || '默认 SKU'"
:unit="item.unit?.name"
/>
</div>
</template>
</t-cell>
</t-cell-group>
<t-empty v-else :description="isLoading ? '正在加载兑换配置' : '暂无兑换配置'" />
<div class="tips" v-text="isNoMore ? `共 ${result.total} 条配置` : '上拉加载更多'" />
</t-pull-down-refresh>
</main>
</div>
<nav-bar-action-menu
v-can="permissionCodes.pointRedeemSku.manage"
:actions="[{ key: 'create', icon: 'add', text: '新增兑换配置', theme: 'primary', action: toCreate }]"
/>
</template>
<script setup lang="ts">
import type { NavBarAction } from "@/types/NavBarAction";
import { Toolkit } from "timi-web";
import PointAPI from "@/api/PointAPI";
import ProductSkuTags from "@/components/ProductSkuTags.vue";
import { useNavBarStore } from "@/store/navBarStore";
import type { PointRedeemSku, PointRedeemSkuStatus } from "@/types/Point";
import { Message } from "@/utils/message";
import { formatWanInteger } from "@/utils/money";
import { getProductPhotoURL } from "@/utils/product";
import { permissionCodes } from "@/utils/permission";
const pageNavBarActionVisible = ref(false);
const pageNavBarActionList = computed<NavBarAction[]>(() => (unref([{ key: "create", icon: "add", text: "新增兑换配置", theme: "primary", action: toCreate }]) as NavBarAction[]).filter(action => action.visible !== false));
async function handlePageNavBarAction(action: NavBarAction): Promise<void> {
pageNavBarActionVisible.value = false;
await action.action();
}
import type { PointRedeemSku, PointRedeemSkuStatus } from "@/types/Point";
defineOptions({ name: "PointRedeemSkuList" });
const router = useRouter();
const navBarStore = useNavBarStore();
const result = reactive({ total: 0, list: [] as PointRedeemSku[] });
const keyword = shallowRef("");
const index = ref(0);
@@ -165,7 +231,7 @@ async function toEdit(item: PointRedeemSku): Promise<void> {
}
onMounted(async () => {
navBarStore.setCustomRightVisible(true);
await reload();
});
@@ -175,7 +241,6 @@ watch(keyword, () => {
onUnmounted(() => {
reloadByKeyword.cancel();
navBarStore.clearRight();
});
</script>
@@ -245,4 +310,46 @@ 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>
+121 -5
View File
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
title="客户兑换"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div v-can="permissionCodes.pointRedemption.create" class="redemption-create">
<t-form class="form" label-width="7rem" v-entrance-transition>
<t-form-item label="客户" required-mark>
@@ -135,8 +180,6 @@ import CodeScanner from "@/components/CodeScanner.vue";
import CustomerProfileCard from "@/components/CustomerProfileCard.vue";
import CustomerSelector from "@/components/CustomerSelector.vue";
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
import { useNavBarStore } from "@/store/navBarStore";
import { useSettingStore } from "@/store/settingStore";
import type { Customer } from "@/types/Customer";
import type { PhotoItem } from "@/types/Photo";
import type { PointAccount, PointRedeemSku } from "@/types/Point";
@@ -148,10 +191,42 @@ import { getProductPhotoURL, getProductQuantityStep } from "@/utils/product";
import { uploadPhotoList } from "@/utils/photo";
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";
defineOptions({ name: "PointRedemptionCreate" });
const router = useRouter();
const navBarStore = useNavBarStore();
const settingStore = useSettingStore();
const userStore = useUserStore();
const customerId = ref("");
@@ -332,7 +407,7 @@ function formatPoint(value?: number): string {
}
onMounted(async () => {
navBarStore.setRightText("兑换", "var(--td-brand-color)", save);
setPageNavBarRightText("兑换", "var(--td-brand-color)", save);
try {
await loadSkuList();
} catch (error) {
@@ -340,7 +415,7 @@ onMounted(async () => {
}
});
onUnmounted(() => navBarStore.clearRight());
onUnmounted(() => clearPageNavBarRight());
</script>
<style scoped lang="less">
@@ -412,4 +487,45 @@ onUnmounted(() => navBarStore.clearRight());
}
}
}
.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>
@@ -1,4 +1,11 @@
<template>
<t-navbar
fixed
:z-index="20"
title="兑换详情"
left-arrow
@left-click="$router.back()"
/>
<div v-can="permissionCodes.pointRedemption.create" class="redemption-detail">
<customer-profile-card
v-if="customer"
+250 -148
View File
@@ -1,162 +1,214 @@
<template>
<div v-can="permissionCodes.pointRedemption.create" class="redemption-list">
<div class="filters glass">
<t-input
v-model.trim="keyword"
class="keyword"
clearable
borderless
placeholder="搜索客户、产品或 SKU"
>
<template #suffix-icon>
<div class="actions">
<t-button
v-if="customerId"
shape="circle"
theme="danger"
variant="text"
size="extra-small"
aria-label="清除客户选择"
@click.stop="clearCustomer"
>
<t-icon name="close" size="1rem" />
</t-button>
<t-button
size="extra-small"
theme="primary"
variant="outline"
content="选择客户"
@click.stop="customerSelectorVisible = true"
/>
</div>
</template>
</t-input>
<t-dropdown-menu class="menus">
<t-dropdown-item
v-model="dateFilterType"
:label="dateFilterLabel"
:options="dateOptions"
@change="selectDateFilter"
/>
</t-dropdown-menu>
</div>
<t-pull-down-refresh
v-model="refreshing"
:refresh-timeout="30000"
@refresh="reload"
@scrolltolower="load"
<div class="page-layout navbar redemption-list">
<t-navbar
fixed
:z-index="20"
title="积分兑换"
left-arrow
@left-click="$router.back()"
>
<div class="list-wrap">
<t-cell-group class="date-summary" theme="card" v-entrance-transition>
<template v-if="isCustomDate">
<t-cell
title="开始时间"
:note="dateRange[0] || '-'"
arrow
@click="openStartTime"
/>
<t-cell
title="结束时间"
:note="dateRange[1] || '-'"
arrow
@click="openEndTime"
/>
</template>
<t-cell title="兑换次数" :note="`${Text.display(result.total)} 次`" />
</t-cell-group>
<div v-if="result.list.length" class="items">
<t-cell-group theme="card">
<t-cell
v-for="item in result.list"
:key="item.id"
class="item"
arrow
v-entrance-transition="{ step: 30 }"
@click="toDetail(item)"
<template #right>
<div
class="nav-actions"
v-if="pageNavBarActionList.length"
v-can="permissionCodes.pointRedemption.create"
>
<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 #left-icon>
<t-image
v-if="getCustomerPhoto(item)"
:src="getCustomerPhoto(item)"
:alt="item.customer?.name || '客户照片'"
fit="cover"
class="avatar"
/>
<div
v-else
class="avatar fallback"
v-text="(item.customer?.name || item.customer?.code || '客').slice(0, 1)"
/>
<template #icon>
<t-icon name="ellipsis" />
</template>
<template #title>
<div class="title">
<strong v-text="item.productNameSnapshot || item.skuNameSnapshot || '未命名产品'" />
<t-tag
size="small"
:theme="item.status === 'FULLY_RETURNED' ? 'default' : 'success'"
:content="statusText(item.status)"
/>
</div>
</template>
<template #note>
<span class="orange" v-text="formatPoint(item.actualPointCost)" />
</template>
<template #description>
<span v-text="`${item.customer?.name || item.customerId || '未知客户'} · ${quantityText(item.quantity)} ${item.unitSnapshot || ''}`" />
</template>
</t-cell>
</t-cell-group>
</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>
<t-empty
v-else
:description="loading ? '正在加载兑换记录' : hasFilter ? '未找到匹配的兑换记录' : '暂无兑换记录'"
/>
</div>
</t-pull-down-refresh>
</template>
</t-navbar>
<main v-can="permissionCodes.pointRedemption.create" class="page-content scroll list">
<t-pull-down-refresh
class="pull-refresh"
v-model="refreshing"
:refresh-timeout="30000"
@refresh="reload"
@scrolltolower="load"
>
<div class="filters glass">
<t-input
v-model.trim="keyword"
class="keyword"
clearable
borderless
placeholder="搜索客户、产品或 SKU"
>
<template #suffix-icon>
<div class="actions">
<t-button
v-if="customerId"
shape="circle"
theme="danger"
variant="text"
size="extra-small"
aria-label="清除客户选择"
@click.stop="clearCustomer"
>
<t-icon name="close" size="1rem" />
</t-button>
<t-button
size="extra-small"
theme="primary"
variant="outline"
content="选择客户"
@click.stop="customerSelectorVisible = true"
/>
</div>
</template>
</t-input>
<t-dropdown-menu class="menus">
<t-dropdown-item
v-model="dateFilterType"
:label="dateFilterLabel"
:options="dateOptions"
@change="selectDateFilter"
/>
</t-dropdown-menu>
</div>
<div class="list-wrap">
<t-cell-group class="date-summary" theme="card" v-entrance-transition>
<template v-if="isCustomDate">
<t-cell
title="开始时间"
:note="dateRange[0] || '-'"
arrow
@click="openStartTime"
/>
<t-cell
title="结束时间"
:note="dateRange[1] || '-'"
arrow
@click="openEndTime"
/>
</template>
<t-cell title="兑换次数" :note="`${Text.display(result.total)} 次`" />
</t-cell-group>
<div v-if="result.list.length" class="items">
<t-cell-group theme="card">
<t-cell
v-for="item in result.list"
:key="item.id"
class="item"
arrow
v-entrance-transition="{ step: 30 }"
@click="toDetail(item)"
>
<template #left-icon>
<t-image
v-if="getCustomerPhoto(item)"
:src="getCustomerPhoto(item)"
:alt="item.customer?.name || '客户照片'"
fit="cover"
class="avatar"
/>
<div
v-else
class="avatar fallback"
v-text="(item.customer?.name || item.customer?.code || '客').slice(0, 1)"
/>
</template>
<template #title>
<div class="title">
<strong v-text="item.productNameSnapshot || item.skuNameSnapshot || '未命名产品'" />
<t-tag
size="small"
:theme="item.status === 'FULLY_RETURNED' ? 'default' : 'success'"
:content="statusText(item.status)"
/>
</div>
</template>
<template #note>
<span class="orange" v-text="formatPoint(item.actualPointCost)" />
</template>
<template #description>
<span v-text="`${item.customer?.name || item.customerId || '未知客户'} · ${quantityText(item.quantity)} ${item.unitSnapshot || ''}`" />
</template>
</t-cell>
</t-cell-group>
</div>
<t-empty
v-else
:description="loading ? '正在加载兑换记录' : hasFilter ? '未找到匹配的兑换记录' : '暂无兑换记录'"
/>
</div>
</t-pull-down-refresh>
</main>
<customer-selector
v-model="customerId"
v-model:visible="customerSelectorVisible"
@change="handleCustomerChange"
/>
<t-popup v-model="startVisible" placement="bottom">
<t-date-time-picker
v-if="startVisible"
v-model="startDraft"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="开始时间"
:default-value="dateRange[0]"
@cancel="cancelStartTime"
@confirm="confirmStartTime"
/>
</t-popup>
<t-popup v-model="endVisible" placement="bottom">
<t-date-time-picker
v-if="endVisible"
v-model="endDraft"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="结束时间"
:default-value="dateRange[1]"
@cancel="cancelEndTime"
@confirm="confirmEndTime"
/>
</t-popup>
</div>
<customer-selector
v-model="customerId"
v-model:visible="customerSelectorVisible"
@change="handleCustomerChange"
/>
<nav-bar-action-menu
v-can="permissionCodes.pointRedemption.create"
:actions="[{ key: 'create', icon: 'add', text: '客户兑换', theme: 'primary', action: toCreate }]"
/>
<t-popup v-model="startVisible" placement="bottom">
<t-date-time-picker
v-if="startVisible"
v-model="startDraft"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="开始时间"
:default-value="dateRange[0]"
@cancel="cancelStartTime"
@confirm="confirmStartTime"
/>
</t-popup>
<t-popup v-model="endVisible" placement="bottom">
<t-date-time-picker
v-if="endVisible"
v-model="endDraft"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="结束时间"
:default-value="dateRange[1]"
@cancel="cancelEndTime"
@confirm="confirmEndTime"
/>
</t-popup>
</template>
<script setup lang="ts">
import type { NavBarAction } from "@/types/NavBarAction";
import { type DropdownValue } from "tdesign-mobile-vue";
import { Text, Time, Toolkit } from "timi-web";
import CustomerAPI from "@/api/CustomerAPI";
import PointAPI from "@/api/PointAPI";
import CustomerSelector from "@/components/CustomerSelector.vue";
import { useNavBarStore } from "@/store/navBarStore";
import type { Customer } from "@/types/Customer";
import type { PointRedemption, PointRedemptionStatus } from "@/types/Point";
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
import { Message } from "@/utils/message";
@@ -165,11 +217,20 @@ import { getPackageQuantityText } from "@/utils/package";
import { getCustomerPhotoURL } from "@/utils/customer";
import { permissionCodes } from "@/utils/permission";
const pageNavBarActionVisible = ref(false);
const pageNavBarActionList = computed<NavBarAction[]>(() => (unref([{ key: "create", icon: "add", text: "客户兑换", theme: "primary", action: toCreate }]) as NavBarAction[]).filter(action => action.visible !== false));
async function handlePageNavBarAction(action: NavBarAction): Promise<void> {
pageNavBarActionVisible.value = false;
await action.action();
}
import type { Customer } from "@/types/Customer";
defineOptions({ name: "PointRedemptionList" });
const route = useRoute();
const router = useRouter();
const navBarStore = useNavBarStore();
const result = reactive({ total: 0, list: [] as PointRedemption[] });
type DateFilterType = "today" | "yesterday" | "thisWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
const dateOptions: Array<{ label: string; value: DateFilterType }> = [
@@ -384,7 +445,7 @@ async function toDetail(item: PointRedemption): Promise<void> {
}
onMounted(async () => {
navBarStore.setCustomRightVisible(true);
try {
if (customerId.value) {
selectedCustomer.value = await CustomerAPI.detail(customerId.value);
@@ -405,7 +466,6 @@ watch(keyword, () => {
onUnmounted(() => {
reloadByKeyword.cancel();
navBarStore.clearRight();
});
</script>
@@ -502,4 +562,46 @@ 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>
+123 -7
View File
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
title="积分规则详情"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div v-can="permissionCodes.pointRule.read" class="point-rule-detail">
<section v-if="rule" class="rule-header" v-entrance-transition>
<div class="point-icon" :class="{ consume: isConsumeRule }">
@@ -96,21 +141,51 @@ import { useUserStore } from "timi-web-api";
import EventAPI from "@/api/EventAPI";
import PointAPI from "@/api/PointAPI";
import { useCurrentStoreStore } from "@/store/currentStoreStore";
import { useNavBarStore } from "@/store/navBarStore";
import type { EventItem } from "@/types/EventItem";
import type { PointRule, PointRuleStatus } from "@/types/Point";
import { getErrorMessage } from "@/utils/error";
import { Message } from "@/utils/message";
import { formatWanInteger } from "@/utils/money";
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";
defineOptions({
name: "PointRuleDetail"
});
const route = useRoute();
const router = useRouter();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const currentStoreStore = useCurrentStoreStore();
@@ -257,7 +332,7 @@ async function removeRule(): Promise<void> {
}
isDeleting.value = true;
navBarStore.clearRight();
clearPageNavBarRight();
try {
await PointAPI.ruleRemove(ruleId);
Message.success("积分规则已删除");
@@ -274,7 +349,7 @@ async function removeRule(): Promise<void> {
function setEditAction(): void {
if (canUpdate.value) {
navBarStore.setRightText("编辑", "var(--td-brand-color)", toEdit);
setPageNavBarRightText("编辑", "var(--td-brand-color)", toEdit);
}
}
@@ -306,12 +381,12 @@ watch(() => route.params.id, async () => {
}, { immediate: true });
onMounted(() => {
navBarStore.clearRight();
clearPageNavBarRight();
setEditAction();
});
onUnmounted(() => {
navBarStore.clearRight();
clearPageNavBarRight();
});
</script>
@@ -391,4 +466,45 @@ 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>
+132 -5
View File
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
:title="routeNavBarTitle"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div v-can="pageAccess" class="point-rule-edit">
<t-form class="form" label-align="left" label-width="7rem">
<card-container v-entrance-transition>
@@ -145,8 +190,6 @@ import EventAPI from "@/api/EventAPI";
import PointRuleScriptPicker from "@/pages/point/component/PointRuleScriptPicker.vue";
import PointAPI from "@/api/PointAPI";
import { useCurrentStoreStore } from "@/store/currentStoreStore";
import { useNavBarStore } from "@/store/navBarStore";
import type { EventItem } from "@/types/EventItem";
import type {
GroovyScript,
PointAction,
@@ -159,6 +202,39 @@ import { getErrorMessage } from "@/utils/error";
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
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";
type PickerValue = string | number;
defineOptions({
@@ -166,8 +242,18 @@ defineOptions({
});
const route = useRoute();
const routeNavBarTitle = computed(() => {
switch (route.name) {
case "PointRuleCreate":
return "新增积分规则";
case "PointRuleEdit":
return "编辑积分规则";
default:
return "";
}
});
const router = useRouter();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const currentStoreStore = useCurrentStoreStore();
const routeId = computed(() => String(route.params.id || ""));
@@ -537,7 +623,7 @@ async function fillForm(): Promise<void> {
onMounted(async () => {
if (userStore.hasPermissions(savePermissionCode.value)) {
navBarStore.setRightText("保存", "var(--td-brand-color)", saveRule);
setPageNavBarRightText("保存", "var(--td-brand-color)", saveRule);
}
try {
await fillForm();
@@ -546,7 +632,7 @@ onMounted(async () => {
}
});
onUnmounted(() => navBarStore.clearRight());
onUnmounted(() => clearPageNavBarRight());
</script>
<style scoped lang="less">
@@ -602,4 +688,45 @@ onUnmounted(() => navBarStore.clearRight());
}
}
}
.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>
+165 -64
View File
@@ -1,86 +1,147 @@
<template>
<div v-can="permissionCodes.pointRule.read" class="point-rule-list">
<div class="filter-menu">
<t-dropdown-menu>
<t-dropdown-item
v-model="statusFilter"
label="规则状态"
:options="statusOptions"
@change="selectStatus"
/>
</t-dropdown-menu>
</div>
<t-pull-down-refresh
class="list-wrapper"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="reload"
@scrolltolower="load"
<div class="page-layout navbar point-rule-list">
<t-navbar
fixed
:z-index="20"
title="积分规则"
left-arrow
@left-click="$router.back()"
>
<t-cell-group
v-if="pageResult.list.length"
class="list empty-cell-title-margin"
theme="card"
>
<t-cell
v-for="item in pageResult.list"
:key="item.id"
class="item"
:arrow="!!item.id"
:hover="!!item.id"
v-entrance-transition="{ step: 30 }"
@click="toDetail(item)"
<template #right>
<div
class="nav-actions"
v-if="(canShowActionMenu) && pageNavBarActionList.length"
>
<template #left-icon>
<div class="point" :class="{ 'consume': item.pointValue && item.pointValue < 0 }">
<t-icon name="money" />
<span v-text="getPointText(item)" />
</div>
</template>
<template #title>
<div class="title">
<h4 class="text" v-text="item.name || '未命名规则'" />
<t-tag
:theme="getStatusTheme(item.status)"
variant="light-outline"
:content="getStatusText(item.status)"
/>
</div>
</template>
<template #description>
<div class="description">
<div v-text="`触发来源:${getTriggerSourceText(item)}`"></div>
<div v-text="`触发对象:${getTriggerRefText(item)}`"></div>
</div>
</template>
</t-cell>
</t-cell-group>
<div class="center-tips" v-text="loadStateText" />
</t-pull-down-refresh>
<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>
</template>
</t-navbar>
<main v-can="permissionCodes.pointRule.read" class="page-content scroll list">
<t-pull-down-refresh
class="list-wrapper pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="reload"
@scrolltolower="load"
>
<div class="filter-menu">
<t-dropdown-menu>
<t-dropdown-item
v-model="statusFilter"
label="规则状态"
:options="statusOptions"
@change="selectStatus"
/>
</t-dropdown-menu>
</div>
<t-cell-group
v-if="pageResult.list.length"
class="list empty-cell-title-margin"
theme="card"
>
<t-cell
v-for="item in pageResult.list"
:key="item.id"
class="item"
:arrow="!!item.id"
:hover="!!item.id"
v-entrance-transition="{ step: 30 }"
@click="toDetail(item)"
>
<template #left-icon>
<div class="point" :class="{ 'consume': item.pointValue && item.pointValue < 0 }">
<t-icon name="money" />
<span v-text="getPointText(item)" />
</div>
</template>
<template #title>
<div class="title">
<h4 class="text" v-text="item.name || '未命名规则'" />
<t-tag
:theme="getStatusTheme(item.status)"
variant="light-outline"
:content="getStatusText(item.status)"
/>
</div>
</template>
<template #description>
<div class="description">
<div v-text="`触发来源:${getTriggerSourceText(item)}`"></div>
<div v-text="`触发对象:${getTriggerRefText(item)}`"></div>
</div>
</template>
</t-cell>
</t-cell-group>
<div class="center-tips" v-text="loadStateText" />
</t-pull-down-refresh>
</main>
</div>
<nav-bar-action-menu v-if="canShowActionMenu" :actions="actionList" />
</template>
<script setup lang="ts">
import type { NavBarAction } from "@/types/NavBarAction";
import { type DropdownValue } from "tdesign-mobile-vue";
import EventAPI from "@/api/EventAPI";
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 { formatWanInteger } from "@/utils/money";
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({
name: "PointRuleList"
});
const router = useRouter();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const currentStoreStore = useCurrentStoreStore();
@@ -294,8 +355,7 @@ async function preparePage(): Promise<void> {
}
onMounted(async () => {
navBarStore.clearRight();
navBarStore.setCustomRightVisible(canShowActionMenu.value);
try {
await preparePage();
} catch {
@@ -303,7 +363,6 @@ onMounted(async () => {
}
});
onUnmounted(() => navBarStore.clearRight());
</script>
<style scoped lang="less">
@@ -371,4 +430,46 @@ onUnmounted(() => navBarStore.clearRight());
}
}
}
.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>
+122 -7
View File
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
title="积分规则排序"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div v-can="permissionCodes.pointRule.update" class="point-rule-sort">
<div class="tip" v-text="'按住右侧拖动手柄调整规则顺序,保存后生效;仅显示启用规则'" v-entrance-transition />
<div class="items">
@@ -49,15 +94,44 @@ import { Message } from "@/utils/message";
import { VueDraggableNext } from "vue-draggable-next";
import EventAPI from "@/api/EventAPI";
import PointAPI from "@/api/PointAPI";
import { useNavBarStore } from "@/store/navBarStore";
import type { EventItem } from "@/types/EventItem";
import type { PointRule } from "@/types/Point";
import { formatWanInteger } from "@/utils/money";
import { permissionCodes } from "@/utils/permission";
defineOptions({ name: "PointRuleSort" });
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
const navBarStore = useNavBarStore();
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" });
const router = useRouter();
const ruleList = ref<PointRule[]>([]);
const eventList = ref<EventItem[]>([]);
@@ -111,8 +185,8 @@ async function saveSort(): Promise<void> {
}
onMounted(async () => {
navBarStore.clearRight();
navBarStore.setRightText("保存", "var(--td-brand-color)", saveSort);
clearPageNavBarRight();
setPageNavBarRightText("保存", "var(--td-brand-color)", saveSort);
try {
await loadData();
} catch {
@@ -120,7 +194,7 @@ onMounted(async () => {
}
});
onUnmounted(() => navBarStore.clearRight());
onUnmounted(() => clearPageNavBarRight());
</script>
<style scoped lang="less">
@@ -164,4 +238,45 @@ onUnmounted(() => navBarStore.clearRight());
.draggable .cell { background: rgba(15, 23, 42, .88); }
}
}
.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>
+121 -5
View File
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
title="客户经营图表"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div v-can="permissionCodes.stat.read" class="gao-chart-page order-data-charts">
<section class="hero">
<div class="eyebrow" v-text="'订单经营分析'" />
@@ -72,14 +117,45 @@ import type {
GaoSalesOrderTypeStatView
} from "@/types/GaoChart";
import { useCurrentStoreStore } from "@/store/currentStoreStore";
import { useNavBarStore } from "@/store/navBarStore";
import { getCurrentStoreId } from "@/utils/store";
import { clearStoreChartCache } from "@/utils/storeChartCache";
import { getErrorMessage } from "@/utils/error";
import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission";
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";
interface SummaryItem {
label: string;
value: string;
@@ -90,7 +166,6 @@ defineOptions({
});
const currentStoreStore = useCurrentStoreStore();
const navBarStore = useNavBarStore();
const dateRange = buildDefaultDateRange();
const dateTextList = buildDateTextList(dateRange[0], dateRange[1]);
const dailyList = ref<GaoSalesOrderDailyStatView[]>([]);
@@ -131,14 +206,14 @@ watch(storeId, async () => {
}, { immediate: true });
onMounted(async () => {
navBarStore.setRightIcon("refresh", reload);
setPageNavBarRightIcon("refresh", reload);
if (!currentStoreStore.currentStoreId) {
await currentStoreStore.loadLoginStore();
}
});
onUnmounted(() => {
navBarStore.clearRight();
clearPageNavBarRight();
});
async function reload(): Promise<void> {
@@ -334,4 +409,45 @@ 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>
+177 -71
View File
@@ -1,90 +1,156 @@
<template>
<div v-can="permissionCodes.productCategory.read" class="product-category-list">
<div class="filters glass">
<t-input
v-model="keyword"
class="keyword"
type="search"
borderless
placeholder="搜索分类名称"
/>
<t-dropdown-menu class="status">
<t-dropdown-item
v-model="status"
label="状态"
:options="statusOptions"
@change="selectStatus"
/>
</t-dropdown-menu>
</div>
<t-pull-down-refresh v-model="isRefreshing" :refresh-timeout="30000" @refresh="refresh" @scrolltolower="loadMore">
<t-cell-group v-if="categoryList.length" theme="card" class="list fix-last-cell-line">
<t-swipe-cell v-for="item in categoryList" :key="item.id" class="item" v-entrance-transition="{ step: 30 }">
<t-cell arrow hover @click="openEditDialog(item)">
<template #title>
<div class="title">
<strong v-text="item.name || '未命名分类'" />
<div class="page-layout navbar product-category-list">
<t-navbar
fixed
:z-index="20"
title="产品分类"
left-arrow
@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>
<template #note>
<t-tag size="small" variant="outline" :theme="getProductCategoryStatusTheme(item.status)" :content="getProductCategoryStatusText(item.status)" />
</t-popover>
</div>
</template>
</t-navbar>
<main v-can="permissionCodes.productCategory.read" class="page-content scroll list">
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
>
<div class="filters glass">
<t-input
v-model="keyword"
class="keyword"
type="search"
borderless
placeholder="搜索分类名称"
/>
<t-dropdown-menu class="status">
<t-dropdown-item
v-model="status"
label="状态"
:options="statusOptions"
@change="selectStatus"
/>
</t-dropdown-menu>
</div>
<t-cell-group v-if="categoryList.length" theme="card" class="list fix-last-cell-line">
<t-swipe-cell v-for="item in categoryList" :key="item.id" class="item" v-entrance-transition="{ step: 30 }">
<t-cell arrow hover @click="openEditDialog(item)">
<template #title>
<div class="title">
<strong v-text="item.name || '未命名分类'" />
</div>
</template>
<template #note>
<t-tag size="small" variant="outline" :theme="getProductCategoryStatusTheme(item.status)" :content="getProductCategoryStatusText(item.status)" />
</template>
</t-cell>
<template v-if="canUpdate && item.status === 'ACTIVE' && item.id" #right>
<t-button class="disable" theme="danger" :loading="disablingId === item.id" @click.stop="disable(item)">停用</t-button>
</template>
</t-cell>
<template v-if="canUpdate && item.status === 'ACTIVE' && item.id" #right>
<t-button class="disable" theme="danger" :loading="disablingId === item.id" @click.stop="disable(item)">停用</t-button>
</template>
</t-swipe-cell>
</t-cell-group>
<div v-else class="center-tips" v-text="emptyText" />
<div v-if="categoryList.length" class="center-tips" v-text="isLoading ? '正在加载更多' : isNoMore ? '已经到底了' : '上拉加载更多'" />
</t-pull-down-refresh>
</t-swipe-cell>
</t-cell-group>
<div v-else class="center-tips" v-text="emptyText" />
<div v-if="categoryList.length" class="center-tips" v-text="isLoading ? '正在加载更多' : isNoMore ? '已经到底了' : '上拉加载更多'" />
</t-pull-down-refresh>
</main>
<t-dialog
v-model:visible="editDialogVisible"
:title="isCreateMode ? '新增产品分类' : '编辑产品分类'"
cancel-btn="取消"
:confirm-btn="isSaving ? { content: '保存中', loading: true } : '保存'"
:close-on-overlay-click="!isSaving"
@cancel="closeEditDialog"
@confirm="saveCategory"
>
<t-form class="edit-form" label-align="left" label-width="5rem">
<t-form-item label="分类名称" required-mark>
<t-input
v-model="formModel.name"
borderless
maxlength="64"
placeholder="请输入分类名称"
/>
</t-form-item>
<t-form-item v-if="!isCreateMode" label="状态" arrow content-align="right" @click="openStatusPicker">
<span v-text="getProductCategoryStatusText(formModel.status)" />
</t-form-item>
</t-form>
</t-dialog>
<t-popup v-model="statusPickerVisible" placement="bottom">
<t-picker v-model="statusDraft" :columns="statusPickerOptions" title="分类状态" @cancel="statusPickerVisible = false" @confirm="confirmStatus" />
</t-popup>
</div>
<t-dialog
v-model:visible="editDialogVisible"
:title="isCreateMode ? '新增产品分类' : '编辑产品分类'"
cancel-btn="取消"
:confirm-btn="isSaving ? { content: '保存中', loading: true } : '保存'"
:close-on-overlay-click="!isSaving"
@cancel="closeEditDialog"
@confirm="saveCategory"
>
<t-form class="edit-form" label-align="left" label-width="5rem">
<t-form-item label="分类名称" required-mark>
<t-input
v-model="formModel.name"
borderless
maxlength="64"
placeholder="请输入分类名称"
/>
</t-form-item>
<t-form-item v-if="!isCreateMode" label="状态" arrow content-align="right" @click="openStatusPicker">
<span v-text="getProductCategoryStatusText(formModel.status)" />
</t-form-item>
</t-form>
</t-dialog>
<t-popup v-model="statusPickerVisible" placement="bottom">
<t-picker v-model="statusDraft" :columns="statusPickerOptions" title="分类状态" @cancel="statusPickerVisible = false" @confirm="confirmStatus" />
</t-popup>
<nav-bar-action-menu v-if="canShowActionMenu" :actions="actionList" />
</template>
<script setup lang="ts">
import type { NavBarAction } from "@/types/NavBarAction";
import { DialogPlugin, type DropdownValue } from "tdesign-mobile-vue";
import { useUserStore } from "timi-web-api";
import ProductAPI from "@/api/ProductAPI";
import type { NavBarAction } from "@/types/NavBarAction";
import type { ProductCategory, ProductCategoryStatus } from "@/types/Product";
import NavBarActionMenu from "@/components/NavBarActionMenu.vue";
import { useNavBarStore } from "@/store/navBarStore";
import { getErrorMessage } from "@/utils/error";
import { getProductCategoryStatusText, getProductCategoryStatusTheme } from "@/utils/product";
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" });
const router = useRouter();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const canCreate = computed(() => userStore.hasPermissions(permissionCodes.productCategory.create));
const canUpdate = computed(() => userStore.hasPermissions(permissionCodes.productCategory.update));
@@ -327,8 +393,7 @@ function disable(item: ProductCategory): void {
}
onMounted(async () => {
navBarStore.clearRight();
navBarStore.setCustomRightVisible(canShowActionMenu.value);
try {
await fetch(true);
} catch (error) {
@@ -348,7 +413,6 @@ watch(keyword, () => {
});
onUnmounted(() => {
navBarStore.clearRight();
statusPickerVisible.value = false;
window.clearTimeout(keywordTimer);
requestToken += 1;
@@ -414,4 +478,46 @@ onUnmounted(() => {
margin: 0;
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>
+122 -7
View File
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
title="产品分类排序"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div v-can="permissionCodes.productCategory.update" class="product-category-rank">
<div class="tip" v-text="'按住右侧拖动手柄调整分类顺序,保存后生效'" />
<div class="items">
@@ -44,16 +89,45 @@
import type { TagProps } from "tdesign-mobile-vue";
import { VueDraggableNext } from "vue-draggable-next";
import ProductAPI from "@/api/ProductAPI";
import { useNavBarStore } from "@/store/navBarStore";
import type { ProductCategory, ProductCategoryStatus } from "@/types/Product";
import { getErrorMessage } from "@/utils/error";
import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission";
import { useUserStore } from "timi-web-api";
defineOptions({ name: "ProductCategoryRank" });
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
const navBarStore = useNavBarStore();
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";
defineOptions({ name: "ProductCategoryRank" });
const userStore = useUserStore();
const router = useRouter();
@@ -109,9 +183,9 @@ async function loadData(): Promise<void> {
}
onMounted(async () => {
navBarStore.clearRight();
clearPageNavBarRight();
if (userStore.hasPermissions(permissionCodes.productCategory.update)) {
navBarStore.setRightText("保存", "var(--td-brand-color)", saveSort);
setPageNavBarRightText("保存", "var(--td-brand-color)", saveSort);
}
try {
await loadData();
@@ -121,7 +195,7 @@ onMounted(async () => {
});
onUnmounted(() => {
navBarStore.clearRight();
clearPageNavBarRight();
});
</script>
@@ -186,4 +260,45 @@ 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>
+121 -5
View File
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
title="产品经营图表"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div v-can="permissionCodes.stat.read" class="gao-chart-page product-data-charts">
<section class="hero">
<div class="eyebrow" v-text="'产品经营分析'" />
@@ -76,14 +121,45 @@ import type {
GaoProductSkuStockHealthView
} from "@/types/GaoChart";
import { useCurrentStoreStore } from "@/store/currentStoreStore";
import { useNavBarStore } from "@/store/navBarStore";
import { getCurrentStoreId } from "@/utils/store";
import { clearStoreChartCache } from "@/utils/storeChartCache";
import { getErrorMessage } from "@/utils/error";
import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission";
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";
interface SummaryItem {
label: string;
value: string;
@@ -94,7 +170,6 @@ defineOptions({
});
const currentStoreStore = useCurrentStoreStore();
const navBarStore = useNavBarStore();
const dateRange = buildDefaultDateRange();
const dateTextList = buildDateTextList(dateRange[0], dateRange[1]);
const salesDailyList = ref<GaoProductSalesDailyStatView[]>([]);
@@ -136,14 +211,14 @@ watch(storeId, async () => {
}, { immediate: true });
onMounted(async () => {
navBarStore.setRightIcon("refresh", reload);
setPageNavBarRightIcon("refresh", reload);
if (!currentStoreStore.currentStoreId) {
await currentStoreStore.loadLoginStore();
}
});
onUnmounted(() => {
navBarStore.clearRight();
clearPageNavBarRight();
});
async function reload(): Promise<void> {
@@ -352,4 +427,45 @@ 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>
+108 -10
View File
@@ -1,4 +1,56 @@
<template>
<t-navbar
fixed
:z-index="20"
title="产品详情"
left-arrow
@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>
</template>
</t-navbar>
<div v-can="permissionCodes.product.read" class="product-detail">
<t-loading v-if="isLoading" class="loading" size="32px" />
<template v-if="product">
@@ -79,7 +131,7 @@
</t-cell-group>
</template>
</div>
<nav-bar-action-menu v-if="actionList.length" :actions="actionList" />
<bottom-popup
v-model="skuDetailVisible"
title="SKU 详情"
@@ -124,16 +176,13 @@
</template>
<script setup lang="ts">
import type { NavBarAction } from "@/types/NavBarAction";
import { DialogPlugin } from "tdesign-mobile-vue";
import { BottomPopup } from "timi-tdesign-mobile";
import { useUserStore } from "timi-web-api";
import ProductAPI from "@/api/ProductAPI";
import NavBarActionMenu from "@/components/NavBarActionMenu.vue";
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
import ProductProfile from "@/pages/product/component/ProductProfile.vue";
import ProductSkuUnitList from "@/pages/product/component/ProductSkuUnitList.vue";
import { useNavBarStore } from "@/store/navBarStore";
import type { NavBarAction } from "@/types/NavBarAction";
import type { PhotoItem } from "@/types/Photo";
import type { Product, ProductSku } from "@/types/Product";
import { getAttachmentReadURL } from "@/utils/attachment";
@@ -148,11 +197,20 @@ 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 MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
defineOptions({ name: "ProductDetail" });
const route = useRoute();
const router = useRouter();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const product = ref<Product>();
const isLoading = ref(false);
@@ -299,17 +357,15 @@ function remove(): void {
}
onMounted(async () => {
navBarStore.clearRight();
navBarStore.setCustomRightVisible(actionList.value.length > 0);
try {
await load();
navBarStore.setCustomRightVisible(actionList.value.length > 0);
} catch (error) {
Message.error(getErrorMessage(error, "产品详情加载失败"));
}
});
onUnmounted(() => navBarStore.clearRight());
</script>
<style scoped lang="less">
@@ -394,4 +450,46 @@ onUnmounted(() => navBarStore.clearRight());
background: rgba(148, 163, 184, .12);
}
}
.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>
+133 -6
View File
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
:title="routeNavBarTitle"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div v-can="savePermissionCode" class="product-edit">
<t-form class="form" label-align="left" label-width="6rem" v-entrance-transition>
<t-form-item label="产品编码" required-mark help="使用英语、拼音或唯一数字">
@@ -216,8 +261,6 @@ import ProductSkuEditor from "@/pages/product/component/ProductSkuEditor.vue";
import ProductSkuUnitEditor from "@/pages/product/component/ProductSkuUnitEditor.vue";
import ProductSkuUnitBatchEditor from "@/pages/product/component/ProductSkuUnitBatchEditor.vue";
import type { MediaSelectorAddAction } from "@/components/mediaSelector/types";
import { useNavBarStore } from "@/store/navBarStore";
import type { PhotoItem } from "@/types/Photo";
import type { Product, ProductAttachmentType, ProductCategory, ProductSku, ProductSkuUnit, ProductSpec, ProductType } from "@/types/Product";
import type { ProductAttachmentItem, ProductForm, ProductSkuForm as SkuForm, ProductSkuUnitForm as UnitForm, ProductSpecForm as SpecForm, ProductSpecValueForm as SpecValueForm } from "@/types/ProductEditor";
import { compressUploadImage } from "@/utils/imageCompression";
@@ -229,6 +272,39 @@ import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission";
import { saveCapturedFilesFromInput } from "@/utils/twaBridge";
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";
type PickerValue = string | number;
const SOLID_COLOR_COVER_PURPOSE = "PRODUCT_SOLID_COLOR_COVER";
@@ -237,8 +313,18 @@ const DEFAULT_COVER_COLOR = "#2F88FF";
defineOptions({ name: "ProductEdit" });
const route = useRoute();
const routeNavBarTitle = computed(() => {
switch (route.name) {
case "ProductCreate":
return "新增产品";
case "ProductEdit":
return "编辑产品";
default:
return "";
}
});
const router = useRouter();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const routeId = computed(() => String(route.params.id || ""));
const isCreateMode = computed(() => !routeId.value);
@@ -1131,9 +1217,9 @@ async function load(): Promise<void> {
}
onMounted(async () => {
navBarStore.clearRight();
clearPageNavBarRight();
if (userStore.hasPermissions(savePermissionCode.value)) {
navBarStore.setRightText("保存", "var(--td-brand-color)", save);
setPageNavBarRightText("保存", "var(--td-brand-color)", save);
}
try {
await load();
@@ -1142,7 +1228,7 @@ onMounted(async () => {
}
});
onUnmounted(() => navBarStore.clearRight());
onUnmounted(() => clearPageNavBarRight());
</script>
<style scoped lang="less">
@@ -1256,4 +1342,45 @@ onUnmounted(() => navBarStore.clearRight());
border-color: rgba(148, 163, 184, .3);
}
}
.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>
+187 -82
View File
@@ -1,97 +1,155 @@
<template>
<div ref="productListRef" v-can="permissionCodes.product.read" class="product-list">
<div class="filters glass">
<t-input
v-model="keyword"
class="keyword"
type="search"
borderless
placeholder="搜索产品名称(拼音)或编码"
/>
<t-dropdown-menu class="menus">
<t-dropdown-item
v-model="status"
label="状态"
:options="statusOptions"
@change="selectStatus"
/>
<t-dropdown-item
v-model="productType"
label="类型"
:options="productTypeOptions"
@change="selectProductType"
/>
<t-dropdown-item
:model-value="categoryIdList"
label="分类"
:options="categoryOptions"
multiple
:options-columns="2"
@change="selectCategory"
@confirm="confirmCategory"
@reset="resetCategory"
@update:model-value="updateCategory"
/>
</t-dropdown-menu>
</div>
<t-pull-down-refresh v-model="isRefreshing" :refresh-timeout="30000" @refresh="refresh" @scrolltolower="loadMore">
<t-cell-group
v-if="productList.length"
class="list fix-last-cell-line empty-cell-title-margin"
theme="card"
<div class="page-layout navbar product-list">
<t-navbar
fixed
:z-index="20"
title="产品库"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
class="nav-actions"
v-if="(route.name === 'ProductList' && 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>
</template>
</t-navbar>
<main ref="productListRef" v-can="permissionCodes.product.read" class="page-content scroll list">
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
>
<t-cell v-for="item in productList" :key="item.id" class="item" arrow hover v-entrance-transition="{ step: 30 }" @click="toDetail(item)">
<template #leftIcon>
<t-image
v-if="getProductPhotoURL(item)"
:src="getProductPhotoURL(item)"
:alt="item.name || '产品图片'"
fit="cover"
class="avatar"
<div class="filters glass">
<t-input
v-model="keyword"
class="keyword"
type="search"
borderless
placeholder="搜索产品名称(拼音)或编码"
/>
<t-dropdown-menu class="menus">
<t-dropdown-item
v-model="status"
label="状态"
:options="statusOptions"
@change="selectStatus"
/>
<div
v-else
class="avatar fallback"
v-text="(item.name || '产').slice(0, 1)"
<t-dropdown-item
v-model="productType"
label="类型"
:options="productTypeOptions"
@change="selectProductType"
/>
</template>
<template #title>
<div class="text-bold" v-text="item.name || '未命名产品'" />
</template>
<template #note>
<t-tag
size="small"
variant="outline"
:theme="getProductStatusTheme(item.status)"
:content="getProductStatusText(item.status)"
<t-dropdown-item
:model-value="categoryIdList"
label="分类"
:options="categoryOptions"
multiple
:options-columns="2"
@change="selectCategory"
@confirm="confirmCategory"
@reset="resetCategory"
@update:model-value="updateCategory"
/>
</template>
<template #description>
<div class="description">
</t-dropdown-menu>
</div>
<t-cell-group
v-if="productList.length"
class="list fix-last-cell-line empty-cell-title-margin"
theme="card"
>
<t-cell v-for="item in productList" :key="item.id" class="item" arrow hover v-entrance-transition="{ step: 30 }" @click="toDetail(item)">
<template #leftIcon>
<t-image
v-if="getProductPhotoURL(item)"
:src="getProductPhotoURL(item)"
:alt="item.name || '产品图片'"
fit="cover"
class="avatar"
/>
<div
v-else
class="avatar fallback"
v-text="(item.name || '产').slice(0, 1)"
/>
</template>
<template #title>
<div class="text-bold" v-text="item.name || '未命名产品'" />
</template>
<template #note>
<t-tag
size="small"
variant="outline"
:content="getProductTypeText(item.productType)"
:theme="getProductStatusTheme(item.status)"
:content="getProductStatusText(item.status)"
/>
</div>
</template>
</t-cell>
</t-cell-group>
<div v-else class="center-tips" v-text="emptyText" />
<div v-if="productList.length" class="center-tips" v-text="isLoading ? '正在加载更多' : isNoMore ? '已经到底了' : '上拉加载更多'" />
</t-pull-down-refresh>
</template>
<template #description>
<div class="description">
<t-tag
size="small"
variant="outline"
:content="getProductTypeText(item.productType)"
/>
</div>
</template>
</t-cell>
</t-cell-group>
<div v-else class="center-tips" v-text="emptyText" />
<div v-if="productList.length" class="center-tips" v-text="isLoading ? '正在加载更多' : isNoMore ? '已经到底了' : '上拉加载更多'" />
</t-pull-down-refresh>
</main>
</div>
<nav-bar-action-menu v-if="route.name === 'ProductList' && canCreate" :actions="actionList" />
</template>
<script setup lang="ts">
import type { NavBarAction } from "@/types/NavBarAction";
import { type DropdownValue } from "tdesign-mobile-vue";
import { useUserStore } from "timi-web-api";
import { onBeforeRouteLeave } from "vue-router";
import ProductAPI from "@/api/ProductAPI";
import NavBarActionMenu from "@/components/NavBarActionMenu.vue";
import { useNavBarStore } from "@/store/navBarStore";
import type { NavBarAction } from "@/types/NavBarAction";
import type { Product, ProductCategory, ProductStatus, ProductType } from "@/types/Product";
import { getErrorMessage } from "@/utils/error";
import { getProductPhotoURL, getProductStatusText, getProductStatusTheme, getProductTypeText } from "@/utils/product";
@@ -99,12 +157,20 @@ import { events, isCurrentStoreEvent, listDataEventKeys, type ListDataChangedPay
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();
}
defineOptions({ name: "ProductList" });
const router = useRouter();
const route = useRoute();
const productListRef = ref<HTMLElement | null>(null);
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const canCreate = computed(() => userStore.hasPermissions(permissionCodes.product.create));
const actionList = computed<NavBarAction[]>(() => canCreate.value ? [{
@@ -165,8 +231,7 @@ function restorePageScrollPosition(): void {
}
function syncNavBar(): void {
navBarStore.clearRight();
navBarStore.setCustomRightVisible(route.name === "ProductList" && canCreate.value);
}
const statusOptions = [
@@ -406,14 +471,12 @@ watch(keyword, () => {
onBeforeRouteLeave(() => {
savePageScrollPosition();
navBarStore.clearRight();
});
onUnmounted(() => {
isDisposed = true;
unregisterProductListEvent?.();
unregisterProductListEvent = undefined;
navBarStore.clearRight();
window.clearTimeout(keywordTimer);
requestToken += 1;
});
@@ -471,4 +534,46 @@ 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>
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
title="批量入库"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div v-can="permissionCodes.productStock.create" class="product-stock-batch-configure">
<t-form class="form" label-width="5rem" v-entrance-transition>
<t-form-item label="入库备注" required-mark>
@@ -140,8 +185,6 @@
import { onBeforeRouteLeave } from "vue-router";
import { useUserStore } from "timi-web-api";
import { useCurrentStoreStore } from "@/store/currentStoreStore";
import { useNavBarStore } from "@/store/navBarStore";
import { type ProductStockBatchSelection, useProductStockBatchStore } from "@/store/productStockBatchStore";
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
import ProductAPI from "@/api/ProductAPI";
import type { ProductSkuUnit, ProductStockManualInBatchItem, ProductStockManualInBatchRequest } from "@/types/Product";
@@ -154,12 +197,48 @@ import { permissionCodes } from "@/utils/permission";
import { getCurrentStoreId } from "@/utils/store";
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";
type PickerValue = string | number;
defineOptions({ name: "ProductStockBatchConfigure" });
const router = useRouter();
const navBarStore = useNavBarStore();
const currentStoreStore = useCurrentStoreStore();
const productStockBatchStore = useProductStockBatchStore();
const userStore = useUserStore();
@@ -264,12 +343,12 @@ function isItemValid(item: ProductStockBatchSelection): boolean {
}
function updateNavBar(): void {
navBarStore.clearRight();
clearPageNavBarRight();
if (!userStore.hasPermissions(permissionCodes.productStock.create)) {
return;
}
navBarStore.setRightText(isSaving.value ? "提交中" : "提交", "var(--td-brand-color)", submit);
navBarStore.setRightDisabled(!canSubmit.value);
setPageNavBarRightText(isSaving.value ? "提交中" : "提交", "var(--td-brand-color)", submit);
setPageNavBarRightDisabled(!canSubmit.value);
}
function selectUnit(item: ProductStockBatchSelection, unit: ProductSkuUnit): void {
@@ -440,9 +519,9 @@ onActivated(() => {
updateNavBar();
});
onBeforeRouteLeave(() => navBarStore.clearRight());
onBeforeRouteLeave(() => clearPageNavBarRight());
onUnmounted(() => navBarStore.clearRight());
onUnmounted(() => clearPageNavBarRight());
</script>
<style scoped lang="less">
@@ -543,4 +622,45 @@ onUnmounted(() => navBarStore.clearRight());
}
}
.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>
+161 -39
View File
@@ -1,36 +1,83 @@
<template>
<div v-can="permissionCodes.productStock.create" class="product-stock-batch-select">
<div class="filters glass">
<t-input
v-model="keyword"
class="keyword"
type="search"
borderless
clearable
placeholder="搜索产品名称或编码"
/>
</div>
<t-pull-down-refresh
class="list-wrap empty-cell-title-margin"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
<div class="page-layout navbar product-stock-batch-select">
<t-navbar
fixed
:z-index="20"
title="选择入库 SKU"
left-arrow
@left-click="$router.back()"
>
<product-sku-selector
class="selector"
v-if="productList.length"
v-model:expanded-product-key-list="expandedProductKeyList"
:items="selectorItemList"
:selected-sku-id-list="selectedSkuIdList"
selection-mode="multiple"
@change="handleProductChange"
@toggle="toggleSku"
@check="toggleProductSkus"
/>
<div v-else class="center-tips" v-text="emptyText" />
<div v-if="productList.length" class="center-tips" v-text="isLoading ? '正在加载更多' : isNoMore ? '已经到底了' : '上拉加载更多'" />
</t-pull-down-refresh>
<template #right>
<div
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>
</t-navbar>
<main v-can="permissionCodes.productStock.create" class="page-content scroll list">
<t-pull-down-refresh
class="list-wrap empty-cell-title-margin pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
>
<div class="filters glass">
<t-input
v-model="keyword"
class="keyword"
type="search"
borderless
clearable
placeholder="搜索产品名称或编码"
/>
</div>
<product-sku-selector
class="selector"
v-if="productList.length"
v-model:expanded-product-key-list="expandedProductKeyList"
:items="selectorItemList"
:selected-sku-id-list="selectedSkuIdList"
selection-mode="multiple"
@change="handleProductChange"
@toggle="toggleSku"
@check="toggleProductSkus"
/>
<div v-else class="center-tips" v-text="emptyText" />
<div v-if="productList.length" class="center-tips" v-text="isLoading ? '正在加载更多' : isNoMore ? '已经到底了' : '上拉加载更多'" />
</t-pull-down-refresh>
</main>
</div>
</template>
@@ -39,8 +86,6 @@ import { onBeforeRouteLeave } from "vue-router";
import { useUserStore } from "timi-web-api";
import ProductAPI from "@/api/ProductAPI";
import { useCurrentStoreStore } from "@/store/currentStoreStore";
import { useNavBarStore } from "@/store/navBarStore";
import { useProductStockBatchStore } from "@/store/productStockBatchStore";
import type { Product, ProductSku, ProductStockProduct } from "@/types/Product";
import type { ProductSkuSelectorItem } from "@/types/ProductSkuSelection";
import { getErrorMessage } from "@/utils/error";
@@ -49,11 +94,47 @@ import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission";
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";
defineOptions({ name: "ProductStockBatchSelect" });
const router = useRouter();
const route = useRoute();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const currentStoreStore = useCurrentStoreStore();
const productStockBatchStore = useProductStockBatchStore();
@@ -133,10 +214,10 @@ function getCurrentRouteDepth(): number {
}
function updateNavBar(): void {
navBarStore.clearRight();
clearPageNavBarRight();
if (canReadAndCreate.value) {
navBarStore.setRightText("下一步", "var(--td-brand-color)", toConfigure);
navBarStore.setRightDisabled(!canContinue.value);
setPageNavBarRightText("下一步", "var(--td-brand-color)", toConfigure);
setPageNavBarRightDisabled(!canContinue.value);
}
}
@@ -361,10 +442,10 @@ onActivated(async () => {
updateNavBar();
});
onBeforeRouteLeave(() => navBarStore.clearRight());
onBeforeRouteLeave(() => clearPageNavBarRight());
onUnmounted(() => {
navBarStore.clearRight();
clearPageNavBarRight();
window.clearTimeout(keywordTimer);
requestToken += 1;
productDetailToken += 1;
@@ -395,4 +476,45 @@ 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>
+9 -5
View File
@@ -1,4 +1,11 @@
<template>
<t-navbar
fixed
:z-index="20"
title="库存详情"
left-arrow
@left-click="$router.back()"
/>
<div v-can="permissionCodes.productStock.read" class="product-stock-detail">
<t-loading v-if="isLoading" class="loading" size="32px" />
<template v-else-if="product && sku && stock">
@@ -103,20 +110,19 @@ import ProductAPI from "@/api/ProductAPI";
import ProductProfile from "@/pages/product/component/ProductProfile.vue";
import ProductStockPackageSummary from "@/pages/product/component/ProductStockPackageSummary.vue";
import ProductStockOperationPopup from "@/pages/product/component/ProductStockOperationPopup.vue";
import { useNavBarStore } from "@/store/navBarStore";
import type { Product, ProductSku, ProductStock, ProductSkuUnit, StockOperationType } from "@/types/Product";
import { getErrorMessage } from "@/utils/error";
import { convertBaseQuantityToPackageQuantity } from "@/utils/package";
import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission";
import type { Product, ProductSku, ProductStock, ProductSkuUnit, StockOperationType } from "@/types/Product";
type ManualStockOperation = Extract<StockOperationType, "MANUAL_IN" | "MANUAL_OUT" | "STOCKTAKE_GAIN" | "STOCKTAKE_LOSS">;
defineOptions({ name: "ProductStockDetail" });
const route = useRoute();
const router = useRouter();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const product = ref<Product>();
const sku = ref<ProductSku>();
@@ -245,7 +251,6 @@ function openOperation(type: ManualStockOperation): void {
}
onMounted(async () => {
navBarStore.clearRight();
try {
await loadAll();
} catch (error) {
@@ -253,7 +258,6 @@ onMounted(async () => {
}
});
onUnmounted(() => navBarStore.clearRight());
</script>
<style scoped lang="less">
+182 -64
View File
@@ -1,63 +1,110 @@
<template>
<div ref="productStockListRef" v-can="permissionCodes.productStock.read" class="product-stock-list">
<div class="filters glass">
<t-input
v-model="keyword"
class="keyword"
type="search"
borderless
clearable
placeholder="搜索产品名称(拼音)或编码"
/>
</div>
<t-pull-down-refresh
class="list-wrap empty-cell-title-margin"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
<div class="page-layout navbar product-stock-list">
<t-navbar
fixed
:z-index="20"
title="选择产品"
left-arrow
@left-click="$router.back()"
>
<t-cell-group v-if="productList.length" theme="card" class="list fix-last-cell-line">
<t-cell
class="item"
v-for="item in productList"
:key="item.productId"
:title="item.productName || '未命名产品'"
arrow
v-entrance-transition="{ step: 30 }"
@click="toSkuList(item)"
<template #right>
<div
v-if="pageNavBarRight.icon || pageNavBarRight.text"
class="nav-right-slot"
>
<template #leftIcon>
<t-image
v-if="getProductPhotoURL(item)"
:src="getProductPhotoURL(item)"
:alt="item.productName || '产品图片'"
fit="cover"
class="avatar"
/>
<div v-else class="avatar fallback" v-text="(item.productName || '产').slice(0, 1)" />
</template>
<template #description>
<div class="stock">
<span class="on-hand">
<span>库存</span>
<strong v-text="getProductQuantityText(item.onHandQuantity)" />
</span>
<span class="available">
<span>可用</span>
<strong v-text="getProductQuantityText(item.availableQuantity)" />
</span>
<span class="reserved">
<span>预占</span>
<strong v-text="getProductQuantityText(item.reservedQuantity)" />
</span>
</div>
</template>
</t-cell>
</t-cell-group>
<div v-else class="center-tips" v-text="emptyText" />
<div v-if="productList.length" class="center-tips" v-text="isLoading ? '正在加载更多' : isNoMore ? '已经到底了' : '上拉加载更多'" />
</t-pull-down-refresh>
<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>
</t-navbar>
<main ref="productStockListRef" v-can="permissionCodes.productStock.read" class="page-content scroll list">
<t-pull-down-refresh
class="list-wrap empty-cell-title-margin pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
>
<div class="filters glass">
<t-input
v-model="keyword"
class="keyword"
type="search"
borderless
clearable
placeholder="搜索产品名称(拼音)或编码"
/>
</div>
<t-cell-group v-if="productList.length" theme="card" class="list fix-last-cell-line">
<t-cell
class="item"
v-for="item in productList"
:key="item.productId"
:title="item.productName || '未命名产品'"
arrow
v-entrance-transition="{ step: 30 }"
@click="toSkuList(item)"
>
<template #leftIcon>
<t-image
v-if="getProductPhotoURL(item)"
:src="getProductPhotoURL(item)"
:alt="item.productName || '产品图片'"
fit="cover"
class="avatar"
/>
<div v-else class="avatar fallback" v-text="(item.productName || '产').slice(0, 1)" />
</template>
<template #description>
<div class="stock">
<span class="on-hand">
<span>库存</span>
<strong v-text="getProductQuantityText(item.onHandQuantity)" />
</span>
<span class="available">
<span>可用</span>
<strong v-text="getProductQuantityText(item.availableQuantity)" />
</span>
<span class="reserved">
<span>预占</span>
<strong v-text="getProductQuantityText(item.reservedQuantity)" />
</span>
</div>
</template>
</t-cell>
</t-cell-group>
<div v-else class="center-tips" v-text="emptyText" />
<div v-if="productList.length" class="center-tips" v-text="isLoading ? '正在加载更多' : isNoMore ? '已经到底了' : '上拉加载更多'" />
</t-pull-down-refresh>
</main>
</div>
</template>
@@ -66,8 +113,6 @@ import { useUserStore } from "timi-web-api";
import { onBeforeRouteLeave } from "vue-router";
import ProductAPI from "@/api/ProductAPI";
import { useCurrentStoreStore } from "@/store/currentStoreStore";
import { useNavBarStore } from "@/store/navBarStore";
import { useProductStockBatchStore } from "@/store/productStockBatchStore";
import type { ProductStockProduct } from "@/types/Product";
import { getErrorMessage } from "@/utils/error";
import { getProductPhotoURL, getProductQuantityText } from "@/utils/product";
@@ -76,12 +121,44 @@ import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission";
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";
defineOptions({ name: "ProductStockList" });
const router = useRouter();
const route = useRoute();
const productStockListRef = ref<HTMLElement | null>(null);
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const currentStoreStore = useCurrentStoreStore();
const productStockBatchStore = useProductStockBatchStore();
@@ -141,9 +218,9 @@ function getCurrentRouteDepth(): number {
}
function updateNavBar(): void {
navBarStore.clearRight();
clearPageNavBarRight();
if (canBatchIn.value) {
navBarStore.setRightText("批量入库", "var(--td-brand-color)", openBatchIn);
setPageNavBarRightText("批量入库", "var(--td-brand-color)", openBatchIn);
}
}
@@ -334,14 +411,14 @@ watch(keyword, () => {
onBeforeRouteLeave(() => {
savePageScrollPosition();
navBarStore.clearRight();
clearPageNavBarRight();
});
onUnmounted(() => {
isDisposed = true;
unregisterProductStockListEvent?.();
unregisterProductStockListEvent = undefined;
navBarStore.clearRight();
clearPageNavBarRight();
window.clearTimeout(keywordTimer);
requestToken += 1;
});
@@ -427,4 +504,45 @@ 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>
@@ -1,4 +1,11 @@
<template>
<t-navbar
fixed
:z-index="20"
title="库存流水详情"
left-arrow
@left-click="$router.back()"
/>
<div v-can="permissionCodes.productStock.read" class="product-stock-record-detail">
<t-loading v-if="isLoading" class="loading" size="32px" />
<template v-else-if="record">
@@ -139,8 +146,6 @@ import { useUserStore, type Attachment } from "timi-web-api";
import ProductAPI from "@/api/ProductAPI";
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
import ProductSkuTags from "@/components/ProductSkuTags.vue";
import { useNavBarStore } from "@/store/navBarStore";
import type { PhotoItem } from "@/types/Photo";
import type { StockBizType, StockRecord } from "@/types/Product";
import { getAttachmentReadURL } from "@/utils/attachment";
import { getErrorMessage } from "@/utils/error";
@@ -150,10 +155,11 @@ import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission";
import { uploadPhotoList } from "@/utils/photo";
import type { PhotoItem } from "@/types/Photo";
defineOptions({ name: "ProductStockRecordDetail" });
const route = useRoute();
const navBarStore = useNavBarStore();
const router = useRouter();
const userStore = useUserStore();
const record = ref<StockRecord>();
@@ -317,7 +323,6 @@ async function loadData(): Promise<void> {
}
onMounted(async () => {
navBarStore.clearRight();
await loadData();
});
@@ -327,7 +332,6 @@ watch(() => String(route.params.id || ""), async (id, previousId) => {
}
});
onUnmounted(() => navBarStore.clearRight());
</script>
<style scoped lang="less">
+217 -198
View File
@@ -1,198 +1,208 @@
<template>
<div v-can="permissionCodes.productStock.read" class="product-stock-record-list">
<div class="filters glass">
<div class="search-row">
<t-input
v-model="keyword"
class="keyword"
type="search"
borderless
clearable
placeholder="搜索产品名称(拼音)或编码"
>
<template #suffix-icon>
<div class="actions">
<t-button
size="extra-small"
theme="primary"
variant="outline"
content="选择产品"
@click.stop="productSelectorVisible = true"
/>
</div>
</template>
</t-input>
</div>
<t-dropdown-menu class="menus">
<t-dropdown-item
v-model="dateFilterType"
:label="dateFilterLabel"
:options="dateOptions"
@change="selectDateFilter"
/>
<t-dropdown-item v-model="operationType" :label="operationFilterLabel" :options="operationOptions" @change="selectOperationType" />
<t-dropdown-item v-model="direction" :label="directionFilterLabel" :options="directionOptions" @change="selectDirection" />
</t-dropdown-menu>
</div>
<t-pull-down-refresh
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
>
<div class="list-wrap">
<t-cell-group v-if="isCustomDate || filteredSku" class="summary" theme="card">
<template v-if="isCustomDate">
<t-cell
title="开始时间"
:note="dateRange[0] || '-'"
arrow
@click="openStartTime"
/>
<t-cell
title="结束时间"
:note="dateRange[1] || '-'"
arrow
@click="openEndTime"
/>
</template>
<template v-if="filteredSku">
<t-cell title="累计入库" :note="getStockSummaryText(inBaseQuantityTotal)" />
<t-cell title="累计出库" :note="getStockSummaryText(outBaseQuantityTotal)" />
</template>
</t-cell-group>
<t-cell-group v-if="filteredProduct && filteredSku" theme="card">
<t-cell class="sku">
<template #leftIcon>
<t-image
v-if="filteredSkuPhotoURL"
class="avatar"
:src="filteredSkuPhotoURL"
:alt="filteredProduct.name || '产品图片'"
fit="cover"
/>
<div
v-else
class="fallback"
v-text="(filteredProduct.name || filteredProduct.code || '产').slice(0, 1)"
/>
</template>
<template #title>
<div class="title">
<strong class="text-bold clip-text" v-text="filteredProduct.name || '未命名产品'" />
<span class="clip-text" v-text="filteredSku.specSummary || filteredSku.name || '默认 SKU'" />
</div>
</template>
<template #note>
<t-tag
variant="light-outline"
theme="primary"
:content="getProductTypeText(filteredProduct.productType)"
/>
</template>
</t-cell>
</t-cell-group>
<t-cell-group v-if="recordList.length" class="list empty-cell-title-margin" theme="card">
<t-cell
v-for="(record, index) in recordList"
:key="record.id || `${record.occurredAt}-${record.requestNo}-${index}`"
class="item"
:arrow="!!record.id"
:hover="!!record.id"
v-entrance-transition="{ step: 30 }"
@click="toDetail(record)"
>
<template #leftIcon>
<t-image
v-if="getCustomerPhotoURL(record.customer, 64)"
:src="getCustomerPhotoURL(record.customer, 64)"
:alt="getCustomerText(record)"
fit="cover"
class="avatar"
/>
<div
v-else-if="record.customer"
class="avatar fallback"
v-text="getCustomerText(record).slice(0, 1)"
/>
<t-image
v-else-if="record.operator"
:src="getOperatorAvatar(record)"
:alt="getOperatorText(record)"
fit="cover"
class="avatar"
/>
<span v-else class="icon" :class="getDeltaClass(record.onHandDelta)">
<t-icon :name="getOperationIcon(record.operationType)" size="1.25rem" />
</span>
</template>
<template #title>
<div class="title">
<span v-if="record.customer" class="actor" v-text="getCustomerText(record)" />
<span v-else-if="record.operator" class="actor" v-text="getOperatorText(record)" />
<strong class="operation" :class="getOperationClass(record.operationType)" v-text="getStockOperationText(record.operationType)" />
<strong class="product-name clip-text" v-text="record.productNameSnapshot || '未命名产品'" />
<t-tag
v-if="record.productNameSnapshot !== record.skuNameSnapshot"
size="small"
:content="record.skuNameSnapshot"
/>
<span
v-if="record.quantity !== undefined && record.quantity !== null && record.quantity !== ''"
class="quantity"
v-text="getStockQuantityText(record)"
/>
</div>
</template>
<template #description>
<div class="description">
<pass-time-label :timestamp="record.occurredAt" underline />
<div class="delta">
<span>库存:</span>
<span
class="value"
:class="getDeltaClass(record.onHandDelta)"
v-text="getDeltaText(record.onHandDelta)"
<div class="page-layout navbar product-stock-record-list">
<t-navbar
fixed
:z-index="20"
title="库存流水"
left-arrow
@left-click="handleNavBarBack"
/>
<main v-can="permissionCodes.productStock.read" class="page-content scroll list">
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
>
<div class="filters glass">
<div class="search-row">
<t-input
v-model="keyword"
class="keyword"
type="search"
borderless
clearable
placeholder="搜索产品名称(拼音)或编码"
>
<template #suffix-icon>
<div class="actions">
<t-button
size="extra-small"
theme="primary"
variant="outline"
content="选择产品"
@click.stop="productSelectorVisible = true"
/>
</div>
</div>
</template>
</t-input>
</div>
<t-dropdown-menu class="menus">
<t-dropdown-item
v-model="dateFilterType"
:label="dateFilterLabel"
:options="dateOptions"
@change="selectDateFilter"
/>
<t-dropdown-item v-model="operationType" :label="operationFilterLabel" :options="operationOptions" @change="selectOperationType" />
<t-dropdown-item v-model="direction" :label="directionFilterLabel" :options="directionOptions" @change="selectDirection" />
</t-dropdown-menu>
</div>
<div class="list-wrap">
<t-cell-group v-if="isCustomDate || filteredSku" class="summary" theme="card">
<template v-if="isCustomDate">
<t-cell
title="开始时间"
:note="dateRange[0] || '-'"
arrow
@click="openStartTime"
/>
<t-cell
title="结束时间"
:note="dateRange[1] || '-'"
arrow
@click="openEndTime"
/>
</template>
</t-cell>
</t-cell-group>
<div v-else class="center-tips" v-text="emptyText" />
<div v-if="recordList.length" class="center-tips" v-text="loadStateText" />
</div>
</t-pull-down-refresh>
<template v-if="filteredSku">
<t-cell title="累计入库" :note="getStockSummaryText(inBaseQuantityTotal)" />
<t-cell title="累计出库" :note="getStockSummaryText(outBaseQuantityTotal)" />
</template>
</t-cell-group>
<t-cell-group v-if="filteredProduct && filteredSku" theme="card">
<t-cell class="sku">
<template #leftIcon>
<t-image
v-if="filteredSkuPhotoURL"
class="avatar"
:src="filteredSkuPhotoURL"
:alt="filteredProduct.name || '产品图片'"
fit="cover"
/>
<div
v-else
class="fallback"
v-text="(filteredProduct.name || filteredProduct.code || '产').slice(0, 1)"
/>
</template>
<template #title>
<div class="title">
<strong class="text-bold clip-text" v-text="filteredProduct.name || '未命名产品'" />
<span class="clip-text" v-text="filteredSku.specSummary || filteredSku.name || '默认 SKU'" />
</div>
</template>
<template #note>
<t-tag
variant="light-outline"
theme="primary"
:content="getProductTypeText(filteredProduct.productType)"
/>
</template>
</t-cell>
</t-cell-group>
<t-cell-group v-if="recordList.length" class="list empty-cell-title-margin" theme="card">
<t-cell
v-for="(record, index) in recordList"
:key="record.id || `${record.occurredAt}-${record.requestNo}-${index}`"
class="item"
:arrow="!!record.id"
:hover="!!record.id"
v-entrance-transition="{ step: 30 }"
@click="toDetail(record)"
>
<template #leftIcon>
<t-image
v-if="getCustomerPhotoURL(record.customer, 64)"
:src="getCustomerPhotoURL(record.customer, 64)"
:alt="getCustomerText(record)"
fit="cover"
class="avatar"
/>
<div
v-else-if="record.customer"
class="avatar fallback"
v-text="getCustomerText(record).slice(0, 1)"
/>
<t-image
v-else-if="record.operator"
:src="getOperatorAvatar(record)"
:alt="getOperatorText(record)"
fit="cover"
class="avatar"
/>
<span v-else class="icon" :class="getDeltaClass(record.onHandDelta)">
<t-icon :name="getOperationIcon(record.operationType)" size="1.25rem" />
</span>
</template>
<template #title>
<div class="title">
<span v-if="record.customer" class="actor" v-text="getCustomerText(record)" />
<span v-else-if="record.operator" class="actor" v-text="getOperatorText(record)" />
<strong class="operation" :class="getOperationClass(record.operationType)" v-text="getStockOperationText(record.operationType)" />
<strong class="product-name clip-text" v-text="record.productNameSnapshot || '未命名产品'" />
<t-tag
v-if="record.productNameSnapshot !== record.skuNameSnapshot"
size="small"
:content="record.skuNameSnapshot"
/>
<span
v-if="record.quantity !== undefined && record.quantity !== null && record.quantity !== ''"
class="quantity"
v-text="getStockQuantityText(record)"
/>
</div>
</template>
<template #description>
<div class="description">
<pass-time-label :timestamp="record.occurredAt" underline />
<div class="delta">
<span>库存:</span>
<span
class="value"
:class="getDeltaClass(record.onHandDelta)"
v-text="getDeltaText(record.onHandDelta)"
/>
</div>
</div>
</template>
</t-cell>
</t-cell-group>
<div v-else class="center-tips" v-text="emptyText" />
<div v-if="recordList.length" class="center-tips" v-text="loadStateText" />
</div>
</t-pull-down-refresh>
</main>
<product-select-popup
v-model="selectedProductSku"
v-model:visible="productSelectorVisible"
@select="handleProductSelect"
/>
<t-popup v-model="startVisible" placement="bottom">
<t-date-time-picker
v-if="startVisible"
v-model="startDraft"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="开始时间"
:default-value="dateRange[0]"
@cancel="cancelStartTime"
@confirm="confirmStartTime"
/>
</t-popup>
<t-popup v-model="endVisible" placement="bottom">
<t-date-time-picker
v-if="endVisible"
v-model="endDraft"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="结束时间"
:default-value="dateRange[1]"
@cancel="cancelEndTime"
@confirm="confirmEndTime"
/>
</t-popup>
</div>
<product-select-popup
v-model="selectedProductSku"
v-model:visible="productSelectorVisible"
@select="handleProductSelect"
/>
<t-popup v-model="startVisible" placement="bottom">
<t-date-time-picker
v-if="startVisible"
v-model="startDraft"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="开始时间"
:default-value="dateRange[0]"
@cancel="cancelStartTime"
@confirm="confirmStartTime"
/>
</t-popup>
<t-popup v-model="endVisible" placement="bottom">
<t-date-time-picker
v-if="endVisible"
v-model="endDraft"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="结束时间"
:default-value="dateRange[1]"
@cancel="cancelEndTime"
@confirm="confirmEndTime"
/>
</t-popup>
</template>
<script setup lang="ts">
@@ -202,8 +212,6 @@ import { UserAPI } from "timi-web-api";
import { onBeforeRouteLeave } from "vue-router";
import ProductAPI from "@/api/ProductAPI";
import ProductSelectPopup from "@/components/productSelector/ProductSelectPopup.vue";
import { useNavBarStore } from "@/store/navBarStore";
import type { Product, ProductSelection, ProductSku, StockOperationType, StockRecord, StockRecordDirection } from "@/types/Product";
import type { ProductSkuSelectionValue } from "@/types/ProductSkuSelection";
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
import { getErrorMessage } from "@/utils/error";
@@ -213,6 +221,8 @@ import { permissionCodes } from "@/utils/permission";
import { getCustomerPhotoURL } from "@/utils/customer";
import { buildFallbackAvatar } from "@/utils/avatar";
import type { Product, ProductSelection, ProductSku, StockOperationType, StockRecord, StockRecordDirection } from "@/types/Product";
defineOptions({ name: "ProductStockRecordList" });
type DateFilterType = "today" | "yesterday" | "thisWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
@@ -221,8 +231,8 @@ type DirectionFilter = "ALL" | StockRecordDirection;
const pageSize = 15;
const route = useRoute();
const pageNavBarBackTo = ref<string>();
const router = useRouter();
const navBarStore = useNavBarStore();
const recordList = ref<StockRecord[]>([]);
const inBaseQuantityTotal = ref<number>();
const outBaseQuantityTotal = ref<number>();
@@ -599,6 +609,17 @@ function buildUnixRange(): [number | undefined, number | undefined] {
];
}
async function handleNavBarBack(): Promise<void> {
const backTo = pageNavBarBackTo.value;
pageNavBarBackTo.value = undefined;
if (backTo) {
await router.push(backTo);
return;
}
await router.back();
}
async function reload(): Promise<void> {
pageIndex.value = 0;
recordList.value = [];
@@ -620,8 +641,7 @@ async function refresh(): Promise<void> {
}
onMounted(async () => {
navBarStore.setBackTo(returnToProductTab ? "/product" : undefined);
navBarStore.clearRight();
pageNavBarBackTo.value = returnToProductTab ? "/product" : undefined;
try {
await Promise.all([loadSkuFilter(), reload()]);
} catch (error) {
@@ -629,7 +649,7 @@ onMounted(async () => {
}
});
onBeforeRouteLeave(() => navBarStore.setBackTo(undefined));
onBeforeRouteLeave(() => pageNavBarBackTo.value = undefined);
watch(keyword, () => {
if (skipNextKeywordChange) {
@@ -647,8 +667,7 @@ watch(keyword, () => {
});
onUnmounted(() => {
navBarStore.setBackTo(undefined);
navBarStore.clearRight();
pageNavBarBackTo.value = undefined;
window.clearTimeout(keywordTimer);
requestToken += 1;
});
+99 -93
View File
@@ -1,114 +1,122 @@
<template>
<div v-can="permissionCodes.productStock.read" class="product-stock-sku-list">
<div class="filters glass">
<t-input
v-model="keyword"
class="keyword"
type="search"
borderless
clearable
placeholder="搜索 SKU 名称、编码或规格"
/>
</div>
<t-pull-down-refresh
class="list-wrap empty-cell-title-margin"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
>
<div class="content">
<t-cell-group theme="card">
<t-cell title="产品" :note="product?.name" />
</t-cell-group>
<t-cell-group
v-if="skuStockList.length"
theme="card"
class="list fix-last-cell-line empty-cell-title-margin"
>
<t-cell
class="item"
v-for="item in skuStockList"
:key="item.skuId || item.id"
arrow
v-entrance-transition="{ step: 30 }"
@click="toDetail(item)"
<div class="page-layout navbar product-stock-sku-list">
<t-navbar
fixed
:z-index="20"
title="选择 SKU"
left-arrow
@left-click="$router.back()"
/>
<main v-can="permissionCodes.productStock.read" class="page-content scroll list">
<t-pull-down-refresh
class="list-wrap empty-cell-title-margin pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
>
<div class="filters glass">
<t-input
v-model="keyword"
class="keyword"
type="search"
borderless
clearable
placeholder="搜索 SKU 名称、编码或规格"
/>
</div>
<div class="content">
<t-cell-group theme="card">
<t-cell title="产品" :note="product?.name" />
</t-cell-group>
<t-cell-group
v-if="skuStockList.length"
theme="card"
class="list fix-last-cell-line empty-cell-title-margin"
>
<template #title>
<div class="title">
<strong v-text="item.sku?.name || '未命名 SKU 明细'" />
<div
v-if="getUnitList(item).length"
class="unit-options"
role="group"
:aria-label="`切换${item.sku?.name || 'SKU'}库存单位`"
>
<t-button
v-for="unit in getUnitList(item)"
:key="unit.id"
size="extra-small"
:theme="getSelectedUnit(item)?.id === unit.id ? 'primary' : 'default'"
:variant="getSelectedUnit(item)?.id === unit.id ? 'base' : 'outline'"
:aria-label="`切换到${unit.name || '未命名单位'}`"
:aria-pressed="getSelectedUnit(item)?.id === unit.id"
@click.stop="selectUnit(item, unit.id || '')"
<t-cell
class="item"
v-for="item in skuStockList"
:key="item.skuId || item.id"
arrow
v-entrance-transition="{ step: 30 }"
@click="toDetail(item)"
>
<template #title>
<div class="title">
<strong v-text="item.sku?.name || '未命名 SKU 明细'" />
<div
v-if="getUnitList(item).length"
class="unit-options"
role="group"
:aria-label="`切换${item.sku?.name || 'SKU'}库存单位`"
>
<span v-text="unit.name || '未命名单位'" />
</t-button>
<t-button
v-for="unit in getUnitList(item)"
:key="unit.id"
size="extra-small"
:theme="getSelectedUnit(item)?.id === unit.id ? 'primary' : 'default'"
:variant="getSelectedUnit(item)?.id === unit.id ? 'base' : 'outline'"
:aria-label="`切换到${unit.name || '未命名单位'}`"
:aria-pressed="getSelectedUnit(item)?.id === unit.id"
@click.stop="selectUnit(item, unit.id || '')"
>
<span v-text="unit.name || '未命名单位'" />
</t-button>
</div>
</div>
</div>
</template>
<template #leftIcon>
<t-image
v-if="getSkuPhotoURL(item)"
:src="getSkuPhotoURL(item)"
:alt="item.sku?.name || 'SKU 图片'"
fit="cover"
class="avatar"
/>
<div v-else class="avatar fallback" v-text="(item.sku?.name || 'S').slice(0, 1)" />
</template>
<template #description>
<div class="stock">
<span class="on-hand">
<span>库存</span>
<strong v-text="getStockQuantityText(item, item.onHandQuantity)" />
</span>
<span class="available">
<span>可用</span>
<strong v-text="getStockQuantityText(item, item.availableQuantity)" />
</span>
<span class="reserved">
<span>预占</span>
<strong v-text="getStockQuantityText(item, item.reservedQuantity)" />
</span>
</div>
</template>
</t-cell>
</t-cell-group>
<div v-else class="center-tips" v-text="emptyText" />
<div v-if="skuStockList.length" class="center-tips" v-text="isLoading ? '正在加载更多' : isNoMore ? '已经到底了' : '上拉加载更多'" />
</div>
</t-pull-down-refresh>
</template>
<template #leftIcon>
<t-image
v-if="getSkuPhotoURL(item)"
:src="getSkuPhotoURL(item)"
:alt="item.sku?.name || 'SKU 图片'"
fit="cover"
class="avatar"
/>
<div v-else class="avatar fallback" v-text="(item.sku?.name || 'S').slice(0, 1)" />
</template>
<template #description>
<div class="stock">
<span class="on-hand">
<span>库存</span>
<strong v-text="getStockQuantityText(item, item.onHandQuantity)" />
</span>
<span class="available">
<span>可用</span>
<strong v-text="getStockQuantityText(item, item.availableQuantity)" />
</span>
<span class="reserved">
<span>预占</span>
<strong v-text="getStockQuantityText(item, item.reservedQuantity)" />
</span>
</div>
</template>
</t-cell>
</t-cell-group>
<div v-else class="center-tips" v-text="emptyText" />
<div v-if="skuStockList.length" class="center-tips" v-text="isLoading ? '正在加载更多' : isNoMore ? '已经到底了' : '上拉加载更多'" />
</div>
</t-pull-down-refresh>
</main>
</div>
</template>
<script setup lang="ts">
import { useUserStore } from "timi-web-api";
import ProductAPI from "@/api/ProductAPI";
import { useNavBarStore } from "@/store/navBarStore";
import type { Product, ProductSkuUnit, ProductStock } from "@/types/Product";
import { getErrorMessage } from "@/utils/error";
import { convertBaseQuantityToPackageQuantity } from "@/utils/package";
import { getProductPhotoURL, getProductQuantityText } from "@/utils/product";
import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission";
import type { Product, ProductSkuUnit, ProductStock } from "@/types/Product";
defineOptions({ name: "ProductStockSkuList" });
const router = useRouter();
const route = useRoute();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const keyword = ref("");
const product = ref<Product>();
@@ -278,7 +286,6 @@ async function toDetail(item: ProductStock): Promise<void> {
}
onMounted(async () => {
navBarStore.clearRight();
if (!userStore.hasPermissions(permissionCodes.productStock.read)) {
return;
}
@@ -308,7 +315,6 @@ watch(keyword, () => {
});
onUnmounted(() => {
navBarStore.clearRight();
window.clearTimeout(keywordTimer);
requestToken += 1;
});
+176 -168
View File
@@ -1,173 +1,183 @@
<template>
<div v-can="permissionCodes.salesOrder.read" class="consumption-record-list">
<div class="filters glass">
<t-input
class="keyword"
:value="customerDisplayText"
readonly
borderless
placeholder="选择或扫码客户"
@click="customerSelectorVisible = true"
<div class="page-layout navbar consumption-record-list">
<t-navbar
fixed
:z-index="20"
title="消费记录"
left-arrow
@left-click="$router.back()"
/>
<main v-can="permissionCodes.salesOrder.read" class="page-content scroll list">
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="reloadRecords"
@scrolltolower="loadRecords"
>
<template #suffix-icon>
<div class="actions">
<t-button
v-if="customerId"
shape="circle"
theme="danger"
variant="text"
size="extra-small"
aria-label="清除客户选择"
@click.stop="clearCustomer"
>
<t-icon name="close" size="1rem" />
</t-button>
<t-button
size="extra-small"
theme="primary"
variant="outline"
:content="scannerVisible ? '关闭扫码' : '扫码'"
@click.stop="toggleScanner"
<div class="filters glass">
<t-input
class="keyword"
:value="customerDisplayText"
readonly
borderless
placeholder="选择或扫码客户"
@click="customerSelectorVisible = true"
>
<template #suffix-icon>
<div class="actions">
<t-button
v-if="customerId"
shape="circle"
theme="danger"
variant="text"
size="extra-small"
aria-label="清除客户选择"
@click.stop="clearCustomer"
>
<t-icon name="close" size="1rem" />
</t-button>
<t-button
size="extra-small"
theme="primary"
variant="outline"
:content="scannerVisible ? '关闭扫码' : '扫码'"
@click.stop="toggleScanner"
/>
</div>
</template>
</t-input>
<t-dropdown-menu class="menus">
<t-dropdown-item
v-model="dateFilterType"
:label="dateFilterLabel"
:options="dateOptions"
@change="selectDateFilter"
/>
<t-dropdown-item
v-model="sourceType"
label="消费来源"
:options="sourceTypeOptions"
@change="reloadRecords"
/>
<t-dropdown-item
v-model="status"
label="消费状态"
:options="statusOptions"
@change="reloadRecords"
/>
</t-dropdown-menu>
</div>
<div class="list-wrap">
<div v-if="scannerVisible" class="scanner-wrap">
<code-scanner
visible
:status-text="scanStatus"
active-text="正在识别客户编码,请将条码或二维码移入取景框。"
@decode="handleDecodedText"
@status-change="handleScanStatusChange"
/>
</div>
</template>
</t-input>
<t-dropdown-menu class="menus">
<t-dropdown-item
v-model="dateFilterType"
:label="dateFilterLabel"
:options="dateOptions"
@change="selectDateFilter"
/>
<t-dropdown-item
v-model="sourceType"
label="消费来源"
:options="sourceTypeOptions"
@change="reloadRecords"
/>
<t-dropdown-item
v-model="status"
label="消费状态"
:options="statusOptions"
@change="reloadRecords"
/>
</t-dropdown-menu>
</div>
<t-pull-down-refresh
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="reloadRecords"
@scrolltolower="loadRecords"
>
<div class="list-wrap">
<div v-if="scannerVisible" class="scanner-wrap">
<code-scanner
visible
:status-text="scanStatus"
active-text="正在识别客户编码,请将条码或二维码移入取景框。"
@decode="handleDecodedText"
@status-change="handleScanStatusChange"
/>
<t-cell-group class="summary" theme="card">
<t-cell
v-if="dateFilterType !== 'all'"
title="开始时间"
:note="dateRange[0] || '-'"
arrow
@click="openStartTime"
/>
<t-cell
v-if="dateFilterType !== 'all'"
title="结束时间"
:note="dateRange[1] || '-'"
arrow
@click="openEndTime"
/>
<t-cell title="记录数" :note="`共 ${total} 条`" />
<t-cell title="消费金额合计" :note="`¥${formatPackageAmount(amountTotal)}`" />
</t-cell-group>
<t-cell-group v-if="recordList.length" class="empty-cell-title-margin" theme="card">
<t-cell
class="item"
v-for="item in recordList"
:key="item.id"
:arrow="canOpenSource(item)"
v-entrance-transition="{ step: 30 }"
@click="openSource(item)"
>
<template #leftIcon>
<t-image
v-if="getCustomerPhotoURL(item.customer, 64)"
:src="getCustomerPhotoURL(item.customer, 64)"
:alt="getCustomerText(item)"
fit="cover"
class="avatar"
/>
<div v-else class="avatar fallback" v-text="getCustomerText(item).slice(0, 1)" />
</template>
<template #title>
<div class="title">
<span class="customer" v-text="getCustomerText(item)" />
<t-tag
class="value"
size="small"
:theme="item.sourceType === 'LEGACY_EVENT' ? 'default' : 'primary'"
variant="light"
:content="getRecordTitle(item)"
/>
</div>
</template>
<template #description>
<div class="description">
<t-tag
size="small"
:theme="item.status === 'ACTIVE' ? 'success' : 'danger'"
variant="light-outline"
:content="getStatusText(item.status)"
/>
<pass-time-label class="time" :timestamp="item.effectiveAt" underline />
</div>
</template>
<template #note>
<strong class="red" v-text="`¥${formatPackageAmount(item.amount)}`" />
</template>
</t-cell>
</t-cell-group>
<div v-else class="center-tips" v-text="isLoading ? '正在加载消费记录' : '暂无消费记录'" />
<div v-if="recordList.length" class="center-tips" v-text="loadStateText" />
</div>
<t-cell-group class="summary" theme="card">
<t-cell
v-if="dateFilterType !== 'all'"
title="开始时间"
:note="dateRange[0] || '-'"
arrow
@click="openStartTime"
/>
<t-cell
v-if="dateFilterType !== 'all'"
title="结束时间"
:note="dateRange[1] || '-'"
arrow
@click="openEndTime"
/>
<t-cell title="记录数" :note="`共 ${total} 条`" />
<t-cell title="消费金额合计" :note="`¥${formatPackageAmount(amountTotal)}`" />
</t-cell-group>
<t-cell-group v-if="recordList.length" class="empty-cell-title-margin" theme="card">
<t-cell
class="item"
v-for="item in recordList"
:key="item.id"
:arrow="canOpenSource(item)"
v-entrance-transition="{ step: 30 }"
@click="openSource(item)"
>
<template #leftIcon>
<t-image
v-if="getCustomerPhotoURL(item.customer, 64)"
:src="getCustomerPhotoURL(item.customer, 64)"
:alt="getCustomerText(item)"
fit="cover"
class="avatar"
/>
<div v-else class="avatar fallback" v-text="getCustomerText(item).slice(0, 1)" />
</template>
<template #title>
<div class="title">
<span class="customer" v-text="getCustomerText(item)" />
<t-tag
class="value"
size="small"
:theme="item.sourceType === 'LEGACY_EVENT' ? 'default' : 'primary'"
variant="light"
:content="getRecordTitle(item)"
/>
</div>
</template>
<template #description>
<div class="description">
<t-tag
size="small"
:theme="item.status === 'ACTIVE' ? 'success' : 'danger'"
variant="light-outline"
:content="getStatusText(item.status)"
/>
<pass-time-label class="time" :timestamp="item.effectiveAt" underline />
</div>
</template>
<template #note>
<strong class="red" v-text="`¥${formatPackageAmount(item.amount)}`" />
</template>
</t-cell>
</t-cell-group>
<div v-else class="center-tips" v-text="isLoading ? '正在加载消费记录' : '暂无消费记录'" />
<div v-if="recordList.length" class="center-tips" v-text="loadStateText" />
</div>
</t-pull-down-refresh>
<customer-selector
v-model="customerId"
v-model:visible="customerSelectorVisible"
:enable-scan="false"
@change="handleCustomerChange"
/>
<t-popup v-model="startVisible" placement="bottom">
<t-date-time-picker
v-if="startVisible"
v-model="startDraft"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="开始时间"
:default-value="dateRange[0]"
@cancel="cancelStartTime"
@confirm="confirmStartTime"
</t-pull-down-refresh>
<customer-selector
v-model="customerId"
v-model:visible="customerSelectorVisible"
:enable-scan="false"
@change="handleCustomerChange"
/>
</t-popup>
<t-popup v-model="endVisible" placement="bottom">
<t-date-time-picker
v-if="endVisible"
v-model="endDraft"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="结束时间"
:default-value="dateRange[1]"
@cancel="cancelEndTime"
@confirm="confirmEndTime"
/>
</t-popup>
<t-popup v-model="startVisible" placement="bottom">
<t-date-time-picker
v-if="startVisible"
v-model="startDraft"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="开始时间"
:default-value="dateRange[0]"
@cancel="cancelStartTime"
@confirm="confirmStartTime"
/>
</t-popup>
<t-popup v-model="endVisible" placement="bottom">
<t-date-time-picker
v-if="endVisible"
v-model="endDraft"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="结束时间"
:default-value="dateRange[1]"
@cancel="cancelEndTime"
@confirm="confirmEndTime"
/>
</t-popup>
</main>
</div>
</template>
@@ -179,8 +189,6 @@ import ConsumptionRecordAPI from "@/api/ConsumptionRecordAPI";
import CustomerAPI from "@/api/CustomerAPI";
import CodeScanner from "@/components/CodeScanner.vue";
import CustomerSelector from "@/components/CustomerSelector.vue";
import { useNavBarStore } from "@/store/navBarStore";
import type { Customer } from "@/types/Customer";
import type {
ConsumptionRecord,
ConsumptionRecordPage,
@@ -194,6 +202,8 @@ import { Message } from "@/utils/message";
import { formatPackageAmount } from "@/utils/package";
import { permissionCodes } from "@/utils/permission";
import type { Customer } from "@/types/Customer";
defineOptions({ name: "ConsumptionRecordList" });
type DateFilterType = "today" | "yesterday" | "thisWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
@@ -201,7 +211,6 @@ type DateFilterType = "today" | "yesterday" | "thisWeek" | "thisMonth" | "lastMo
const pageSize = 20;
const route = useRoute();
const router = useRouter();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const dateOptions: Array<{ label: string; value: DateFilterType }> = [
{ label: "全部时间", value: "all" },
@@ -454,7 +463,6 @@ async function openSource(record: ConsumptionRecord): Promise<void> {
}
onMounted(async () => {
navBarStore.clearRight();
applyRouteQuery();
await loadSelectedCustomer();
await reloadRecords();
+9 -4
View File
@@ -1,4 +1,11 @@
<template>
<t-navbar
fixed
:z-index="20"
title="资金记录详情"
left-arrow
@left-click="$router.back()"
/>
<div v-can="pageAccess" class="package-record-detail">
<template v-if="record">
<section class="hero" v-entrance-transition>
@@ -125,8 +132,6 @@ import { PassTimeLabel, Text } from "timi-web";
import { useUserStore } from "timi-web-api";
import SalesOrderAPI from "@/api/SalesOrderAPI";
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
import { useNavBarStore } from "@/store/navBarStore";
import type { FundRecord, FundRecordStatus } from "@/types/SalesOrder";
import type { PhotoItem } from "@/types/Photo";
import { getAttachmentReadURL } from "@/utils/attachment";
import { getErrorMessage } from "@/utils/error";
@@ -136,6 +141,8 @@ import { getFundOperationText, getFundStatusText } from "@/utils/salesOrder";
import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission";
import type { FundRecord, FundRecordStatus } from "@/types/SalesOrder";
type ReasonAction = "reject" | "cancel";
defineOptions({ name: "FundRecordDetail" });
@@ -144,7 +151,6 @@ defineOptions({ name: "FundRecordDetail" });
const route = useRoute();
const router = useRouter();
const userStore = useUserStore();
const navBarStore = useNavBarStore();
const isOperating = ref(false);
// ---------- 资金记录 ----------
@@ -329,7 +335,6 @@ async function toRevoke(): Promise<void> {
// ---------- 生命周期 ----------
onMounted(loadData);
onUnmounted(() => navBarStore.clearRight());
</script>
<style scoped lang="less">
+175 -163
View File
@@ -1,171 +1,186 @@
<template>
<div v-can="pageAccess" class="sales-order-record-list">
<div class="filters glass">
<t-input
class="customer"
v-model.trim="customerSearchKeyword"
borderless
placeholder="输入客户编码或姓名"
@enter="applyCustomerSearch"
<div class="page-layout navbar sales-order-record-list">
<t-navbar
fixed
:z-index="20"
title="资金流水"
left-arrow
@left-click="$router.back()"
/>
<main v-can="pageAccess" class="page-content scroll list">
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="reload"
@scrolltolower="loadMore"
>
<template #suffix-icon>
<div class="actions">
<t-button
v-if="customerId"
shape="circle"
theme="danger"
variant="text"
size="extra-small"
aria-label="清除客户选择"
@click.stop="clearCustomer"
>
<t-icon name="close" size="1rem" />
</t-button>
<t-button
size="extra-small"
theme="primary"
variant="outline"
content="选择客户"
@click.stop="customerSelectorVisible = true"
<div class="filters glass">
<t-input
class="customer"
v-model.trim="customerSearchKeyword"
borderless
placeholder="输入客户编码或姓名"
@enter="applyCustomerSearch"
>
<template #suffix-icon>
<div class="actions">
<t-button
v-if="customerId"
shape="circle"
theme="danger"
variant="text"
size="extra-small"
aria-label="清除客户选择"
@click.stop="clearCustomer"
>
<t-icon name="close" size="1rem" />
</t-button>
<t-button
size="extra-small"
theme="primary"
variant="outline"
content="选择客户"
@click.stop="customerSelectorVisible = true"
/>
</div>
</template>
</t-input>
<t-dropdown-menu class="menus">
<t-dropdown-item
v-model="dateFilterType"
:label="dateFilterLabel"
:options="dateOptions"
@change="selectDateFilter"
/>
</div>
</template>
</t-input>
<t-dropdown-menu class="menus">
<t-dropdown-item
v-model="dateFilterType"
:label="dateFilterLabel"
:options="dateOptions"
@change="selectDateFilter"
/>
<t-dropdown-item
v-if="!isSelfReceiveOnly"
v-model="operationType"
:label="operationFilterLabel"
:options="operationOptions"
@change="selectOperation"
/>
<t-dropdown-item
v-model="status"
label="状态"
:options="statusOptions"
@change="selectStatus"
/>
</t-dropdown-menu>
</div>
<t-pull-down-refresh v-model="isRefreshing" :refresh-timeout="30000" @refresh="reload" @scrolltolower="loadMore">
<t-cell-group v-if="isCustomDate" class="date-summary" theme="card">
<t-cell
title="开始时间"
:note="dateRange[0] || '-'"
arrow
@click="openStartTime"
/>
<t-cell
title="结束时间"
:note="dateRange[1] || '-'"
arrow
@click="openEndTime"
/>
</t-cell-group>
<t-cell-group v-if="recordList.length" class="empty-cell-title-margin" theme="card">
<t-cell
class="item"
v-for="item in recordList"
:key="item.id"
arrow
v-entrance-transition="{ step: 30 }"
@click="toDetail(item)"
>
<template #leftIcon>
<t-image
v-if="getCustomerPhotoURL(item.customer, 64)"
:src="getCustomerPhotoURL(item.customer, 64)"
:alt="getCustomerText(item)"
fit="cover"
class="avatar"
<t-dropdown-item
v-if="!isSelfReceiveOnly"
v-model="operationType"
:label="operationFilterLabel"
:options="operationOptions"
@change="selectOperation"
/>
<div v-else class="avatar fallback" v-text="getCustomerText(item).slice(0, 1)" />
</template>
<template #title>
<div class="title">
<span class="customer clip-text" v-text="getCustomerText(item)" />
<span class="type" :class="getOperationClass(item.operationType)" v-text="getFundOperationText(item.operationType)" />
<t-tag
size="small"
:content="getRecordStatusText(item)"
variant="light-outline"
:theme="getRecordStatusTheme(item)"
<t-dropdown-item
v-model="status"
label="状态"
:options="statusOptions"
@change="selectStatus"
/>
</t-dropdown-menu>
</div>
<t-cell-group v-if="isCustomDate" class="date-summary" theme="card">
<t-cell
title="开始时间"
:note="dateRange[0] || '-'"
arrow
@click="openStartTime"
/>
<t-cell
title="结束时间"
:note="dateRange[1] || '-'"
arrow
@click="openEndTime"
/>
</t-cell-group>
<t-cell-group v-if="recordList.length" class="empty-cell-title-margin" theme="card">
<t-cell
class="item"
v-for="item in recordList"
:key="item.id"
arrow
v-entrance-transition="{ step: 30 }"
@click="toDetail(item)"
>
<template #leftIcon>
<t-image
v-if="getCustomerPhotoURL(item.customer, 64)"
:src="getCustomerPhotoURL(item.customer, 64)"
:alt="getCustomerText(item)"
fit="cover"
class="avatar"
/>
</div>
</template>
<template #description>
<div class="description">
<div class="operator">
<div class="field">
<span class="label">发起人</span>
<span class="text-bold" v-text="getOperatorText(item)" />
</div>
<div v-if="item.verifier" class="field">
<span class="label">核销人</span>
<span class="text-bold" v-text="getVerifierText(item)" />
</div>
<pass-time-label :timestamp="item.occurredAt" underline />
<div v-else class="avatar fallback" v-text="getCustomerText(item).slice(0, 1)" />
</template>
<template #title>
<div class="title">
<span class="customer clip-text" v-text="getCustomerText(item)" />
<span class="type" :class="getOperationClass(item.operationType)" v-text="getFundOperationText(item.operationType)" />
<t-tag
size="small"
:content="getRecordStatusText(item)"
variant="light-outline"
:theme="getRecordStatusTheme(item)"
/>
</div>
<div class="amounts">
<div class="order-amount">
<span class="label">订单总价</span>
<span>¥</span>
<span v-text="formatPackageAmount(item.salesOrderAmount)" />
</template>
<template #description>
<div class="description">
<div class="operator">
<div class="field">
<span class="label">发起人</span>
<span class="text-bold" v-text="getOperatorText(item)" />
</div>
<div v-if="item.verifier" class="field">
<span class="label">核销人</span>
<span class="text-bold" v-text="getVerifierText(item)" />
</div>
<pass-time-label :timestamp="item.occurredAt" underline />
</div>
<div class="unpaid-amount">
<span class="label">剩余待收</span>
<span>¥</span>
<span v-text="formatPackageAmount(item.salesOrderUnpaidAmountSnapshot)" />
</div>
<div class="record-amount">
<span class="label">流水金额</span>
<span class="red">¥</span>
<span class="value red" v-text="formatPackageAmount(item.amount)" />
<div class="amounts">
<div class="order-amount">
<span class="label">订单总价</span>
<span>¥</span>
<span v-text="formatPackageAmount(item.salesOrderAmount)" />
</div>
<div class="unpaid-amount">
<span class="label">剩余待收</span>
<span>¥</span>
<span v-text="formatPackageAmount(item.salesOrderUnpaidAmountSnapshot)" />
</div>
<div class="record-amount">
<span class="label">流水金额</span>
<span class="red">¥</span>
<span class="value red" v-text="formatPackageAmount(item.amount)" />
</div>
</div>
</div>
</div>
</template>
</t-cell>
</t-cell-group>
<div v-else class="empty" v-text="loading ? '正在加载资金流水' : '暂无资金流水'" />
<div class="center-tips" v-text="loadStateText" />
</t-pull-down-refresh>
</template>
</t-cell>
</t-cell-group>
<div v-else class="empty" v-text="loading ? '正在加载资金流水' : '暂无资金流水'" />
<div class="center-tips" v-text="loadStateText" />
</t-pull-down-refresh>
</main>
<customer-selector
v-model="customerId"
v-model:visible="customerSelectorVisible"
@change="handleCustomerChange"
/>
<t-popup v-model="startVisible" placement="bottom">
<t-date-time-picker
v-if="startVisible"
v-model="startDraft"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="开始时间"
:default-value="dateRange[0]"
@cancel="cancelStartTime"
@confirm="confirmStartTime"
/>
</t-popup>
<t-popup v-model="endVisible" placement="bottom">
<t-date-time-picker
v-if="endVisible"
v-model="endDraft"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="结束时间"
:default-value="dateRange[1]"
@cancel="cancelEndTime"
@confirm="confirmEndTime"
/>
</t-popup>
</div>
<customer-selector
v-model="customerId"
v-model:visible="customerSelectorVisible"
@change="handleCustomerChange"
/>
<t-popup v-model="startVisible" placement="bottom">
<t-date-time-picker
v-if="startVisible"
v-model="startDraft"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="开始时间"
:default-value="dateRange[0]"
@cancel="cancelStartTime"
@confirm="confirmStartTime"
/>
</t-popup>
<t-popup v-model="endVisible" placement="bottom">
<t-date-time-picker
v-if="endVisible"
v-model="endDraft"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="结束时间"
:default-value="dateRange[1]"
@cancel="cancelEndTime"
@confirm="confirmEndTime"
/>
</t-popup>
</template>
<script setup lang="ts">
@@ -175,8 +190,6 @@ import { useUserStore } from "timi-web-api";
import CustomerAPI from "@/api/CustomerAPI";
import SalesOrderAPI from "@/api/SalesOrderAPI";
import CustomerSelector from "@/components/CustomerSelector.vue";
import { useNavBarStore } from "@/store/navBarStore";
import type { Customer } from "@/types/Customer";
import type { FundOperationType, FundRecord, FundRecordStatus } from "@/types/SalesOrder";
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
import { getErrorMessage } from "@/utils/error";
@@ -186,13 +199,14 @@ import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission";
import { getCustomerPhotoURL } from "@/utils/customer";
import type { Customer } from "@/types/Customer";
defineOptions({ name: "FundRecordList" });
type DateFilterType = "today" | "yesterday" | "thisWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
const route = useRoute();
const router = useRouter();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const recordList = ref<FundRecord[]>([]);
const operationType = ref(route.query.operationType === "RECEIVE" ? "RECEIVE" : "ALL");
@@ -503,7 +517,6 @@ function getCurrentRouteDepth(): number {
}
onMounted(async () => {
navBarStore.clearRight();
try {
if (customerId.value) {
selectedCustomer.value = await CustomerAPI.detail(customerId.value);
@@ -515,7 +528,6 @@ onMounted(async () => {
}
});
onUnmounted(() => navBarStore.clearRight());
</script>
<style scoped lang="less">
+121 -5
View File
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
title="资金冲正"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div v-can="permissionCodes.fund.revoke" class="package-operation-edit">
<t-cell-group v-if="record" title="原资金记录" theme="card" v-entrance-transition>
<t-cell title="操作类型" :note="getFundOperationText(record.operationType)" />
@@ -106,8 +151,6 @@ import { Time } from "timi-web";
import { useUserStore, type Attachment } from "timi-web-api";
import SalesOrderAPI from "@/api/SalesOrderAPI";
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
import { useNavBarStore } from "@/store/navBarStore";
import type { FundRecord } from "@/types/SalesOrder";
import type { PhotoItem } from "@/types/Photo";
import { createPackageRequestNo, formatPackageAmount } from "@/utils/package";
import { getFundOperationText, getFundStatusText } from "@/utils/salesOrder";
@@ -117,12 +160,44 @@ import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission";
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";
defineOptions({ name: "FundRecordRevoke" });
const route = useRoute();
const router = useRouter();
const userStore = useUserStore();
const navBarStore = useNavBarStore();
const record = ref<FundRecord>();
const reason = ref("");
const remark = ref("");
@@ -281,12 +356,12 @@ async function save(): Promise<void> {
onMounted(async () => {
if (userStore.hasPermissions(permissionCodes.fund.revoke)) {
navBarStore.setRightText("提交", "var(--td-error-color)", save);
setPageNavBarRightText("提交", "var(--td-error-color)", save);
}
await loadData();
});
onUnmounted(() => navBarStore.clearRight());
onUnmounted(() => clearPageNavBarRight());
</script>
<style scoped lang="less">
@@ -319,4 +394,45 @@ onUnmounted(() => navBarStore.clearRight());
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>
+121 -5
View File
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
title="取消销售订单"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div v-can="permissionCodes.salesOrder.cancel" class="sales-order-operation">
<t-notice-bar
theme="warning"
@@ -57,18 +102,48 @@
import { useUserStore } from "timi-web-api";
import FulfillmentAPI from "@/api/FulfillmentAPI";
import SalesOrderAPI from "@/api/SalesOrderAPI";
import { useNavBarStore } from "@/store/navBarStore";
import type { SalesOrder } from "@/types/SalesOrder";
import { getErrorMessage } from "@/utils/error";
import { emitListDataChanged, listDataEventKeys } from "@/utils/listDataEvents";
import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission";
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";
defineOptions({ name: "SalesOrderCancel" });
const route = useRoute();
const router = useRouter();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const order = ref<SalesOrder>();
const loading = ref(false);
@@ -144,10 +219,10 @@ async function save(): Promise<void> {
onMounted(async () => {
if (!userStore.hasPermissions(permissionCodes.salesOrder.cancel)) return;
navBarStore.setRightText("确认", "var(--td-error-color)", save);
setPageNavBarRightText("确认", "var(--td-error-color)", save);
await loadData();
});
onUnmounted(() => navBarStore.clearRight());
onUnmounted(() => clearPageNavBarRight());
</script>
<style scoped lang="less">
@@ -165,4 +240,45 @@ onUnmounted(() => navBarStore.clearRight());
}
}
}
.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>
+8 -4
View File
@@ -1,4 +1,11 @@
<template>
<t-navbar
fixed
:z-index="20"
title="直接产品下单"
left-arrow
@left-click="$router.back()"
/>
<div v-can="permissionCodes.salesOrder.create" class="sales-order-create">
<t-form class="form" label-align="left" label-width="5.25rem" v-entrance-transition>
<t-form-item label="客户" required-mark>
@@ -252,13 +259,12 @@ import { permissionCodes } from "@/utils/permission";
import { buildProductStockPreview, getProductStockShortageMessage, mergeProductStockRequirements } from "@/utils/productStock";
import type { ProductStockPreviewItem } from "@/utils/productStock";
import { uploadPhotoList } from "@/utils/photo";
import { useNavBarStore } from "@/store/navBarStore";
import { useSettingStore } from "@/store/settingStore";
type FormItem = Partial<DirectProductOrderItemRequest> & { clientKey: string; productName: string; unitPriceText: string };
defineOptions({ name: "SalesOrderCreate" });
const router = useRouter();
const navBarStore = useNavBarStore();
const settingStore = useSettingStore();
const userStore = useUserStore();
const canPriceOverride = computed(() => userStore.hasPermissions(permissionCodes.salesOrder.priceOverride));
@@ -616,9 +622,7 @@ async function submitOrder(): Promise<void> {
}
onMounted(() => {
addItem();
navBarStore.clearRight();
});
onUnmounted(() => navBarStore.clearRight());
</script>
<style scoped lang="less">
+9 -5
View File
@@ -1,4 +1,11 @@
<template>
<t-navbar
fixed
:z-index="20"
title="销售订单详情"
left-arrow
@left-click="$router.back()"
/>
<div v-can="permissionCodes.salesOrder.read" class="sales-order-detail">
<template v-if="order">
<customer-profile-card
@@ -232,8 +239,6 @@ import SalesOrderAPI from "@/api/SalesOrderAPI";
import CustomerProfileCard from "@/components/CustomerProfileCard.vue";
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
import ProductSkuTags from "@/components/ProductSkuTags.vue";
import { useNavBarStore } from "@/store/navBarStore";
import type { GaoSalesOrderItem, GaoSalesPaymentStatus, SalesOrder } from "@/types/SalesOrder";
import type { PhotoItem } from "@/types/Photo";
import { convertPackageQuantity, formatPackageAmount, getPackageQuantityText } from "@/utils/package";
import { getAttachmentReadURL } from "@/utils/attachment";
@@ -251,10 +256,11 @@ import { Message } from "@/utils/message";
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
import { uploadPhotoList } from "@/utils/photo";
import type { GaoSalesOrderItem, GaoSalesPaymentStatus, SalesOrder } from "@/types/SalesOrder";
defineOptions({ name: "SalesOrderDetail" });
const route = useRoute();
const router = useRouter();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const order = ref<SalesOrder>();
const hasPendingFulfillment = ref(false);
@@ -370,7 +376,6 @@ function getItemFulfillmentStatus(item: GaoSalesOrderItem): { text: string; them
async function loadData(): Promise<void> {
const id = String(route.params.id || "");
isEditing.value = false;
navBarStore.clearRight();
if (!id) {
order.value = undefined;
hasPendingFulfillment.value = false;
@@ -510,7 +515,6 @@ function getCurrentRouteDepth(): number {
onMounted(loadData);
watch(() => route.params.id, loadData);
onUnmounted(() => navBarStore.clearRight());
</script>
<style scoped lang="less">
+206 -107
View File
@@ -1,106 +1,161 @@
<template>
<div ref="salesOrderListRef" v-can="permissionCodes.salesOrder.read" class="sales-order-list">
<div class="filters glass">
<div class="search-row">
<t-input
v-model.trim="keyword"
class="keyword"
type="text"
enterkeyhint="search"
clearable
borderless
placeholder="订单号或客户"
>
<template #suffix-icon>
<div class="actions">
<t-button
size="extra-small"
theme="primary"
variant="outline"
content="选择客户"
@click.stop="customerSelectorVisible = true"
/>
</div>
</template>
</t-input>
<t-button
class="filter-button"
size="small"
theme="light"
variant="outline"
@click="filterVisible = true"
>
<template #icon>
<t-icon name="filter-1" />
</template>
<span>筛选</span>
</t-button>
</div>
</div>
<t-pull-down-refresh
class="list-wrap"
v-model="refreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
<div class="page-layout navbar sales-order-list">
<t-navbar
fixed
:z-index="20"
title="销售订单"
left-arrow
@left-click="$router.back()"
>
<div class="items">
<sales-order-summary
v-if="customerId"
ref="customerOrderSummaryRef"
:customer="selectedCustomer"
/>
<t-cell-group v-if="packageConfigId" class="selected-package" theme="card">
<t-cell title="套餐" :note="selectedPackageName">
<template #left-icon>
<t-icon name="layers" />
<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-cell>
</t-cell-group>
<sales-order-filter-summary
:filter="appliedFilter"
:total="total"
:package-config-id="packageConfigId"
@confirm="confirmFilter"
/>
<sales-order-list-cell
v-for="item in list"
:key="item.id"
class="item"
:order="item"
:can-receive="canReceive"
:can-fulfill="canCreateFulfillment"
:can-cancel="canCancel"
:can-refund="canRefund"
:can-store-manager="canStoreManager"
v-entrance-transition="{ step: 30 }"
@click="toDetail(item)"
@cancel="toCancel(item)"
@receive="toPayment(item)"
@fulfill="toFulfillment(item)"
@refund="toRefund(item)"
@confirm-no-refund="toNoRefund(item)"
/>
<div v-if="!list.length" class="empty" v-text="loading ? '正在加载销售订单' : '暂无销售订单'" />
</div>
<div class="center-tips" v-text="loading ? '正在加载' : noMore ? '已经到底了' : '上拉加载更多'" />
</t-pull-down-refresh>
</t-popover>
</div>
</template>
</t-navbar>
<main ref="salesOrderListRef" v-can="permissionCodes.salesOrder.read" class="page-content scroll list">
<t-pull-down-refresh
class="list-wrap pull-refresh"
v-model="refreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
>
<div class="filters glass">
<div class="search-row">
<t-input
v-model.trim="keyword"
class="keyword"
type="text"
enterkeyhint="search"
clearable
borderless
placeholder="订单号或客户"
>
<template #suffix-icon>
<div class="actions">
<t-button
size="extra-small"
theme="primary"
variant="outline"
content="选择客户"
@click.stop="customerSelectorVisible = true"
/>
</div>
</template>
</t-input>
<t-button
class="filter-button"
size="small"
theme="light"
variant="outline"
@click="filterVisible = true"
>
<template #icon>
<t-icon name="filter-1" />
</template>
<span>筛选</span>
</t-button>
</div>
</div>
<div class="items">
<sales-order-summary
v-if="customerId"
ref="customerOrderSummaryRef"
:customer="selectedCustomer"
/>
<t-cell-group v-if="packageConfigId" class="selected-package" theme="card">
<t-cell title="套餐" :note="selectedPackageName">
<template #left-icon>
<t-icon name="layers" />
</template>
</t-cell>
</t-cell-group>
<sales-order-filter-summary
:filter="appliedFilter"
:total="total"
:package-config-id="packageConfigId"
@confirm="confirmFilter"
/>
<sales-order-list-cell
v-for="item in list"
:key="item.id"
class="item"
:order="item"
:can-receive="canReceive"
:can-fulfill="canCreateFulfillment"
:can-cancel="canCancel"
:can-refund="canRefund"
:can-store-manager="canStoreManager"
v-entrance-transition="{ step: 30 }"
@click="toDetail(item)"
@cancel="toCancel(item)"
@receive="toPayment(item)"
@fulfill="toFulfillment(item)"
@refund="toRefund(item)"
@confirm-no-refund="toNoRefund(item)"
/>
<div v-if="!list.length" class="empty" v-text="loading ? '正在加载销售订单' : '暂无销售订单'" />
</div>
<div class="center-tips" v-text="loading ? '正在加载' : noMore ? '已经到底了' : '上拉加载更多'" />
</t-pull-down-refresh>
</main>
<customer-selector
v-model="customerId"
v-model:visible="customerSelectorVisible"
@change="handleCustomerChange"
/>
<sales-order-filter-popup
v-model:visible="filterVisible"
:model-value="appliedFilter"
:package-config-id="packageConfigId"
@confirm="confirmFilter"
/>
</div>
<nav-bar-action-menu v-if="route.name === 'SalesOrderList' && actions.length" :actions="actions" />
<customer-selector
v-model="customerId"
v-model:visible="customerSelectorVisible"
@change="handleCustomerChange"
/>
<sales-order-filter-popup
v-model:visible="filterVisible"
:model-value="appliedFilter"
:package-config-id="packageConfigId"
@confirm="confirmFilter"
/>
</template>
<script setup lang="ts">
import type { NavBarAction } from "@/types/NavBarAction";
import { Toolkit } from "timi-web";
import { useUserStore } from "timi-web-api";
import { onBeforeRouteLeave } from "vue-router";
@@ -108,14 +163,10 @@ import CustomerAPI from "@/api/CustomerAPI";
import PackageAPI from "@/api/PackageAPI";
import SalesOrderAPI from "@/api/SalesOrderAPI";
import CustomerSelector from "@/components/CustomerSelector.vue";
import NavBarActionMenu from "@/components/NavBarActionMenu.vue";
import SalesOrderFilterPopup from "@/pages/salesOrder/components/SalesOrderFilterPopup.vue";
import SalesOrderFilterSummary from "@/pages/salesOrder/components/SalesOrderFilterSummary.vue";
import SalesOrderListCell from "@/pages/salesOrder/components/SalesOrderListCell.vue";
import SalesOrderSummary from "@/pages/salesOrder/components/SalesOrderSummary.vue";
import { useCurrentStoreStore } from "@/store/currentStoreStore";
import { useNavBarStore } from "@/store/navBarStore";
import type { Customer } from "@/types/Customer";
import type { GaoPackageConfig } from "@/types/Package";
import type {
GaoSalesOrderStatus,
@@ -138,6 +189,17 @@ 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";
defineOptions({ name: "SalesOrderList" });
const SALES_ORDER_FILTER_STORAGE_KEY = "gao-customer-h5:sales-order-filter";
@@ -145,7 +207,6 @@ const route = useRoute();
const router = useRouter();
const salesOrderListRef = ref<HTMLElement | null>(null);
const currentStoreStore = useCurrentStoreStore();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const canCreate = computed(() => userStore.hasPermissions(permissionCodes.salesOrder.create));
const canCreatePackageOrder = computed(() => userStore.hasPermissions(permissionCodes.customerPackage.create));
@@ -701,8 +762,7 @@ watch(() => currentStoreStore.currentStoreId, async (value, oldValue) => {
onMounted(async () => {
unregisterSalesOrderListEvent = events.register(listDataEventKeys.salesOrderChanged, (payload: ListDataChangedPayload) => requestEventRefresh(payload));
syncCachedRouteContext();
navBarStore.clearRight();
navBarStore.setCustomRightVisible(!!actions.value.length);
applyRouteFilters();
lastAppliedRouteFilterKey = routeFilterKey.value;
try {
@@ -731,8 +791,7 @@ onActivated(async () => {
} else {
restorePageScrollPosition();
}
navBarStore.clearRight();
navBarStore.setCustomRightVisible(!!actions.value.length);
});
onDeactivated(() => {
@@ -740,7 +799,6 @@ onDeactivated(() => {
savePageScrollPosition();
}
filterVisible.value = false;
navBarStore.clearRight();
});
onBeforeRouteLeave(to => {
@@ -756,7 +814,6 @@ onUnmounted(() => {
isDisposed = true;
unregisterSalesOrderListEvent?.();
unregisterSalesOrderListEvent = undefined;
navBarStore.clearRight();
search.cancel();
});
</script>
@@ -831,4 +888,46 @@ onUnmounted(() => {
text-align: center;
}
}
.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>
+122 -5
View File
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
title="确认无需退款"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div v-can="permissionCodes.fund.refund" class="sales-order-operation">
<t-cell-group v-if="order" title="销售订单" theme="card"><t-cell title="订单号" :note="order.orderNo || order.id" /><t-cell title="当前退款状态" :note="order.refundStatus || '未知'" /></t-cell-group>
<t-form v-if="order" class="form" label-align="left" label-width="6rem">
@@ -11,15 +56,46 @@
<script setup lang="ts">
import { useUserStore } from "timi-web-api";
import SalesOrderAPI from "@/api/SalesOrderAPI";
import { useNavBarStore } from "@/store/navBarStore";
import type { SalesOrder } from "@/types/SalesOrder";
import { getErrorMessage } from "@/utils/error";
import { emitListDataChanged, listDataEventKeys } from "@/utils/listDataEvents";
import { Message } from "@/utils/message";
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";
defineOptions({ name: "SalesOrderNoRefund" });
const route = useRoute(); const router = useRouter(); const navBarStore = useNavBarStore(); const userStore = useUserStore();
const route = useRoute(); const router = useRouter(); const userStore = useUserStore();
const order = ref<SalesOrder>(); const loading = ref(false); const saving = ref(false); const reason = ref("");
async function loadData(): Promise<void> {
const id = String(route.params.id || "");
@@ -42,14 +118,55 @@ async function save(): Promise<void> {
}
onMounted(async () => {
if (!userStore.hasPermissions(permissionCodes.fund.refund)) return;
navBarStore.setRightText("确认提交", "var(--td-brand-color)", save);
setPageNavBarRightText("确认提交", "var(--td-brand-color)", save);
await loadData();
});
onUnmounted(() => navBarStore.clearRight());
onUnmounted(() => clearPageNavBarRight());
</script>
<style scoped lang="less">
.sales-order-operation { gap: 1rem; padding: calc(var(--app-nav-height) + 1rem) 1rem 2rem; display: flex; flex-direction: column;
.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>
+121 -5
View File
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
title="登记收款"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div v-can="permissionCodes.fundReceive.create" class="sales-order-operation">
<t-cell-group
v-if="order"
@@ -96,8 +141,6 @@ import { useUserStore, type Attachment } from "timi-web-api";
import { Time } from "timi-web";
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
import SalesOrderAPI from "@/api/SalesOrderAPI";
import { useNavBarStore } from "@/store/navBarStore";
import type { SalesOrder } from "@/types/SalesOrder";
import type { PhotoItem } from "@/types/Photo";
import { createPackageRequestNo, formatPackageAmount, formatPackageAmountInput, parsePackageAmount } from "@/utils/package";
import { getErrorMessage } from "@/utils/error";
@@ -106,10 +149,42 @@ import { Message } from "@/utils/message";
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
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";
defineOptions({ name: "SalesOrderPayment" });
const route = useRoute();
const router = useRouter();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const order = ref<SalesOrder>();
const loading = ref(false);
@@ -216,10 +291,10 @@ async function save(): Promise<void> {
onMounted(async () => {
if (!userStore.hasPermissions(permissionCodes.fundReceive.create)) return;
navBarStore.setRightText("提交", "var(--td-brand-color)", save);
setPageNavBarRightText("提交", "var(--td-brand-color)", save);
await loadData();
});
onUnmounted(() => navBarStore.clearRight());
onUnmounted(() => clearPageNavBarRight());
</script>
<style scoped lang="less">
@@ -245,4 +320,45 @@ onUnmounted(() => navBarStore.clearRight());
padding: 0 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>
+121 -5
View File
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
title="登记退款"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div v-can="permissionCodes.fund.refund" class="sales-order-operation">
<t-cell-group
v-if="order"
@@ -118,8 +163,6 @@ import { Time } from "timi-web";
import { useUserStore, type Attachment } from "timi-web-api";
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
import SalesOrderAPI from "@/api/SalesOrderAPI";
import { useNavBarStore } from "@/store/navBarStore";
import type { SalesOrder } from "@/types/SalesOrder";
import type { PhotoItem } from "@/types/Photo";
import { createPackageRequestNo, formatPackageAmount, formatPackageAmountInput, parsePackageAmount } from "@/utils/package";
import { getErrorMessage } from "@/utils/error";
@@ -128,10 +171,42 @@ import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission";
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";
defineOptions({ name: "SalesOrderRefund" });
const route = useRoute();
const router = useRouter();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const order = ref<SalesOrder>();
const loading = ref(false);
@@ -252,10 +327,10 @@ async function save(): Promise<void> {
onMounted(async () => {
if (!userStore.hasPermissions(permissionCodes.fund.refund)) return;
navBarStore.setRightText("提交", "var(--td-error-color)", save);
setPageNavBarRightText("提交", "var(--td-error-color)", save);
await loadData();
});
onUnmounted(() => navBarStore.clearRight());
onUnmounted(() => clearPageNavBarRight());
</script>
<style scoped lang="less">
@@ -290,4 +365,45 @@ onUnmounted(() => navBarStore.clearRight());
padding: 0 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>
+7
View File
@@ -1,4 +1,11 @@
<template>
<t-navbar
fixed
:z-index="20"
title="关于"
left-arrow
@left-click="$router.back()"
/>
<div class="about-page">
<section class="brand" v-entrance-transition>
<logo @click="handleLogoClick" />
+22
View File
@@ -1,4 +1,11 @@
<template>
<t-navbar
fixed
:z-index="20"
:title="routeNavBarTitle"
left-arrow
@left-click="$router.back()"
/>
<div class="agreement-page">
<template v-if="article">
<header class="header" v-entrance-transition>
@@ -34,6 +41,21 @@ defineOptions({
});
const route = useRoute();
const routeNavBarTitle = computed(() => {
switch (route.name) {
case "Agreement":
return "协议";
case "ServiceAgreement":
return "服务协议";
case "PrivacyAgreement":
return "隐私协议";
case "OpenSourceAgreement":
return "开源软件协议";
default:
return "";
}
});
const article = ref<Article>();
const isLoading = ref(false);
let loadToken = 0;
+7
View File
@@ -1,4 +1,11 @@
<template>
<t-navbar
fixed
:z-index="20"
title="应用设置"
left-arrow
@left-click="$router.back()"
/>
<div class="settings-page">
<t-cell-group title="显示" theme="card" v-entrance-transition>
<t-cell class="theme" title="显示模式">
+7
View File
@@ -1,4 +1,11 @@
<template>
<t-navbar
fixed
:z-index="20"
title="使用说明"
left-arrow
@left-click="$router.back()"
/>
<div class="help-page empty-cell-title-margin">
<div class="filters glass">
<t-input
+19 -8
View File
@@ -1,4 +1,11 @@
<template>
<t-navbar
fixed
:z-index="20"
:title="pageNavBarTitle"
left-arrow
@left-click="$router.back()"
/>
<div class="help-article-page">
<template v-if="article">
<article-view
@@ -19,16 +26,20 @@
import { onBeforeRouteLeave } from "vue-router";
import { type Article, ArticleAPI, AttachmentAPI } from "timi-web-api";
import { ArticleView } from "timi-tdesign-mobile";
import { useNavBarStore } from "@/store/navBarStore";
import { getErrorMessage } from "@/utils/error";
import { Message } from "@/utils/message";
import { getErrorMessage } from "@/utils/error";
defineOptions({
name: "HelpArticle"
});
const route = useRoute();
const navBarStore = useNavBarStore();
const pageNavBarTitle = ref("");
function setPageNavBarTitle(value?: string): void {
pageNavBarTitle.value = value || "";
}
const article = ref<Article>();
const isLoading = ref(false);
let loadToken = 0;
@@ -37,15 +48,15 @@ function resolveAttachmentUrl(attachmentId: string): string {
return AttachmentAPI.getReadURL(attachmentId);
}
function getRouteNavBarTitle(): string {
return typeof route.meta.navBarTitle === "string" ? route.meta.navBarTitle : "";
function getFallbackPageTitle(): string {
return "使用说明";
}
async function loadArticle(): Promise<void> {
const requestToken = loadToken + 1;
loadToken = requestToken;
article.value = undefined;
navBarStore.setTitle(getRouteNavBarTitle());
setPageNavBarTitle(getFallbackPageTitle());
const articleId = String(route.params.id || "").trim();
if (!articleId) {
return;
@@ -58,7 +69,7 @@ async function loadArticle(): Promise<void> {
return;
}
article.value = result;
navBarStore.setTitle(result.title?.trim() || getRouteNavBarTitle());
setPageNavBarTitle(result.title?.trim() || getFallbackPageTitle());
} catch (error) {
Message.error(getErrorMessage(error, "使用说明加载失败"));
} finally {
@@ -74,7 +85,7 @@ watch(() => route.params.id, async () => {
onBeforeRouteLeave(() => {
loadToken += 1;
navBarStore.setTitle(getRouteNavBarTitle());
setPageNavBarTitle(getFallbackPageTitle());
});
</script>
@@ -1,4 +1,11 @@
<template>
<t-navbar
fixed
:z-index="20"
title="营业日管理"
left-arrow
@left-click="$router.back()"
/>
<div
v-if="store"
v-can="permissionCodes.store.read"
+124 -8
View File
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
title="门店日记详情"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div v-can="permissionCodes.storeDiary.read" class="store-diary-detail">
<template v-if="article">
<header class="header" v-entrance-transition>
@@ -73,8 +118,6 @@ import { UserAPI, type Attachment, useUserStore } from "timi-web-api";
import StoreDiaryAPI from "@/api/StoreDiaryAPI";
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
import { useCurrentStoreStore } from "@/store/currentStoreStore";
import { useNavBarStore } from "@/store/navBarStore";
import type { StoreDiary } from "@/types/StoreDiary";
import type { PhotoItem } from "@/types/Photo";
import { getAttachmentReadURL } from "@/utils/attachment";
import { buildFallbackAvatar } from "@/utils/avatar";
@@ -82,13 +125,45 @@ import { getErrorMessage } from "@/utils/error";
import { Message } from "@/utils/message";
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";
defineOptions({
name: "StoreDiaryDetail"
});
const route = useRoute();
const router = useRouter();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const currentStoreStore = useCurrentStoreStore();
const canUpdate = computed(() => userStore.hasPermissions(permissionCodes.storeDiary.update));
@@ -129,17 +204,17 @@ async function prepareStoreScope(): Promise<void> {
function setRightAction(): void {
if (article.value?.id && canUpdate.value) {
navBarStore.setRightText("编辑", "var(--td-brand-color)", toEdit);
setPageNavBarRightText("编辑", "var(--td-brand-color)", toEdit);
return;
}
navBarStore.clearRight();
clearPageNavBarRight();
}
async function loadArticle(): Promise<void> {
const requestToken = loadToken + 1;
loadToken = requestToken;
article.value = undefined;
navBarStore.clearRight();
clearPageNavBarRight();
const id = String(route.params.id || "");
if (!id) {
return;
@@ -192,7 +267,7 @@ async function confirmDelete(): Promise<void> {
async onConfirm() {
dialog.destroy();
isDeleting.value = true;
navBarStore.clearRight();
clearPageNavBarRight();
try {
await StoreDiaryAPI.remove(diaryId);
Message.success("门店日记已删除");
@@ -209,7 +284,7 @@ async function confirmDelete(): Promise<void> {
onMounted(loadArticle);
onUnmounted(() => navBarStore.clearRight());
onUnmounted(() => clearPageNavBarRight());
</script>
<style scoped lang="less">
@@ -296,4 +371,45 @@ onUnmounted(() => navBarStore.clearRight());
}
}
}
.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>
+132 -5
View File
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
:title="routeNavBarTitle"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div v-can="pageAccess" class="store-diary-edit">
<t-form class="form" label-align="left" label-width="5rem" v-entrance-transition>
<t-form-item label="日记标题" required-mark>
@@ -83,8 +128,6 @@ import { AttachmentAPI, type Attachment, useUserStore } from "timi-web-api";
import StoreDiaryAPI from "@/api/StoreDiaryAPI";
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
import { useCurrentStoreStore } from "@/store/currentStoreStore";
import { useNavBarStore } from "@/store/navBarStore";
import type { StoreDiary } from "@/types/StoreDiary";
import type { PhotoItem } from "@/types/Photo";
import { getErrorMessage } from "@/utils/error";
import { compressUploadImage, compressUploadImageList } from "@/utils/imageCompression";
@@ -93,13 +136,56 @@ import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission";
import { saveCapturedFilesFromInput } from "@/utils/twaBridge";
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";
defineOptions({
name: "StoreDiaryEdit"
});
const route = useRoute();
const routeNavBarTitle = computed(() => {
switch (route.name) {
case "StoreDiaryCreate":
return "新增门店日记";
case "StoreDiaryEdit":
return "编辑门店日记";
default:
return "";
}
});
const router = useRouter();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const currentStoreStore = useCurrentStoreStore();
const routeId = computed(() => String(route.params.id || ""));
@@ -383,7 +469,7 @@ async function loadArticle(): Promise<void> {
onMounted(async () => {
if (userStore.hasPermissions(savePermissionCode.value)) {
navBarStore.setRightText("保存", "var(--td-brand-color)", save);
setPageNavBarRightText("保存", "var(--td-brand-color)", save);
}
try {
await loadArticle();
@@ -392,7 +478,7 @@ onMounted(async () => {
}
});
onUnmounted(() => navBarStore.clearRight());
onUnmounted(() => clearPageNavBarRight());
</script>
<style scoped lang="less">
@@ -466,4 +552,45 @@ onUnmounted(() => navBarStore.clearRight());
}
}
}
.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>
+181 -78
View File
@@ -1,103 +1,166 @@
<template>
<t-pull-down-refresh
v-can="permissionCodes.storeDiary.read"
class="store-diary-list"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
>
<div class="content">
<section class="calendar" v-entrance-transition>
<t-calendar
:key="calendarRenderKey"
class="calendar-view"
:value="selectedCalendarDate"
:min-date="calendarMinDate"
:format="calendarFormat"
switch-mode="month"
:use-popup="false"
@panel-change="handleCalendarPanelChange"
@select="selectCalendarDate"
/>
</section>
<t-button
v-if="canCreate"
class="cell-button"
theme="primary"
@click="toCreateToday"
>
新增今天日记
</t-button>
<t-cell-group v-if="pageResult.list.length" class="items fix-last-cell-line" theme="card">
<t-swipe-cell
v-for="(item, index) in pageResult.list"
:key="item.id || index"
class="item"
v-entrance-transition="{ step: 30 }"
<div class="page-layout navbar store-diary-list">
<t-navbar
fixed
:z-index="20"
title="门店日记"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
class="nav-actions"
v-if="(canShowActionMenu) && pageNavBarActionList.length"
>
<store-diary-list-item :diary="item" @select="toDetail" />
<template v-if="canDelete" #right>
<t-popover
v-model:visible="pageNavBarActionVisible"
placement="bottom-right"
:show-arrow="false"
theme="light"
>
<t-button
class="swipe-cell-button"
theme="danger"
:loading="isDeleting && deletingId === item.id"
@click.stop="confirmDelete(item)"
class="trigger"
variant="text"
:aria-label="'更多操作'"
type="button"
>
删除
<template #icon>
<t-icon name="ellipsis" />
</template>
</t-button>
</template>
</t-swipe-cell>
</t-cell-group>
<div class="center-tips" v-text="loadStateText" />
</div>
</t-pull-down-refresh>
<nav-bar-action-menu v-if="canShowActionMenu" :actions="actionList" />
<bottom-popup
v-model="diaryPopupVisible"
:title="`${selectedDateText} 门店日记`"
height="min(80vh, 40rem)"
left-button-text="关闭"
right-button-text=""
@left-button-click="closeDiaryPopup"
>
<div class="diary-popup">
<t-cell-group v-if="selectedDateDiaries.length">
<store-diary-list-item
v-for="(item, index) in selectedDateDiaries"
:key="item.id || index"
:diary="item"
hover
@select="toSelectedDiary"
/>
</t-cell-group>
<div v-else class="popup-empty" v-text="'该日期暂无门店日记'" />
</div>
</bottom-popup>
<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>
</template>
</t-navbar>
<main class="page-content scroll list">
<t-pull-down-refresh
v-can="permissionCodes.storeDiary.read"
class="store-diary-list pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
>
<div class="content">
<section class="calendar" v-entrance-transition>
<t-calendar
:key="calendarRenderKey"
class="calendar-view"
:value="selectedCalendarDate"
:min-date="calendarMinDate"
:format="calendarFormat"
switch-mode="month"
:use-popup="false"
@panel-change="handleCalendarPanelChange"
@select="selectCalendarDate"
/>
</section>
<t-button
v-if="canCreate"
class="cell-button"
theme="primary"
@click="toCreateToday"
>
新增今天日记
</t-button>
<t-cell-group v-if="pageResult.list.length" class="items fix-last-cell-line" theme="card">
<t-swipe-cell
v-for="(item, index) in pageResult.list"
:key="item.id || index"
class="item"
v-entrance-transition="{ step: 30 }"
>
<store-diary-list-item :diary="item" @select="toDetail" />
<template v-if="canDelete" #right>
<t-button
class="swipe-cell-button"
theme="danger"
:loading="isDeleting && deletingId === item.id"
@click.stop="confirmDelete(item)"
>
删除
</t-button>
</template>
</t-swipe-cell>
</t-cell-group>
<div class="center-tips" v-text="loadStateText" />
</div>
</t-pull-down-refresh>
</main>
<bottom-popup
v-model="diaryPopupVisible"
:title="`${selectedDateText} 门店日记`"
height="min(80vh, 40rem)"
left-button-text="关闭"
right-button-text=""
@left-button-click="closeDiaryPopup"
>
<div class="diary-popup">
<t-cell-group v-if="selectedDateDiaries.length">
<store-diary-list-item
v-for="(item, index) in selectedDateDiaries"
:key="item.id || index"
:diary="item"
hover
@select="toSelectedDiary"
/>
</t-cell-group>
<div v-else class="popup-empty" v-text="'该日期暂无门店日记'" />
</div>
</bottom-popup>
</div>
</template>
<script setup lang="ts">
import type { NavBarAction } from "@/types/NavBarAction";
import { BottomPopup } from "timi-tdesign-mobile";
import { type CalendarProps, DialogPlugin, type TDate } from "tdesign-mobile-vue";
import { type PageResult, useUserStore } from "timi-web-api";
import { Time } from "timi-web";
import StoreDiaryAPI, { type StoreDiaryListOptions } from "@/api/StoreDiaryAPI";
import { useCurrentStoreStore } from "@/store/currentStoreStore";
import { useNavBarStore } from "@/store/navBarStore";
import StoreDiaryListItem from "@/pages/store/component/StoreDiaryListItem.vue";
import type { NavBarAction } from "@/types/NavBarAction";
import type { StoreDiary } from "@/types/StoreDiary";
import { getErrorMessage } from "@/utils/error";
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 StoreDiaryListItem from "@/pages/store/component/StoreDiaryListItem.vue";
defineOptions({
name: "StoreDiaryList"
});
const router = useRouter();
const route = useRoute();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const currentStoreStore = useCurrentStoreStore();
const canCreate = computed(() => userStore.hasPermissions(permissionCodes.storeDiary.create));
@@ -418,8 +481,7 @@ async function preparePage(): Promise<void> {
}
onMounted(async () => {
navBarStore.clearRight();
navBarStore.setCustomRightVisible(canShowActionMenu.value);
try {
await preparePage();
} catch (error) {
@@ -427,7 +489,6 @@ onMounted(async () => {
}
});
onUnmounted(() => navBarStore.clearRight());
</script>
<style scoped lang="less">
@@ -506,4 +567,46 @@ onUnmounted(() => navBarStore.clearRight());
}
}
}
.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>
+132 -5
View File
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
:title="routeNavBarTitle"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div v-can="savePermissionCode" class="store-edit">
<t-form class="form" label-align="left" v-entrance-transition>
<t-form-item v-if="!isStoreManagerScope" label="编码">
@@ -60,18 +105,59 @@ import { useUserStore } from "timi-web-api";
import StoreAPI from "@/api/StoreAPI";
import StoreRemoveDialog from "@/components/StoreRemoveDialog.vue";
import { useCurrentStoreStore } from "@/store/currentStoreStore";
import { useNavBarStore } from "@/store/navBarStore";
import type { Store, StoreStatus } from "@/types/Store";
import { gaoRoleCodes, 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 { Store, StoreStatus } from "@/types/Store";
defineOptions({
name: "StoreEdit"
});
const route = useRoute();
const routeNavBarTitle = computed(() => {
switch (route.name) {
case "StoreCreate":
return "新增门店";
case "StoreEdit":
return "编辑门店";
default:
return "";
}
});
const router = useRouter();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const currentStoreStore = useCurrentStoreStore();
const routeId = computed(() => String(route.params.id || ""));
@@ -144,7 +230,7 @@ function validateForm(): boolean {
onMounted(async () => {
if (userStore.hasPermissions(savePermissionCode.value)) {
navBarStore.setRightText("保存", "var(--td-brand-color)", doSave);
setPageNavBarRightText("保存", "var(--td-brand-color)", doSave);
}
try {
if (!routeId.value) {
@@ -157,7 +243,7 @@ onMounted(async () => {
}
});
onUnmounted(() => navBarStore.clearRight());
onUnmounted(() => clearPageNavBarRight());
// ---------- 删除 ----------
@@ -216,4 +302,45 @@ 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>
+157 -56
View File
@@ -1,80 +1,141 @@
<template>
<div v-can="permissionCodes.store.read" class="store-list">
<t-pull-down-refresh
class="list-wrapper"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="fetch"
<div class="page-layout navbar store-list">
<t-navbar
fixed
:z-index="20"
title="门店管理"
left-arrow
@left-click="$router.back()"
>
<t-cell-group theme="card" class="fix-last-cell-line">
<t-swipe-cell
v-entrance-transition="{ step: 30 }"
v-for="item in pageResult.list"
:key="item.id"
class="item"
<template #right>
<div
class="nav-actions"
v-if="(canShowActionMenu) && pageNavBarActionList.length"
>
<t-cell
class="cell"
arrow
@click="toEdit(item)"
<t-popover
v-model:visible="pageNavBarActionVisible"
placement="bottom-right"
:show-arrow="false"
theme="light"
>
<template #title>
<div class="header">
<div class="title text-bold clip-text" v-text="item.name || '未命名门店'"></div>
<t-tag size="small" :theme="getStoreStatusTheme(item.status)" variant="outline" :content="getStoreStatusText(item.status)" />
</div>
</template>
<template #description>
<div class="description">
<span class="gray" v-text="item.telephone ? `电话:${item.telephone}` : '电话:-'" />
<span class="gray" v-text="item.address ? `地址:${item.address}` : '地址:-'" />
</div>
</template>
</t-cell>
<template v-if="canDeleteStore" #right>
<t-button
class="delete"
theme="danger"
:loading="isRemoving && removingStoreId === item.id"
@click.stop="openRemoveDialog(item)"
class="trigger"
variant="text"
:aria-label="'更多操作'"
type="button"
>
删除
<template #icon>
<t-icon name="ellipsis" />
</template>
</t-button>
</template>
</t-swipe-cell>
</t-cell-group>
<div v-if="!pageResult.list.length" class="center-tips" v-text="isLoading ? '正在加载门店' : '暂无门店'" />
<div v-if="pageResult.list.length" class="center-tips" v-text="isNoMore ? '已加载全部门店' : '上拉加载更多'" />
</t-pull-down-refresh>
<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>
</template>
</t-navbar>
<main v-can="permissionCodes.store.read" class="page-content scroll list">
<t-pull-down-refresh
class="list-wrapper pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="fetch"
>
<t-cell-group theme="card" class="fix-last-cell-line">
<t-swipe-cell
v-entrance-transition="{ step: 30 }"
v-for="item in pageResult.list"
:key="item.id"
class="item"
>
<t-cell
class="cell"
arrow
@click="toEdit(item)"
>
<template #title>
<div class="header">
<div class="title text-bold clip-text" v-text="item.name || '未命名门店'"></div>
<t-tag size="small" :theme="getStoreStatusTheme(item.status)" variant="outline" :content="getStoreStatusText(item.status)" />
</div>
</template>
<template #description>
<div class="description">
<span class="gray" v-text="item.telephone ? `电话:${item.telephone}` : '电话:-'" />
<span class="gray" v-text="item.address ? `地址:${item.address}` : '地址:-'" />
</div>
</template>
</t-cell>
<template v-if="canDeleteStore" #right>
<t-button
class="delete"
theme="danger"
:loading="isRemoving && removingStoreId === item.id"
@click.stop="openRemoveDialog(item)"
>
删除
</t-button>
</template>
</t-swipe-cell>
</t-cell-group>
<div v-if="!pageResult.list.length" class="center-tips" v-text="isLoading ? '正在加载门店' : '暂无门店'" />
<div v-if="pageResult.list.length" class="center-tips" v-text="isNoMore ? '已加载全部门店' : '上拉加载更多'" />
</t-pull-down-refresh>
</main>
<store-remove-dialog
v-model:visible="removeDialogVisible"
:store="removeTarget"
:loading="isRemoving"
@confirm="removeStore"
/>
</div>
<store-remove-dialog
v-model:visible="removeDialogVisible"
:store="removeTarget"
:loading="isRemoving"
@confirm="removeStore"
/>
<nav-bar-action-menu v-if="canShowActionMenu" :actions="actionList" />
</template>
<script setup lang="ts">
import type { NavBarAction } from "@/types/NavBarAction";
import { Message } from "@/utils/message";
import { Time, WebToolkit } from "timi-web";
import { type Page, type PageResult, useUserStore } from "timi-web-api";
import StoreAPI from "@/api/StoreAPI";
import StoreRemoveDialog from "@/components/StoreRemoveDialog.vue";
import { useNavBarStore } from "@/store/navBarStore";
import type { Store } from "@/types/Store";
import type { NavBarAction } from "@/types/NavBarAction";
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
import { getStoreStatusText, getStoreStatusTheme } from "@/utils/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 type { Store } from "@/types/Store";
defineOptions({
name: "StoreList"
});
const router = useRouter();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const isStoreManagerScope = computed(() => userStore.hasRoles(gaoRoleCodes.storeManager) && !userStore.hasRoles(gaoRoleCodes.globalManager));
const canCreateStore = computed(() => userStore.hasPermissions(permissionCodes.store.create));
@@ -234,8 +295,7 @@ async function removeStore(store: Store): Promise<void> {
}
onMounted(async () => {
navBarStore.clearRight();
navBarStore.setCustomRightVisible(canShowActionMenu.value);
try {
await fetch();
} catch {
@@ -244,7 +304,6 @@ onMounted(async () => {
});
onUnmounted(() => {
navBarStore.clearRight();
});
</script>
@@ -307,4 +366,46 @@ 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>
+122 -7
View File
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
title="门店排序"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
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>
</t-navbar>
<div v-can="permissionCodes.store.update" class="store-sort">
<div class="tip" v-text="'按住右侧拖动手柄调整门店顺序,保存后生效'" />
<div class="items">
@@ -49,16 +94,45 @@
import type { TagProps } from "tdesign-mobile-vue";
import { VueDraggableNext } from "vue-draggable-next";
import StoreAPI from "@/api/StoreAPI";
import { useNavBarStore } from "@/store/navBarStore";
import type { Store, StoreStatus } from "@/types/Store";
import { Message } from "@/utils/message";
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";
defineOptions({
name: "StoreSort"
});
const navBarStore = useNavBarStore();
const router = useRouter();
// ---------- 列表数据 ----------
@@ -131,8 +205,8 @@ async function loadData(): Promise<void> {
}
onMounted(async () => {
navBarStore.clearRight();
navBarStore.setRightText("保存", "var(--td-brand-color)", saveSort);
clearPageNavBarRight();
setPageNavBarRightText("保存", "var(--td-brand-color)", saveSort);
try {
await loadData();
} catch {
@@ -141,7 +215,7 @@ onMounted(async () => {
});
onUnmounted(() => {
navBarStore.clearRight();
clearPageNavBarRight();
});
</script>
@@ -207,4 +281,45 @@ 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>
@@ -1,5 +1,5 @@
<template>
<div v-can="permissionCodes.stat.read" class="data-charts-page">
<template v-can="permissionCodes.stat.read">
<div class="store-data-charts">
<store-chart-summary v-entrance-transition :date-text-list="dateTextList" />
<t-segmented
v-model="chartMode"
@@ -126,9 +126,9 @@ function buildDateTextList(begin: Date, end: Date): string[] {
</script>
<style scoped lang="less">
.data-charts-page {
gap: 1rem;
padding: calc(var(--app-nav-height) + 1rem) 1rem 1rem 1rem;
.store-data-charts {
gap: .5rem;
padding: 0 1rem;
display: flex;
flex-direction: column;
+129 -12
View File
@@ -1,5 +1,48 @@
<template>
<div class="home-tab">
<t-navbar
fixed
:z-index="20"
title="客户"
>
<template #right>
<div
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>
</t-navbar>
<main class="page-content scroll column home-tab">
<section
v-for="group in visibleEntryGroupList"
:key="group.title"
@@ -52,12 +95,47 @@
</template>
</t-button>
</div>
</div>
</main>
</template>
<script setup lang="ts">
import { NotifyAPI, useUserStore } from "timi-web-api";
import { useNavBarStore } from "@/store/navBarStore";
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";
defineOptions({
@@ -65,7 +143,6 @@ defineOptions({
});
const router = useRouter();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const unreadNotifyCount = ref(0);
let isPageActive = true;
@@ -160,33 +237,32 @@ async function loadUnreadNotifyCount(): Promise<void> {
console.warn("未读通知数量加载失败", error);
}
if (isPageActive) {
navBarStore.setRightBadge(unreadNotifyCount.value);
setPageNavBarRightBadge(unreadNotifyCount.value);
}
}
onMounted(async () => {
navBarStore.clearRight();
clearPageNavBarRight();
if (canReadNotify.value) {
navBarStore.setRightIcon("notification", async () => {
setPageNavBarRightIcon("notification", async () => {
await router.push("/notify");
});
navBarStore.setRightBadge(0);
setPageNavBarRightBadge(0);
await loadUnreadNotifyCount();
}
});
onUnmounted(() => {
isPageActive = false;
navBarStore.clearRight();
clearPageNavBarRight();
});
</script>
<style scoped lang="less">
.home-tab {
gap: 1rem;
display: flex;
padding: calc(var(--app-nav-height) + 1rem) 1rem 6rem 1rem;
flex-direction: column;
padding-left: 1rem;
padding-right: 1rem;
.entry-group {
@@ -285,4 +361,45 @@ 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>
+4 -6
View File
@@ -1,12 +1,13 @@
<template>
<div class="product-tab">
<t-navbar fixed :z-index="20" title="产品" />
<main class="page-content scroll column product-tab">
<t-cell-group
v-for="(group, index) in visibleMenuGroupList"
:key="group.title"
class="menu-group"
:title="group.title"
theme="card"
v-entrance-transition="{ step: 30 }"
v-entrance-transition
>
<t-cell
v-for="item in group.items"
@@ -23,7 +24,7 @@
</t-cell>
</t-cell-group>
<div v-if="!visibleMenuGroupList.length" class="empty" v-text="'当前账号暂无产品管理权限'" />
</div>
</main>
</template>
<script setup lang="ts">
@@ -177,8 +178,5 @@ async function go(path: string): Promise<void> {
<style scoped lang="less">
.product-tab {
gap: .5rem;
display: flex;
padding: calc(var(--app-nav-height)) 0 6rem;
flex-direction: column;
}
</style>
+3 -5
View File
@@ -1,5 +1,6 @@
<template>
<div class="management-tab">
<t-navbar fixed :z-index="20" title="管理" />
<main class="page-content scroll column management-tab">
<t-cell-group class="user-card" theme="card" v-entrance-transition>
<t-cell
v-if="currentUser"
@@ -63,7 +64,7 @@
<p>技术支持:夜雨</p>
<p>Copyright © 2026 imyeyu.com</p>
</footer>
</div>
</main>
</template>
<script lang="ts">
@@ -323,9 +324,6 @@ onBeforeRouteLeave(() => {
<style scoped lang="less">
.management-tab {
gap: .5rem;
display: flex;
padding: calc(var(--app-nav-height) + 1rem) 0 5rem 0;
flex-direction: column;
.user-card {
+168 -62
View File
@@ -1,54 +1,95 @@
<template>
<div class="store-tab">
<section v-entrance-transition v-if="canViewStore || canManageStore" class="store-header">
<t-cell-group class="store-card" theme="card">
<t-cell
v-if="canViewStore"
class="info"
:title="currentStoreStore.currentStoreName"
:description="currentStore?.address"
<t-navbar fixed :z-index="20" title="门店">
<template #right>
<div
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"
/>
<t-cell
v-if="canSelectStore"
class="action"
title="切换门店"
note="选择使用门店"
arrow
hover
@click="openStorePicker"
>
<template #leftIcon>
<t-icon name="swap" />
</template>
</t-cell>
<t-cell
v-if="canManageStore"
class="action"
title="门店管理"
note="管理门店资料和营业日"
arrow
hover
@click="goStoreManagement"
>
<template #leftIcon>
<t-icon name="shop-3" />
</template>
</t-cell>
<t-cell
v-if="canManageStoreDiary"
class="action"
title="门店日记"
note="记录门店经营日常"
arrow
hover
@click="goStoreDiaryManagement"
>
<template #leftIcon>
<t-icon name="file" />
</template>
</t-cell>
</t-cell-group>
</section>
</div>
</template>
</t-navbar>
<main class="page-content scroll column store-tab">
<t-cell-group
v-if="canViewStore || canManageStore"
theme="card"
v-entrance-transition
>
<t-cell
v-if="canViewStore"
class="info"
:title="currentStoreStore.currentStoreName"
:description="currentStore?.address"
/>
<t-cell
v-if="canSelectStore"
class="action"
title="切换门店"
note="选择使用门店"
arrow
hover
@click="openStorePicker"
>
<template #leftIcon>
<t-icon name="swap" />
</template>
</t-cell>
<t-cell
v-if="canManageStore"
class="action"
title="门店管理"
note="管理门店资料和营业日"
arrow
hover
@click="goStoreManagement"
>
<template #leftIcon>
<t-icon name="shop-3" />
</template>
</t-cell>
<t-cell
v-if="canManageStoreDiary"
class="action"
title="门店日记"
note="记录门店经营日常"
arrow
hover
@click="goStoreDiaryManagement"
>
<template #leftIcon>
<t-icon name="file" />
</template>
</t-cell>
</t-cell-group>
<store-data-charts :key="`${currentStoreStore.currentStoreId}-${chartRefreshKey}`" />
<t-popup v-model="storePickerVisible" placement="bottom">
<t-picker
@@ -59,20 +100,51 @@
@confirm="confirmStorePicker"
/>
</t-popup>
</div>
</main>
</template>
<script setup lang="ts">
import { Message } from "@/utils/message";
import { useUserStore } from "timi-web-api";
import { useCurrentStoreStore } from "@/store/currentStoreStore";
import { useNavBarStore } from "@/store/navBarStore";
import { gaoRoleCodes, gaoStoreScopePermissionCodes, permissionCodes } from "@/utils/permission";
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";
type PickerValue = string | number;
const StoreDataCharts = defineAsyncComponent(() => import("@/pages/store/StoreDataCharts.vue"));
const StoreDataCharts = defineAsyncComponent(() => import("@/pages/store/component/StoreDataCharts.vue"));
defineOptions({
name: "StoreTab"
@@ -81,7 +153,6 @@ defineOptions({
const router = useRouter();
const userStore = useUserStore();
const currentStoreStore = useCurrentStoreStore();
const navBarStore = useNavBarStore();
const chartRefreshKey = ref(0);
const currentStore = computed(() => currentStoreStore.currentStore);
@@ -168,7 +239,7 @@ async function goStoreDiaryManagement(): Promise<void> {
}
onMounted(async () => {
navBarStore.setRightIcon("refresh", refreshCharts);
setPageNavBarRightIcon("refresh", refreshCharts);
if (canSelectStore.value) {
await currentStoreStore.loadStoreList();
} else if (canLoadLoginStore.value) {
@@ -177,14 +248,12 @@ onMounted(async () => {
});
onUnmounted(() => {
navBarStore.clearRight();
clearPageNavBarRight();
});
</script>
<style scoped lang="less">
.store-tab {
padding: calc(var(--app-nav-height) + 1rem) 0 6rem 0;
.store-header {
.store-card {
@@ -196,10 +265,6 @@ onUnmounted(() => {
}
}
}
:deep(.data-charts-page) {
padding-top: 1rem;
}
}
:global(html.theme-dark) {
@@ -213,4 +278,45 @@ 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>
+174 -55
View File
@@ -1,78 +1,156 @@
<template>
<div v-can="corePermissionCodes.tag.read" class="tag-list">
<div class="filters glass">
<t-input
v-model.trim="keyword"
class="search"
type="search"
borderless
placeholder="搜索标签"
/>
</div>
<t-pull-down-refresh
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
<div class="page-layout navbar tag-list">
<t-navbar
fixed
:z-index="20"
title="标签管理"
left-arrow
@left-click="$router.back()"
>
<div class="tag-panel">
<template #right>
<div
v-entrance-transition="{ step: 30 }"
class="item bg-white"
v-for="item in tagList"
:key="item.id"
@click="openEditDialog(item)"
v-if="pageNavBarRight.icon || pageNavBarRight.text"
class="nav-right-slot"
>
<span class="name" v-text="getTagName(item)" />
<button
v-if="canDeleteTag"
type="button"
class="close"
@click="confirmRemoveTag(item, $event)"
<t-badge
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined"
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<t-icon name="close" size="1rem" />
<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>
</t-navbar>
<main v-can="corePermissionCodes.tag.read" class="page-content scroll list">
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
>
<div class="filters glass">
<t-input
v-model.trim="keyword"
class="search"
type="search"
borderless
placeholder="搜索标签"
/>
</div>
<div class="tag-panel">
<div
v-entrance-transition="{ step: 30 }"
class="item bg-white"
v-for="item in tagList"
:key="item.id"
@click="openEditDialog(item)"
>
<span class="name" v-text="getTagName(item)" />
<button
v-if="canDeleteTag"
type="button"
class="close"
@click="confirmRemoveTag(item, $event)"
>
<t-icon name="close" size="1rem" />
</button>
</div>
</div>
<div v-if="!tagList.length" class="empty" v-text="emptyText" />
<div v-if="tagList.length" class="center-tips" v-text="isLoading ? '正在加载更多' : isNoMore ? '已经到底了' : '上拉加载更多'" />
</t-pull-down-refresh>
</main>
<t-dialog
v-model:visible="editDialogVisible"
:title="isCreateMode ? '新增标签' : '编辑标签'"
cancel-btn="取消"
confirm-btn="保存"
@cancel="closeEditDialog"
@confirm="saveTag"
>
<div class="edit-dialog">
<t-input
v-model.trim="formModel.name"
class="name-input"
borderless
clearable
placeholder="标签名称"
/>
</div>
<div v-if="!tagList.length" class="empty" v-text="emptyText" />
<div v-if="tagList.length" class="center-tips" v-text="isLoading ? '正在加载更多' : isNoMore ? '已经到底了' : '上拉加载更多'" />
</t-pull-down-refresh>
</t-dialog>
</div>
<t-dialog
v-model:visible="editDialogVisible"
:title="isCreateMode ? '新增标签' : '编辑标签'"
cancel-btn="取消"
confirm-btn="保存"
@cancel="closeEditDialog"
@confirm="saveTag"
>
<div class="edit-dialog">
<t-input
v-model.trim="formModel.name"
class="name-input"
borderless
clearable
placeholder="标签名称"
/>
</div>
</t-dialog>
</template>
<script setup lang="ts">
import { DialogPlugin } from "tdesign-mobile-vue";
import { type Page, useUserStore } from "timi-web-api";
import TagAPI from "@/api/TagAPI";
import { useNavBarStore } from "@/store/navBarStore";
import type { Tag } from "@/types/Tag";
import { corePermissionCodes } 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 { Tag } from "@/types/Tag";
defineOptions({
name: "TagList"
});
const userStore = useUserStore();
const navBarStore = useNavBarStore();
const pageSize = 100;
const keyword = ref("");
@@ -250,9 +328,9 @@ async function removeTag(id: string): Promise<void> {
}
onMounted(async () => {
navBarStore.clearRight();
clearPageNavBarRight();
if (userStore.hasPermissions(corePermissionCodes.tag.create)) {
navBarStore.setRightText("新增", "var(--td-brand-color)", openCreateDialog);
setPageNavBarRightText("新增", "var(--td-brand-color)", openCreateDialog);
}
await reload();
});
@@ -265,7 +343,7 @@ watch(keyword, () => {
});
onUnmounted(() => {
navBarStore.clearRight();
clearPageNavBarRight();
window.clearTimeout(keywordTimer);
});
</script>
@@ -358,4 +436,45 @@ 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>

Some files were not shown because too many files have changed in this diff Show More