refactor layout
This commit is contained in:
@@ -38,6 +38,103 @@ html.theme-dark body {
|
|||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.page-layout,
|
||||||
|
.main-layout {
|
||||||
|
color: var(--td-text-color-primary);
|
||||||
|
background: var(--td-bg-color-page);
|
||||||
|
min-height: 100vh;
|
||||||
|
box-sizing: border-box;
|
||||||
|
|
||||||
|
.page-content {
|
||||||
|
flex: 1;
|
||||||
|
inset: 0;
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
overflow: hidden;
|
||||||
|
position: absolute;
|
||||||
|
min-height: 0;
|
||||||
|
padding-top: calc(env(safe-area-inset-top, 0px) + 48px + 1rem);
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem);
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
&.scroll {
|
||||||
|
overflow: auto;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.column {
|
||||||
|
gap: .5rem;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pull-refresh {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
overflow-x: hidden;
|
||||||
|
overflow-y: auto;
|
||||||
|
padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem);
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
|
||||||
|
.t-pull-down-refresh__track {
|
||||||
|
height: auto;
|
||||||
|
min-height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filters {
|
||||||
|
--td-search-bg-color: var(--tui-white);
|
||||||
|
--td-search-square-radius: 1rem;
|
||||||
|
|
||||||
|
top: -1rem;
|
||||||
|
margin: -1rem 0 1rem 0;
|
||||||
|
padding: 1rem 1rem 0 1rem;
|
||||||
|
z-index: 2;
|
||||||
|
position: sticky;
|
||||||
|
|
||||||
|
[class*="__input-box"] {
|
||||||
|
border-color: var(--td-component-border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tabs {
|
||||||
|
--td-tab-item-height: 32px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.navbar {
|
||||||
|
--app-nav-height: calc(env(safe-area-inset-top, 0px) + 48px);
|
||||||
|
|
||||||
|
.t-navbar__content {
|
||||||
|
color: var(--tui-black, #000);
|
||||||
|
overflow: visible;
|
||||||
|
box-shadow: 0 3px 8px rgba(0, 0, 0, .1);
|
||||||
|
background: rgba(250, 250, 250, .8);
|
||||||
|
backdrop-filter: blur(10px);
|
||||||
|
-webkit-backdrop-filter: blur(10px);
|
||||||
|
}
|
||||||
|
|
||||||
|
&.tabbar {
|
||||||
|
|
||||||
|
.page-content.scroll,
|
||||||
|
.page-content.column {
|
||||||
|
padding-bottom: 5rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-content.scroll.list {
|
||||||
|
padding-top: 0;
|
||||||
|
padding-bottom: 0;
|
||||||
|
|
||||||
|
.pull-refresh {
|
||||||
|
padding-top: calc(48px + 1rem);
|
||||||
|
padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.loading {
|
.loading {
|
||||||
margin: 1rem auto;
|
margin: 1rem auto;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,117 +0,0 @@
|
|||||||
<template>
|
|
||||||
<teleport v-if="navBarStore.customRightVisible && visibleActionList.length" to="#app-nav-right">
|
|
||||||
<div class="nav-actions">
|
|
||||||
<t-popover
|
|
||||||
v-model:visible="actionVisible"
|
|
||||||
placement="bottom-right"
|
|
||||||
:show-arrow="false"
|
|
||||||
theme="light"
|
|
||||||
>
|
|
||||||
<t-button
|
|
||||||
class="trigger"
|
|
||||||
variant="text"
|
|
||||||
:aria-label="triggerLabel"
|
|
||||||
type="button"
|
|
||||||
>
|
|
||||||
<template #icon>
|
|
||||||
<t-icon :name="triggerIcon" />
|
|
||||||
</template>
|
|
||||||
<span v-if="triggerText" v-text="triggerText" />
|
|
||||||
</t-button>
|
|
||||||
<template #content>
|
|
||||||
<div class="menu">
|
|
||||||
<t-button
|
|
||||||
v-for="action in visibleActionList"
|
|
||||||
:key="action.key"
|
|
||||||
class="menu-item"
|
|
||||||
variant="text"
|
|
||||||
type="button"
|
|
||||||
:theme="action.theme"
|
|
||||||
:loading="action.loading"
|
|
||||||
:disabled="action.disabled || action.loading"
|
|
||||||
@click="handleAction(action)"
|
|
||||||
>
|
|
||||||
<template v-if="action.icon" #icon>
|
|
||||||
<t-icon :name="action.icon" />
|
|
||||||
</template>
|
|
||||||
<span v-text="action.text" />
|
|
||||||
</t-button>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</t-popover>
|
|
||||||
</div>
|
|
||||||
</teleport>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
import type { NavBarAction } from "@/types/NavBarAction";
|
|
||||||
|
|
||||||
defineOptions({
|
|
||||||
name: "NavBarActionMenu"
|
|
||||||
});
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
actions: readonly NavBarAction[];
|
|
||||||
triggerIcon?: string;
|
|
||||||
triggerLabel?: string;
|
|
||||||
triggerText?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const props = withDefaults(defineProps<Props>(), {
|
|
||||||
triggerIcon: "ellipsis",
|
|
||||||
triggerLabel: "更多操作",
|
|
||||||
triggerText: ""
|
|
||||||
});
|
|
||||||
|
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const actionVisible = ref(false);
|
|
||||||
const visibleActionList = computed(() => props.actions.filter(action => action.visible !== false));
|
|
||||||
|
|
||||||
async function handleAction(action: NavBarAction): Promise<void> {
|
|
||||||
actionVisible.value = false;
|
|
||||||
await action.action();
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped lang="less">
|
|
||||||
.nav-actions {
|
|
||||||
--td-popover-padding: 0 .5rem;
|
|
||||||
|
|
||||||
: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,152 +0,0 @@
|
|||||||
<template>
|
|
||||||
<t-navbar
|
|
||||||
ref="navBarRef"
|
|
||||||
class="nav-bar"
|
|
||||||
:left-arrow="!!navBarStore.canBack"
|
|
||||||
:z-index="20"
|
|
||||||
@left-click="emit('back')"
|
|
||||||
>
|
|
||||||
<template #title>
|
|
||||||
<div id="app-nav-title" class="slot">
|
|
||||||
<span v-if="!navBarStore.customTitleVisible" class="nav-title-text" v-text="navBarStore.title" />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<template v-if="navBarStore.customRightVisible || navBarStore.rightIcon || navBarStore.rightText" #right>
|
|
||||||
<div class="nav-right-slot">
|
|
||||||
<div v-if="navBarStore.customRightVisible" id="app-nav-right" />
|
|
||||||
<t-badge
|
|
||||||
v-else-if="navBarStore.rightIcon && navBarStore.rightBadge !== undefined"
|
|
||||||
class="badge"
|
|
||||||
:count="navBarStore.rightBadge"
|
|
||||||
:max-count="99"
|
|
||||||
:show-zero="false"
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
class="button"
|
|
||||||
type="button"
|
|
||||||
:disabled="navBarStore.rightDisabled"
|
|
||||||
@click="emit('rightAction')"
|
|
||||||
>
|
|
||||||
<t-icon :name="navBarStore.rightIcon" size="1.25rem" />
|
|
||||||
</button>
|
|
||||||
</t-badge>
|
|
||||||
<button
|
|
||||||
v-else-if="navBarStore.rightIcon"
|
|
||||||
class="button"
|
|
||||||
type="button"
|
|
||||||
:disabled="navBarStore.rightDisabled"
|
|
||||||
@click="emit('rightAction')"
|
|
||||||
>
|
|
||||||
<t-icon :name="navBarStore.rightIcon" size="1.25rem" />
|
|
||||||
</button>
|
|
||||||
<span
|
|
||||||
v-else
|
|
||||||
v-text="navBarStore.rightText"
|
|
||||||
class="nav-text"
|
|
||||||
:style="{ color: navBarStore.rightDisabled ? 'var(--td-text-color-disabled)' : navBarStore.rightTextColor ? navBarStore.rightTextColor : 'var(--td-text-color-primary, #333)' }"
|
|
||||||
:class="{ clickable: !!navBarStore.rightAction && !navBarStore.rightDisabled, disabled: navBarStore.rightDisabled }"
|
|
||||||
@click="emit('rightAction')"
|
|
||||||
></span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</t-navbar>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
|
|
||||||
type TNavBarRef = { $el?: HTMLElement };
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
|
||||||
back: [];
|
|
||||||
rightAction: [];
|
|
||||||
}>();
|
|
||||||
|
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const navBarRef = ref<TNavBarRef>();
|
|
||||||
|
|
||||||
function getElement(): HTMLElement | undefined {
|
|
||||||
return navBarRef.value?.$el?.querySelector(".t-navbar__content") || undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
defineExpose({
|
|
||||||
getElement
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped lang="less">
|
|
||||||
.nav-bar {
|
|
||||||
|
|
||||||
:deep(.t-navbar__content) {
|
|
||||||
color: var(--tui-black, #000);
|
|
||||||
overflow: visible;
|
|
||||||
box-shadow: 0 3px 8px rgba(0, 0, 0, .1);
|
|
||||||
background: rgba(250, 250, 250, .8);
|
|
||||||
backdrop-filter: blur(10px);
|
|
||||||
-webkit-backdrop-filter: blur(10px);
|
|
||||||
}
|
|
||||||
|
|
||||||
.badge {
|
|
||||||
|
|
||||||
:deep(.t-badge__content) {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.button {
|
|
||||||
padding: 0;
|
|
||||||
border: none;
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
color: var(--td-text-color-primary, #333);
|
|
||||||
background: transparent;
|
|
||||||
|
|
||||||
&:disabled {
|
|
||||||
color: var(--td-text-color-disabled);
|
|
||||||
cursor: not-allowed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.slot {
|
|
||||||
min-width: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-title-text {
|
|
||||||
overflow: hidden;
|
|
||||||
display: block;
|
|
||||||
white-space: nowrap;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-right-slot {
|
|
||||||
width: 6rem;
|
|
||||||
height: 100%;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: flex-end;
|
|
||||||
|
|
||||||
:deep(.t-badge) {
|
|
||||||
display: inline-flex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-text {
|
|
||||||
cursor: default;
|
|
||||||
|
|
||||||
&.clickable {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.disabled {
|
|
||||||
cursor: not-allowed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.t-navbar__right),
|
|
||||||
:deep(.t-navbar__right-content) {
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,209 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div ref="navBarRef" class="ios26-nav-bar">
|
|
||||||
<div class="left">
|
|
||||||
<button
|
|
||||||
v-if="navBarStore.canBack"
|
|
||||||
class="pill back"
|
|
||||||
type="button"
|
|
||||||
@click="emit('back')"
|
|
||||||
>
|
|
||||||
<t-icon name="chevron-left" size="1.35rem" />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div id="title" class="pill title">
|
|
||||||
<span
|
|
||||||
v-if="!navBarStore.customTitleVisible"
|
|
||||||
class="text"
|
|
||||||
v-text="navBarStore.title"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="right">
|
|
||||||
<div
|
|
||||||
v-if="navBarStore.customRightVisible || navBarStore.rightIcon || navBarStore.rightText"
|
|
||||||
class="pill slot"
|
|
||||||
>
|
|
||||||
<div v-if="navBarStore.customRightVisible" id="app-nav-right" />
|
|
||||||
<t-badge
|
|
||||||
v-else-if="navBarStore.rightIcon && navBarStore.rightBadge !== undefined"
|
|
||||||
class="badge"
|
|
||||||
:count="navBarStore.rightBadge"
|
|
||||||
:max-count="99"
|
|
||||||
:show-zero="false"
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
class="button"
|
|
||||||
type="button"
|
|
||||||
:disabled="navBarStore.rightDisabled"
|
|
||||||
@click="emit('rightAction')"
|
|
||||||
>
|
|
||||||
<t-icon :name="navBarStore.rightIcon" size="1.25rem" />
|
|
||||||
</button>
|
|
||||||
</t-badge>
|
|
||||||
<button
|
|
||||||
v-else-if="navBarStore.rightIcon"
|
|
||||||
class="button"
|
|
||||||
type="button"
|
|
||||||
:disabled="navBarStore.rightDisabled"
|
|
||||||
@click="emit('rightAction')"
|
|
||||||
>
|
|
||||||
<t-icon :name="navBarStore.rightIcon" size="1.25rem" />
|
|
||||||
</button>
|
|
||||||
<span
|
|
||||||
v-else
|
|
||||||
v-text="navBarStore.rightText"
|
|
||||||
class="text"
|
|
||||||
:style="{ color: navBarStore.rightDisabled ? 'var(--td-text-color-disabled)' : navBarStore.rightTextColor ? navBarStore.rightTextColor : 'var(--td-text-color-primary, #333)' }"
|
|
||||||
:class="{ clickable: !!navBarStore.rightAction && !navBarStore.rightDisabled, disabled: navBarStore.rightDisabled }"
|
|
||||||
@click="emit('rightAction')"
|
|
||||||
></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
|
||||||
back: [];
|
|
||||||
rightAction: [];
|
|
||||||
}>();
|
|
||||||
|
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const navBarRef = ref<HTMLElement>();
|
|
||||||
|
|
||||||
function getElement(): HTMLElement | undefined {
|
|
||||||
return navBarRef.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
defineExpose({
|
|
||||||
getElement
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped lang="less">
|
|
||||||
.ios26-nav-bar {
|
|
||||||
top: calc(env(safe-area-inset-top, 0px) + 2rem);
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
z-index: 20;
|
|
||||||
height: 2.5rem;
|
|
||||||
padding: 0 .75rem;
|
|
||||||
position: fixed;
|
|
||||||
|
|
||||||
.pill {
|
|
||||||
height: 2.5rem;
|
|
||||||
display: flex;
|
|
||||||
min-width: 0;
|
|
||||||
align-items: center;
|
|
||||||
border-radius: 999px;
|
|
||||||
background: rgba(250, 250, 250, .72);
|
|
||||||
box-shadow: 0 .25rem .875rem rgba(0, 0, 0, .1);
|
|
||||||
backdrop-filter: blur(18px) saturate(180%);
|
|
||||||
-webkit-backdrop-filter: blur(18px) saturate(180%);
|
|
||||||
}
|
|
||||||
|
|
||||||
.left,
|
|
||||||
.right,
|
|
||||||
#title {
|
|
||||||
top: 0;
|
|
||||||
position: absolute;
|
|
||||||
}
|
|
||||||
|
|
||||||
.left {
|
|
||||||
left: .75rem;
|
|
||||||
|
|
||||||
.back {
|
|
||||||
width: 2.5rem;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.title {
|
|
||||||
left: 50%;
|
|
||||||
padding: 0 1rem;
|
|
||||||
min-width: 8rem;
|
|
||||||
max-width: calc(100vw - 4rem);
|
|
||||||
transform: translateX(-50%);
|
|
||||||
justify-content: center;
|
|
||||||
|
|
||||||
.text {
|
|
||||||
overflow: hidden;
|
|
||||||
color: var(--td-text-color-primary, #333);
|
|
||||||
display: block;
|
|
||||||
font-size: 1rem;
|
|
||||||
font-weight: 600;
|
|
||||||
white-space: nowrap;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.right {
|
|
||||||
right: .75rem;
|
|
||||||
display: flex;
|
|
||||||
justify-content: flex-end;
|
|
||||||
|
|
||||||
.button {
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.slot {
|
|
||||||
gap: .5rem;
|
|
||||||
max-width: 8rem;
|
|
||||||
padding: 0 .75rem;
|
|
||||||
justify-content: flex-end;
|
|
||||||
|
|
||||||
:deep(.t-badge) {
|
|
||||||
display: inline-flex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.badge {
|
|
||||||
|
|
||||||
:deep(.t-badge__content) {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.text {
|
|
||||||
overflow: hidden;
|
|
||||||
cursor: default;
|
|
||||||
white-space: nowrap;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
|
|
||||||
&.clickable {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.disabled {
|
|
||||||
cursor: not-allowed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.back,
|
|
||||||
.right .button {
|
|
||||||
padding: 0;
|
|
||||||
border: none;
|
|
||||||
color: var(--td-text-color-primary, #333);
|
|
||||||
background: rgba(250, 250, 250, .72);
|
|
||||||
|
|
||||||
&:disabled {
|
|
||||||
color: var(--td-text-color-disabled);
|
|
||||||
cursor: not-allowed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) {
|
|
||||||
|
|
||||||
.pill,
|
|
||||||
.back,
|
|
||||||
.button {
|
|
||||||
background: rgba(36, 36, 36, .72);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,161 +0,0 @@
|
|||||||
<template>
|
|
||||||
<ios26-nav-bar
|
|
||||||
v-if="navBarStore.isShowing && isIos26Standalone"
|
|
||||||
ref="navBarRef"
|
|
||||||
@back="doBack"
|
|
||||||
@right-action="doRightAction"
|
|
||||||
/>
|
|
||||||
<default-nav-bar
|
|
||||||
v-else-if="navBarStore.isShowing"
|
|
||||||
ref="navBarRef"
|
|
||||||
@back="doBack"
|
|
||||||
@right-action="doRightAction"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import DefaultNavBar from "@/components/navbar/DefaultNavBar.vue";
|
|
||||||
import Ios26NavBar from "@/components/navbar/iOS26NavBar.vue";
|
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
|
|
||||||
type NavBarExpose = {
|
|
||||||
getElement: () => HTMLElement | undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
|
||||||
heightChange: [value: string];
|
|
||||||
}>();
|
|
||||||
|
|
||||||
const router = useRouter();
|
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
|
|
||||||
// ---------- 导航高度 ----------
|
|
||||||
|
|
||||||
const navBarRef = ref<NavBarExpose>();
|
|
||||||
const isIos26Standalone = ref(false);
|
|
||||||
let navBarResizeObs: ResizeObserver | undefined;
|
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
isIos26Standalone.value = isIos26StandaloneMode();
|
|
||||||
await syncNavBarHeight();
|
|
||||||
});
|
|
||||||
|
|
||||||
watch(() => navBarStore.isShowing, async () => {
|
|
||||||
await syncNavBarHeight();
|
|
||||||
}, { flush: "post" });
|
|
||||||
|
|
||||||
onUnmounted(() => {
|
|
||||||
if (navBarResizeObs) {
|
|
||||||
navBarResizeObs.disconnect();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
async function syncNavBarHeight(): Promise<void> {
|
|
||||||
if (navBarResizeObs) {
|
|
||||||
navBarResizeObs.disconnect();
|
|
||||||
navBarResizeObs = undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
emitLayoutHeight();
|
|
||||||
await nextTick();
|
|
||||||
|
|
||||||
const navBarElement = navBarRef.value?.getElement();
|
|
||||||
if (!navBarElement) {
|
|
||||||
navBarStore.setHeight(0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
navBarResizeObs = new ResizeObserver((entries) => {
|
|
||||||
for (const entry of entries) {
|
|
||||||
navBarStore.setHeight(entry.contentRect.height);
|
|
||||||
emitLayoutHeight();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
navBarResizeObs.observe(navBarElement);
|
|
||||||
navBarStore.setHeight(navBarElement.getBoundingClientRect().height);
|
|
||||||
emitLayoutHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
function emitLayoutHeight(): void {
|
|
||||||
if (!navBarStore.isShowing) {
|
|
||||||
emit("heightChange", "0px");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (isIos26Standalone.value) {
|
|
||||||
emit("heightChange", "calc(env(safe-area-inset-top, 0px) + 5.25rem)");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
emit("heightChange", "48px");
|
|
||||||
}
|
|
||||||
|
|
||||||
function isIos26StandaloneMode(): boolean {
|
|
||||||
const nav = window.navigator as Navigator & { standalone?: boolean };
|
|
||||||
const isStandalone = nav.standalone === true || window.matchMedia("(display-mode: standalone)").matches;
|
|
||||||
if (!isStandalone) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 26 <= getIosEffectiveMajorVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* iOS 26 standalone 的 UA 可能仍带 iPhone OS 18_x,但 Version 主版本会暴露新 WebApp 行为。
|
|
||||||
*/
|
|
||||||
function getIosEffectiveMajorVersion(): number {
|
|
||||||
const nav = window.navigator;
|
|
||||||
const userAgent = nav.userAgent;
|
|
||||||
const isIosLike = /iP(hone|od|ad)/.test(userAgent) || (nav.platform === "MacIntel" && 1 < nav.maxTouchPoints);
|
|
||||||
if (!isIosLike) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const osMajor = getUserAgentMajorVersion(userAgent, /OS (\d+)[._]/);
|
|
||||||
const versionMajor = getUserAgentMajorVersion(userAgent, /Version\/(\d+)[._]/);
|
|
||||||
return Math.max(osMajor, versionMajor);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getUserAgentMajorVersion(userAgent: string, pattern: RegExp): number {
|
|
||||||
const match = userAgent.match(pattern);
|
|
||||||
if (!match) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Number(match[1]) || 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------- 导航返回 ----------
|
|
||||||
|
|
||||||
let isBacking = false;
|
|
||||||
|
|
||||||
async function doBack(): Promise<void> {
|
|
||||||
if (isBacking) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
isBacking = true;
|
|
||||||
const backTo = navBarStore.backTo;
|
|
||||||
navBarStore.setBackTo(undefined);
|
|
||||||
navBarStore.clearRight();
|
|
||||||
try {
|
|
||||||
if (backTo) {
|
|
||||||
await router.push(backTo);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await router.back();
|
|
||||||
} finally {
|
|
||||||
isBacking = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------- 右侧操作 ----------
|
|
||||||
|
|
||||||
async function doRightAction(): Promise<void> {
|
|
||||||
if (navBarStore.rightDisabled || !navBarStore.rightAction) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await navBarStore.rightAction();
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
+14
-27
@@ -1,11 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="main-layout">
|
<div class="main-layout diselect">
|
||||||
<app-nav-bar @height-change="onChangeNavBarHeight" />
|
<div class="content">
|
||||||
<div class="router-view">
|
|
||||||
<page-transition
|
<page-transition
|
||||||
:keep-alive="shouldKeepAlive"
|
:keep-alive="shouldKeepAlive"
|
||||||
:page-background="globalUIStore.bodyBackground"
|
:page-background="globalUIStore.bodyBackground"
|
||||||
page-class="page"
|
:page-class="pageClass"
|
||||||
:respect-reduced-motion="false"
|
:respect-reduced-motion="false"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -37,7 +36,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import AppNavBar from "@/components/navbar/index.vue";
|
|
||||||
import { useGlobalUIStore } from "@/store/globalUI";
|
import { useGlobalUIStore } from "@/store/globalUI";
|
||||||
import { useTabBarStore } from "@/store/tabBarStore";
|
import { useTabBarStore } from "@/store/tabBarStore";
|
||||||
import { permissionCodes } from "@/utils/permission";
|
import { permissionCodes } from "@/utils/permission";
|
||||||
@@ -57,14 +55,6 @@ function shouldKeepAlive(sourceRoute: RouteLocationNormalizedLoaded): boolean {
|
|||||||
return cachedRouteNames.has(String(sourceRoute.name));
|
return cachedRouteNames.has(String(sourceRoute.name));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------- 导航边距 ----------
|
|
||||||
|
|
||||||
const navBarHeight = ref("0px");
|
|
||||||
|
|
||||||
function onChangeNavBarHeight(value: string): void {
|
|
||||||
navBarHeight.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------- Tab 切换 ----------
|
// ---------- Tab 切换 ----------
|
||||||
|
|
||||||
type TabItem = {
|
type TabItem = {
|
||||||
@@ -174,24 +164,21 @@ const isTabBarPaddingNeeded = computed(() => {
|
|||||||
return route.meta.tabBarPadding !== false;
|
return route.meta.tabBarPadding !== false;
|
||||||
});
|
});
|
||||||
|
|
||||||
const tabBarHeight = computed(() => {
|
const pageClass = computed(() => ({
|
||||||
if (isTabBarPaddingNeeded.value) {
|
"page-layout": true,
|
||||||
return "6rem";
|
navbar: true,
|
||||||
}
|
tabbar: isTabBarPaddingNeeded.value
|
||||||
|
}));
|
||||||
|
|
||||||
return "0rem";
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
.main-layout {
|
.main-layout {
|
||||||
--app-nav-height: v-bind(navBarHeight);
|
height: 100vh;
|
||||||
--app-tab-height: v-bind(tabBarHeight);
|
overflow: hidden;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
height: 100%;
|
.content {
|
||||||
transition: padding-bottom .24s ease;
|
|
||||||
|
|
||||||
.router-view {
|
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,9 +189,9 @@ const tabBarHeight = computed(() => {
|
|||||||
bottom: 1rem;
|
bottom: 1rem;
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
transform: translateY(0);
|
transform: translateY(0);
|
||||||
backdrop-filter: blur(10px);
|
|
||||||
pointer-events: auto;
|
|
||||||
transition: opacity 520ms, transform 520ms var(--tui-bezier);
|
transition: opacity 520ms, transform 520ms var(--tui-bezier);
|
||||||
|
pointer-events: auto;
|
||||||
|
backdrop-filter: blur(10px);
|
||||||
|
|
||||||
&.is-hidden {
|
&.is-hidden {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="root-layout diselect">
|
|
||||||
<router-view />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
defineOptions({
|
|
||||||
name: "RootLayout"
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="less" scoped>
|
|
||||||
.root-layout {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
position: relative;
|
|
||||||
min-height: 100vh;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,6 +1,26 @@
|
|||||||
<template>
|
<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">
|
<div v-if="canUseAi" class="ai-chat-page">
|
||||||
<ai-chat-panel
|
<ai-chat-panel
|
||||||
|
ref="aiChatPanel"
|
||||||
:store-name="currentStoreStore.currentStoreName"
|
:store-name="currentStoreStore.currentStoreName"
|
||||||
:session-key="sessionKey"
|
:session-key="sessionKey"
|
||||||
:store-id="aiStoreId"
|
:store-id="aiStoreId"
|
||||||
@@ -26,6 +46,11 @@ const sessionKey = computed(() => `${userStore.loginUser.user?.id || userStore.l
|
|||||||
const canUseAi = computed(() => userStore.hasRoles(gaoRoleCodes.storeManager));
|
const canUseAi = computed(() => userStore.hasRoles(gaoRoleCodes.storeManager));
|
||||||
const isGlobalManager = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
|
const isGlobalManager = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
|
||||||
const aiStoreId = computed(() => canUseAi.value && isGlobalManager.value ? currentStoreStore.currentStoreId : undefined);
|
const aiStoreId = computed(() => canUseAi.value && isGlobalManager.value ? currentStoreStore.currentStoreId : undefined);
|
||||||
|
type AiChatPanelExpose = {
|
||||||
|
isBusy: boolean;
|
||||||
|
openConversationList: () => void;
|
||||||
|
};
|
||||||
|
const aiChatPanelRef = useTemplateRef<AiChatPanelExpose>("aiChatPanel");
|
||||||
|
|
||||||
function startNewConversation(): void {
|
function startNewConversation(): void {
|
||||||
conversationResetToken.value += 1;
|
conversationResetToken.value += 1;
|
||||||
@@ -33,6 +58,18 @@ function startNewConversation(): void {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<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 {
|
.ai-chat-page {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|||||||
@@ -88,11 +88,11 @@ import {
|
|||||||
} from "@/api/GaoAiAPI";
|
} from "@/api/GaoAiAPI";
|
||||||
import AiConversationList from "@/pages/ai/components/AiConversationList.vue";
|
import AiConversationList from "@/pages/ai/components/AiConversationList.vue";
|
||||||
import { aiQuickQuestionList, loadAiQuickQuestions, refreshAiQuickQuestions } from "@/pages/ai/aiChatQuestions";
|
import { aiQuickQuestionList, loadAiQuickQuestions, refreshAiQuickQuestions } from "@/pages/ai/aiChatQuestions";
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
import { getErrorMessage } from "@/utils/error";
|
|
||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { useUserStore } from "timi-web-api/store";
|
import { useUserStore } from "timi-web-api/store";
|
||||||
|
|
||||||
|
import { getErrorMessage } from "@/utils/error";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "AiChatPanel"
|
name: "AiChatPanel"
|
||||||
});
|
});
|
||||||
@@ -108,7 +108,6 @@ const emit = defineEmits<{
|
|||||||
"new-conversation": [];
|
"new-conversation": [];
|
||||||
}>();
|
}>();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
type MessageListExpose = {
|
type MessageListExpose = {
|
||||||
scrollToBottom: () => Promise<void>;
|
scrollToBottom: () => Promise<void>;
|
||||||
};
|
};
|
||||||
@@ -174,6 +173,11 @@ function openConversationList(): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
isBusy,
|
||||||
|
openConversationList
|
||||||
|
});
|
||||||
|
|
||||||
async function selectConversation(conversation: GaoAiConversation): Promise<void> {
|
async function selectConversation(conversation: GaoAiConversation): Promise<void> {
|
||||||
if (isBusy.value || !conversation.id) {
|
if (isBusy.value || !conversation.id) {
|
||||||
return;
|
return;
|
||||||
@@ -330,14 +334,9 @@ function isFailedConversationMessage(message: GaoAiConversationMessage): boolean
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navBarStore.clearRight();
|
|
||||||
navBarStore.setRightText("历史", "var(--td-brand-color)", openConversationList);
|
|
||||||
await loadAiQuickQuestions();
|
await loadAiQuickQuestions();
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(isBusy, value => navBarStore.setRightDisabled(value));
|
|
||||||
|
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
|
|||||||
@@ -1,4 +1,11 @@
|
|||||||
<template>
|
<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 v-can="permissionCodes.stat.read" class="customer-data-charts-page">
|
||||||
<div class="filters glass">
|
<div class="filters glass">
|
||||||
<t-input
|
<t-input
|
||||||
@@ -95,6 +102,17 @@ defineOptions({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
|
const routeNavBarTitle = computed(() => {
|
||||||
|
switch (route.name) {
|
||||||
|
case "CustomerDataCharts":
|
||||||
|
return "客户数据";
|
||||||
|
case "CustomerDataChartsFromCustomer":
|
||||||
|
return "客户数据图表";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
});
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
// ---------- 路由 ----------
|
// ---------- 路由 ----------
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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
|
<div
|
||||||
v-if="customer"
|
v-if="customer"
|
||||||
v-can="permissionCodes.customer.read"
|
v-can="permissionCodes.customer.read"
|
||||||
@@ -149,8 +194,6 @@ import CustomerProfileCard from "@/components/CustomerProfileCard.vue";
|
|||||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
||||||
import TagSelector from "@/components/TagSelector.vue";
|
import TagSelector from "@/components/TagSelector.vue";
|
||||||
import CustomerTagCard from "@/pages/customer/component/CustomerTagCard.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 { PointAccount } from "@/types/Point";
|
||||||
import type { PhotoItem } from "@/types/Photo";
|
import type { PhotoItem } from "@/types/Photo";
|
||||||
import type { GaoSalesOrderType } from "@/types/SalesOrder";
|
import type { GaoSalesOrderType } from "@/types/SalesOrder";
|
||||||
@@ -161,13 +204,45 @@ import { normalizeBodyAreaValue } from "@/utils/customer";
|
|||||||
import { corePermissionCodes, permissionCodes } from "@/utils/permission";
|
import { corePermissionCodes, permissionCodes } from "@/utils/permission";
|
||||||
import { LunarCalendar } from "@/utils/LunarCalendar";
|
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({
|
defineOptions({
|
||||||
name: "CustomerDetail"
|
name: "CustomerDetail"
|
||||||
});
|
});
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
|
||||||
const isRemoving = ref(false);
|
const isRemoving = ref(false);
|
||||||
@@ -501,9 +576,9 @@ async function toCustomerDataCharts(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateNavBar(): void {
|
function updateNavBar(): void {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
if (userStore.hasPermissions(permissionCodes.customer.update)) {
|
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();
|
updateNavBar();
|
||||||
});
|
});
|
||||||
watch(() => route.params.id, loadCustomer);
|
watch(() => route.params.id, loadCustomer);
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
onUnmounted(() => clearPageNavBarRight());
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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">
|
<div v-can="savePermissionCode" class="customer-edit">
|
||||||
<t-form class="form" label-align="left" label-width="5rem" :disabled="isCustomerBound" v-entrance-transition>
|
<t-form class="form" label-align="left" label-width="5rem" :disabled="isCustomerBound" v-entrance-transition>
|
||||||
<t-form-item label="客户编码">
|
<t-form-item label="客户编码">
|
||||||
@@ -236,8 +281,6 @@ import type { MediaSelectorAddAction } from "@/components/mediaSelector/types";
|
|||||||
import TagSelector from "@/components/TagSelector.vue";
|
import TagSelector from "@/components/TagSelector.vue";
|
||||||
import CustomerTagCard from "@/pages/customer/component/CustomerTagCard.vue";
|
import CustomerTagCard from "@/pages/customer/component/CustomerTagCard.vue";
|
||||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
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 { BodyAreaValue, Customer, CustomerAttachmentType, EditableCustomerPhoto } from "@/types/Customer";
|
||||||
import type { Tag } from "@/types/Tag";
|
import type { Tag } from "@/types/Tag";
|
||||||
import { bodyAreaLabelMap } from "@/utils/bodyArea";
|
import { bodyAreaLabelMap } from "@/utils/bodyArea";
|
||||||
@@ -247,16 +290,63 @@ import { corePermissionCodes, gaoRoleCodes, permissionCodes } from "@/utils/perm
|
|||||||
import { compressUploadImage } from "@/utils/imageCompression";
|
import { compressUploadImage } from "@/utils/imageCompression";
|
||||||
import { saveCapturedFilesFromInput } from "@/utils/twaBridge";
|
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({
|
defineOptions({
|
||||||
name: "CustomerEdit"
|
name: "CustomerEdit"
|
||||||
});
|
});
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
|
const routeNavBarTitle = computed(() => {
|
||||||
|
switch (route.name) {
|
||||||
|
case "CustomerCreate":
|
||||||
|
return "新增客户";
|
||||||
|
case "CustomerEdit":
|
||||||
|
return "编辑客户";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
});
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const settingStore = useSettingStore();
|
const settingStore = useSettingStore();
|
||||||
const currentStoreStore = useCurrentStoreStore();
|
const currentStoreStore = useCurrentStoreStore();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const isCreateMode = computed(() => route.name === "CustomerCreate");
|
const isCreateMode = computed(() => route.name === "CustomerCreate");
|
||||||
const savePermissionCode = computed(() => isCreateMode.value ? permissionCodes.customer.create : permissionCodes.customer.update);
|
const savePermissionCode = computed(() => isCreateMode.value ? permissionCodes.customer.create : permissionCodes.customer.update);
|
||||||
const hasCustomerDeletePermission = computed(() => userStore.hasPermissions(permissionCodes.customer.delete));
|
const hasCustomerDeletePermission = computed(() => userStore.hasPermissions(permissionCodes.customer.delete));
|
||||||
@@ -497,7 +587,7 @@ function handlePhotoAction(action: MediaSelectorAddAction): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
watch(isCustomerBound, (value) => {
|
watch(isCustomerBound, (value) => {
|
||||||
navBarStore.setRightDisabled(value);
|
setPageNavBarRightDisabled(value);
|
||||||
if (!value) {
|
if (!value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -553,10 +643,10 @@ async function loadDetail() {
|
|||||||
onMounted(loadDetail);
|
onMounted(loadDetail);
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
if (userStore.hasPermissions(savePermissionCode.value)) {
|
if (userStore.hasPermissions(savePermissionCode.value)) {
|
||||||
navBarStore.setRightText("保存", "var(--td-brand-color)", doSubmit);
|
setPageNavBarRightText("保存", "var(--td-brand-color)", doSubmit);
|
||||||
navBarStore.setRightDisabled(isCustomerBound.value);
|
setPageNavBarRightDisabled(isCustomerBound.value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -741,7 +831,7 @@ async function toBoundCustomerEdit(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
});
|
});
|
||||||
|
|
||||||
function buildAttachmentList(): Attachment[] {
|
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>
|
</style>
|
||||||
|
|
||||||
|
|||||||
@@ -1,49 +1,58 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-can="permissionCodes.customer.read" class="customer-invite-rank">
|
<div class="page-layout navbar customer-invite-rank">
|
||||||
<t-pull-down-refresh
|
<t-navbar
|
||||||
class="list-wrapper"
|
fixed
|
||||||
v-model="isRefreshing"
|
:z-index="20"
|
||||||
:refresh-timeout="30000"
|
title="客户邀请排行"
|
||||||
@refresh="refresh"
|
left-arrow
|
||||||
@scrolltolower="loadRanks"
|
@left-click="$router.back()"
|
||||||
>
|
/>
|
||||||
<t-cell-group v-if="rankedCustomerList.length" class="list" theme="card">
|
<main v-can="permissionCodes.customer.read" class="page-content scroll list">
|
||||||
<customer-cell
|
<t-pull-down-refresh
|
||||||
v-for="(item, index) in rankedCustomerList"
|
class="list-wrapper pull-refresh"
|
||||||
:key="item.id || item.code || index"
|
v-model="isRefreshing"
|
||||||
v-entrance-transition="{ step: 30 }"
|
:refresh-timeout="30000"
|
||||||
class="item"
|
@refresh="refresh"
|
||||||
:class="{ 'in-top3': index < 3 }"
|
@scrolltolower="loadRanks"
|
||||||
:customer="item"
|
>
|
||||||
arrow
|
<t-cell-group v-if="rankedCustomerList.length" class="list" theme="card">
|
||||||
hover
|
<customer-cell
|
||||||
@click="toCustomerDetail(item)"
|
v-for="(item, index) in rankedCustomerList"
|
||||||
>
|
:key="item.id || item.code || index"
|
||||||
<template #note>
|
v-entrance-transition="{ step: 30 }"
|
||||||
<div
|
class="item"
|
||||||
class="rank"
|
:class="{ 'in-top3': index < 3 }"
|
||||||
:class="{
|
:customer="item"
|
||||||
top1: index === 0,
|
arrow
|
||||||
top2: index === 1,
|
hover
|
||||||
top3: index === 2
|
@click="toCustomerDetail(item)"
|
||||||
}"
|
>
|
||||||
v-text="String(index + 1)"
|
<template #note>
|
||||||
/>
|
<div
|
||||||
</template>
|
class="rank"
|
||||||
<template #description>
|
:class="{
|
||||||
<div class="description">
|
top1: index === 0,
|
||||||
<t-tag
|
top2: index === 1,
|
||||||
theme="primary"
|
top3: index === 2
|
||||||
variant="light-outline"
|
}"
|
||||||
:content="getInvitedCountText(item)"
|
v-text="String(index + 1)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</template>
|
||||||
</template>
|
<template #description>
|
||||||
</customer-cell>
|
<div class="description">
|
||||||
</t-cell-group>
|
<t-tag
|
||||||
<div v-else class="center-tips" v-text="emptyText" />
|
theme="primary"
|
||||||
<div v-if="rankedCustomerList.length" class="center-tips" v-text="loadStateText" />
|
variant="light-outline"
|
||||||
</t-pull-down-refresh>
|
: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>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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
|
<div
|
||||||
v-can="permissionCodes.customer.read"
|
v-can="permissionCodes.customer.read"
|
||||||
class="customer-invite-relation"
|
class="customer-invite-relation"
|
||||||
@@ -52,12 +97,43 @@ import { type PageResult, useUserStore } from "timi-web-api";
|
|||||||
import CustomerAPI, { type CustomerPage } from "@/api/CustomerAPI";
|
import CustomerAPI, { type CustomerPage } from "@/api/CustomerAPI";
|
||||||
import CustomerInviteRelationChart from "@/pages/customer/component/CustomerInviteRelationChart.vue";
|
import CustomerInviteRelationChart from "@/pages/customer/component/CustomerInviteRelationChart.vue";
|
||||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
import type { Customer } from "@/types/Customer";
|
|
||||||
import { getErrorMessage } from "@/utils/error";
|
import { getErrorMessage } from "@/utils/error";
|
||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
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 = {
|
type InviteColorLegendItem = {
|
||||||
color: string;
|
color: string;
|
||||||
label: string;
|
label: string;
|
||||||
@@ -69,7 +145,6 @@ defineOptions({
|
|||||||
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const currentStoreStore = useCurrentStoreStore();
|
const currentStoreStore = useCurrentStoreStore();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const chartComponent = ref<InstanceType<typeof CustomerInviteRelationChart>>();
|
const chartComponent = ref<InstanceType<typeof CustomerInviteRelationChart>>();
|
||||||
const customerList = ref<Customer[]>([]);
|
const customerList = ref<Customer[]>([]);
|
||||||
@@ -197,7 +272,7 @@ async function toInviteRank(): Promise<void> {
|
|||||||
// ---------- 生命周期 ----------
|
// ---------- 生命周期 ----------
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navBarStore.setRightText("排行", "var(--td-brand-color)", toInviteRank);
|
setPageNavBarRightText("排行", "var(--td-brand-color)", toInviteRank);
|
||||||
await loadCustomers();
|
await loadCustomers();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -206,7 +281,7 @@ watch(searchKeyword, () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
});
|
});
|
||||||
</script>
|
</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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<t-navbar
|
||||||
|
fixed
|
||||||
|
:z-index="20"
|
||||||
|
title="邀请客户"
|
||||||
|
left-arrow
|
||||||
|
@left-click="$router.back()"
|
||||||
|
/>
|
||||||
<div v-can="permissionCodes.customer.read" class="customer-invitee-list">
|
<div v-can="permissionCodes.customer.read" class="customer-invitee-list">
|
||||||
<customer-profile-card
|
<customer-profile-card
|
||||||
v-if="customer"
|
v-if="customer"
|
||||||
|
|||||||
+227
-127
@@ -1,132 +1,186 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-can="permissionCodes.customer.read" class="customer-list">
|
<div class="page-layout navbar customer-list">
|
||||||
<div class="filters glass">
|
<t-navbar
|
||||||
<t-input
|
fixed
|
||||||
v-model.trim="keyword"
|
:z-index="20"
|
||||||
class="search"
|
title="客户管理"
|
||||||
placeholder="搜索编码、姓名(拼音)、电话"
|
left-arrow
|
||||||
borderless
|
@left-click="$router.back()"
|
||||||
>
|
|
||||||
<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="list-wrap">
|
<template #right>
|
||||||
<t-cell-group class="summary" theme="card">
|
<div
|
||||||
<t-cell
|
class="nav-actions"
|
||||||
v-if="dateFilterType !== 'all'"
|
v-if="(canShowActionMenu) && pageNavBarActionList.length"
|
||||||
title="开始时间"
|
>
|
||||||
:note="dateRange[0] || '-'"
|
<t-popover
|
||||||
arrow
|
v-model:visible="pageNavBarActionVisible"
|
||||||
@click="openStartTime"
|
placement="bottom-right"
|
||||||
/>
|
:show-arrow="false"
|
||||||
<t-cell
|
theme="light"
|
||||||
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
|
<t-button
|
||||||
class="cell"
|
class="trigger"
|
||||||
:customer="item"
|
variant="text"
|
||||||
arrow
|
:aria-label="'更多操作'"
|
||||||
@click="toDetail(item)"
|
type="button"
|
||||||
>
|
>
|
||||||
<template #description>
|
<template #icon>
|
||||||
<telephone-link :value="item.telephone" />
|
<t-icon name="ellipsis" />
|
||||||
</template>
|
</template>
|
||||||
</customer-cell>
|
</t-button>
|
||||||
<template v-if="canDeleteCustomer" #right>
|
<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
|
<t-button
|
||||||
class="delete"
|
size="extra-small"
|
||||||
theme="danger"
|
theme="primary"
|
||||||
:loading="isRemoving && removingCustomerId === item.id"
|
variant="outline"
|
||||||
@click.stop="openRemoveDialog(item)"
|
@click.stop="toggleScanner"
|
||||||
>
|
>
|
||||||
删除
|
<template #icon>
|
||||||
|
<t-icon name="scan" />
|
||||||
|
</template>
|
||||||
|
<span v-text="scannerVisible ? '关闭扫码' : '扫码'" />
|
||||||
</t-button>
|
</t-button>
|
||||||
</template>
|
</template>
|
||||||
</t-swipe-cell>
|
</t-input>
|
||||||
</t-cell-group>
|
<t-dropdown-menu ref="filterMenu" class="menus">
|
||||||
<div v-if="!pageResult.list.length" class="center-tips" v-text="isLoading ? '正在加载客户' : '暂无客户数据'" />
|
<t-dropdown-item
|
||||||
<div v-if="pageResult.list.length" class="center-tips" v-text="isLoading ? '正在加载更多' : isNoMore ? '已经到底了' : '上拉加载更多'" />
|
v-model="dateFilterType"
|
||||||
</div>
|
:label="dateFilterLabel"
|
||||||
</t-pull-down-refresh>
|
:options="dateOptions"
|
||||||
<tag-selector
|
@change="selectDateFilter"
|
||||||
v-model="selectedTagIdList"
|
/>
|
||||||
v-model:visible="tagSelectorVisible"
|
<t-dropdown-item
|
||||||
@change="handleTagFilterChanged"
|
v-if="canReadTag"
|
||||||
/>
|
:label="tagFilterText"
|
||||||
<customer-remove-dialog
|
@open="handleTagFilterOpen"
|
||||||
v-model:visible="removeDialogVisible"
|
/>
|
||||||
:customer="removeTarget"
|
</t-dropdown-menu>
|
||||||
:loading="isRemoving"
|
</div>
|
||||||
@confirm="removeCustomer"
|
<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>
|
</div>
|
||||||
<nav-bar-action-menu v-if="canShowActionMenu" :actions="actionList" />
|
|
||||||
<t-popup v-model="startVisible" placement="bottom">
|
<t-popup v-model="startVisible" placement="bottom">
|
||||||
<t-date-time-picker
|
<t-date-time-picker
|
||||||
v-if="startVisible"
|
v-if="startVisible"
|
||||||
@@ -154,6 +208,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import type { NavBarAction } from "@/types/NavBarAction";
|
||||||
import type { DropdownValue } from "tdesign-mobile-vue";
|
import type { DropdownValue } from "tdesign-mobile-vue";
|
||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { Time, Toolkit, WebToolkit } from "timi-web";
|
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 CustomerRemoveDialog from "@/pages/customer/component/CustomerRemoveDialog.vue";
|
||||||
import TagSelector from "@/components/TagSelector.vue";
|
import TagSelector from "@/components/TagSelector.vue";
|
||||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
import { useSettingStore } from "@/store/settingStore";
|
|
||||||
import type { Customer } from "@/types/Customer";
|
import type { Customer } from "@/types/Customer";
|
||||||
import type { NavBarAction } from "@/types/NavBarAction";
|
|
||||||
import type { Tag } from "@/types/Tag";
|
import type { Tag } from "@/types/Tag";
|
||||||
import { buildPresetDateRange, parseDateTime } from "@/utils/date";
|
import { buildPresetDateRange, parseDateTime } from "@/utils/date";
|
||||||
import { corePermissionCodes, gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
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({
|
defineOptions({
|
||||||
name: "CustomerList"
|
name: "CustomerList"
|
||||||
});
|
});
|
||||||
@@ -181,7 +243,6 @@ const router = useRouter();
|
|||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const currentStoreStore = useCurrentStoreStore();
|
const currentStoreStore = useCurrentStoreStore();
|
||||||
const settingStore = useSettingStore();
|
const settingStore = useSettingStore();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const isRefreshing = ref(false);
|
const isRefreshing = ref(false);
|
||||||
const isExporting = ref(false);
|
const isExporting = ref(false);
|
||||||
const isRemoving = ref(false);
|
const isRemoving = ref(false);
|
||||||
@@ -409,8 +470,7 @@ async function loadData(): Promise<void> {
|
|||||||
onMounted(loadData);
|
onMounted(loadData);
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
navBarStore.clearRight();
|
|
||||||
navBarStore.setCustomRightVisible(canShowActionMenu.value);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(keyword, async () => {
|
watch(keyword, async () => {
|
||||||
@@ -421,7 +481,6 @@ watch(keyword, async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
navBarStore.clearRight();
|
|
||||||
window.clearTimeout(keywordTimer);
|
window.clearTimeout(keywordTimer);
|
||||||
scannerVisible.value = false;
|
scannerVisible.value = false;
|
||||||
});
|
});
|
||||||
@@ -504,7 +563,6 @@ function buildCreatedAtRange(): [number | undefined, number | undefined] {
|
|||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
.customer-list {
|
.customer-list {
|
||||||
padding: var(--app-nav-height) 0 1rem 0;
|
|
||||||
|
|
||||||
.filters {
|
.filters {
|
||||||
top: var(--app-nav-height);
|
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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<t-navbar
|
||||||
|
fixed
|
||||||
|
:z-index="20"
|
||||||
|
title="生成二维码"
|
||||||
|
left-arrow
|
||||||
|
@left-click="$router.back()"
|
||||||
|
/>
|
||||||
<div v-can="permissionCodes.qrCode.create" class="qr-page">
|
<div v-can="permissionCodes.qrCode.create" class="qr-page">
|
||||||
<t-form class="form" label-align="left" v-entrance-transition>
|
<t-form class="form" label-align="left" v-entrance-transition>
|
||||||
<t-form-item label="编码前缀">
|
<t-form-item label="编码前缀">
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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
|
<div
|
||||||
v-can="permissionCodes.event.read"
|
v-can="permissionCodes.event.read"
|
||||||
class="registration-event-detail"
|
class="registration-event-detail"
|
||||||
@@ -128,20 +173,50 @@ import EventAPI from "@/api/EventAPI";
|
|||||||
import EventOptionSelector from "@/components/EventOptionSelector.vue";
|
import EventOptionSelector from "@/components/EventOptionSelector.vue";
|
||||||
import EventRemoveDialog from "@/pages/event/component/EventRemoveDialog.vue";
|
import EventRemoveDialog from "@/pages/event/component/EventRemoveDialog.vue";
|
||||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
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 { getEventBizTypeText, isPackagePurchaseEvent } from "@/utils/event";
|
||||||
import { formatPackageAmount, getPackageConfigStatusText } from "@/utils/package";
|
import { formatPackageAmount, getPackageConfigStatusText } from "@/utils/package";
|
||||||
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
||||||
import { Message } from "@/utils/message";
|
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({
|
defineOptions({
|
||||||
name: "EventDetail"
|
name: "EventDetail"
|
||||||
});
|
});
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const currentStoreStore = useCurrentStoreStore();
|
const currentStoreStore = useCurrentStoreStore();
|
||||||
const moduleCode: ModuleCode = "GAO";
|
const moduleCode: ModuleCode = "GAO";
|
||||||
@@ -365,21 +440,21 @@ watch(() => route.params.id, async () => {
|
|||||||
}, { immediate: true });
|
}, { immediate: true });
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
if (canUpdate.value) {
|
if (canUpdate.value) {
|
||||||
navBarStore.setRightText("编辑", "var(--td-brand-color)", toEdit);
|
setPageNavBarRightText("编辑", "var(--td-brand-color)", toEdit);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(canUpdate, value => {
|
watch(canUpdate, value => {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
if (value) {
|
if (value) {
|
||||||
navBarStore.setRightText("编辑", "var(--td-brand-color)", toEdit);
|
setPageNavBarRightText("编辑", "var(--td-brand-color)", toEdit);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -467,4 +542,45 @@ onUnmounted(() => {
|
|||||||
.option-popup {
|
.option-popup {
|
||||||
padding: 1rem;
|
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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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">
|
<div v-can="pageAccess" class="event-edit">
|
||||||
<t-form class="form" label-align="left" label-width="7rem" v-entrance-transition>
|
<t-form class="form" label-align="left" label-width="7rem" v-entrance-transition>
|
||||||
<t-form-item label="颜色">
|
<t-form-item label="颜色">
|
||||||
@@ -232,14 +277,45 @@ import type { ColorObject } from "tdesign-mobile-vue";
|
|||||||
import EventAPI from "@/api/EventAPI";
|
import EventAPI from "@/api/EventAPI";
|
||||||
import EventOptionEditor from "@/pages/event/component/EventOptionEditor.vue";
|
import EventOptionEditor from "@/pages/event/component/EventOptionEditor.vue";
|
||||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
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 { getErrorMessage } from "@/utils/error";
|
||||||
import { normalizeEventOptionGroupList, prepareEventOptionGroupList, validateEventOptionGroupList } from "@/utils/eventOption";
|
import { normalizeEventOptionGroupList, prepareEventOptionGroupList, validateEventOptionGroupList } from "@/utils/eventOption";
|
||||||
import { getEventBizTypeText } from "@/utils/event";
|
import { getEventBizTypeText } from "@/utils/event";
|
||||||
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
||||||
import { Message } from "@/utils/message";
|
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 PickerValue = string | number;
|
||||||
|
|
||||||
type LimitOption = {
|
type LimitOption = {
|
||||||
@@ -252,8 +328,18 @@ defineOptions({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
|
const routeNavBarTitle = computed(() => {
|
||||||
|
switch (route.name) {
|
||||||
|
case "EventCreate":
|
||||||
|
return "新增登记事件";
|
||||||
|
case "EventEdit":
|
||||||
|
return "编辑登记事件";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
});
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const currentStoreStore = useCurrentStoreStore();
|
const currentStoreStore = useCurrentStoreStore();
|
||||||
const routeId = computed(() => String(route.params.id || ""));
|
const routeId = computed(() => String(route.params.id || ""));
|
||||||
@@ -724,9 +810,9 @@ async function fillForm(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
if (userStore.hasPermissions(savePermissionCode.value)) {
|
if (userStore.hasPermissions(savePermissionCode.value)) {
|
||||||
navBarStore.setRightText("保存", "var(--td-brand-color)", saveEventItem);
|
setPageNavBarRightText("保存", "var(--td-brand-color)", saveEventItem);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await fillForm();
|
await fillForm();
|
||||||
@@ -735,7 +821,7 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
onUnmounted(() => clearPageNavBarRight());
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<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>
|
</style>
|
||||||
|
|||||||
+183
-81
@@ -1,107 +1,169 @@
|
|||||||
<template>
|
<template>
|
||||||
<div
|
<div class="page-layout navbar registration-event-list">
|
||||||
v-can="{ value: [permissionCodes.event.read, permissionCodes.user.read], mode: 'and' }"
|
<t-navbar
|
||||||
class="registration-event-list"
|
fixed
|
||||||
>
|
:z-index="20"
|
||||||
<t-pull-down-refresh
|
title="登记事件管理"
|
||||||
v-model="isRefreshing"
|
left-arrow
|
||||||
:refresh-timeout="30000"
|
@left-click="$router.back()"
|
||||||
@refresh="refresh"
|
|
||||||
@scrolltolower="fetch"
|
|
||||||
>
|
>
|
||||||
<t-cell-group class="fix-last-cell-line" theme="card">
|
<template #right>
|
||||||
<t-swipe-cell
|
<div
|
||||||
v-entrance-transition="{ step: 30 }"
|
class="nav-actions"
|
||||||
v-for="item in visibleEventList"
|
v-if="(canShowActionMenu) && pageNavBarActionList.length"
|
||||||
:key="item.id"
|
|
||||||
class="item"
|
|
||||||
>
|
>
|
||||||
<t-cell
|
<t-popover
|
||||||
class="cell"
|
v-model:visible="pageNavBarActionVisible"
|
||||||
:arrow="!!item.id"
|
placement="bottom-right"
|
||||||
:hover="!!item.id"
|
:show-arrow="false"
|
||||||
@click="toEventItem(item)"
|
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
|
<t-button
|
||||||
class="delete"
|
class="trigger"
|
||||||
theme="danger"
|
variant="text"
|
||||||
:loading="isRemoving && removingEventId === item.id"
|
:aria-label="'更多操作'"
|
||||||
@click.stop="openRemoveDialog(item)"
|
type="button"
|
||||||
>
|
>
|
||||||
删除
|
<template #icon>
|
||||||
|
<t-icon name="ellipsis" />
|
||||||
|
</template>
|
||||||
</t-button>
|
</t-button>
|
||||||
</template>
|
<template #content>
|
||||||
</t-swipe-cell>
|
<div class="menu">
|
||||||
</t-cell-group>
|
<t-button
|
||||||
<div v-if="!visibleEventList.length" class="empty-block" v-text="emptyText" />
|
v-for="action in pageNavBarActionList"
|
||||||
<div v-if="visibleEventList.length" class="center-tips" v-text="isNoMore ? '已经到底了' : '上拉加载更多'" />
|
:key="action.key"
|
||||||
</t-pull-down-refresh>
|
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>
|
</div>
|
||||||
<nav-bar-action-menu v-if="canShowActionMenu" :actions="actionList" />
|
|
||||||
<event-remove-dialog
|
|
||||||
v-model:visible="removeDialogVisible"
|
|
||||||
:event="removeTarget"
|
|
||||||
:loading="isRemoving"
|
|
||||||
@confirm="removeEvent"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import type { NavBarAction } from "@/types/NavBarAction";
|
||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { type Page, type PageResult, type Role, useUserStore } from "timi-web-api";
|
import { type Page, type PageResult, type Role, useUserStore } from "timi-web-api";
|
||||||
import EventAPI from "@/api/EventAPI";
|
import EventAPI from "@/api/EventAPI";
|
||||||
import EventRemoveDialog from "@/pages/event/component/EventRemoveDialog.vue";
|
import EventRemoveDialog from "@/pages/event/component/EventRemoveDialog.vue";
|
||||||
import ManagedUserAPI from "@/api/ManagedUserAPI";
|
import ManagedUserAPI from "@/api/ManagedUserAPI";
|
||||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
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 { getEventBizTypeText, isRetiredEvent } from "@/utils/event";
|
||||||
import { getEventValueUnitText } from "@/utils/eventValue";
|
import { getEventValueUnitText } from "@/utils/eventValue";
|
||||||
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
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({
|
defineOptions({
|
||||||
name: "eventList"
|
name: "eventList"
|
||||||
});
|
});
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const currentStoreStore = useCurrentStoreStore();
|
const currentStoreStore = useCurrentStoreStore();
|
||||||
|
|
||||||
@@ -336,8 +398,7 @@ async function toSort(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navBarStore.clearRight();
|
|
||||||
navBarStore.setCustomRightVisible(canShowActionMenu.value);
|
|
||||||
try {
|
try {
|
||||||
await loadData();
|
await loadData();
|
||||||
} catch {
|
} catch {
|
||||||
@@ -346,7 +407,6 @@ onMounted(async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
navBarStore.clearRight();
|
|
||||||
});
|
});
|
||||||
</script>
|
</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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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">
|
<div v-can="permissionCodes.eventRecord.read" class="event-record-detail">
|
||||||
<customer-profile-card
|
<customer-profile-card
|
||||||
v-entrance-transition
|
v-entrance-transition
|
||||||
@@ -105,8 +150,6 @@ import CustomerProfileCard from "@/components/CustomerProfileCard.vue";
|
|||||||
import EventOptionSelector from "@/components/EventOptionSelector.vue";
|
import EventOptionSelector from "@/components/EventOptionSelector.vue";
|
||||||
import EventRecordVerifyDialog from "@/components/EventRecordVerifyDialog.vue";
|
import EventRecordVerifyDialog from "@/components/EventRecordVerifyDialog.vue";
|
||||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.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 { PhotoItem } from "@/types/Photo";
|
||||||
import type { PointLedgerChangeType } from "@/types/Point";
|
import type { PointLedgerChangeType } from "@/types/Point";
|
||||||
import { getAttachmentReadURL } from "@/utils/attachment";
|
import { getAttachmentReadURL } from "@/utils/attachment";
|
||||||
@@ -117,13 +160,45 @@ import { formatEventNumberValue } from "@/utils/eventValue";
|
|||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { permissionCodes } from "@/utils/permission";
|
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({
|
defineOptions({
|
||||||
name: "EventRecordDetail"
|
name: "EventRecordDetail"
|
||||||
});
|
});
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
|
||||||
// ---------- 记录数据 ----------
|
// ---------- 记录数据 ----------
|
||||||
@@ -383,16 +458,16 @@ watch(() => route.params.id, async () => {
|
|||||||
}, { immediate: true });
|
}, { immediate: true });
|
||||||
|
|
||||||
function updateNavBarAction(): void {
|
function updateNavBarAction(): void {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
if (canUpdateRecord.value) {
|
if (canUpdateRecord.value) {
|
||||||
navBarStore.setRightText("编辑", "var(--td-brand-color)", toEdit);
|
setPageNavBarRightText("编辑", "var(--td-brand-color)", toEdit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(canUpdateRecord, updateNavBarAction, { immediate: true });
|
watch(canUpdateRecord, updateNavBarAction, { immediate: true });
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
});
|
});
|
||||||
</script>
|
</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>
|
</style>
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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">
|
<div v-can="pageAccess" class="registration-record-edit">
|
||||||
<t-form class="form" label-align="left" v-entrance-transition>
|
<t-form class="form" label-align="left" v-entrance-transition>
|
||||||
<t-form-item label="客户" required-mark>
|
<t-form-item label="客户" required-mark>
|
||||||
@@ -222,8 +267,6 @@ import EventOptionSelector from "@/components/EventOptionSelector.vue";
|
|||||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
||||||
import EventSelector from "@/components/EventSelector.vue";
|
import EventSelector from "@/components/EventSelector.vue";
|
||||||
import { useEventRecordPhoto } from "@/pages/event/component/useEventRecordPhoto";
|
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 { Customer } from "@/types/Customer";
|
||||||
import type { EventItem, EventOptionSelectionMap } from "@/types/EventItem";
|
import type { EventItem, EventOptionSelectionMap } from "@/types/EventItem";
|
||||||
import type { EventRecord } from "@/types/EventRecord";
|
import type { EventRecord } from "@/types/EventRecord";
|
||||||
@@ -233,15 +276,60 @@ import { getEventRecordPhotoURL, hasPhotoAttachment } from "@/utils/eventRecord"
|
|||||||
import { getEventNumberValuePlaceholder, resolveEventNumberValue } from "@/utils/eventValue";
|
import { getEventNumberValuePlaceholder, resolveEventNumberValue } from "@/utils/eventValue";
|
||||||
import { permissionCodes } from "@/utils/permission";
|
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({
|
defineOptions({
|
||||||
name: "EventRecordEdit"
|
name: "EventRecordEdit"
|
||||||
});
|
});
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
|
const routeNavBarTitle = computed(() => {
|
||||||
|
switch (route.name) {
|
||||||
|
case "CustomerEventRecordCreate":
|
||||||
|
return "登记";
|
||||||
|
case "EventRecordCreate":
|
||||||
|
return "新增登记事件记录";
|
||||||
|
case "EventRecordEdit":
|
||||||
|
return "编辑登记事件记录";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
});
|
||||||
const settingStore = useSettingStore();
|
const settingStore = useSettingStore();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
|
|
||||||
// ---------- 路由权限 ----------
|
// ---------- 路由权限 ----------
|
||||||
|
|
||||||
@@ -712,14 +800,14 @@ async function loadRecordForEdit(): Promise<void> {
|
|||||||
onMounted(loadPageData);
|
onMounted(loadPageData);
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
if (userStore.hasPermissions(pageAccess.value)) {
|
if (userStore.hasPermissions(pageAccess.value)) {
|
||||||
navBarStore.setRightText(saveButtonText.value, "var(--td-brand-color)", submitRecord);
|
setPageNavBarRightText(saveButtonText.value, "var(--td-brand-color)", submitRecord);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(customerCode, async (value) => {
|
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>
|
</style>
|
||||||
|
|||||||
+240
-138
@@ -1,141 +1,197 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-can="permissionCodes.eventRecord.read" class="registration-record-list">
|
<div class="page-layout navbar registration-record-list">
|
||||||
<div class="filters glass">
|
<t-navbar
|
||||||
<div class="search-date">
|
fixed
|
||||||
<t-input
|
:z-index="20"
|
||||||
v-model.trim="keyword"
|
title="登记事件记录管理"
|
||||||
class="search-input"
|
left-arrow
|
||||||
type="search"
|
@left-click="$router.back()"
|
||||||
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="list-wrapper">
|
<template #right>
|
||||||
<t-cell-group v-entrance-transition class="summary" theme="card">
|
<div
|
||||||
<t-cell
|
class="nav-actions"
|
||||||
title="开始时间"
|
v-if="(canShowActionMenu) && pageNavBarActionList.length"
|
||||||
: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
|
<t-popover
|
||||||
v-entrance-transition="{ step: 30 }"
|
v-model:visible="pageNavBarActionVisible"
|
||||||
v-for="item in pageResult.list"
|
placement="bottom-right"
|
||||||
:key="item.id"
|
:show-arrow="false"
|
||||||
:record="item"
|
theme="light"
|
||||||
@updated="reloadRecords"
|
>
|
||||||
/>
|
<t-button
|
||||||
</t-cell-group>
|
class="trigger"
|
||||||
<div v-else class="center-tips" v-text="isLoading ? '正在加载登记事件记录' : '暂无登记事件记录'" />
|
variant="text"
|
||||||
<div v-if="pageResult.list.length" class="center-tips" v-text="loadStateText" />
|
:aria-label="'更多操作'"
|
||||||
</div>
|
type="button"
|
||||||
</t-pull-down-refresh>
|
>
|
||||||
|
<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>
|
</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>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import type { NavBarAction } from "@/types/NavBarAction";
|
||||||
import type { DropdownValue } from "tdesign-mobile-vue";
|
import type { DropdownValue } from "tdesign-mobile-vue";
|
||||||
import { Time, Text, WebToolkit } from "timi-web";
|
import { Time, Text, WebToolkit } from "timi-web";
|
||||||
import { useUserStore } from "timi-web-api";
|
import { useUserStore } from "timi-web-api";
|
||||||
@@ -143,16 +199,23 @@ import EventAPI from "@/api/EventAPI";
|
|||||||
import EventRecordAPI from "@/api/EventRecordAPI";
|
import EventRecordAPI from "@/api/EventRecordAPI";
|
||||||
import CustomerSelector from "@/components/CustomerSelector.vue";
|
import CustomerSelector from "@/components/CustomerSelector.vue";
|
||||||
import EventRecordCell from "@/pages/event/component/EventRecordCell.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 { EventOptionStat, EventRecordPage, EventRecordPageResult, VerificationStatus } from "@/types/EventRecord";
|
||||||
import type { NavBarAction } from "@/types/NavBarAction";
|
|
||||||
import { isRetiredEvent } from "@/utils/event";
|
import { isRetiredEvent } from "@/utils/event";
|
||||||
import { formatEventNumberValue } from "@/utils/eventValue";
|
import { formatEventNumberValue } from "@/utils/eventValue";
|
||||||
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
|
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
|
||||||
import { permissionCodes } from "@/utils/permission";
|
import { permissionCodes } from "@/utils/permission";
|
||||||
import { Message } from "@/utils/message.ts";
|
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 DateFilterType = "today" | "yesterday" | "thisWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
|
||||||
type VerificationFilter = "ALL" | VerificationStatus;
|
type VerificationFilter = "ALL" | VerificationStatus;
|
||||||
|
|
||||||
@@ -163,7 +226,6 @@ defineOptions({
|
|||||||
const pageSize = 20;
|
const pageSize = 20;
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const dateOptions: Array<{ label: string; value: DateFilterType }> = [
|
const dateOptions: Array<{ label: string; value: DateFilterType }> = [
|
||||||
{ label: "今天", value: "today" },
|
{ label: "今天", value: "today" },
|
||||||
@@ -669,15 +731,13 @@ function buildUnixRange(): [number, number] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navBarStore.clearRight();
|
|
||||||
navBarStore.setCustomRightVisible(canShowActionMenu.value);
|
|
||||||
await loadActions();
|
await loadActions();
|
||||||
initialized = true;
|
initialized = true;
|
||||||
await reloadRecords();
|
await reloadRecords();
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
navBarStore.clearRight();
|
|
||||||
window.clearTimeout(keywordTimer);
|
window.clearTimeout(keywordTimer);
|
||||||
});
|
});
|
||||||
</script>
|
</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>
|
</style>
|
||||||
|
|||||||
+129
-120
@@ -1,127 +1,136 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-can="permissionCodes.stat.read" class="event-record-rank">
|
<div class="page-layout navbar event-record-rank">
|
||||||
<div class="filters">
|
<t-navbar
|
||||||
<t-dropdown-menu class="filter-menu">
|
fixed
|
||||||
<t-dropdown-item
|
:z-index="20"
|
||||||
v-model="rankType"
|
title="登记记录排行"
|
||||||
:label="rankTypeLabel"
|
left-arrow
|
||||||
:options="rankTypeOptions"
|
@left-click="$router.back()"
|
||||||
@change="selectRankType"
|
/>
|
||||||
/>
|
<main v-can="permissionCodes.stat.read" class="page-content scroll list">
|
||||||
<t-dropdown-item
|
<t-pull-down-refresh
|
||||||
v-model="dateFilterType"
|
class="list-wrapper pull-refresh"
|
||||||
:label="dateFilterLabel"
|
v-model="isRefreshing"
|
||||||
:options="dateOptions"
|
:refresh-timeout="30000"
|
||||||
@change="selectDateFilter"
|
@refresh="reloadRanks"
|
||||||
/>
|
@scrolltolower="loadRanks"
|
||||||
<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"
|
|
||||||
>
|
>
|
||||||
<customer-cell
|
<div class="filters">
|
||||||
v-entrance-transition="{ step: 30 }"
|
<t-dropdown-menu class="filter-menu">
|
||||||
v-for="(item, index) in pageResult.list"
|
<t-dropdown-item
|
||||||
:key="item.customerId"
|
v-model="rankType"
|
||||||
class="item"
|
:label="rankTypeLabel"
|
||||||
:class="{ 'in-top3': index < 3}"
|
:options="rankTypeOptions"
|
||||||
arrow
|
@change="selectRankType"
|
||||||
@click="toCustomerDetail(item.customerId || '')"
|
/>
|
||||||
:customer="item.customer"
|
<t-dropdown-item
|
||||||
>
|
v-model="dateFilterType"
|
||||||
<template #note>
|
:label="dateFilterLabel"
|
||||||
<div
|
:options="dateOptions"
|
||||||
class="rank"
|
@change="selectDateFilter"
|
||||||
:class="{
|
/>
|
||||||
top1: index === 0,
|
<t-dropdown-item
|
||||||
top2: index === 1,
|
v-model="eventFilter"
|
||||||
top3: index === 2,
|
:label="eventFilterLabel"
|
||||||
}"
|
options-columns="2"
|
||||||
v-text="index + 1"
|
:options="eventOptions"
|
||||||
/>
|
multiple
|
||||||
</template>
|
/>
|
||||||
<template #description>
|
</t-dropdown-menu>
|
||||||
<div class="description">
|
</div>
|
||||||
<t-tag
|
<t-cell-group v-if="isCustomRange" class="time-range" theme="card">
|
||||||
v-if="rankType === 'TOTAL_DAYS'"
|
<t-cell
|
||||||
size="small"
|
title="开始时间"
|
||||||
variant="outline"
|
:note="dateRange[0] || '-'"
|
||||||
:content="`累计天数 ${item.totalEventDays || 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
|
</template>
|
||||||
v-else-if="rankType === 'TOTAL_COUNT'"
|
<template #description>
|
||||||
size="small"
|
<div class="description">
|
||||||
variant="outline"
|
<t-tag
|
||||||
:content="`累计次数 ${item.totalEventCount || 0}`"
|
v-if="rankType === 'TOTAL_DAYS'"
|
||||||
/>
|
size="small"
|
||||||
<t-tag
|
variant="outline"
|
||||||
v-else-if="rankType === 'CONTINUOUS_DAYS'"
|
:content="`累计天数 ${item.totalEventDays || 0}`"
|
||||||
size="small"
|
/>
|
||||||
variant="outline"
|
<t-tag
|
||||||
:content="`连续天数 ${item.recentContinuousEventDays || 0}`"
|
v-else-if="rankType === 'TOTAL_COUNT'"
|
||||||
/>
|
size="small"
|
||||||
<t-tag
|
variant="outline"
|
||||||
v-else
|
:content="`累计次数 ${item.totalEventCount || 0}`"
|
||||||
size="small"
|
/>
|
||||||
variant="outline"
|
<t-tag
|
||||||
:content="`登记数值 ${getTotalNumberValueText(item)}`"
|
v-else-if="rankType === 'CONTINUOUS_DAYS'"
|
||||||
/>
|
size="small"
|
||||||
</div>
|
variant="outline"
|
||||||
</template>
|
:content="`连续天数 ${item.recentContinuousEventDays || 0}`"
|
||||||
</customer-cell>
|
/>
|
||||||
</t-cell-group>
|
<t-tag
|
||||||
<div v-else class="center-tips" v-text="emptyStateText" />
|
v-else
|
||||||
<div v-if="pageResult.list.length" class="center-tips" v-text="loadStateText" />
|
size="small"
|
||||||
</t-pull-down-refresh>
|
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>
|
</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>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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 v-can="permissionCodes.event.update" class="registration-event-sort">
|
||||||
<div class="tip" v-text="'按住右侧拖动手柄调整事件顺序,保存后生效'" v-entrance-transition />
|
<div class="tip" v-text="'按住右侧拖动手柄调整事件顺序,保存后生效'" v-entrance-transition />
|
||||||
<div class="items">
|
<div class="items">
|
||||||
@@ -52,16 +97,45 @@
|
|||||||
import { type TagProps } from "tdesign-mobile-vue";
|
import { type TagProps } from "tdesign-mobile-vue";
|
||||||
import { VueDraggableNext } from "vue-draggable-next";
|
import { VueDraggableNext } from "vue-draggable-next";
|
||||||
import EventAPI from "@/api/EventAPI";
|
import EventAPI from "@/api/EventAPI";
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
import type { EventItem, EventStatus } from "@/types/EventItem";
|
|
||||||
import { permissionCodes } from "@/utils/permission";
|
import { permissionCodes } from "@/utils/permission";
|
||||||
import { Message } from "@/utils/message.ts";
|
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({
|
defineOptions({
|
||||||
name: "EventSort"
|
name: "EventSort"
|
||||||
});
|
});
|
||||||
|
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
// ---------- 列表数据 ----------
|
// ---------- 列表数据 ----------
|
||||||
@@ -147,8 +221,8 @@ async function loadData(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
navBarStore.setRightText("保存", "var(--td-brand-color)", saveSort);
|
setPageNavBarRightText("保存", "var(--td-brand-color)", saveSort);
|
||||||
try {
|
try {
|
||||||
await loadData();
|
await loadData();
|
||||||
} catch {
|
} catch {
|
||||||
@@ -157,7 +231,7 @@ onMounted(async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
});
|
});
|
||||||
</script>
|
</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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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">
|
<div v-can="permissionCodes.customerFollowUpReminder.read" class="follow-up-reminder-detail">
|
||||||
<t-empty v-if="!detail" :description="isLoading ? '正在加载跟进提醒' : '跟进提醒不存在'" />
|
<t-empty v-if="!detail" :description="isLoading ? '正在加载跟进提醒' : '跟进提醒不存在'" />
|
||||||
<template v-else>
|
<template v-else>
|
||||||
@@ -89,12 +134,43 @@ import { getErrorMessage } from "@/utils/error";
|
|||||||
import FollowUpReminderAPI from "@/api/FollowUpReminderAPI";
|
import FollowUpReminderAPI from "@/api/FollowUpReminderAPI";
|
||||||
import CustomerProfileCard from "@/components/CustomerProfileCard.vue";
|
import CustomerProfileCard from "@/components/CustomerProfileCard.vue";
|
||||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.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 type { PhotoItem } from "@/types/Photo";
|
||||||
import { getAttachmentReadURL } from "@/utils/attachment";
|
import { getAttachmentReadURL } from "@/utils/attachment";
|
||||||
import { corePermissionCodes, permissionCodes } from "@/utils/permission";
|
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";
|
type NotifyTagTheme = "default" | "success" | "warning" | "primary" | "danger";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
@@ -103,7 +179,6 @@ defineOptions({
|
|||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
|
||||||
const detail = ref<FollowUpReminder>();
|
const detail = ref<FollowUpReminder>();
|
||||||
@@ -181,7 +256,7 @@ async function loadDetail(): Promise<void> {
|
|||||||
loadToken = token;
|
loadToken = token;
|
||||||
detail.value = undefined;
|
detail.value = undefined;
|
||||||
internalNotifyStatus.value = undefined;
|
internalNotifyStatus.value = undefined;
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
const id = String(route.params.id || "");
|
const id = String(route.params.id || "");
|
||||||
if (!id) {
|
if (!id) {
|
||||||
return;
|
return;
|
||||||
@@ -207,7 +282,7 @@ async function loadDetail(): Promise<void> {
|
|||||||
|
|
||||||
function setEditAction(): void {
|
function setEditAction(): void {
|
||||||
if (canUpdate.value) {
|
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> {
|
async function remove(id: string): Promise<void> {
|
||||||
isDeleting.value = true;
|
isDeleting.value = true;
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
try {
|
try {
|
||||||
await FollowUpReminderAPI.remove(id);
|
await FollowUpReminderAPI.remove(id);
|
||||||
Message.success("跟进提醒已删除");
|
Message.success("跟进提醒已删除");
|
||||||
@@ -322,7 +397,7 @@ watch(() => route.params.id, async () => {
|
|||||||
await loadDetail();
|
await loadDetail();
|
||||||
}, { immediate: true });
|
}, { immediate: true });
|
||||||
|
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
onUnmounted(() => clearPageNavBarRight());
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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">
|
<div v-can="pageAccess" class="follow-up-reminder-edit">
|
||||||
<t-form class="form" label-width="6rem">
|
<t-form class="form" label-width="6rem">
|
||||||
<t-form-item label="客户" content-align="right" required-mark>
|
<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 ManagedUserSelector from "@/pages/followUpReminder/component/ManagedUserSelector.vue";
|
||||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
||||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
import type { Customer } from "@/types/Customer";
|
|
||||||
import type { ManagedUser } from "@/types/ManagedUser";
|
import type { ManagedUser } from "@/types/ManagedUser";
|
||||||
import type {
|
import type {
|
||||||
FollowUpReminder,
|
FollowUpReminder,
|
||||||
@@ -135,15 +178,58 @@ import { getAttachmentReadURL } from "@/utils/attachment";
|
|||||||
import { parseDateTime } from "@/utils/date";
|
import { parseDateTime } from "@/utils/date";
|
||||||
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
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({
|
defineOptions({
|
||||||
name: "FollowUpReminderEdit"
|
name: "FollowUpReminderEdit"
|
||||||
});
|
});
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
|
const routeNavBarTitle = computed(() => {
|
||||||
|
switch (route.name) {
|
||||||
|
case "CustomerFollowUpReminderCreate":
|
||||||
|
return "新增跟进提醒";
|
||||||
|
case "CustomerFollowUpReminderEdit":
|
||||||
|
return "编辑跟进提醒";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
});
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const currentStoreStore = useCurrentStoreStore();
|
const currentStoreStore = useCurrentStoreStore();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
|
|
||||||
const routeId = computed(() => String(route.params.id || ""));
|
const routeId = computed(() => String(route.params.id || ""));
|
||||||
const isEditMode = computed(() => !!routeId.value);
|
const isEditMode = computed(() => !!routeId.value);
|
||||||
@@ -567,7 +653,7 @@ async function save(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navBarStore.setRightText(isEditMode.value ? "保存" : "提交", "var(--td-brand-color)", save);
|
setPageNavBarRightText(isEditMode.value ? "保存" : "提交", "var(--td-brand-color)", save);
|
||||||
try {
|
try {
|
||||||
await loadForm();
|
await loadForm();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -575,7 +661,7 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
onUnmounted(() => clearPageNavBarRight());
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<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>
|
</style>
|
||||||
|
|||||||
@@ -1,180 +1,236 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-can="permissionCodes.customerFollowUpReminder.read" class="follow-up-reminder-list">
|
<div class="page-layout navbar follow-up-reminder-list">
|
||||||
<div class="filters glass">
|
<t-navbar
|
||||||
<t-input
|
fixed
|
||||||
v-model="customerSearchKeyword"
|
:z-index="20"
|
||||||
class="customer"
|
title="客户跟进提醒"
|
||||||
type="search"
|
left-arrow
|
||||||
borderless
|
@left-click="$router.back()"
|
||||||
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="list-wrap">
|
<template #right>
|
||||||
<customer-profile-card class="customer" :customer="selectedCustomer" />
|
<div
|
||||||
<t-cell-group class="summary" theme="card">
|
class="nav-actions"
|
||||||
<t-cell title="提醒数量" :note="`共 ${pageResult.total} 条`" />
|
v-if="(canCreate) && pageNavBarActionList.length"
|
||||||
<t-cell v-if="dateFilterType !== 'all'" title="提醒时间" :note="dateFilterLabel" />
|
>
|
||||||
<t-cell v-if="selectedResponsibleId" title="负责人" :note="selectedResponsibleName" />
|
<t-popover
|
||||||
</t-cell-group>
|
v-model:visible="pageNavBarActionVisible"
|
||||||
<t-cell-group v-if="pageResult.list.length" class="items fix-last-cell-line empty-cell-title-margin" theme="card">
|
placement="bottom-right"
|
||||||
<t-swipe-cell
|
:show-arrow="false"
|
||||||
v-for="(item, index) in pageResult.list"
|
theme="light"
|
||||||
:key="item.id || index"
|
|
||||||
class="item"
|
|
||||||
>
|
>
|
||||||
<t-cell
|
<t-button
|
||||||
v-entrance-transition="{ step: 30 }"
|
class="trigger"
|
||||||
class="cell"
|
variant="text"
|
||||||
arrow
|
:aria-label="'更多操作'"
|
||||||
@click="toDetail(item)"
|
type="button"
|
||||||
>
|
>
|
||||||
<template #leftIcon>
|
<template #icon>
|
||||||
<t-image
|
<t-icon name="ellipsis" />
|
||||||
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>
|
||||||
<template #title>
|
</t-button>
|
||||||
<div class="title">
|
<template #content>
|
||||||
<div class="name-channel">
|
<div class="menu">
|
||||||
<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
|
<t-button
|
||||||
v-if="canComplete && item.status === 'PENDING'"
|
v-for="action in pageNavBarActionList"
|
||||||
class="complete swipe-cell-button"
|
:key="action.key"
|
||||||
|
class="menu-item"
|
||||||
variant="text"
|
variant="text"
|
||||||
:loading="operatingId === item.id && operatingType === 'complete'"
|
type="button"
|
||||||
@click.stop="confirmComplete(item)"
|
:theme="action.theme"
|
||||||
>完成</t-button>
|
:loading="action.loading"
|
||||||
<t-button
|
:disabled="action.disabled || action.loading"
|
||||||
v-if="canDelete"
|
@click="handlePageNavBarAction(action)"
|
||||||
class="delete swipe-cell-button"
|
>
|
||||||
variant="text"
|
<template v-if="action.icon" #icon>
|
||||||
:loading="operatingId === item.id && operatingType === 'delete'"
|
<t-icon :name="action.icon" />
|
||||||
@click.stop="confirmDelete(item)"
|
</template>
|
||||||
>删除</t-button>
|
<span v-text="action.text" />
|
||||||
|
</t-button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</t-swipe-cell>
|
</t-popover>
|
||||||
</t-cell-group>
|
</div>
|
||||||
<div class="center-tips" v-text="isLoading ? '正在加载提醒' : pageResult.list.length ? (isNoMore ? '已经到底了' : '上拉加载更多') : '暂无跟进提醒'" />
|
</template>
|
||||||
</div>
|
</t-navbar>
|
||||||
</t-pull-down-refresh>
|
<main v-can="permissionCodes.customerFollowUpReminder.read" class="page-content scroll list">
|
||||||
<customer-selector
|
<t-pull-down-refresh
|
||||||
v-model="selectedCustomerId"
|
class="pull-refresh"
|
||||||
v-model:visible="customerSelectorVisible"
|
v-model="isRefreshing"
|
||||||
:initial-keyword="customerSearchKeyword"
|
:refresh-timeout="30000"
|
||||||
:store-id="currentStoreStore.currentStoreId"
|
@refresh="refresh"
|
||||||
:enable-scan="true"
|
@scrolltolower="fetch"
|
||||||
@change="handleCustomerSelected"
|
>
|
||||||
/>
|
<div class="filters glass">
|
||||||
<managed-user-selector
|
<t-input
|
||||||
v-model="selectedResponsibleId"
|
v-model="customerSearchKeyword"
|
||||||
v-model:visible="responsibleSelectorVisible"
|
class="customer"
|
||||||
:store-id="currentStoreStore.currentStoreId"
|
type="search"
|
||||||
@change="handleResponsibleSelected"
|
borderless
|
||||||
/>
|
placeholder="输入客户编码、姓名或拼音"
|
||||||
<t-popup v-model="startVisible" placement="bottom">
|
@enter="applyCustomerSearch"
|
||||||
<t-date-time-picker
|
@clear="clearCustomer"
|
||||||
v-if="startVisible"
|
>
|
||||||
v-model="startDraft"
|
<template #suffix-icon>
|
||||||
format="YYYY-MM-DD HH:mm"
|
<t-button
|
||||||
:mode="['date', 'minute']"
|
size="extra-small"
|
||||||
title="提醒开始时间"
|
theme="primary"
|
||||||
@cancel="startVisible = false"
|
variant="outline"
|
||||||
@confirm="confirmStart"
|
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>
|
<managed-user-selector
|
||||||
<t-popup v-model="endVisible" placement="bottom">
|
v-model="selectedResponsibleId"
|
||||||
<t-date-time-picker
|
v-model:visible="responsibleSelectorVisible"
|
||||||
v-if="endVisible"
|
:store-id="currentStoreStore.currentStoreId"
|
||||||
v-model="endDraft"
|
@change="handleResponsibleSelected"
|
||||||
format="YYYY-MM-DD HH:mm"
|
|
||||||
:mode="['date', 'minute']"
|
|
||||||
title="提醒结束时间"
|
|
||||||
@cancel="endVisible = false"
|
|
||||||
@confirm="confirmEnd"
|
|
||||||
/>
|
/>
|
||||||
</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>
|
</div>
|
||||||
<nav-bar-action-menu v-if="canCreate" :actions="actionList" />
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import type { NavBarAction } from "@/types/NavBarAction";
|
||||||
import { DialogPlugin, type DropdownValue } from "tdesign-mobile-vue";
|
import { DialogPlugin, type DropdownValue } from "tdesign-mobile-vue";
|
||||||
import { Time } from "timi-web";
|
import { Time } from "timi-web";
|
||||||
import { type PageResult, useUserStore } from "timi-web-api";
|
import { type PageResult, useUserStore } from "timi-web-api";
|
||||||
@@ -185,14 +241,22 @@ import CustomerAPI from "@/api/CustomerAPI";
|
|||||||
import CustomerSelector from "@/components/CustomerSelector.vue";
|
import CustomerSelector from "@/components/CustomerSelector.vue";
|
||||||
import ManagedUserSelector from "@/pages/followUpReminder/component/ManagedUserSelector.vue";
|
import ManagedUserSelector from "@/pages/followUpReminder/component/ManagedUserSelector.vue";
|
||||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
import type { Customer } from "@/types/Customer";
|
|
||||||
import type { ManagedUser } from "@/types/ManagedUser";
|
import type { ManagedUser } from "@/types/ManagedUser";
|
||||||
import type { FollowUpReminder, FollowUpReminderPage, FollowUpReminderStatus } from "@/types/FollowUpReminder";
|
import type { FollowUpReminder, FollowUpReminderPage, FollowUpReminderStatus } from "@/types/FollowUpReminder";
|
||||||
import { getCustomerPhotoURL } from "@/utils/customer";
|
import { getCustomerPhotoURL } from "@/utils/customer";
|
||||||
import { parseDateTime } from "@/utils/date";
|
import { parseDateTime } from "@/utils/date";
|
||||||
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
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";
|
type DateFilterType = "all" | "today" | "next7" | "custom";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
@@ -203,7 +267,6 @@ const router = useRouter();
|
|||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const currentStoreStore = useCurrentStoreStore();
|
const currentStoreStore = useCurrentStoreStore();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
|
|
||||||
const isGlobalManager = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
|
const isGlobalManager = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
|
||||||
const canCreate = computed(() => userStore.hasPermissions(permissionCodes.customerFollowUpReminder.create));
|
const canCreate = computed(() => userStore.hasPermissions(permissionCodes.customerFollowUpReminder.create));
|
||||||
@@ -611,7 +674,7 @@ async function toDetail(item: FollowUpReminder): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navBarStore.setCustomRightVisible(canCreate.value);
|
|
||||||
try {
|
try {
|
||||||
await loadStoreScope();
|
await loadStoreScope();
|
||||||
const queryCustomerId = String(route.query.customerId || "");
|
const queryCustomerId = String(route.query.customerId || "");
|
||||||
@@ -637,7 +700,6 @@ watch(() => route.query.customerId, async value => {
|
|||||||
await refresh();
|
await refresh();
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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">
|
<div v-can="permissionCodes.orderFulfillment.create" class="fulfillment-create">
|
||||||
<t-cell-group title="履约来源" theme="card">
|
<t-cell-group title="履约来源" theme="card">
|
||||||
<t-cell title="销售订单" :note="order?.orderNo || order?.id || '未找到来源订单'" />
|
<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 MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
||||||
import ProductSkuTags from "@/components/ProductSkuTags.vue";
|
import ProductSkuTags from "@/components/ProductSkuTags.vue";
|
||||||
import ProductStockPreview from "@/components/ProductStockPreview.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 { useUserStore } from "timi-web-api";
|
||||||
import type { GaoOrderFulfillmentItemRequest } from "@/types/Fulfillment";
|
import type { GaoOrderFulfillmentItemRequest } from "@/types/Fulfillment";
|
||||||
import type { GaoSalesOrderItem, SalesOrder } from "@/types/SalesOrder";
|
import type { GaoSalesOrderItem, SalesOrder } from "@/types/SalesOrder";
|
||||||
@@ -178,10 +221,42 @@ import {
|
|||||||
import { uploadPhotoList } from "@/utils/photo";
|
import { uploadPhotoList } from "@/utils/photo";
|
||||||
import { getProductPhotoURL, getProductQuantityStep } from "@/utils/product";
|
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" });
|
defineOptions({ name: "OrderFulfillmentCreate" });
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const order = ref<SalesOrder>();
|
const order = ref<SalesOrder>();
|
||||||
const quantityMap = reactive<Record<string, string | number>>({});
|
const quantityMap = reactive<Record<string, string | number>>({});
|
||||||
@@ -615,12 +690,12 @@ async function save(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navBarStore.setRightText("提交", "var(--td-brand-color)", save);
|
setPageNavBarRightText("提交", "var(--td-brand-color)", save);
|
||||||
await loadData();
|
await loadData();
|
||||||
});
|
});
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
window.clearTimeout(stockPreviewTimer);
|
window.clearTimeout(stockPreviewTimer);
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
});
|
});
|
||||||
</script>
|
</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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<t-navbar
|
||||||
|
fixed
|
||||||
|
:z-index="20"
|
||||||
|
title="履约单详情"
|
||||||
|
left-arrow
|
||||||
|
@left-click="$router.back()"
|
||||||
|
/>
|
||||||
<div v-can="permissionCodes.orderFulfillment.read" class="fulfillment-detail">
|
<div v-can="permissionCodes.orderFulfillment.read" class="fulfillment-detail">
|
||||||
<template v-if="fulfillment">
|
<template v-if="fulfillment">
|
||||||
<t-cell-group title="履约单信息" theme="card" v-entrance-transition>
|
<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 ProductSkuTags from "@/components/ProductSkuTags.vue";
|
||||||
import ProductStockPreview from "@/components/ProductStockPreview.vue";
|
import ProductStockPreview from "@/components/ProductStockPreview.vue";
|
||||||
import OrderFulfillmentRevoke from "@/pages/fulfillment/components/OrderFulfillmentRevoke.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 { GaoSalesOrderItemType, SalesOrder } from "@/types/SalesOrder";
|
||||||
import type { PhotoItem } from "@/types/Photo";
|
import type { PhotoItem } from "@/types/Photo";
|
||||||
import { addPackageQuantity, getPackageQuantityText } from "@/utils/package";
|
import { addPackageQuantity, getPackageQuantityText } from "@/utils/package";
|
||||||
@@ -146,11 +151,12 @@ import { permissionCodes } from "@/utils/permission";
|
|||||||
import type { ProductStockPreviewItem } from "@/utils/productStock";
|
import type { ProductStockPreviewItem } from "@/utils/productStock";
|
||||||
import { buildProductStockPreview, mergeProductStockRequirements } from "@/utils/productStock";
|
import { buildProductStockPreview, mergeProductStockRequirements } from "@/utils/productStock";
|
||||||
|
|
||||||
|
import type { OrderFulfillment, OrderFulfillmentItem } from "@/types/Fulfillment";
|
||||||
|
|
||||||
type ReasonAction = "reject" | "cancel";
|
type ReasonAction = "reject" | "cancel";
|
||||||
defineOptions({ name: "OrderFulfillmentDetail" });
|
defineOptions({ name: "OrderFulfillmentDetail" });
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const fulfillment = ref<OrderFulfillment>();
|
const fulfillment = ref<OrderFulfillment>();
|
||||||
const order = ref<SalesOrder>();
|
const order = ref<SalesOrder>();
|
||||||
@@ -341,7 +347,6 @@ async function submitReason(): Promise<void> {
|
|||||||
finally { operating.value = false; }
|
finally { operating.value = false; }
|
||||||
}
|
}
|
||||||
onMounted(loadData);
|
onMounted(loadData);
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
|
|||||||
@@ -1,161 +1,217 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-can="permissionCodes.orderFulfillment.read" class="fulfillment-list">
|
<div class="page-layout navbar fulfillment-list">
|
||||||
<div class="filters glass">
|
<t-navbar
|
||||||
<t-input
|
fixed
|
||||||
class="customer"
|
:z-index="20"
|
||||||
:value="customerDisplayText"
|
title="履约记录"
|
||||||
readonly
|
left-arrow
|
||||||
borderless
|
@left-click="$router.back()"
|
||||||
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="list-wrap">
|
<template #right>
|
||||||
<t-cell-group v-if="salesOrder || selectedSkuOptionList.length" class="filter-info" theme="card">
|
<div
|
||||||
<template v-if="salesOrder">
|
class="nav-actions"
|
||||||
<t-cell title="订单号" :note="salesOrder.orderNo || salesOrder.id || '未知订单'" />
|
v-if="(canCreate) && pageNavBarActionList.length"
|
||||||
<t-cell title="订单类型" :note="getSalesOrderTypeText(salesOrder.orderType)" />
|
>
|
||||||
<t-cell title="订单状态">
|
<t-popover
|
||||||
<template #note>
|
v-model:visible="pageNavBarActionVisible"
|
||||||
<t-tag
|
placement="bottom-right"
|
||||||
:content="getSalesOrderStatusText(salesOrder.status)"
|
:show-arrow="false"
|
||||||
:theme="getStatusTheme(salesOrder.status)"
|
theme="light"
|
||||||
variant="light-outline"
|
>
|
||||||
/>
|
<t-button
|
||||||
|
class="trigger"
|
||||||
|
variant="text"
|
||||||
|
:aria-label="'更多操作'"
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
<template #icon>
|
||||||
|
<t-icon name="ellipsis" />
|
||||||
</template>
|
</template>
|
||||||
</t-cell>
|
</t-button>
|
||||||
</template>
|
<template #content>
|
||||||
<t-cell v-if="selectedSkuOptionList.length" class="sku-filter-cell" title="已筛选 SKU">
|
<div class="menu">
|
||||||
<template #note>
|
<t-button
|
||||||
<div class="selected-sku-list">
|
v-for="action in pageNavBarActionList"
|
||||||
<t-tag
|
:key="action.key"
|
||||||
v-for="sku in selectedSkuOptionList"
|
class="menu-item"
|
||||||
:key="sku.skuId"
|
variant="text"
|
||||||
size="small"
|
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"
|
theme="primary"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
:content="formatSelectedSkuName(sku.productName, sku.skuName)"
|
content="选择客户"
|
||||||
|
@click.stop="customerSelectorVisible = true"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</t-cell>
|
</t-input>
|
||||||
</t-cell-group>
|
<t-dropdown-menu ref="filterMenuRef" class="menus">
|
||||||
<t-cell-group v-if="isCustomDate" class="date-summary" theme="card">
|
<t-dropdown-item
|
||||||
<t-cell
|
v-model="dateFilterType"
|
||||||
title="开始时间"
|
:label="dateFilterLabel"
|
||||||
:note="dateRange[0] || '-'"
|
:options="dateOptions"
|
||||||
arrow
|
@change="selectDateFilter"
|
||||||
@click="openStartTime"
|
/>
|
||||||
/>
|
<t-dropdown-item
|
||||||
<t-cell
|
:label="skuFilterLabel"
|
||||||
title="结束时间"
|
:options="[]"
|
||||||
:note="dateRange[1] || '-'"
|
@open="openSkuFilter"
|
||||||
arrow
|
/>
|
||||||
@click="openEndTime"
|
<t-dropdown-item
|
||||||
/>
|
v-model="status"
|
||||||
</t-cell-group>
|
label="履约状态"
|
||||||
<div v-if="list.length" class="items">
|
:options="statusOptions"
|
||||||
<order-fulfillment-list-cell
|
@change="selectStatus"
|
||||||
v-for="item in list"
|
/>
|
||||||
:key="item.id"
|
</t-dropdown-menu>
|
||||||
class="item"
|
|
||||||
:fulfillment="item"
|
|
||||||
v-entrance-transition="{ step: 30 }"
|
|
||||||
@detail="toDetail(item)"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="center-tips" v-text="loading ? '正在加载履约单' : '暂无履约单'" />
|
<div class="list-wrap">
|
||||||
<div class="center-tips" v-text="loading ? '正在加载' : noMore ? '已经到底了' : '上拉加载更多'" />
|
<t-cell-group v-if="salesOrder || selectedSkuOptionList.length" class="filter-info" theme="card">
|
||||||
</div>
|
<template v-if="salesOrder">
|
||||||
</t-pull-down-refresh>
|
<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>
|
</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>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import type { NavBarAction } from "@/types/NavBarAction";
|
||||||
import { type DropdownValue } from "tdesign-mobile-vue";
|
import { type DropdownValue } from "tdesign-mobile-vue";
|
||||||
import { Time } from "timi-web";
|
import { Time } from "timi-web";
|
||||||
import { useUserStore } from "timi-web-api";
|
import { useUserStore } from "timi-web-api";
|
||||||
@@ -163,12 +219,7 @@ import CustomerAPI from "@/api/CustomerAPI";
|
|||||||
import FulfillmentAPI from "@/api/FulfillmentAPI";
|
import FulfillmentAPI from "@/api/FulfillmentAPI";
|
||||||
import SalesOrderAPI from "@/api/SalesOrderAPI";
|
import SalesOrderAPI from "@/api/SalesOrderAPI";
|
||||||
import CustomerSelector from "@/components/CustomerSelector.vue";
|
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 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 { Customer } from "@/types/Customer";
|
||||||
import type { SalesOrder } from "@/types/SalesOrder";
|
import type { SalesOrder } from "@/types/SalesOrder";
|
||||||
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
|
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
|
||||||
@@ -177,12 +228,22 @@ import { Message } from "@/utils/message";
|
|||||||
import { permissionCodes } from "@/utils/permission";
|
import { permissionCodes } from "@/utils/permission";
|
||||||
import { getSalesOrderStatusText, getSalesOrderTypeText, getStatusTheme } from "@/utils/salesOrder";
|
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" });
|
defineOptions({ name: "OrderFulfillmentList" });
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const filterMenuRef = ref<{ collapseMenu: () => void }>();
|
const filterMenuRef = ref<{ collapseMenu: () => void }>();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const canCreate = computed(() => userStore.hasPermissions(permissionCodes.orderFulfillment.create));
|
const canCreate = computed(() => userStore.hasPermissions(permissionCodes.orderFulfillment.create));
|
||||||
const actions = computed<NavBarAction[]>(() => [
|
const actions = computed<NavBarAction[]>(() => [
|
||||||
@@ -531,8 +592,7 @@ function getCurrentRouteDepth(): number {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navBarStore.clearRight();
|
|
||||||
navBarStore.setCustomRightVisible(canCreate.value);
|
|
||||||
try {
|
try {
|
||||||
await loadSalesOrder();
|
await loadSalesOrder();
|
||||||
if (customerId.value) {
|
if (customerId.value) {
|
||||||
@@ -544,7 +604,6 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,11 @@
|
|||||||
<template>
|
<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">
|
<div v-can="permissionCodes.eventRecord.create" class="quick-sign-in-page">
|
||||||
<t-cell-group v-if="!isEventLoading && !eventLoadFailed" theme="card">
|
<t-cell-group v-if="!isEventLoading && !eventLoadFailed" theme="card">
|
||||||
<t-cell title="登记事件" arrow @click="eventPopupVisible = true">
|
<t-cell title="登记事件" arrow @click="eventPopupVisible = true">
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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">
|
<div v-can="corePermissionCodes.notify.create" class="notify-management-create">
|
||||||
<t-empty v-if="!canCreate" description="暂无发送通知权限" />
|
<t-empty v-if="!canCreate" description="暂无发送通知权限" />
|
||||||
<t-form v-else class="form" label-align="left" label-width="5rem">
|
<t-form v-else class="form" label-align="left" label-width="5rem">
|
||||||
@@ -82,7 +127,38 @@ import NotifyRecipientPicker, {
|
|||||||
type NotifyRecipientScopeOption
|
type NotifyRecipientScopeOption
|
||||||
} from "@/pages/notify/component/NotifyRecipientPicker.vue";
|
} from "@/pages/notify/component/NotifyRecipientPicker.vue";
|
||||||
import { corePermissionCodes, coreRoleCodes, gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
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";
|
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
@@ -90,7 +166,6 @@ defineOptions({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const currentStoreStore = useCurrentStoreStore();
|
const currentStoreStore = useCurrentStoreStore();
|
||||||
const notifyEditorRef = ref<NotifyEditorExpose>();
|
const notifyEditorRef = ref<NotifyEditorExpose>();
|
||||||
@@ -192,7 +267,7 @@ const scheduleDraftText = ref("");
|
|||||||
const minimumScheduleText = computed(() => Time.formatDateTime(new Date(Time.now() + Time.M)));
|
const minimumScheduleText = computed(() => Time.formatDateTime(new Date(Time.now() + Time.M)));
|
||||||
|
|
||||||
function updateNavActionText(): void {
|
function updateNavActionText(): void {
|
||||||
navBarStore.setRightText(scheduleAtText.value ? "提交" : "发送", "var(--td-brand-color)", saveNotification);
|
setPageNavBarRightText(scheduleAtText.value ? "提交" : "发送", "var(--td-brand-color)", saveNotification);
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(scheduleAtText, updateNavActionText);
|
watch(scheduleAtText, updateNavActionText);
|
||||||
@@ -356,7 +431,7 @@ async function loadRecipients(): Promise<void> {
|
|||||||
// ---------- 生命周期 ----------
|
// ---------- 生命周期 ----------
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
if (!canCreate.value) {
|
if (!canCreate.value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -370,7 +445,7 @@ onMounted(async () => {
|
|||||||
await loadRecipients();
|
await loadRecipients();
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
onUnmounted(() => clearPageNavBarRight());
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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">
|
<div v-can="corePermissionCodes.notify.read" class="notify-detail">
|
||||||
<t-empty
|
<t-empty
|
||||||
v-if="!detail"
|
v-if="!detail"
|
||||||
@@ -44,10 +89,41 @@ import { DialogPlugin } from "tdesign-mobile-vue";
|
|||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { getErrorMessage } from "@/utils/error";
|
import { getErrorMessage } from "@/utils/error";
|
||||||
import { getAttachmentReadURL } from "@/utils/attachment";
|
import { getAttachmentReadURL } from "@/utils/attachment";
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
import { corePermissionCodes } from "@/utils/permission";
|
|
||||||
import NotifyContent from "@/pages/notify/component/NotifyContent.vue";
|
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 NotifyTagTheme = "default" | "success" | "warning" | "primary" | "danger";
|
||||||
type RecipientFilter = "all" | "unread" | "read";
|
type RecipientFilter = "all" | "unread" | "read";
|
||||||
|
|
||||||
@@ -57,7 +133,6 @@ defineOptions({
|
|||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const canDeleteNotify = computed(() => userStore.hasPermissions(corePermissionCodes.notify.delete));
|
const canDeleteNotify = computed(() => userStore.hasPermissions(corePermissionCodes.notify.delete));
|
||||||
const canCancelNotify = computed(() => userStore.hasPermissions(corePermissionCodes.notify.cancel));
|
const canCancelNotify = computed(() => userStore.hasPermissions(corePermissionCodes.notify.cancel));
|
||||||
@@ -108,7 +183,7 @@ async function loadDetail(): Promise<void> {
|
|||||||
const requestToken = loadToken + 1;
|
const requestToken = loadToken + 1;
|
||||||
loadToken = requestToken;
|
loadToken = requestToken;
|
||||||
detail.value = undefined;
|
detail.value = undefined;
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
const notifyId = String(route.params.id || "");
|
const notifyId = String(route.params.id || "");
|
||||||
if (!notifyId) {
|
if (!notifyId) {
|
||||||
return;
|
return;
|
||||||
@@ -133,7 +208,7 @@ async function loadDetail(): Promise<void> {
|
|||||||
|
|
||||||
function setRightAction(): void {
|
function setRightAction(): void {
|
||||||
if (detail.value?.id && canDeleteNotify.value) {
|
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() {
|
async onConfirm() {
|
||||||
dialog.destroy();
|
dialog.destroy();
|
||||||
isDeleting.value = true;
|
isDeleting.value = true;
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
try {
|
try {
|
||||||
await NotifyAPI.managementDelete(notifyId);
|
await NotifyAPI.managementDelete(notifyId);
|
||||||
Message.success("通知已删除");
|
Message.success("通知已删除");
|
||||||
@@ -257,8 +332,8 @@ watch(() => route.params.id, async () => {
|
|||||||
await loadDetail();
|
await loadDetail();
|
||||||
}, { immediate: true });
|
}, { immediate: true });
|
||||||
|
|
||||||
onMounted(() => navBarStore.clearRight());
|
onMounted(() => clearPageNavBarRight());
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
onUnmounted(() => clearPageNavBarRight());
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
@@ -281,4 +356,45 @@ onUnmounted(() => navBarStore.clearRight());
|
|||||||
background: #FFF;
|
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>
|
</style>
|
||||||
|
|||||||
+177
-58
@@ -1,60 +1,108 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-can="corePermissionCodes.notify.read" class="notify-management">
|
<div class="page-layout navbar notify-management">
|
||||||
<t-pull-down-refresh
|
<t-navbar
|
||||||
v-model="isRefreshing"
|
fixed
|
||||||
:refresh-timeout="30000"
|
:z-index="20"
|
||||||
@refresh="refresh"
|
title="通知管理"
|
||||||
@scrolltolower="loadMore"
|
left-arrow
|
||||||
|
@left-click="$router.back()"
|
||||||
>
|
>
|
||||||
<t-cell-group
|
<template #right>
|
||||||
v-if="pageResult.list.length"
|
<div
|
||||||
class="items fix-last-cell-line"
|
v-if="pageNavBarRight.icon || pageNavBarRight.text"
|
||||||
theme="card"
|
class="nav-right-slot"
|
||||||
>
|
|
||||||
<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)">
|
<t-badge
|
||||||
<template #leftIcon>
|
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined"
|
||||||
<div class="icon" :class="{ scheduled: isScheduled(item) }">
|
class="badge"
|
||||||
<t-icon :name="isScheduled(item) ? 'time' : 'notification'" size="1.25rem" />
|
:count="pageNavBarRight.badge"
|
||||||
</div>
|
: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>
|
||||||
<template #title>
|
</t-swipe-cell>
|
||||||
<div class="title">
|
</t-cell-group>
|
||||||
<span v-text="getSubject(item)" />
|
<t-empty v-else-if="!isLoading" description="暂无已发送通知" />
|
||||||
</div>
|
<div class="center-tips" v-text="loadStateText" />
|
||||||
</template>
|
</t-pull-down-refresh>
|
||||||
<template #description>
|
</main>
|
||||||
<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>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -64,7 +112,38 @@ import { NotifyAPI, type Notify, type NotifyManagementItem, type Page, type Page
|
|||||||
import { DialogPlugin } from "tdesign-mobile-vue";
|
import { DialogPlugin } from "tdesign-mobile-vue";
|
||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { getErrorMessage } from "@/utils/error";
|
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";
|
import { corePermissionCodes } from "@/utils/permission";
|
||||||
|
|
||||||
type NotifyTagTheme = "default" | "success" | "warning" | "primary" | "danger";
|
type NotifyTagTheme = "default" | "success" | "warning" | "primary" | "danger";
|
||||||
@@ -75,7 +154,6 @@ defineOptions({
|
|||||||
|
|
||||||
const pageSize = 20;
|
const pageSize = 20;
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const canReadNotify = computed(() => userStore.hasPermissions(corePermissionCodes.notify.read));
|
const canReadNotify = computed(() => userStore.hasPermissions(corePermissionCodes.notify.read));
|
||||||
const canCreateNotify = computed(() => userStore.hasPermissions(corePermissionCodes.notify.create));
|
const canCreateNotify = computed(() => userStore.hasPermissions(corePermissionCodes.notify.create));
|
||||||
@@ -255,17 +333,17 @@ async function confirmDelete(item: NotifyManagementItem): Promise<void> {
|
|||||||
// ---------- 生命周期 ----------
|
// ---------- 生命周期 ----------
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
if (!canReadNotify.value) {
|
if (!canReadNotify.value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (canCreateNotify.value) {
|
if (canCreateNotify.value) {
|
||||||
navBarStore.setRightText("新建", "var(--td-brand-color)", toCreate);
|
setPageNavBarRightText("新建", "var(--td-brand-color)", toCreate);
|
||||||
}
|
}
|
||||||
await reloadList();
|
await reloadList();
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
onUnmounted(() => clearPageNavBarRight());
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<t-navbar
|
||||||
|
fixed
|
||||||
|
:z-index="20"
|
||||||
|
title="发送用户"
|
||||||
|
left-arrow
|
||||||
|
@left-click="$router.back()"
|
||||||
|
/>
|
||||||
<div v-can="corePermissionCodes.notify.read" class="notify-recipient-list">
|
<div v-can="corePermissionCodes.notify.read" class="notify-recipient-list">
|
||||||
<template v-if="detail">
|
<template v-if="detail">
|
||||||
<t-segmented
|
<t-segmented
|
||||||
@@ -55,7 +62,7 @@ import { PassTimeLabel, Time } from "timi-web";
|
|||||||
import { NotifyAPI, type Notify, type NotifyDetail } from "timi-web-api";
|
import { NotifyAPI, type Notify, type NotifyDetail } from "timi-web-api";
|
||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { getErrorMessage } from "@/utils/error";
|
import { getErrorMessage } from "@/utils/error";
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
import { corePermissionCodes } from "@/utils/permission";
|
import { corePermissionCodes } from "@/utils/permission";
|
||||||
|
|
||||||
type RecipientFilter = "all" | "unread" | "read";
|
type RecipientFilter = "all" | "unread" | "read";
|
||||||
@@ -66,7 +73,6 @@ defineOptions({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
|
|
||||||
// ---------- 通知数据 ----------
|
// ---------- 通知数据 ----------
|
||||||
|
|
||||||
@@ -164,7 +170,6 @@ watch(() => route.query.filter, () => {
|
|||||||
recipientFilter.value = getRecipientFilterFromRoute();
|
recipientFilter.value = getRecipientFilterFromRoute();
|
||||||
});
|
});
|
||||||
|
|
||||||
onMounted(() => navBarStore.clearRight());
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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">
|
<div v-can="corePermissionCodes.notify.read" class="notify-detail">
|
||||||
<notify-content
|
<notify-content
|
||||||
v-if="detail"
|
v-if="detail"
|
||||||
@@ -17,16 +62,46 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { NotifyAPI, type NotifyDetail } from "timi-web-api";
|
import { NotifyAPI, type NotifyDetail } from "timi-web-api";
|
||||||
import { DialogPlugin } from "tdesign-mobile-vue";
|
import { DialogPlugin } from "tdesign-mobile-vue";
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
import { getErrorMessage } from "@/utils/error";
|
|
||||||
import { getAttachmentReadURL } from "@/utils/attachment";
|
import { getAttachmentReadURL } from "@/utils/attachment";
|
||||||
import { corePermissionCodes } from "@/utils/permission";
|
import { corePermissionCodes } from "@/utils/permission";
|
||||||
import { Message } from "@/utils/message.ts";
|
import { Message } from "@/utils/message.ts";
|
||||||
import NotifyContent from "@/pages/notify/component/NotifyContent.vue";
|
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 route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "UserNotifyDetail"
|
name: "UserNotifyDetail"
|
||||||
@@ -42,7 +117,7 @@ let loadToken = 0;
|
|||||||
async function loadDetail(): Promise<void> {
|
async function loadDetail(): Promise<void> {
|
||||||
const requestToken = loadToken + 1;
|
const requestToken = loadToken + 1;
|
||||||
loadToken = requestToken;
|
loadToken = requestToken;
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
const detailId = String(route.params.id || "");
|
const detailId = String(route.params.id || "");
|
||||||
if (!detailId) {
|
if (!detailId) {
|
||||||
detail.value = undefined;
|
detail.value = undefined;
|
||||||
@@ -72,7 +147,7 @@ async function loadDetail(): Promise<void> {
|
|||||||
|
|
||||||
function setDeleteAction(): void {
|
function setDeleteAction(): void {
|
||||||
if (detail.value?.id) {
|
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;
|
isDeleting.value = true;
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
try {
|
try {
|
||||||
await NotifyAPI.deleteInternal(detailId);
|
await NotifyAPI.deleteInternal(detailId);
|
||||||
Message.success("通知已删除");
|
Message.success("通知已删除");
|
||||||
@@ -150,11 +225,11 @@ watch(() => route.params.id, async () => {
|
|||||||
}, { immediate: true });
|
}, { immediate: true });
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -162,4 +237,45 @@ onUnmounted(() => {
|
|||||||
.notify-detail {
|
.notify-detail {
|
||||||
padding: var(--app-nav-height) 0 1rem 0;
|
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>
|
</style>
|
||||||
|
|||||||
@@ -1,67 +1,115 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-can="corePermissionCodes.notify.read" class="notify-list">
|
<div class="page-layout navbar notify-list">
|
||||||
<t-segmented
|
<t-navbar
|
||||||
v-model="filterMode"
|
fixed
|
||||||
class="filter"
|
:z-index="20"
|
||||||
block
|
title="站内通知"
|
||||||
:options="filterOptions"
|
left-arrow
|
||||||
@change="switchFilter"
|
@left-click="$router.back()"
|
||||||
v-entrance-transition
|
|
||||||
/>
|
|
||||||
<t-pull-down-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">
|
<template #right>
|
||||||
<t-swipe-cell
|
<div
|
||||||
v-for="item in pageResult.list"
|
v-if="pageNavBarRight.icon || pageNavBarRight.text"
|
||||||
:key="item.id"
|
class="nav-right-slot"
|
||||||
class="item"
|
|
||||||
v-entrance-transition="{ step: 30 }"
|
|
||||||
>
|
>
|
||||||
<t-cell arrow hover @click="toDetail(item)">
|
<t-badge
|
||||||
<template #leftIcon>
|
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined"
|
||||||
<div class="icon" :class="{ unread: isUnread(item) }">
|
class="badge"
|
||||||
<t-icon name="notification" size="1.25rem" />
|
:count="pageNavBarRight.badge"
|
||||||
</div>
|
:max-count="99"
|
||||||
</template>
|
:show-zero="false"
|
||||||
<template #title>
|
>
|
||||||
<div class="title">
|
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
|
||||||
<span v-text="getSubject(item)" />
|
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
|
||||||
</div>
|
</button>
|
||||||
</template>
|
</t-badge>
|
||||||
<template #description>
|
<button
|
||||||
<pass-time-label :timestamp="item.sendAt" underline />
|
v-else-if="pageNavBarRight.icon"
|
||||||
</template>
|
class="button"
|
||||||
<template #note>
|
type="button"
|
||||||
<t-tag
|
:disabled="pageNavBarRight.disabled"
|
||||||
v-if="filterMode === 'all' && isUnread(item)"
|
@click="handlePageNavBarRightAction"
|
||||||
class="unread-label"
|
>
|
||||||
|
<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"
|
theme="danger"
|
||||||
size="small"
|
:loading="deletingId === item.id"
|
||||||
>未读</t-tag>
|
@click.stop="confirmDelete(item)"
|
||||||
|
>
|
||||||
|
删除
|
||||||
|
</t-button>
|
||||||
</template>
|
</template>
|
||||||
</t-cell>
|
</t-swipe-cell>
|
||||||
<template #right>
|
</t-cell-group>
|
||||||
<t-button
|
<t-empty
|
||||||
class="delete"
|
v-else-if="!isLoading"
|
||||||
theme="danger"
|
description="暂无站内通知"
|
||||||
:loading="deletingId === item.id"
|
/>
|
||||||
@click.stop="confirmDelete(item)"
|
<div class="center-tips" v-text="loadStateText" />
|
||||||
>
|
</t-pull-down-refresh>
|
||||||
删除
|
</main>
|
||||||
</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>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -70,10 +118,41 @@ import { PassTimeLabel } from "timi-web";
|
|||||||
import { NotifyAPI, type NotifyDetail, type Page, type PageResult, useUserStore } from "timi-web-api";
|
import { NotifyAPI, type NotifyDetail, type Page, type PageResult, useUserStore } from "timi-web-api";
|
||||||
import { DialogPlugin } from "tdesign-mobile-vue";
|
import { DialogPlugin } from "tdesign-mobile-vue";
|
||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
import { getErrorMessage } from "@/utils/error";
|
|
||||||
import { corePermissionCodes } from "@/utils/permission";
|
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";
|
type NotifyFilter = "all" | "unread";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
@@ -82,7 +161,6 @@ defineOptions({
|
|||||||
|
|
||||||
const pageSize = 20;
|
const pageSize = 20;
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const canReadNotify = computed(() => userStore.hasPermissions(corePermissionCodes.notify.read));
|
const canReadNotify = computed(() => userStore.hasPermissions(corePermissionCodes.notify.read));
|
||||||
|
|
||||||
@@ -276,9 +354,9 @@ function updateNavBarAction(): void {
|
|||||||
if (!isPageActive) {
|
if (!isPageActive) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
if (0 < unreadCount.value) {
|
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 () => {
|
onMounted(async () => {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
if (!canReadNotify.value) {
|
if (!canReadNotify.value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -320,7 +398,7 @@ onMounted(async () => {
|
|||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
isPageActive = false;
|
isPageActive = false;
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
});
|
});
|
||||||
</script>
|
</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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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">
|
<div v-can="permissionCodes.packageConfig.read" class="package-config-detail">
|
||||||
<template v-if="config">
|
<template v-if="config">
|
||||||
<section class="hero" v-entrance-transition>
|
<section class="hero" v-entrance-transition>
|
||||||
@@ -92,19 +137,49 @@ import { useUserStore } from "timi-web-api";
|
|||||||
import PackageAPI from "@/api/PackageAPI";
|
import PackageAPI from "@/api/PackageAPI";
|
||||||
import ProductSkuTags from "@/components/ProductSkuTags.vue";
|
import ProductSkuTags from "@/components/ProductSkuTags.vue";
|
||||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
import type { GaoPackageConfig, PackageConfigItem, PackageConfigStatus } from "@/types/Package";
|
|
||||||
import { getErrorMessage } from "@/utils/error";
|
import { getErrorMessage } from "@/utils/error";
|
||||||
import { formatPackageAmount, getPackageConfigStatusText } from "@/utils/package";
|
import { formatPackageAmount, getPackageConfigStatusText } from "@/utils/package";
|
||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
||||||
import { getProductPhotoURL as getProductPhotoUrl } from "@/utils/product";
|
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" });
|
defineOptions({ name: "PackageConfigDetail" });
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const currentStoreStore = useCurrentStoreStore();
|
const currentStoreStore = useCurrentStoreStore();
|
||||||
const config = ref<GaoPackageConfig>();
|
const config = ref<GaoPackageConfig>();
|
||||||
@@ -197,20 +272,20 @@ function removeConfig(): void {
|
|||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await loadData();
|
await loadData();
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
if (canUpdate.value) {
|
if (canUpdate.value) {
|
||||||
navBarStore.setRightText("编辑", "var(--td-brand-color)", toEdit);
|
setPageNavBarRightText("编辑", "var(--td-brand-color)", toEdit);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(canUpdate, value => {
|
watch(canUpdate, value => {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
if (value) {
|
if (value) {
|
||||||
navBarStore.setRightText("编辑", "var(--td-brand-color)", toEdit);
|
setPageNavBarRightText("编辑", "var(--td-brand-color)", toEdit);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
onUnmounted(() => clearPageNavBarRight());
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
@@ -352,4 +427,45 @@ onUnmounted(() => navBarStore.clearRight());
|
|||||||
color: #fdba74;
|
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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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">
|
<div v-can="savePermissionCode" class="package-config-edit">
|
||||||
<t-form class="form" label-align="left" label-width="6rem" v-entrance-transition>
|
<t-form class="form" label-align="left" label-width="6rem" v-entrance-transition>
|
||||||
<t-form-item label="套餐名称" required-mark>
|
<t-form-item label="套餐名称" required-mark>
|
||||||
@@ -112,29 +157,74 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { AnimatedAmount, AnimatedNumber, Time } from "timi-web";
|
import { AnimatedAmount, Time } from "timi-web";
|
||||||
import { useUserStore } from "timi-web-api";
|
import { useUserStore } from "timi-web-api";
|
||||||
import PackageAPI from "@/api/PackageAPI";
|
import PackageAPI from "@/api/PackageAPI";
|
||||||
import ProductSelectFormItem from "@/components/productSelector/ProductSelectFormItem.vue";
|
import ProductSelectFormItem from "@/components/productSelector/ProductSelectFormItem.vue";
|
||||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
import type { GaoPackageConfig, PackageConfigItem, PackageConfigStatus } from "@/types/Package";
|
|
||||||
import ProductAPI from "@/api/ProductAPI";
|
import ProductAPI from "@/api/ProductAPI";
|
||||||
import type { Product, ProductSelection, ProductSku, ProductSkuUnit } from "@/types/Product";
|
import type { Product, ProductSelection, ProductSku, ProductSkuUnit } from "@/types/Product";
|
||||||
import { getErrorMessage } from "@/utils/error";
|
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 { Message } from "@/utils/message";
|
||||||
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
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 };
|
type PackageConfigFormItem = Partial<PackageConfigItem> & { clientKey: string };
|
||||||
|
|
||||||
defineOptions({ name: "PackageConfigEdit" });
|
defineOptions({ name: "PackageConfigEdit" });
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
|
const routeNavBarTitle = computed(() => {
|
||||||
|
switch (route.name) {
|
||||||
|
case "PackageConfigCreate":
|
||||||
|
return "新增套餐配置";
|
||||||
|
case "PackageConfigEdit":
|
||||||
|
return "编辑套餐配置";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
});
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const currentStoreStore = useCurrentStoreStore();
|
const currentStoreStore = useCurrentStoreStore();
|
||||||
const routeId = computed(() => String(route.params.id || ""));
|
const routeId = computed(() => String(route.params.id || ""));
|
||||||
const isCreateMode = computed(() => !routeId.value);
|
const isCreateMode = computed(() => !routeId.value);
|
||||||
@@ -434,7 +524,7 @@ async function loadData(): Promise<void> {
|
|||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
if (userStore.hasPermissions(savePermissionCode.value)) {
|
if (userStore.hasPermissions(savePermissionCode.value)) {
|
||||||
navBarStore.setRightText("保存", "var(--td-brand-color)", save);
|
setPageNavBarRightText("保存", "var(--td-brand-color)", save);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await loadData();
|
await loadData();
|
||||||
@@ -443,7 +533,7 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
onUnmounted(() => clearPageNavBarRight());
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<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>
|
</style>
|
||||||
|
|||||||
@@ -1,102 +1,163 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-can="permissionCodes.packageConfig.read" class="package-config-list">
|
<div class="page-layout navbar package-config-list">
|
||||||
<div class="filters glass">
|
<t-navbar
|
||||||
<t-input
|
fixed
|
||||||
v-model.trim="keyword"
|
:z-index="20"
|
||||||
class="keyword"
|
title="套餐配置"
|
||||||
borderless
|
left-arrow
|
||||||
clearable
|
@left-click="$router.back()"
|
||||||
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"
|
|
||||||
>
|
>
|
||||||
<t-cell-group
|
<template #right>
|
||||||
v-if="configList.length"
|
<div
|
||||||
class="list fix-last-cell-line empty-cell-title-margin"
|
class="nav-actions"
|
||||||
theme="card"
|
v-if="(canCreate) && pageNavBarActionList.length"
|
||||||
>
|
|
||||||
<t-cell
|
|
||||||
class="item"
|
|
||||||
v-for="item in configList"
|
|
||||||
:key="item.id"
|
|
||||||
v-entrance-transition="{ step: 30 }"
|
|
||||||
>
|
>
|
||||||
<template #title>
|
<t-popover
|
||||||
<div class="title">
|
v-model:visible="pageNavBarActionVisible"
|
||||||
<strong v-text="item.name || '未命名套餐'" />
|
placement="bottom-right"
|
||||||
<t-tag :content="getPackageConfigStatusText(item.status)" variant="light-outline" :theme="getStatusTheme(item.status)" />
|
:show-arrow="false"
|
||||||
</div>
|
theme="light"
|
||||||
</template>
|
>
|
||||||
<template #description>
|
<t-button
|
||||||
<div class="description">
|
class="trigger"
|
||||||
<div class="products">
|
variant="text"
|
||||||
<t-tag
|
:aria-label="'更多操作'"
|
||||||
v-for="productItem in item.itemList || []"
|
type="button"
|
||||||
:key="productItem.id || `${productItem.skuId}-${productItem.skuUnitId}`"
|
>
|
||||||
:content="getProductRightText(productItem)"
|
<template #icon>
|
||||||
theme="primary"
|
<t-icon name="ellipsis" />
|
||||||
variant="light"
|
</template>
|
||||||
/>
|
</t-button>
|
||||||
<t-tag v-if="!item.itemList?.length" content="暂无产品权益" />
|
<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>
|
||||||
<div class="price-actions">
|
</template>
|
||||||
<div class="price">
|
</t-popover>
|
||||||
<span class="red">¥</span>
|
</div>
|
||||||
<span class="value red" v-text="formatPackageAmount(item.standardAmount)" />
|
</template>
|
||||||
</div>
|
</t-navbar>
|
||||||
<div v-if="item.id" class="actions" @click.stop>
|
<main v-can="permissionCodes.packageConfig.read" class="page-content scroll list">
|
||||||
<t-button
|
<t-pull-down-refresh
|
||||||
class="detail"
|
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"
|
theme="primary"
|
||||||
size="extra-small"
|
variant="light"
|
||||||
content="详情"
|
|
||||||
@click.stop="toDetail(item)"
|
|
||||||
/>
|
/>
|
||||||
|
<t-tag v-if="!item.itemList?.length" content="暂无产品权益" />
|
||||||
</div>
|
</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>
|
||||||
</div>
|
</template>
|
||||||
</template>
|
</t-cell>
|
||||||
</t-cell>
|
</t-cell-group>
|
||||||
</t-cell-group>
|
<div v-else class="center-tips" v-text="loading ? '正在加载套餐配置' : '暂无套餐配置'" />
|
||||||
<div v-else class="center-tips" v-text="loading ? '正在加载套餐配置' : '暂无套餐配置'" />
|
<div class="center-tips" v-text="loadStateText" />
|
||||||
<div class="center-tips" v-text="loadStateText" />
|
</t-pull-down-refresh>
|
||||||
</t-pull-down-refresh>
|
</main>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<nav-bar-action-menu v-if="canCreate" :actions="actionList" />
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import type { NavBarAction } from "@/types/NavBarAction";
|
||||||
import { type DropdownValue } from "tdesign-mobile-vue";
|
import { type DropdownValue } from "tdesign-mobile-vue";
|
||||||
import { Toolkit } from "timi-web";
|
import { Toolkit } from "timi-web";
|
||||||
import { useUserStore } from "timi-web-api";
|
import { useUserStore } from "timi-web-api";
|
||||||
import PackageAPI from "@/api/PackageAPI";
|
import PackageAPI from "@/api/PackageAPI";
|
||||||
import type { GaoPackageConfig, PackageConfigItem, PackageConfigStatus } from "@/types/Package";
|
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 { formatPackageAmount, getPackageConfigStatusText, getPackageQuantityText } from "@/utils/package";
|
||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { permissionCodes } from "@/utils/permission";
|
import { permissionCodes } from "@/utils/permission";
|
||||||
import { getProductSkuSnapshotText } from "@/utils/product";
|
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" });
|
defineOptions({ name: "PackageConfigList" });
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const canCreate = computed(() => userStore.hasPermissions(permissionCodes.packageConfig.create));
|
const canCreate = computed(() => userStore.hasPermissions(permissionCodes.packageConfig.create));
|
||||||
const actionList = computed<NavBarAction[]>(() => canCreate.value ? [{
|
const actionList = computed<NavBarAction[]>(() => canCreate.value ? [{
|
||||||
@@ -197,8 +258,7 @@ function getProductRightText(item: PackageConfigItem): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navBarStore.clearRight();
|
|
||||||
navBarStore.setCustomRightVisible(canCreate.value);
|
|
||||||
try {
|
try {
|
||||||
await reload();
|
await reload();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -207,7 +267,6 @@ onMounted(async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
navBarStore.clearRight();
|
|
||||||
reloadByKeyword.cancel();
|
reloadByKeyword.cancel();
|
||||||
});
|
});
|
||||||
</script>
|
</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>
|
</style>
|
||||||
|
|||||||
@@ -1,70 +1,80 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-can="permissionCodes.packageConfig.read" class="package-order-config-list">
|
<div class="page-layout navbar package-order-config-list">
|
||||||
<div class="filters glass">
|
<t-navbar
|
||||||
<t-input
|
fixed
|
||||||
v-model.trim="keyword"
|
:z-index="20"
|
||||||
class="keyword"
|
title="选择套餐"
|
||||||
borderless
|
left-arrow
|
||||||
clearable
|
@left-click="$router.back()"
|
||||||
placeholder="搜索套餐名称或说明"
|
/>
|
||||||
/>
|
<main v-can="permissionCodes.packageConfig.read" class="page-content scroll list">
|
||||||
<t-dropdown-menu class="status">
|
<t-pull-down-refresh
|
||||||
<t-dropdown-item
|
class="pull-refresh"
|
||||||
v-model="status"
|
v-model="refreshing"
|
||||||
label="状态"
|
:refresh-timeout="30000"
|
||||||
:options="statusOptions"
|
@refresh="reload"
|
||||||
@change="selectStatus"
|
@scrolltolower="loadMore"
|
||||||
/>
|
|
||||||
</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"
|
|
||||||
>
|
>
|
||||||
<t-cell
|
<div class="filters glass">
|
||||||
v-for="item in configList"
|
<t-input
|
||||||
:key="item.id"
|
v-model.trim="keyword"
|
||||||
class="item"
|
class="keyword"
|
||||||
arrow
|
borderless
|
||||||
v-entrance-transition="{ step: 30 }"
|
clearable
|
||||||
@click="selectConfig(item)"
|
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>
|
<t-cell
|
||||||
<div class="title">
|
v-for="item in configList"
|
||||||
<strong class="name clip-text" v-text="item.name || '未命名套餐'" />
|
:key="item.id"
|
||||||
<t-tag :content="getPackageConfigStatusText(item.status)" variant="light-outline" :theme="getStatusTheme(item.status)" />
|
class="item"
|
||||||
</div>
|
arrow
|
||||||
</template>
|
v-entrance-transition="{ step: 30 }"
|
||||||
<template #description>
|
@click="selectConfig(item)"
|
||||||
<div class="description">
|
>
|
||||||
<div class="products">
|
<template #title>
|
||||||
<t-tag
|
<div class="title">
|
||||||
v-for="productItem in item.itemList || []"
|
<strong class="name clip-text" v-text="item.name || '未命名套餐'" />
|
||||||
:key="productItem.id || `${productItem.skuId}-${productItem.skuUnitId}`"
|
<t-tag :content="getPackageConfigStatusText(item.status)" variant="light-outline" :theme="getStatusTheme(item.status)" />
|
||||||
:content="getProductText(productItem)"
|
|
||||||
theme="primary"
|
|
||||||
variant="light"
|
|
||||||
/>
|
|
||||||
<t-tag v-if="!item.itemList?.length" content="暂无产品权益" />
|
|
||||||
</div>
|
</div>
|
||||||
<div class="price">
|
</template>
|
||||||
<span class="label gray">标准价:</span>
|
<template #description>
|
||||||
<span class="value red" v-text="formatPackageAmount(item.standardAmount)" />
|
<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>
|
||||||
</div>
|
</template>
|
||||||
</template>
|
</t-cell>
|
||||||
</t-cell>
|
</t-cell-group>
|
||||||
</t-cell-group>
|
<div v-else class="center-tips" v-text="loading ? '正在加载套餐' : '暂无套餐'" />
|
||||||
<div v-else class="center-tips" v-text="loading ? '正在加载套餐' : '暂无套餐'" />
|
<div class="center-tips" v-text="loadStateText" />
|
||||||
<div class="center-tips" v-text="loadStateText" />
|
</t-pull-down-refresh>
|
||||||
</t-pull-down-refresh>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -72,19 +82,18 @@
|
|||||||
import { type DropdownValue } from "tdesign-mobile-vue";
|
import { type DropdownValue } from "tdesign-mobile-vue";
|
||||||
import { Toolkit } from "timi-web";
|
import { Toolkit } from "timi-web";
|
||||||
import PackageAPI from "@/api/PackageAPI";
|
import PackageAPI from "@/api/PackageAPI";
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
import type { GaoPackageConfig, PackageConfigItem, PackageConfigStatus } from "@/types/Package";
|
|
||||||
import { getErrorMessage } from "@/utils/error";
|
import { getErrorMessage } from "@/utils/error";
|
||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { formatPackageAmount, getPackageConfigStatusText, getPackageQuantityText } from "@/utils/package";
|
import { formatPackageAmount, getPackageConfigStatusText, getPackageQuantityText } from "@/utils/package";
|
||||||
import { permissionCodes } from "@/utils/permission";
|
import { permissionCodes } from "@/utils/permission";
|
||||||
import { getProductSkuSnapshotText } from "@/utils/product";
|
import { getProductSkuSnapshotText } from "@/utils/product";
|
||||||
|
|
||||||
|
import type { GaoPackageConfig, PackageConfigItem, PackageConfigStatus } from "@/types/Package";
|
||||||
|
|
||||||
defineOptions({ name: "PackageOrderConfigList" });
|
defineOptions({ name: "PackageOrderConfigList" });
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
|
|
||||||
const keyword = ref("");
|
const keyword = ref("");
|
||||||
const status = ref("ALL");
|
const status = ref("ALL");
|
||||||
@@ -184,7 +193,6 @@ function getProductText(item: PackageConfigItem): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navBarStore.clearRight();
|
|
||||||
try {
|
try {
|
||||||
await reload();
|
await reload();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -193,7 +201,6 @@ onMounted(async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
navBarStore.clearRight();
|
|
||||||
reloadByKeyword.cancel();
|
reloadByKeyword.cancel();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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">
|
<div v-can="permissionCodes.customerPackage.create" class="package-purchase">
|
||||||
<t-form class="form" label-align="left" v-entrance-transition>
|
<t-form class="form" label-align="left" v-entrance-transition>
|
||||||
<t-form-item label="客户" required-mark>
|
<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 ProductSelectFormItem from "@/components/productSelector/ProductSelectFormItem.vue";
|
||||||
import ProductStockPreview from "@/components/ProductStockPreview.vue";
|
import ProductStockPreview from "@/components/ProductStockPreview.vue";
|
||||||
import { usePackagePurchase } from "@/pages/package/usePackagePurchase";
|
import { usePackagePurchase } from "@/pages/package/usePackagePurchase";
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
import { useSettingStore } from "@/store/settingStore";
|
|
||||||
import type { Customer } from "@/types/Customer";
|
import type { Customer } from "@/types/Customer";
|
||||||
import type { PhotoItem } from "@/types/Photo";
|
import type { PhotoItem } from "@/types/Photo";
|
||||||
import type { GaoPackageConfig, PackageAttachment, PackageConfigItem, PackagePurchaseItem } from "@/types/Package";
|
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 { uploadPhotoList } from "@/utils/photo";
|
||||||
import { getProductPhotoURL, getProductSkuSnapshotText } from "@/utils/product";
|
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({
|
defineOptions({
|
||||||
name: "PackagePurchase"
|
name: "PackagePurchase"
|
||||||
});
|
});
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
|
const routeNavBarTitle = computed(() => {
|
||||||
|
switch (route.name) {
|
||||||
|
case "PackagePurchase":
|
||||||
|
return "购买套餐";
|
||||||
|
case "CustomerPackageCreate":
|
||||||
|
return "创建客户套餐";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
});
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const settingStore = useSettingStore();
|
const settingStore = useSettingStore();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
|
||||||
@@ -938,9 +1024,9 @@ async function selectConfig(item: GaoPackageConfig): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
if (userStore.hasPermissions(permissionCodes.customerPackage.create)) {
|
if (userStore.hasPermissions(permissionCodes.customerPackage.create)) {
|
||||||
navBarStore.setRightText("提交", "var(--td-brand-color)", submitRecord);
|
setPageNavBarRightText("提交", "var(--td-brand-color)", submitRecord);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await loadPageData();
|
await loadPageData();
|
||||||
@@ -949,7 +1035,7 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
onUnmounted(() => clearPageNavBarRight());
|
||||||
|
|
||||||
watch(config, value => {
|
watch(config, value => {
|
||||||
if (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>
|
</style>
|
||||||
|
|||||||
@@ -1,33 +1,42 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-can="{ value: [corePermissionCodes.role.read, corePermissionCodes.permission.read], mode: 'and' }" class="permission-list">
|
<div class="page-layout navbar permission-list">
|
||||||
<t-pull-down-refresh
|
<t-navbar
|
||||||
class="list-wrapper"
|
fixed
|
||||||
v-model="isRefreshing"
|
:z-index="20"
|
||||||
:refresh-timeout="30000"
|
title="权限管理"
|
||||||
@refresh="refresh"
|
left-arrow
|
||||||
>
|
@left-click="$router.back()"
|
||||||
<div class="content">
|
/>
|
||||||
<t-cell-group v-entrance-transition class="header" theme="card">
|
<main v-can="{ value: [corePermissionCodes.role.read, corePermissionCodes.permission.read], mode: 'and' }" class="page-content scroll list">
|
||||||
<t-cell title="当前账号角色聚合权限 P">
|
<t-pull-down-refresh
|
||||||
<template #description>
|
class="list-wrapper pull-refresh"
|
||||||
<div>你拥有以下权限,可执行权限对应的功能,这些权限来自上级角色直接授权或子角色继承。</div>
|
v-model="isRefreshing"
|
||||||
<permission-legend />
|
:refresh-timeout="30000"
|
||||||
</template>
|
@refresh="refresh"
|
||||||
</t-cell>
|
>
|
||||||
|
<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>
|
||||||
<t-cell-group v-if="sortedPermissions.length" theme="card">
|
<t-empty v-if="!permissionStore.loading && !isSourceLoading" description="暂无权限" />
|
||||||
<t-swipe-cell
|
</div>
|
||||||
v-entrance-transition="{ step: 30 }"
|
</t-pull-down-refresh>
|
||||||
v-for="item in sortedPermissions"
|
</main>
|
||||||
: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>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<t-navbar
|
||||||
|
fixed
|
||||||
|
:z-index="20"
|
||||||
|
title="权限设置"
|
||||||
|
left-arrow
|
||||||
|
@left-click="$router.back()"
|
||||||
|
/>
|
||||||
<div
|
<div
|
||||||
v-can="{ value: [corePermissionCodes.role.read, corePermissionCodes.permission.read], mode: 'and' }"
|
v-can="{ value: [corePermissionCodes.role.read, corePermissionCodes.permission.read], mode: 'and' }"
|
||||||
class="permission-settings"
|
class="permission-settings"
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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
|
<div
|
||||||
v-can="{ value: [corePermissionCodes.role.read, corePermissionCodes.permission.read, corePermissionCodes.rolePermission.read], mode: 'and' }"
|
v-can="{ value: [corePermissionCodes.role.read, corePermissionCodes.permission.read, corePermissionCodes.rolePermission.read], mode: 'and' }"
|
||||||
class="role-delegation-permission-assign"
|
class="role-delegation-permission-assign"
|
||||||
@@ -45,17 +90,47 @@
|
|||||||
import type { DropdownOption, DropdownValue } from "tdesign-mobile-vue";
|
import type { DropdownOption, DropdownValue } from "tdesign-mobile-vue";
|
||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { type Permission, useUserStore } from "timi-web-api";
|
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 { getErrorMessage } from "@/utils/error";
|
||||||
import { corePermissionCodes, coreRoleCodes } from "@/utils/permission";
|
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({
|
defineOptions({
|
||||||
name: "RoleDelegationPermissionAssign"
|
name: "RoleDelegationPermissionAssign"
|
||||||
});
|
});
|
||||||
|
|
||||||
const permissionStore = usePermissionSettingsStore();
|
const permissionStore = usePermissionSettingsStore();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
@@ -146,15 +221,14 @@ async function savePermissionList(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateNavBar(): void {
|
function updateNavBar(): void {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
if (canEditActiveRole.value && canUpdateRolePermission.value) {
|
if (canEditActiveRole.value && canUpdateRolePermission.value) {
|
||||||
navBarStore.setRightText("保存", "var(--td-brand-color)", savePermissionList);
|
setPageNavBarRightText("保存", "var(--td-brand-color)", savePermissionList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
watch([canEditActiveRole, canUpdateRolePermission], updateNavBar, { immediate: true });
|
watch([canEditActiveRole, canUpdateRolePermission], updateNavBar, { immediate: true });
|
||||||
onMounted(updateNavBar);
|
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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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">
|
<div v-can="pageAccess" class="role-edit">
|
||||||
<t-form v-entrance-transition class="form" label-align="left">
|
<t-form v-entrance-transition class="form" label-align="left">
|
||||||
<t-form-item label="名称">
|
<t-form-item label="名称">
|
||||||
@@ -102,7 +147,46 @@ import { BottomPopup } from "timi-tdesign-mobile";
|
|||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { useUserStore } from "timi-web-api";
|
import { useUserStore } from "timi-web-api";
|
||||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
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 {
|
import {
|
||||||
moduleCode,
|
moduleCode,
|
||||||
type Permission,
|
type Permission,
|
||||||
@@ -110,18 +194,24 @@ import {
|
|||||||
type RoleDraft,
|
type RoleDraft,
|
||||||
usePermissionSettingsStore
|
usePermissionSettingsStore
|
||||||
} from "@/store/permissionSettingsStore";
|
} 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({
|
defineOptions({
|
||||||
name: "RoleEdit"
|
name: "RoleEdit"
|
||||||
});
|
});
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
|
const routeNavBarTitle = computed(() => {
|
||||||
|
switch (route.name) {
|
||||||
|
case "RoleCreate":
|
||||||
|
return "新增角色";
|
||||||
|
case "RoleEdit":
|
||||||
|
return "编辑角色";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
});
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const permissionStore = usePermissionSettingsStore();
|
const permissionStore = usePermissionSettingsStore();
|
||||||
const currentStoreStore = useCurrentStoreStore();
|
const currentStoreStore = useCurrentStoreStore();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
@@ -467,13 +557,13 @@ async function getCurrentStoreId(): Promise<string> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateNavBar(): void {
|
function updateNavBar(): void {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
if (!hasSavePermission.value) {
|
if (!hasSavePermission.value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
navBarStore.setRightText("保存", "var(--td-brand-color)", saveBaseInfo);
|
setPageNavBarRightText("保存", "var(--td-brand-color)", saveBaseInfo);
|
||||||
navBarStore.setRightDisabled(!canSaveBaseInfo.value);
|
setPageNavBarRightDisabled(!canSaveBaseInfo.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
watch([hasSavePermission, canSaveBaseInfo], updateNavBar, { immediate: true });
|
watch([hasSavePermission, canSaveBaseInfo], updateNavBar, { immediate: true });
|
||||||
@@ -483,7 +573,7 @@ onMounted(async () => {
|
|||||||
updateNavBar();
|
updateNavBar();
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
onUnmounted(() => clearPageNavBarRight());
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
@@ -545,4 +635,45 @@ onUnmounted(() => navBarStore.clearRight());
|
|||||||
background: #0f172a;
|
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>
|
</style>
|
||||||
|
|||||||
@@ -1,36 +1,83 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-can="{ value: [corePermissionCodes.role.read, corePermissionCodes.permission.read], mode: 'and' }" class="role-list">
|
<div class="page-layout navbar role-list">
|
||||||
<t-pull-down-refresh
|
<t-navbar
|
||||||
class="list-wrapper"
|
fixed
|
||||||
v-model="isRefreshing"
|
:z-index="20"
|
||||||
:refresh-timeout="30000"
|
title="角色管理"
|
||||||
@refresh="refresh"
|
left-arrow
|
||||||
|
@left-click="$router.back()"
|
||||||
>
|
>
|
||||||
<t-cell-group v-if="sortedRoles.length" theme="card">
|
<template #right>
|
||||||
<t-swipe-cell
|
<div
|
||||||
v-entrance-transition="{ step: 30 }"
|
v-if="pageNavBarRight.icon || pageNavBarRight.text"
|
||||||
v-for="item in sortedRoles"
|
class="nav-right-slot"
|
||||||
:key="item.id"
|
>
|
||||||
class="item"
|
<t-badge
|
||||||
|
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined"
|
||||||
|
class="badge"
|
||||||
|
:count="pageNavBarRight.badge"
|
||||||
|
:max-count="99"
|
||||||
|
:show-zero="false"
|
||||||
>
|
>
|
||||||
<t-cell
|
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
|
||||||
:title="item.name"
|
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
|
||||||
:note="`${item.code} · ${getRoleScopeLabel(item)}`"
|
</button>
|
||||||
arrow
|
</t-badge>
|
||||||
hover
|
<button
|
||||||
@click="router.push(`/management/permissions/roles/${item.id}`)"
|
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>
|
<t-cell
|
||||||
<div class="title" v-text="item.name" :style="{ paddingLeft: `${item.level * 1.25}rem` }" />
|
: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>
|
</template>
|
||||||
</t-cell>
|
</t-swipe-cell>
|
||||||
<template #right>
|
</t-cell-group>
|
||||||
<t-button v-if="canDeleteRole(item)" v-can="corePermissionCodes.role.delete" class="delete" theme="danger" @click="removeRole(item.id)">删除</t-button>
|
<t-empty v-else-if="!permissionStore.loading" description="暂无角色" />
|
||||||
</template>
|
</t-pull-down-refresh>
|
||||||
</t-swipe-cell>
|
</main>
|
||||||
</t-cell-group>
|
|
||||||
<t-empty v-else-if="!permissionStore.loading" description="暂无角色" />
|
|
||||||
</t-pull-down-refresh>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -38,17 +85,47 @@
|
|||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { useUserStore } from "timi-web-api";
|
import { useUserStore } from "timi-web-api";
|
||||||
import type { Role } from "@/store/permissionSettingsStore";
|
import type { Role } from "@/store/permissionSettingsStore";
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
import { usePermissionSettingsStore } from "@/store/permissionSettingsStore";
|
|
||||||
import { getErrorMessage } from "@/utils/error";
|
import { getErrorMessage } from "@/utils/error";
|
||||||
import { corePermissionCodes, coreRoleCodes } from "@/utils/permission";
|
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({
|
defineOptions({
|
||||||
name: "RoleList"
|
name: "RoleList"
|
||||||
});
|
});
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const permissionStore = usePermissionSettingsStore();
|
const permissionStore = usePermissionSettingsStore();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const isRefreshing = ref(false);
|
const isRefreshing = ref(false);
|
||||||
@@ -113,9 +190,9 @@ async function refresh(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
if (canCreateRole.value) {
|
if (canCreateRole.value) {
|
||||||
navBarStore.setRightText("添加", "var(--td-brand-color)", toCreate);
|
setPageNavBarRightText("添加", "var(--td-brand-color)", toCreate);
|
||||||
}
|
}
|
||||||
await permissionStore.loadAll();
|
await permissionStore.loadAll();
|
||||||
await refreshAuthorizationScope();
|
await refreshAuthorizationScope();
|
||||||
@@ -125,7 +202,7 @@ onMounted(async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
});
|
});
|
||||||
|
|
||||||
function getDisplayRoleList(): Role[] {
|
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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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
|
<div
|
||||||
v-can="{ value: [corePermissionCodes.role.read, corePermissionCodes.permission.read, corePermissionCodes.rolePermission.read], mode: 'and' }"
|
v-can="{ value: [corePermissionCodes.role.read, corePermissionCodes.permission.read, corePermissionCodes.rolePermission.read], mode: 'and' }"
|
||||||
class="role-permission-assign"
|
class="role-permission-assign"
|
||||||
@@ -52,17 +97,47 @@
|
|||||||
import type { DropdownOption, DropdownValue } from "tdesign-mobile-vue";
|
import type { DropdownOption, DropdownValue } from "tdesign-mobile-vue";
|
||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { type Permission, useUserStore } from "timi-web-api";
|
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 { getErrorMessage } from "@/utils/error";
|
||||||
import { corePermissionCodes, coreRoleCodes } from "@/utils/permission";
|
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({
|
defineOptions({
|
||||||
name: "RolePermissionAssign"
|
name: "RolePermissionAssign"
|
||||||
});
|
});
|
||||||
|
|
||||||
const permissionStore = usePermissionSettingsStore();
|
const permissionStore = usePermissionSettingsStore();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
@@ -165,9 +240,9 @@ async function savePermissionList(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateNavBar(): void {
|
function updateNavBar(): void {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
if (canEditActiveRole.value && canUpdateRolePermission.value) {
|
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);
|
onMounted(updateNavBar);
|
||||||
onUnmounted(() => {
|
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>
|
</style>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
|
|||||||
@@ -1,4 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<t-navbar
|
||||||
|
fixed
|
||||||
|
:z-index="20"
|
||||||
|
title="积分账户详情"
|
||||||
|
left-arrow
|
||||||
|
@left-click="$router.back()"
|
||||||
|
/>
|
||||||
<div v-can="permissionCodes.point.accountRead" class="point-account-detail">
|
<div v-can="permissionCodes.point.accountRead" class="point-account-detail">
|
||||||
<card-container v-if="customer" v-entrance-transition>
|
<card-container v-if="customer" v-entrance-transition>
|
||||||
<customer-profile-card :customer="customer" />
|
<customer-profile-card :customer="customer" />
|
||||||
|
|||||||
@@ -1,58 +1,68 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-can="permissionCodes.point.accountRead" class="point-account-list">
|
<div class="page-layout navbar point-account-list">
|
||||||
<div class="filters glass">
|
<t-navbar
|
||||||
<t-input
|
fixed
|
||||||
v-model.trim="keyword"
|
:z-index="20"
|
||||||
class="customer"
|
title="积分账户"
|
||||||
placeholder="搜索客户编码、姓名(拼音)"
|
left-arrow
|
||||||
borderless
|
@left-click="$router.back()"
|
||||||
>
|
|
||||||
<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"
|
|
||||||
/>
|
/>
|
||||||
|
<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>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<t-navbar
|
||||||
|
fixed
|
||||||
|
:z-index="20"
|
||||||
|
title="人工调整积分"
|
||||||
|
left-arrow
|
||||||
|
@left-click="$router.back()"
|
||||||
|
/>
|
||||||
<div v-can="permissionCodes.point.adjust" class="point-adjust">
|
<div v-can="permissionCodes.point.adjust" class="point-adjust">
|
||||||
<t-notice-bar
|
<t-notice-bar
|
||||||
theme="warning"
|
theme="warning"
|
||||||
|
|||||||
@@ -1,4 +1,11 @@
|
|||||||
<template>
|
<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">
|
<div v-if="customer" v-can="permissionCodes.point.ledgerRead" class="point-ledger-detail">
|
||||||
<customer-profile-card
|
<customer-profile-card
|
||||||
class="customer-profile"
|
class="customer-profile"
|
||||||
|
|||||||
+142
-132
@@ -1,143 +1,153 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-can="permissionCodes.point.ledgerRead" class="point-ledger-list">
|
<div class="page-layout navbar point-ledger-list">
|
||||||
<div class="filters glass">
|
<t-navbar
|
||||||
<t-input
|
fixed
|
||||||
v-model="customerKeyword"
|
:z-index="20"
|
||||||
class="customer"
|
title="积分流水"
|
||||||
type="search"
|
left-arrow
|
||||||
borderless
|
@left-click="$router.back()"
|
||||||
placeholder="输入客户编码或姓名"
|
/>
|
||||||
@clear="searchCustomer"
|
<main v-can="permissionCodes.point.ledgerRead" class="page-content scroll list">
|
||||||
@enter="searchCustomer"
|
<t-pull-down-refresh
|
||||||
@input="searchCustomer"
|
class="pull-refresh"
|
||||||
|
v-model="isRefreshing"
|
||||||
|
:refresh-timeout="30000"
|
||||||
|
@refresh="reload"
|
||||||
|
@scrolltolower="load"
|
||||||
>
|
>
|
||||||
<template #suffix-icon>
|
<div class="filters glass">
|
||||||
<t-button
|
<t-input
|
||||||
size="extra-small"
|
v-model="customerKeyword"
|
||||||
theme="primary"
|
class="customer"
|
||||||
variant="outline"
|
type="search"
|
||||||
content="选择客户"
|
borderless
|
||||||
@click.stop="selectorVisible = true"
|
placeholder="输入客户编码或姓名"
|
||||||
/>
|
@clear="searchCustomer"
|
||||||
</template>
|
@enter="searchCustomer"
|
||||||
</t-input>
|
@input="searchCustomer"
|
||||||
<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)"
|
|
||||||
>
|
>
|
||||||
<template #leftIcon>
|
<template #suffix-icon>
|
||||||
<t-image
|
<t-button
|
||||||
v-if="getCustomerPhotoURL(item.customer!, 64)"
|
size="extra-small"
|
||||||
:src="getCustomerPhotoURL(item.customer!, 64)"
|
theme="primary"
|
||||||
fit="cover"
|
variant="outline"
|
||||||
class="avatar"
|
content="选择客户"
|
||||||
|
@click.stop="selectorVisible = true"
|
||||||
/>
|
/>
|
||||||
<div v-else class="avatar fallback" v-text="(item.customer?.name || item.customer?.code || '客').slice(0, 1)" />
|
|
||||||
</template>
|
</template>
|
||||||
<template #title>
|
</t-input>
|
||||||
<div class="title">
|
<t-dropdown-menu class="menus">
|
||||||
<t-tag
|
<t-dropdown-item
|
||||||
class="type-icon"
|
v-model="changeTypeFilter"
|
||||||
:theme="item.pointDelta && 0 < item.pointDelta ? 'success' : 'danger'"
|
label="流水类型"
|
||||||
:content="getLedgerShortType(item)"
|
:options="changeTypeOptions"
|
||||||
variant="outline"
|
@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 v-else class="avatar fallback" v-text="(item.customer?.name || item.customer?.code || '客').slice(0, 1)" />
|
||||||
</div>
|
</template>
|
||||||
</template>
|
<template #title>
|
||||||
<template #description>
|
<div class="title">
|
||||||
<div class="description">
|
<t-tag
|
||||||
<div>
|
class="type-icon"
|
||||||
<span>时间:</span>
|
:theme="item.pointDelta && 0 < item.pointDelta ? 'success' : 'danger'"
|
||||||
<pass-time-label :timestamp="item.occurredAt" underline />
|
:content="getLedgerShortType(item)"
|
||||||
|
variant="outline"
|
||||||
|
/>
|
||||||
|
<div class="name" v-text="item.customer?.name" />
|
||||||
</div>
|
</div>
|
||||||
<div v-text="`余额:${formatPointValue(item.balanceBefore)} → ${formatPointValue(item.balanceAfter)}`" />
|
</template>
|
||||||
<div v-text="item.remark" />
|
<template #description>
|
||||||
</div>
|
<div class="description">
|
||||||
</template>
|
<div>
|
||||||
<template #note>
|
<span>时间:</span>
|
||||||
<div class="delta keep-text" :class="getLedgerTheme(item)" v-text="getLedgerDelta(item)" />
|
<pass-time-label :timestamp="item.occurredAt" underline />
|
||||||
</template>
|
</div>
|
||||||
</t-cell>
|
<div v-text="`余额:${formatPointValue(item.balanceBefore)} → ${formatPointValue(item.balanceAfter)}`" />
|
||||||
</t-cell-group>
|
<div v-text="item.remark" />
|
||||||
<div class="center-tips" v-text="loadStateText" />
|
</div>
|
||||||
</div>
|
</template>
|
||||||
</t-pull-down-refresh>
|
<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>
|
</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>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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">
|
<div v-can="permissionCodes.pointRedeemSku.manage" class="redeem-sku-edit">
|
||||||
<t-form class="form" v-entrance-transition>
|
<t-form class="form" v-entrance-transition>
|
||||||
<product-select-form-item
|
<product-select-form-item
|
||||||
@@ -58,18 +103,59 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import PointAPI from "@/api/PointAPI";
|
import PointAPI from "@/api/PointAPI";
|
||||||
import ProductSelectFormItem from "@/components/productSelector/ProductSelectFormItem.vue";
|
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 type { ProductSelection } from "@/types/Product";
|
||||||
import { getErrorMessage } from "@/utils/error";
|
import { getErrorMessage } from "@/utils/error";
|
||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { normalizePackageQuantity } from "@/utils/package";
|
import { normalizePackageQuantity } from "@/utils/package";
|
||||||
import { permissionCodes } from "@/utils/permission";
|
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" });
|
defineOptions({ name: "PointRedeemSkuEdit" });
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
|
const routeNavBarTitle = computed(() => {
|
||||||
|
switch (route.name) {
|
||||||
|
case "PointRedeemSkuCreate":
|
||||||
|
return "新增兑换商品";
|
||||||
|
case "PointRedeemSkuEdit":
|
||||||
|
return "编辑兑换商品";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
});
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const selection = ref<{ skuId: string; skuUnitId: string }>();
|
const selection = ref<{ skuId: string; skuUnitId: string }>();
|
||||||
const statusVisible = ref(false);
|
const statusVisible = ref(false);
|
||||||
const statusDraft = ref<Array<string | number>>(["DRAFT"]);
|
const statusDraft = ref<Array<string | number>>(["DRAFT"]);
|
||||||
@@ -188,7 +274,7 @@ async function remove(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navBarStore.setRightText("保存", "var(--td-brand-color)", save);
|
setPageNavBarRightText("保存", "var(--td-brand-color)", save);
|
||||||
try {
|
try {
|
||||||
await load();
|
await load();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -196,7 +282,7 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
onUnmounted(() => clearPageNavBarRight());
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
@@ -210,4 +296,45 @@ onUnmounted(() => navBarStore.clearRight());
|
|||||||
font-size: .875rem;
|
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>
|
</style>
|
||||||
|
|||||||
@@ -1,85 +1,151 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-can="permissionCodes.pointRedeemSku.manage" class="redeem-sku-list">
|
<div class="page-layout navbar redeem-sku-list">
|
||||||
<div class="filters glass">
|
<t-navbar
|
||||||
<t-input
|
fixed
|
||||||
v-model.trim="keyword"
|
:z-index="20"
|
||||||
class="keyword"
|
title="兑换商品"
|
||||||
type="search"
|
left-arrow
|
||||||
borderless
|
@left-click="$router.back()"
|
||||||
clearable
|
>
|
||||||
placeholder="搜索产品名称、编码或 SKU"
|
<template #right>
|
||||||
/>
|
<div
|
||||||
</div>
|
class="nav-actions"
|
||||||
<t-pull-down-refresh v-model="isRefreshing" :refresh-timeout="30000" @refresh="reload" @scrolltolower="load">
|
v-if="pageNavBarActionList.length"
|
||||||
<t-cell-group v-if="result.list.length" theme="card">
|
v-can="permissionCodes.pointRedeemSku.manage"
|
||||||
<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-popover
|
||||||
<t-image
|
v-model:visible="pageNavBarActionVisible"
|
||||||
v-if="getProductPhoto(item)"
|
placement="bottom-right"
|
||||||
:src="getProductPhoto(item)"
|
:show-arrow="false"
|
||||||
:alt="item.product?.name || item.sku?.name || '产品图片'"
|
theme="light"
|
||||||
fit="cover"
|
>
|
||||||
class="avatar"
|
<t-button
|
||||||
/>
|
class="trigger"
|
||||||
<div
|
variant="text"
|
||||||
v-else
|
:aria-label="'更多操作'"
|
||||||
class="avatar fallback"
|
type="button"
|
||||||
v-text="(item.product?.name || item.sku?.name || '产').slice(0, 1)"
|
>
|
||||||
/>
|
<template #icon>
|
||||||
</template>
|
<t-icon name="ellipsis" />
|
||||||
<template #title>
|
</template>
|
||||||
<span class="clip-text" v-text="item.product?.name || item.sku?.name || '未命名产品'" />
|
</t-button>
|
||||||
</template>
|
<template #content>
|
||||||
<template #note>
|
<div class="menu">
|
||||||
<span class="orange keep-text" v-text="formatPoint(item.defaultPointCost)" />
|
<t-button
|
||||||
</template>
|
v-for="action in pageNavBarActionList"
|
||||||
<template #description>
|
:key="action.key"
|
||||||
<div class="description">
|
class="menu-item"
|
||||||
<t-tag
|
variant="text"
|
||||||
size="small"
|
type="button"
|
||||||
:theme="item.status === 'ACTIVE' ? 'success' : 'default'"
|
:theme="action.theme"
|
||||||
:content="statusText(item.status)"
|
: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
|
<div
|
||||||
:product-name="item.product?.name"
|
v-else
|
||||||
:fallback="item.sku?.specSummary || item.sku?.name || '默认 SKU'"
|
class="avatar fallback"
|
||||||
:unit="item.unit?.name"
|
v-text="(item.product?.name || item.sku?.name || '产').slice(0, 1)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</template>
|
||||||
</template>
|
<template #title>
|
||||||
</t-cell>
|
<span class="clip-text" v-text="item.product?.name || item.sku?.name || '未命名产品'" />
|
||||||
</t-cell-group>
|
</template>
|
||||||
<t-empty v-else :description="isLoading ? '正在加载兑换配置' : '暂无兑换配置'" />
|
<template #note>
|
||||||
<div class="tips" v-text="isNoMore ? `共 ${result.total} 条配置` : '上拉加载更多'" />
|
<span class="orange keep-text" v-text="formatPoint(item.defaultPointCost)" />
|
||||||
</t-pull-down-refresh>
|
</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>
|
</div>
|
||||||
<nav-bar-action-menu
|
|
||||||
v-can="permissionCodes.pointRedeemSku.manage"
|
|
||||||
:actions="[{ key: 'create', icon: 'add', text: '新增兑换配置', theme: 'primary', action: toCreate }]"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import type { NavBarAction } from "@/types/NavBarAction";
|
||||||
import { Toolkit } from "timi-web";
|
import { Toolkit } from "timi-web";
|
||||||
import PointAPI from "@/api/PointAPI";
|
import PointAPI from "@/api/PointAPI";
|
||||||
import ProductSkuTags from "@/components/ProductSkuTags.vue";
|
import ProductSkuTags from "@/components/ProductSkuTags.vue";
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
import type { PointRedeemSku, PointRedeemSkuStatus } from "@/types/Point";
|
|
||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { formatWanInteger } from "@/utils/money";
|
import { formatWanInteger } from "@/utils/money";
|
||||||
import { getProductPhotoURL } from "@/utils/product";
|
import { getProductPhotoURL } from "@/utils/product";
|
||||||
import { permissionCodes } from "@/utils/permission";
|
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" });
|
defineOptions({ name: "PointRedeemSkuList" });
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const result = reactive({ total: 0, list: [] as PointRedeemSku[] });
|
const result = reactive({ total: 0, list: [] as PointRedeemSku[] });
|
||||||
const keyword = shallowRef("");
|
const keyword = shallowRef("");
|
||||||
const index = ref(0);
|
const index = ref(0);
|
||||||
@@ -165,7 +231,7 @@ async function toEdit(item: PointRedeemSku): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navBarStore.setCustomRightVisible(true);
|
|
||||||
await reload();
|
await reload();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -175,7 +241,6 @@ watch(keyword, () => {
|
|||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
reloadByKeyword.cancel();
|
reloadByKeyword.cancel();
|
||||||
navBarStore.clearRight();
|
|
||||||
});
|
});
|
||||||
</script>
|
</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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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">
|
<div v-can="permissionCodes.pointRedemption.create" class="redemption-create">
|
||||||
<t-form class="form" label-width="7rem" v-entrance-transition>
|
<t-form class="form" label-width="7rem" v-entrance-transition>
|
||||||
<t-form-item label="客户" required-mark>
|
<t-form-item label="客户" required-mark>
|
||||||
@@ -135,8 +180,6 @@ import CodeScanner from "@/components/CodeScanner.vue";
|
|||||||
import CustomerProfileCard from "@/components/CustomerProfileCard.vue";
|
import CustomerProfileCard from "@/components/CustomerProfileCard.vue";
|
||||||
import CustomerSelector from "@/components/CustomerSelector.vue";
|
import CustomerSelector from "@/components/CustomerSelector.vue";
|
||||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.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 { Customer } from "@/types/Customer";
|
||||||
import type { PhotoItem } from "@/types/Photo";
|
import type { PhotoItem } from "@/types/Photo";
|
||||||
import type { PointAccount, PointRedeemSku } from "@/types/Point";
|
import type { PointAccount, PointRedeemSku } from "@/types/Point";
|
||||||
@@ -148,10 +191,42 @@ import { getProductPhotoURL, getProductQuantityStep } from "@/utils/product";
|
|||||||
import { uploadPhotoList } from "@/utils/photo";
|
import { uploadPhotoList } from "@/utils/photo";
|
||||||
import { permissionCodes } from "@/utils/permission";
|
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" });
|
defineOptions({ name: "PointRedemptionCreate" });
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const settingStore = useSettingStore();
|
const settingStore = useSettingStore();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const customerId = ref("");
|
const customerId = ref("");
|
||||||
@@ -332,7 +407,7 @@ function formatPoint(value?: number): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navBarStore.setRightText("兑换", "var(--td-brand-color)", save);
|
setPageNavBarRightText("兑换", "var(--td-brand-color)", save);
|
||||||
try {
|
try {
|
||||||
await loadSkuList();
|
await loadSkuList();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -340,7 +415,7 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
onUnmounted(() => clearPageNavBarRight());
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<t-navbar
|
||||||
|
fixed
|
||||||
|
:z-index="20"
|
||||||
|
title="兑换详情"
|
||||||
|
left-arrow
|
||||||
|
@left-click="$router.back()"
|
||||||
|
/>
|
||||||
<div v-can="permissionCodes.pointRedemption.create" class="redemption-detail">
|
<div v-can="permissionCodes.pointRedemption.create" class="redemption-detail">
|
||||||
<customer-profile-card
|
<customer-profile-card
|
||||||
v-if="customer"
|
v-if="customer"
|
||||||
|
|||||||
@@ -1,162 +1,214 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-can="permissionCodes.pointRedemption.create" class="redemption-list">
|
<div class="page-layout navbar redemption-list">
|
||||||
<div class="filters glass">
|
<t-navbar
|
||||||
<t-input
|
fixed
|
||||||
v-model.trim="keyword"
|
:z-index="20"
|
||||||
class="keyword"
|
title="积分兑换"
|
||||||
clearable
|
left-arrow
|
||||||
borderless
|
@left-click="$router.back()"
|
||||||
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="list-wrap">
|
<template #right>
|
||||||
<t-cell-group class="date-summary" theme="card" v-entrance-transition>
|
<div
|
||||||
<template v-if="isCustomDate">
|
class="nav-actions"
|
||||||
<t-cell
|
v-if="pageNavBarActionList.length"
|
||||||
title="开始时间"
|
v-can="permissionCodes.pointRedemption.create"
|
||||||
:note="dateRange[0] || '-'"
|
>
|
||||||
arrow
|
<t-popover
|
||||||
@click="openStartTime"
|
v-model:visible="pageNavBarActionVisible"
|
||||||
/>
|
placement="bottom-right"
|
||||||
<t-cell
|
:show-arrow="false"
|
||||||
title="结束时间"
|
theme="light"
|
||||||
:note="dateRange[1] || '-'"
|
>
|
||||||
arrow
|
<t-button
|
||||||
@click="openEndTime"
|
class="trigger"
|
||||||
/>
|
variant="text"
|
||||||
</template>
|
:aria-label="'更多操作'"
|
||||||
<t-cell title="兑换次数" :note="`${Text.display(result.total)} 次`" />
|
type="button"
|
||||||
</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>
|
<template #icon>
|
||||||
<t-image
|
<t-icon name="ellipsis" />
|
||||||
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>
|
||||||
<template #title>
|
</t-button>
|
||||||
<div class="title">
|
<template #content>
|
||||||
<strong v-text="item.productNameSnapshot || item.skuNameSnapshot || '未命名产品'" />
|
<div class="menu">
|
||||||
<t-tag
|
<t-button
|
||||||
size="small"
|
v-for="action in pageNavBarActionList"
|
||||||
:theme="item.status === 'FULLY_RETURNED' ? 'default' : 'success'"
|
:key="action.key"
|
||||||
:content="statusText(item.status)"
|
class="menu-item"
|
||||||
/>
|
variant="text"
|
||||||
</div>
|
type="button"
|
||||||
</template>
|
:theme="action.theme"
|
||||||
<template #note>
|
:loading="action.loading"
|
||||||
<span class="orange" v-text="formatPoint(item.actualPointCost)" />
|
:disabled="action.disabled || action.loading"
|
||||||
</template>
|
@click="handlePageNavBarAction(action)"
|
||||||
<template #description>
|
>
|
||||||
<span v-text="`${item.customer?.name || item.customerId || '未知客户'} · ${quantityText(item.quantity)} ${item.unitSnapshot || ''}`" />
|
<template v-if="action.icon" #icon>
|
||||||
</template>
|
<t-icon :name="action.icon" />
|
||||||
</t-cell>
|
</template>
|
||||||
</t-cell-group>
|
<span v-text="action.text" />
|
||||||
|
</t-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</t-popover>
|
||||||
</div>
|
</div>
|
||||||
<t-empty
|
</template>
|
||||||
v-else
|
</t-navbar>
|
||||||
:description="loading ? '正在加载兑换记录' : hasFilter ? '未找到匹配的兑换记录' : '暂无兑换记录'"
|
<main v-can="permissionCodes.pointRedemption.create" class="page-content scroll list">
|
||||||
/>
|
<t-pull-down-refresh
|
||||||
</div>
|
class="pull-refresh"
|
||||||
</t-pull-down-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>
|
</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>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import type { NavBarAction } from "@/types/NavBarAction";
|
||||||
import { type DropdownValue } from "tdesign-mobile-vue";
|
import { type DropdownValue } from "tdesign-mobile-vue";
|
||||||
import { Text, Time, Toolkit } from "timi-web";
|
import { Text, Time, Toolkit } from "timi-web";
|
||||||
import CustomerAPI from "@/api/CustomerAPI";
|
import CustomerAPI from "@/api/CustomerAPI";
|
||||||
import PointAPI from "@/api/PointAPI";
|
import PointAPI from "@/api/PointAPI";
|
||||||
import CustomerSelector from "@/components/CustomerSelector.vue";
|
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 type { PointRedemption, PointRedemptionStatus } from "@/types/Point";
|
||||||
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
|
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
|
||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
@@ -165,11 +217,20 @@ import { getPackageQuantityText } from "@/utils/package";
|
|||||||
import { getCustomerPhotoURL } from "@/utils/customer";
|
import { getCustomerPhotoURL } from "@/utils/customer";
|
||||||
import { permissionCodes } from "@/utils/permission";
|
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" });
|
defineOptions({ name: "PointRedemptionList" });
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const result = reactive({ total: 0, list: [] as PointRedemption[] });
|
const result = reactive({ total: 0, list: [] as PointRedemption[] });
|
||||||
type DateFilterType = "today" | "yesterday" | "thisWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
|
type DateFilterType = "today" | "yesterday" | "thisWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
|
||||||
const dateOptions: Array<{ label: string; value: DateFilterType }> = [
|
const dateOptions: Array<{ label: string; value: DateFilterType }> = [
|
||||||
@@ -384,7 +445,7 @@ async function toDetail(item: PointRedemption): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navBarStore.setCustomRightVisible(true);
|
|
||||||
try {
|
try {
|
||||||
if (customerId.value) {
|
if (customerId.value) {
|
||||||
selectedCustomer.value = await CustomerAPI.detail(customerId.value);
|
selectedCustomer.value = await CustomerAPI.detail(customerId.value);
|
||||||
@@ -405,7 +466,6 @@ watch(keyword, () => {
|
|||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
reloadByKeyword.cancel();
|
reloadByKeyword.cancel();
|
||||||
navBarStore.clearRight();
|
|
||||||
});
|
});
|
||||||
</script>
|
</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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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">
|
<div v-can="permissionCodes.pointRule.read" class="point-rule-detail">
|
||||||
<section v-if="rule" class="rule-header" v-entrance-transition>
|
<section v-if="rule" class="rule-header" v-entrance-transition>
|
||||||
<div class="point-icon" :class="{ consume: isConsumeRule }">
|
<div class="point-icon" :class="{ consume: isConsumeRule }">
|
||||||
@@ -96,21 +141,51 @@ import { useUserStore } from "timi-web-api";
|
|||||||
import EventAPI from "@/api/EventAPI";
|
import EventAPI from "@/api/EventAPI";
|
||||||
import PointAPI from "@/api/PointAPI";
|
import PointAPI from "@/api/PointAPI";
|
||||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
import type { EventItem } from "@/types/EventItem";
|
|
||||||
import type { PointRule, PointRuleStatus } from "@/types/Point";
|
import type { PointRule, PointRuleStatus } from "@/types/Point";
|
||||||
import { getErrorMessage } from "@/utils/error";
|
import { getErrorMessage } from "@/utils/error";
|
||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { formatWanInteger } from "@/utils/money";
|
import { formatWanInteger } from "@/utils/money";
|
||||||
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
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({
|
defineOptions({
|
||||||
name: "PointRuleDetail"
|
name: "PointRuleDetail"
|
||||||
});
|
});
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const currentStoreStore = useCurrentStoreStore();
|
const currentStoreStore = useCurrentStoreStore();
|
||||||
|
|
||||||
@@ -257,7 +332,7 @@ async function removeRule(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isDeleting.value = true;
|
isDeleting.value = true;
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
try {
|
try {
|
||||||
await PointAPI.ruleRemove(ruleId);
|
await PointAPI.ruleRemove(ruleId);
|
||||||
Message.success("积分规则已删除");
|
Message.success("积分规则已删除");
|
||||||
@@ -274,7 +349,7 @@ async function removeRule(): Promise<void> {
|
|||||||
|
|
||||||
function setEditAction(): void {
|
function setEditAction(): void {
|
||||||
if (canUpdate.value) {
|
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 });
|
}, { immediate: true });
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
setEditAction();
|
setEditAction();
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
});
|
});
|
||||||
</script>
|
</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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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">
|
<div v-can="pageAccess" class="point-rule-edit">
|
||||||
<t-form class="form" label-align="left" label-width="7rem">
|
<t-form class="form" label-align="left" label-width="7rem">
|
||||||
<card-container v-entrance-transition>
|
<card-container v-entrance-transition>
|
||||||
@@ -145,8 +190,6 @@ import EventAPI from "@/api/EventAPI";
|
|||||||
import PointRuleScriptPicker from "@/pages/point/component/PointRuleScriptPicker.vue";
|
import PointRuleScriptPicker from "@/pages/point/component/PointRuleScriptPicker.vue";
|
||||||
import PointAPI from "@/api/PointAPI";
|
import PointAPI from "@/api/PointAPI";
|
||||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
import type { EventItem } from "@/types/EventItem";
|
|
||||||
import type {
|
import type {
|
||||||
GroovyScript,
|
GroovyScript,
|
||||||
PointAction,
|
PointAction,
|
||||||
@@ -159,6 +202,39 @@ import { getErrorMessage } from "@/utils/error";
|
|||||||
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
||||||
import { Message } from "@/utils/message";
|
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;
|
type PickerValue = string | number;
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
@@ -166,8 +242,18 @@ defineOptions({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
|
const routeNavBarTitle = computed(() => {
|
||||||
|
switch (route.name) {
|
||||||
|
case "PointRuleCreate":
|
||||||
|
return "新增积分规则";
|
||||||
|
case "PointRuleEdit":
|
||||||
|
return "编辑积分规则";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
});
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const currentStoreStore = useCurrentStoreStore();
|
const currentStoreStore = useCurrentStoreStore();
|
||||||
const routeId = computed(() => String(route.params.id || ""));
|
const routeId = computed(() => String(route.params.id || ""));
|
||||||
@@ -537,7 +623,7 @@ async function fillForm(): Promise<void> {
|
|||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
if (userStore.hasPermissions(savePermissionCode.value)) {
|
if (userStore.hasPermissions(savePermissionCode.value)) {
|
||||||
navBarStore.setRightText("保存", "var(--td-brand-color)", saveRule);
|
setPageNavBarRightText("保存", "var(--td-brand-color)", saveRule);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await fillForm();
|
await fillForm();
|
||||||
@@ -546,7 +632,7 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
onUnmounted(() => clearPageNavBarRight());
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<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>
|
</style>
|
||||||
|
|||||||
@@ -1,86 +1,147 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-can="permissionCodes.pointRule.read" class="point-rule-list">
|
<div class="page-layout navbar point-rule-list">
|
||||||
<div class="filter-menu">
|
<t-navbar
|
||||||
<t-dropdown-menu>
|
fixed
|
||||||
<t-dropdown-item
|
:z-index="20"
|
||||||
v-model="statusFilter"
|
title="积分规则"
|
||||||
label="规则状态"
|
left-arrow
|
||||||
:options="statusOptions"
|
@left-click="$router.back()"
|
||||||
@change="selectStatus"
|
|
||||||
/>
|
|
||||||
</t-dropdown-menu>
|
|
||||||
</div>
|
|
||||||
<t-pull-down-refresh
|
|
||||||
class="list-wrapper"
|
|
||||||
v-model="isRefreshing"
|
|
||||||
:refresh-timeout="30000"
|
|
||||||
@refresh="reload"
|
|
||||||
@scrolltolower="load"
|
|
||||||
>
|
>
|
||||||
<t-cell-group
|
<template #right>
|
||||||
v-if="pageResult.list.length"
|
<div
|
||||||
class="list empty-cell-title-margin"
|
class="nav-actions"
|
||||||
theme="card"
|
v-if="(canShowActionMenu) && pageNavBarActionList.length"
|
||||||
>
|
|
||||||
<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>
|
<t-popover
|
||||||
<div class="point" :class="{ 'consume': item.pointValue && item.pointValue < 0 }">
|
v-model:visible="pageNavBarActionVisible"
|
||||||
<t-icon name="money" />
|
placement="bottom-right"
|
||||||
<span v-text="getPointText(item)" />
|
:show-arrow="false"
|
||||||
</div>
|
theme="light"
|
||||||
</template>
|
>
|
||||||
<template #title>
|
<t-button
|
||||||
<div class="title">
|
class="trigger"
|
||||||
<h4 class="text" v-text="item.name || '未命名规则'" />
|
variant="text"
|
||||||
<t-tag
|
:aria-label="'更多操作'"
|
||||||
:theme="getStatusTheme(item.status)"
|
type="button"
|
||||||
variant="light-outline"
|
>
|
||||||
:content="getStatusText(item.status)"
|
<template #icon>
|
||||||
/>
|
<t-icon name="ellipsis" />
|
||||||
</div>
|
</template>
|
||||||
</template>
|
</t-button>
|
||||||
<template #description>
|
<template #content>
|
||||||
<div class="description">
|
<div class="menu">
|
||||||
<div v-text="`触发来源:${getTriggerSourceText(item)}`"></div>
|
<t-button
|
||||||
<div v-text="`触发对象:${getTriggerRefText(item)}`"></div>
|
v-for="action in pageNavBarActionList"
|
||||||
</div>
|
:key="action.key"
|
||||||
</template>
|
class="menu-item"
|
||||||
</t-cell>
|
variant="text"
|
||||||
</t-cell-group>
|
type="button"
|
||||||
<div class="center-tips" v-text="loadStateText" />
|
:theme="action.theme"
|
||||||
</t-pull-down-refresh>
|
: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>
|
</div>
|
||||||
<nav-bar-action-menu v-if="canShowActionMenu" :actions="actionList" />
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import type { NavBarAction } from "@/types/NavBarAction";
|
||||||
import { type DropdownValue } from "tdesign-mobile-vue";
|
import { type DropdownValue } from "tdesign-mobile-vue";
|
||||||
import EventAPI from "@/api/EventAPI";
|
import EventAPI from "@/api/EventAPI";
|
||||||
import PointAPI from "@/api/PointAPI";
|
import PointAPI from "@/api/PointAPI";
|
||||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
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 type { PointRule, PointRuleStatus } from "@/types/Point";
|
||||||
import { formatWanInteger } from "@/utils/money";
|
import { formatWanInteger } from "@/utils/money";
|
||||||
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
||||||
import { type Page, type PageResult, useUserStore } from "timi-web-api";
|
import { type Page, type PageResult, useUserStore } from "timi-web-api";
|
||||||
import { Message } from "@/utils/message.ts";
|
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({
|
defineOptions({
|
||||||
name: "PointRuleList"
|
name: "PointRuleList"
|
||||||
});
|
});
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const currentStoreStore = useCurrentStoreStore();
|
const currentStoreStore = useCurrentStoreStore();
|
||||||
|
|
||||||
@@ -294,8 +355,7 @@ async function preparePage(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navBarStore.clearRight();
|
|
||||||
navBarStore.setCustomRightVisible(canShowActionMenu.value);
|
|
||||||
try {
|
try {
|
||||||
await preparePage();
|
await preparePage();
|
||||||
} catch {
|
} catch {
|
||||||
@@ -303,7 +363,6 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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 v-can="permissionCodes.pointRule.update" class="point-rule-sort">
|
||||||
<div class="tip" v-text="'按住右侧拖动手柄调整规则顺序,保存后生效;仅显示启用规则'" v-entrance-transition />
|
<div class="tip" v-text="'按住右侧拖动手柄调整规则顺序,保存后生效;仅显示启用规则'" v-entrance-transition />
|
||||||
<div class="items">
|
<div class="items">
|
||||||
@@ -49,15 +94,44 @@ import { Message } from "@/utils/message";
|
|||||||
import { VueDraggableNext } from "vue-draggable-next";
|
import { VueDraggableNext } from "vue-draggable-next";
|
||||||
import EventAPI from "@/api/EventAPI";
|
import EventAPI from "@/api/EventAPI";
|
||||||
import PointAPI from "@/api/PointAPI";
|
import PointAPI from "@/api/PointAPI";
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
import type { EventItem } from "@/types/EventItem";
|
|
||||||
import type { PointRule } from "@/types/Point";
|
import type { PointRule } from "@/types/Point";
|
||||||
import { formatWanInteger } from "@/utils/money";
|
import { formatWanInteger } from "@/utils/money";
|
||||||
import { permissionCodes } from "@/utils/permission";
|
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 router = useRouter();
|
||||||
const ruleList = ref<PointRule[]>([]);
|
const ruleList = ref<PointRule[]>([]);
|
||||||
const eventList = ref<EventItem[]>([]);
|
const eventList = ref<EventItem[]>([]);
|
||||||
@@ -111,8 +185,8 @@ async function saveSort(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
navBarStore.setRightText("保存", "var(--td-brand-color)", saveSort);
|
setPageNavBarRightText("保存", "var(--td-brand-color)", saveSort);
|
||||||
try {
|
try {
|
||||||
await loadData();
|
await loadData();
|
||||||
} catch {
|
} catch {
|
||||||
@@ -120,7 +194,7 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
onUnmounted(() => clearPageNavBarRight());
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
@@ -164,4 +238,45 @@ onUnmounted(() => navBarStore.clearRight());
|
|||||||
.draggable .cell { background: rgba(15, 23, 42, .88); }
|
.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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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">
|
<div v-can="permissionCodes.stat.read" class="gao-chart-page order-data-charts">
|
||||||
<section class="hero">
|
<section class="hero">
|
||||||
<div class="eyebrow" v-text="'订单经营分析'" />
|
<div class="eyebrow" v-text="'订单经营分析'" />
|
||||||
@@ -72,14 +117,45 @@ import type {
|
|||||||
GaoSalesOrderTypeStatView
|
GaoSalesOrderTypeStatView
|
||||||
} from "@/types/GaoChart";
|
} from "@/types/GaoChart";
|
||||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
import { getCurrentStoreId } from "@/utils/store";
|
|
||||||
import { clearStoreChartCache } from "@/utils/storeChartCache";
|
import { clearStoreChartCache } from "@/utils/storeChartCache";
|
||||||
import { getErrorMessage } from "@/utils/error";
|
import { getErrorMessage } from "@/utils/error";
|
||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { permissionCodes } from "@/utils/permission";
|
import { permissionCodes } from "@/utils/permission";
|
||||||
import { buildDateTextList, formatMoney, formatQuantity, toUnixRange } from "@/pages/product/component/chartUtils";
|
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 {
|
interface SummaryItem {
|
||||||
label: string;
|
label: string;
|
||||||
value: string;
|
value: string;
|
||||||
@@ -90,7 +166,6 @@ defineOptions({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const currentStoreStore = useCurrentStoreStore();
|
const currentStoreStore = useCurrentStoreStore();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const dateRange = buildDefaultDateRange();
|
const dateRange = buildDefaultDateRange();
|
||||||
const dateTextList = buildDateTextList(dateRange[0], dateRange[1]);
|
const dateTextList = buildDateTextList(dateRange[0], dateRange[1]);
|
||||||
const dailyList = ref<GaoSalesOrderDailyStatView[]>([]);
|
const dailyList = ref<GaoSalesOrderDailyStatView[]>([]);
|
||||||
@@ -131,14 +206,14 @@ watch(storeId, async () => {
|
|||||||
}, { immediate: true });
|
}, { immediate: true });
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navBarStore.setRightIcon("refresh", reload);
|
setPageNavBarRightIcon("refresh", reload);
|
||||||
if (!currentStoreStore.currentStoreId) {
|
if (!currentStoreStore.currentStoreId) {
|
||||||
await currentStoreStore.loadLoginStore();
|
await currentStoreStore.loadLoginStore();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
});
|
});
|
||||||
|
|
||||||
async function reload(): Promise<void> {
|
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>
|
</style>
|
||||||
|
|||||||
@@ -1,90 +1,156 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-can="permissionCodes.productCategory.read" class="product-category-list">
|
<div class="page-layout navbar product-category-list">
|
||||||
<div class="filters glass">
|
<t-navbar
|
||||||
<t-input
|
fixed
|
||||||
v-model="keyword"
|
:z-index="20"
|
||||||
class="keyword"
|
title="产品分类"
|
||||||
type="search"
|
left-arrow
|
||||||
borderless
|
@left-click="$router.back()"
|
||||||
placeholder="搜索分类名称"
|
>
|
||||||
/>
|
<template #right>
|
||||||
<t-dropdown-menu class="status">
|
<div
|
||||||
<t-dropdown-item
|
class="nav-actions"
|
||||||
v-model="status"
|
v-if="(canShowActionMenu) && pageNavBarActionList.length"
|
||||||
label="状态"
|
>
|
||||||
:options="statusOptions"
|
<t-popover
|
||||||
@change="selectStatus"
|
v-model:visible="pageNavBarActionVisible"
|
||||||
/>
|
placement="bottom-right"
|
||||||
</t-dropdown-menu>
|
:show-arrow="false"
|
||||||
</div>
|
theme="light"
|
||||||
<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-button
|
||||||
<t-swipe-cell v-for="item in categoryList" :key="item.id" class="item" v-entrance-transition="{ step: 30 }">
|
class="trigger"
|
||||||
<t-cell arrow hover @click="openEditDialog(item)">
|
variant="text"
|
||||||
<template #title>
|
:aria-label="'更多操作'"
|
||||||
<div class="title">
|
type="button"
|
||||||
<strong v-text="item.name || '未命名分类'" />
|
>
|
||||||
|
<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>
|
||||||
</template>
|
</template>
|
||||||
<template #note>
|
</t-popover>
|
||||||
<t-tag size="small" variant="outline" :theme="getProductCategoryStatusTheme(item.status)" :content="getProductCategoryStatusText(item.status)" />
|
</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>
|
</template>
|
||||||
</t-cell>
|
</t-swipe-cell>
|
||||||
<template v-if="canUpdate && item.status === 'ACTIVE' && item.id" #right>
|
</t-cell-group>
|
||||||
<t-button class="disable" theme="danger" :loading="disablingId === item.id" @click.stop="disable(item)">停用</t-button>
|
<div v-else class="center-tips" v-text="emptyText" />
|
||||||
</template>
|
<div v-if="categoryList.length" class="center-tips" v-text="isLoading ? '正在加载更多' : isNoMore ? '已经到底了' : '上拉加载更多'" />
|
||||||
</t-swipe-cell>
|
</t-pull-down-refresh>
|
||||||
</t-cell-group>
|
</main>
|
||||||
<div v-else class="center-tips" v-text="emptyText" />
|
<t-dialog
|
||||||
<div v-if="categoryList.length" class="center-tips" v-text="isLoading ? '正在加载更多' : isNoMore ? '已经到底了' : '上拉加载更多'" />
|
v-model:visible="editDialogVisible"
|
||||||
</t-pull-down-refresh>
|
: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>
|
</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>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import type { NavBarAction } from "@/types/NavBarAction";
|
||||||
import { DialogPlugin, type DropdownValue } from "tdesign-mobile-vue";
|
import { DialogPlugin, type DropdownValue } from "tdesign-mobile-vue";
|
||||||
import { useUserStore } from "timi-web-api";
|
import { useUserStore } from "timi-web-api";
|
||||||
import ProductAPI from "@/api/ProductAPI";
|
import ProductAPI from "@/api/ProductAPI";
|
||||||
import type { NavBarAction } from "@/types/NavBarAction";
|
|
||||||
import type { ProductCategory, ProductCategoryStatus } from "@/types/Product";
|
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 { getProductCategoryStatusText, getProductCategoryStatusTheme } from "@/utils/product";
|
||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { permissionCodes } from "@/utils/permission";
|
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" });
|
defineOptions({ name: "ProductCategoryList" });
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const canCreate = computed(() => userStore.hasPermissions(permissionCodes.productCategory.create));
|
const canCreate = computed(() => userStore.hasPermissions(permissionCodes.productCategory.create));
|
||||||
const canUpdate = computed(() => userStore.hasPermissions(permissionCodes.productCategory.update));
|
const canUpdate = computed(() => userStore.hasPermissions(permissionCodes.productCategory.update));
|
||||||
@@ -327,8 +393,7 @@ function disable(item: ProductCategory): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navBarStore.clearRight();
|
|
||||||
navBarStore.setCustomRightVisible(canShowActionMenu.value);
|
|
||||||
try {
|
try {
|
||||||
await fetch(true);
|
await fetch(true);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -348,7 +413,6 @@ watch(keyword, () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
navBarStore.clearRight();
|
|
||||||
statusPickerVisible.value = false;
|
statusPickerVisible.value = false;
|
||||||
window.clearTimeout(keywordTimer);
|
window.clearTimeout(keywordTimer);
|
||||||
requestToken += 1;
|
requestToken += 1;
|
||||||
@@ -414,4 +478,46 @@ onUnmounted(() => {
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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 v-can="permissionCodes.productCategory.update" class="product-category-rank">
|
||||||
<div class="tip" v-text="'按住右侧拖动手柄调整分类顺序,保存后生效'" />
|
<div class="tip" v-text="'按住右侧拖动手柄调整分类顺序,保存后生效'" />
|
||||||
<div class="items">
|
<div class="items">
|
||||||
@@ -44,16 +89,45 @@
|
|||||||
import type { TagProps } from "tdesign-mobile-vue";
|
import type { TagProps } from "tdesign-mobile-vue";
|
||||||
import { VueDraggableNext } from "vue-draggable-next";
|
import { VueDraggableNext } from "vue-draggable-next";
|
||||||
import ProductAPI from "@/api/ProductAPI";
|
import ProductAPI from "@/api/ProductAPI";
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
import type { ProductCategory, ProductCategoryStatus } from "@/types/Product";
|
|
||||||
import { getErrorMessage } from "@/utils/error";
|
import { getErrorMessage } from "@/utils/error";
|
||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { permissionCodes } from "@/utils/permission";
|
import { permissionCodes } from "@/utils/permission";
|
||||||
import { useUserStore } from "timi-web-api";
|
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 userStore = useUserStore();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
@@ -109,9 +183,9 @@ async function loadData(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
if (userStore.hasPermissions(permissionCodes.productCategory.update)) {
|
if (userStore.hasPermissions(permissionCodes.productCategory.update)) {
|
||||||
navBarStore.setRightText("保存", "var(--td-brand-color)", saveSort);
|
setPageNavBarRightText("保存", "var(--td-brand-color)", saveSort);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await loadData();
|
await loadData();
|
||||||
@@ -121,7 +195,7 @@ onMounted(async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
});
|
});
|
||||||
</script>
|
</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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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">
|
<div v-can="permissionCodes.stat.read" class="gao-chart-page product-data-charts">
|
||||||
<section class="hero">
|
<section class="hero">
|
||||||
<div class="eyebrow" v-text="'产品经营分析'" />
|
<div class="eyebrow" v-text="'产品经营分析'" />
|
||||||
@@ -76,14 +121,45 @@ import type {
|
|||||||
GaoProductSkuStockHealthView
|
GaoProductSkuStockHealthView
|
||||||
} from "@/types/GaoChart";
|
} from "@/types/GaoChart";
|
||||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
import { getCurrentStoreId } from "@/utils/store";
|
|
||||||
import { clearStoreChartCache } from "@/utils/storeChartCache";
|
import { clearStoreChartCache } from "@/utils/storeChartCache";
|
||||||
import { getErrorMessage } from "@/utils/error";
|
import { getErrorMessage } from "@/utils/error";
|
||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { permissionCodes } from "@/utils/permission";
|
import { permissionCodes } from "@/utils/permission";
|
||||||
import { buildDateTextList, formatMoney, formatQuantity, sumNumber, toUnixRange } from "@/pages/product/component/chartUtils";
|
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 {
|
interface SummaryItem {
|
||||||
label: string;
|
label: string;
|
||||||
value: string;
|
value: string;
|
||||||
@@ -94,7 +170,6 @@ defineOptions({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const currentStoreStore = useCurrentStoreStore();
|
const currentStoreStore = useCurrentStoreStore();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const dateRange = buildDefaultDateRange();
|
const dateRange = buildDefaultDateRange();
|
||||||
const dateTextList = buildDateTextList(dateRange[0], dateRange[1]);
|
const dateTextList = buildDateTextList(dateRange[0], dateRange[1]);
|
||||||
const salesDailyList = ref<GaoProductSalesDailyStatView[]>([]);
|
const salesDailyList = ref<GaoProductSalesDailyStatView[]>([]);
|
||||||
@@ -136,14 +211,14 @@ watch(storeId, async () => {
|
|||||||
}, { immediate: true });
|
}, { immediate: true });
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navBarStore.setRightIcon("refresh", reload);
|
setPageNavBarRightIcon("refresh", reload);
|
||||||
if (!currentStoreStore.currentStoreId) {
|
if (!currentStoreStore.currentStoreId) {
|
||||||
await currentStoreStore.loadLoginStore();
|
await currentStoreStore.loadLoginStore();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
});
|
});
|
||||||
|
|
||||||
async function reload(): Promise<void> {
|
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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,56 @@
|
|||||||
<template>
|
<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">
|
<div v-can="permissionCodes.product.read" class="product-detail">
|
||||||
<t-loading v-if="isLoading" class="loading" size="32px" />
|
<t-loading v-if="isLoading" class="loading" size="32px" />
|
||||||
<template v-if="product">
|
<template v-if="product">
|
||||||
@@ -79,7 +131,7 @@
|
|||||||
</t-cell-group>
|
</t-cell-group>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
<nav-bar-action-menu v-if="actionList.length" :actions="actionList" />
|
|
||||||
<bottom-popup
|
<bottom-popup
|
||||||
v-model="skuDetailVisible"
|
v-model="skuDetailVisible"
|
||||||
title="SKU 详情"
|
title="SKU 详情"
|
||||||
@@ -124,16 +176,13 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import type { NavBarAction } from "@/types/NavBarAction";
|
||||||
import { DialogPlugin } from "tdesign-mobile-vue";
|
import { DialogPlugin } from "tdesign-mobile-vue";
|
||||||
import { BottomPopup } from "timi-tdesign-mobile";
|
import { BottomPopup } from "timi-tdesign-mobile";
|
||||||
import { useUserStore } from "timi-web-api";
|
import { useUserStore } from "timi-web-api";
|
||||||
import ProductAPI from "@/api/ProductAPI";
|
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 ProductProfile from "@/pages/product/component/ProductProfile.vue";
|
||||||
import ProductSkuUnitList from "@/pages/product/component/ProductSkuUnitList.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 { PhotoItem } from "@/types/Photo";
|
||||||
import type { Product, ProductSku } from "@/types/Product";
|
import type { Product, ProductSku } from "@/types/Product";
|
||||||
import { getAttachmentReadURL } from "@/utils/attachment";
|
import { getAttachmentReadURL } from "@/utils/attachment";
|
||||||
@@ -148,11 +197,20 @@ import { Message } from "@/utils/message";
|
|||||||
import { permissionCodes } from "@/utils/permission";
|
import { permissionCodes } from "@/utils/permission";
|
||||||
import { Text } from "timi-web";
|
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" });
|
defineOptions({ name: "ProductDetail" });
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const product = ref<Product>();
|
const product = ref<Product>();
|
||||||
const isLoading = ref(false);
|
const isLoading = ref(false);
|
||||||
@@ -299,17 +357,15 @@ function remove(): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navBarStore.clearRight();
|
|
||||||
navBarStore.setCustomRightVisible(actionList.value.length > 0);
|
|
||||||
try {
|
try {
|
||||||
await load();
|
await load();
|
||||||
navBarStore.setCustomRightVisible(actionList.value.length > 0);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
Message.error(getErrorMessage(error, "产品详情加载失败"));
|
Message.error(getErrorMessage(error, "产品详情加载失败"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
@@ -394,4 +450,46 @@ onUnmounted(() => navBarStore.clearRight());
|
|||||||
background: rgba(148, 163, 184, .12);
|
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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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">
|
<div v-can="savePermissionCode" class="product-edit">
|
||||||
<t-form class="form" label-align="left" label-width="6rem" v-entrance-transition>
|
<t-form class="form" label-align="left" label-width="6rem" v-entrance-transition>
|
||||||
<t-form-item label="产品编码" required-mark help="使用英语、拼音或唯一数字">
|
<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 ProductSkuUnitEditor from "@/pages/product/component/ProductSkuUnitEditor.vue";
|
||||||
import ProductSkuUnitBatchEditor from "@/pages/product/component/ProductSkuUnitBatchEditor.vue";
|
import ProductSkuUnitBatchEditor from "@/pages/product/component/ProductSkuUnitBatchEditor.vue";
|
||||||
import type { MediaSelectorAddAction } from "@/components/mediaSelector/types";
|
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 { 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 type { ProductAttachmentItem, ProductForm, ProductSkuForm as SkuForm, ProductSkuUnitForm as UnitForm, ProductSpecForm as SpecForm, ProductSpecValueForm as SpecValueForm } from "@/types/ProductEditor";
|
||||||
import { compressUploadImage } from "@/utils/imageCompression";
|
import { compressUploadImage } from "@/utils/imageCompression";
|
||||||
@@ -229,6 +272,39 @@ import { Message } from "@/utils/message";
|
|||||||
import { permissionCodes } from "@/utils/permission";
|
import { permissionCodes } from "@/utils/permission";
|
||||||
import { saveCapturedFilesFromInput } from "@/utils/twaBridge";
|
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;
|
type PickerValue = string | number;
|
||||||
|
|
||||||
const SOLID_COLOR_COVER_PURPOSE = "PRODUCT_SOLID_COLOR_COVER";
|
const SOLID_COLOR_COVER_PURPOSE = "PRODUCT_SOLID_COLOR_COVER";
|
||||||
@@ -237,8 +313,18 @@ const DEFAULT_COVER_COLOR = "#2F88FF";
|
|||||||
defineOptions({ name: "ProductEdit" });
|
defineOptions({ name: "ProductEdit" });
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
|
const routeNavBarTitle = computed(() => {
|
||||||
|
switch (route.name) {
|
||||||
|
case "ProductCreate":
|
||||||
|
return "新增产品";
|
||||||
|
case "ProductEdit":
|
||||||
|
return "编辑产品";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
});
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const routeId = computed(() => String(route.params.id || ""));
|
const routeId = computed(() => String(route.params.id || ""));
|
||||||
const isCreateMode = computed(() => !routeId.value);
|
const isCreateMode = computed(() => !routeId.value);
|
||||||
@@ -1131,9 +1217,9 @@ async function load(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
if (userStore.hasPermissions(savePermissionCode.value)) {
|
if (userStore.hasPermissions(savePermissionCode.value)) {
|
||||||
navBarStore.setRightText("保存", "var(--td-brand-color)", save);
|
setPageNavBarRightText("保存", "var(--td-brand-color)", save);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await load();
|
await load();
|
||||||
@@ -1142,7 +1228,7 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
onUnmounted(() => clearPageNavBarRight());
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
@@ -1256,4 +1342,45 @@ onUnmounted(() => navBarStore.clearRight());
|
|||||||
border-color: rgba(148, 163, 184, .3);
|
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>
|
</style>
|
||||||
|
|||||||
@@ -1,97 +1,155 @@
|
|||||||
<template>
|
<template>
|
||||||
<div ref="productListRef" v-can="permissionCodes.product.read" class="product-list">
|
<div class="page-layout navbar product-list">
|
||||||
<div class="filters glass">
|
<t-navbar
|
||||||
<t-input
|
fixed
|
||||||
v-model="keyword"
|
:z-index="20"
|
||||||
class="keyword"
|
title="产品库"
|
||||||
type="search"
|
left-arrow
|
||||||
borderless
|
@left-click="$router.back()"
|
||||||
placeholder="搜索产品名称(拼音)或编码"
|
>
|
||||||
/>
|
<template #right>
|
||||||
<t-dropdown-menu class="menus">
|
<div
|
||||||
<t-dropdown-item
|
class="nav-actions"
|
||||||
v-model="status"
|
v-if="(route.name === 'ProductList' && canCreate) && pageNavBarActionList.length"
|
||||||
label="状态"
|
>
|
||||||
:options="statusOptions"
|
<t-popover
|
||||||
@change="selectStatus"
|
v-model:visible="pageNavBarActionVisible"
|
||||||
/>
|
placement="bottom-right"
|
||||||
<t-dropdown-item
|
:show-arrow="false"
|
||||||
v-model="productType"
|
theme="light"
|
||||||
label="类型"
|
>
|
||||||
:options="productTypeOptions"
|
<t-button
|
||||||
@change="selectProductType"
|
class="trigger"
|
||||||
/>
|
variant="text"
|
||||||
<t-dropdown-item
|
:aria-label="'更多操作'"
|
||||||
:model-value="categoryIdList"
|
type="button"
|
||||||
label="分类"
|
>
|
||||||
:options="categoryOptions"
|
<template #icon>
|
||||||
multiple
|
<t-icon name="ellipsis" />
|
||||||
:options-columns="2"
|
</template>
|
||||||
@change="selectCategory"
|
</t-button>
|
||||||
@confirm="confirmCategory"
|
<template #content>
|
||||||
@reset="resetCategory"
|
<div class="menu">
|
||||||
@update:model-value="updateCategory"
|
<t-button
|
||||||
/>
|
v-for="action in pageNavBarActionList"
|
||||||
</t-dropdown-menu>
|
:key="action.key"
|
||||||
</div>
|
class="menu-item"
|
||||||
<t-pull-down-refresh v-model="isRefreshing" :refresh-timeout="30000" @refresh="refresh" @scrolltolower="loadMore">
|
variant="text"
|
||||||
<t-cell-group
|
type="button"
|
||||||
v-if="productList.length"
|
:theme="action.theme"
|
||||||
class="list fix-last-cell-line empty-cell-title-margin"
|
:loading="action.loading"
|
||||||
theme="card"
|
: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)">
|
<div class="filters glass">
|
||||||
<template #leftIcon>
|
<t-input
|
||||||
<t-image
|
v-model="keyword"
|
||||||
v-if="getProductPhotoURL(item)"
|
class="keyword"
|
||||||
:src="getProductPhotoURL(item)"
|
type="search"
|
||||||
:alt="item.name || '产品图片'"
|
borderless
|
||||||
fit="cover"
|
placeholder="搜索产品名称(拼音)或编码"
|
||||||
class="avatar"
|
/>
|
||||||
|
<t-dropdown-menu class="menus">
|
||||||
|
<t-dropdown-item
|
||||||
|
v-model="status"
|
||||||
|
label="状态"
|
||||||
|
:options="statusOptions"
|
||||||
|
@change="selectStatus"
|
||||||
/>
|
/>
|
||||||
<div
|
<t-dropdown-item
|
||||||
v-else
|
v-model="productType"
|
||||||
class="avatar fallback"
|
label="类型"
|
||||||
v-text="(item.name || '产').slice(0, 1)"
|
:options="productTypeOptions"
|
||||||
|
@change="selectProductType"
|
||||||
/>
|
/>
|
||||||
</template>
|
<t-dropdown-item
|
||||||
<template #title>
|
:model-value="categoryIdList"
|
||||||
<div class="text-bold" v-text="item.name || '未命名产品'" />
|
label="分类"
|
||||||
</template>
|
:options="categoryOptions"
|
||||||
<template #note>
|
multiple
|
||||||
<t-tag
|
:options-columns="2"
|
||||||
size="small"
|
@change="selectCategory"
|
||||||
variant="outline"
|
@confirm="confirmCategory"
|
||||||
:theme="getProductStatusTheme(item.status)"
|
@reset="resetCategory"
|
||||||
:content="getProductStatusText(item.status)"
|
@update:model-value="updateCategory"
|
||||||
/>
|
/>
|
||||||
</template>
|
</t-dropdown-menu>
|
||||||
<template #description>
|
</div>
|
||||||
<div class="description">
|
<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
|
<t-tag
|
||||||
size="small"
|
size="small"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
:content="getProductTypeText(item.productType)"
|
:theme="getProductStatusTheme(item.status)"
|
||||||
|
:content="getProductStatusText(item.status)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</template>
|
||||||
</template>
|
<template #description>
|
||||||
</t-cell>
|
<div class="description">
|
||||||
</t-cell-group>
|
<t-tag
|
||||||
<div v-else class="center-tips" v-text="emptyText" />
|
size="small"
|
||||||
<div v-if="productList.length" class="center-tips" v-text="isLoading ? '正在加载更多' : isNoMore ? '已经到底了' : '上拉加载更多'" />
|
variant="outline"
|
||||||
</t-pull-down-refresh>
|
: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>
|
</div>
|
||||||
<nav-bar-action-menu v-if="route.name === 'ProductList' && canCreate" :actions="actionList" />
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import type { NavBarAction } from "@/types/NavBarAction";
|
||||||
import { type DropdownValue } from "tdesign-mobile-vue";
|
import { type DropdownValue } from "tdesign-mobile-vue";
|
||||||
import { useUserStore } from "timi-web-api";
|
import { useUserStore } from "timi-web-api";
|
||||||
import { onBeforeRouteLeave } from "vue-router";
|
import { onBeforeRouteLeave } from "vue-router";
|
||||||
import ProductAPI from "@/api/ProductAPI";
|
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 type { Product, ProductCategory, ProductStatus, ProductType } from "@/types/Product";
|
||||||
import { getErrorMessage } from "@/utils/error";
|
import { getErrorMessage } from "@/utils/error";
|
||||||
import { getProductPhotoURL, getProductStatusText, getProductStatusTheme, getProductTypeText } from "@/utils/product";
|
import { getProductPhotoURL, getProductStatusText, getProductStatusTheme, getProductTypeText } from "@/utils/product";
|
||||||
@@ -99,12 +157,20 @@ import { events, isCurrentStoreEvent, listDataEventKeys, type ListDataChangedPay
|
|||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { permissionCodes } from "@/utils/permission";
|
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" });
|
defineOptions({ name: "ProductList" });
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const productListRef = ref<HTMLElement | null>(null);
|
const productListRef = ref<HTMLElement | null>(null);
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const canCreate = computed(() => userStore.hasPermissions(permissionCodes.product.create));
|
const canCreate = computed(() => userStore.hasPermissions(permissionCodes.product.create));
|
||||||
const actionList = computed<NavBarAction[]>(() => canCreate.value ? [{
|
const actionList = computed<NavBarAction[]>(() => canCreate.value ? [{
|
||||||
@@ -165,8 +231,7 @@ function restorePageScrollPosition(): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function syncNavBar(): void {
|
function syncNavBar(): void {
|
||||||
navBarStore.clearRight();
|
|
||||||
navBarStore.setCustomRightVisible(route.name === "ProductList" && canCreate.value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const statusOptions = [
|
const statusOptions = [
|
||||||
@@ -406,14 +471,12 @@ watch(keyword, () => {
|
|||||||
|
|
||||||
onBeforeRouteLeave(() => {
|
onBeforeRouteLeave(() => {
|
||||||
savePageScrollPosition();
|
savePageScrollPosition();
|
||||||
navBarStore.clearRight();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
isDisposed = true;
|
isDisposed = true;
|
||||||
unregisterProductListEvent?.();
|
unregisterProductListEvent?.();
|
||||||
unregisterProductListEvent = undefined;
|
unregisterProductListEvent = undefined;
|
||||||
navBarStore.clearRight();
|
|
||||||
window.clearTimeout(keywordTimer);
|
window.clearTimeout(keywordTimer);
|
||||||
requestToken += 1;
|
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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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">
|
<div v-can="permissionCodes.productStock.create" class="product-stock-batch-configure">
|
||||||
<t-form class="form" label-width="5rem" v-entrance-transition>
|
<t-form class="form" label-width="5rem" v-entrance-transition>
|
||||||
<t-form-item label="入库备注" required-mark>
|
<t-form-item label="入库备注" required-mark>
|
||||||
@@ -140,8 +185,6 @@
|
|||||||
import { onBeforeRouteLeave } from "vue-router";
|
import { onBeforeRouteLeave } from "vue-router";
|
||||||
import { useUserStore } from "timi-web-api";
|
import { useUserStore } from "timi-web-api";
|
||||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
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 MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
||||||
import ProductAPI from "@/api/ProductAPI";
|
import ProductAPI from "@/api/ProductAPI";
|
||||||
import type { ProductSkuUnit, ProductStockManualInBatchItem, ProductStockManualInBatchRequest } from "@/types/Product";
|
import type { ProductSkuUnit, ProductStockManualInBatchItem, ProductStockManualInBatchRequest } from "@/types/Product";
|
||||||
@@ -154,12 +197,48 @@ import { permissionCodes } from "@/utils/permission";
|
|||||||
import { getCurrentStoreId } from "@/utils/store";
|
import { getCurrentStoreId } from "@/utils/store";
|
||||||
import { uploadPhotoList } from "@/utils/photo";
|
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;
|
type PickerValue = string | number;
|
||||||
|
|
||||||
defineOptions({ name: "ProductStockBatchConfigure" });
|
defineOptions({ name: "ProductStockBatchConfigure" });
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const currentStoreStore = useCurrentStoreStore();
|
const currentStoreStore = useCurrentStoreStore();
|
||||||
const productStockBatchStore = useProductStockBatchStore();
|
const productStockBatchStore = useProductStockBatchStore();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
@@ -264,12 +343,12 @@ function isItemValid(item: ProductStockBatchSelection): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateNavBar(): void {
|
function updateNavBar(): void {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
if (!userStore.hasPermissions(permissionCodes.productStock.create)) {
|
if (!userStore.hasPermissions(permissionCodes.productStock.create)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
navBarStore.setRightText(isSaving.value ? "提交中" : "提交", "var(--td-brand-color)", submit);
|
setPageNavBarRightText(isSaving.value ? "提交中" : "提交", "var(--td-brand-color)", submit);
|
||||||
navBarStore.setRightDisabled(!canSubmit.value);
|
setPageNavBarRightDisabled(!canSubmit.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectUnit(item: ProductStockBatchSelection, unit: ProductSkuUnit): void {
|
function selectUnit(item: ProductStockBatchSelection, unit: ProductSkuUnit): void {
|
||||||
@@ -440,9 +519,9 @@ onActivated(() => {
|
|||||||
updateNavBar();
|
updateNavBar();
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeRouteLeave(() => navBarStore.clearRight());
|
onBeforeRouteLeave(() => clearPageNavBarRight());
|
||||||
|
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
onUnmounted(() => clearPageNavBarRight());
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<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>
|
</style>
|
||||||
|
|||||||
@@ -1,36 +1,83 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-can="permissionCodes.productStock.create" class="product-stock-batch-select">
|
<div class="page-layout navbar product-stock-batch-select">
|
||||||
<div class="filters glass">
|
<t-navbar
|
||||||
<t-input
|
fixed
|
||||||
v-model="keyword"
|
:z-index="20"
|
||||||
class="keyword"
|
title="选择入库 SKU"
|
||||||
type="search"
|
left-arrow
|
||||||
borderless
|
@left-click="$router.back()"
|
||||||
clearable
|
|
||||||
placeholder="搜索产品名称或编码"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<t-pull-down-refresh
|
|
||||||
class="list-wrap empty-cell-title-margin"
|
|
||||||
v-model="isRefreshing"
|
|
||||||
:refresh-timeout="30000"
|
|
||||||
@refresh="refresh"
|
|
||||||
@scrolltolower="loadMore"
|
|
||||||
>
|
>
|
||||||
<product-sku-selector
|
<template #right>
|
||||||
class="selector"
|
<div
|
||||||
v-if="productList.length"
|
v-if="pageNavBarRight.icon || pageNavBarRight.text"
|
||||||
v-model:expanded-product-key-list="expandedProductKeyList"
|
class="nav-right-slot"
|
||||||
:items="selectorItemList"
|
>
|
||||||
:selected-sku-id-list="selectedSkuIdList"
|
<t-badge
|
||||||
selection-mode="multiple"
|
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined"
|
||||||
@change="handleProductChange"
|
class="badge"
|
||||||
@toggle="toggleSku"
|
:count="pageNavBarRight.badge"
|
||||||
@check="toggleProductSkus"
|
:max-count="99"
|
||||||
/>
|
:show-zero="false"
|
||||||
<div v-else class="center-tips" v-text="emptyText" />
|
>
|
||||||
<div v-if="productList.length" class="center-tips" v-text="isLoading ? '正在加载更多' : isNoMore ? '已经到底了' : '上拉加载更多'" />
|
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
|
||||||
</t-pull-down-refresh>
|
<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>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -39,8 +86,6 @@ import { onBeforeRouteLeave } from "vue-router";
|
|||||||
import { useUserStore } from "timi-web-api";
|
import { useUserStore } from "timi-web-api";
|
||||||
import ProductAPI from "@/api/ProductAPI";
|
import ProductAPI from "@/api/ProductAPI";
|
||||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
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 { Product, ProductSku, ProductStockProduct } from "@/types/Product";
|
||||||
import type { ProductSkuSelectorItem } from "@/types/ProductSkuSelection";
|
import type { ProductSkuSelectorItem } from "@/types/ProductSkuSelection";
|
||||||
import { getErrorMessage } from "@/utils/error";
|
import { getErrorMessage } from "@/utils/error";
|
||||||
@@ -49,11 +94,47 @@ import { Message } from "@/utils/message";
|
|||||||
import { permissionCodes } from "@/utils/permission";
|
import { permissionCodes } from "@/utils/permission";
|
||||||
import { getCurrentStoreId } from "@/utils/store";
|
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" });
|
defineOptions({ name: "ProductStockBatchSelect" });
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const currentStoreStore = useCurrentStoreStore();
|
const currentStoreStore = useCurrentStoreStore();
|
||||||
const productStockBatchStore = useProductStockBatchStore();
|
const productStockBatchStore = useProductStockBatchStore();
|
||||||
@@ -133,10 +214,10 @@ function getCurrentRouteDepth(): number {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateNavBar(): void {
|
function updateNavBar(): void {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
if (canReadAndCreate.value) {
|
if (canReadAndCreate.value) {
|
||||||
navBarStore.setRightText("下一步", "var(--td-brand-color)", toConfigure);
|
setPageNavBarRightText("下一步", "var(--td-brand-color)", toConfigure);
|
||||||
navBarStore.setRightDisabled(!canContinue.value);
|
setPageNavBarRightDisabled(!canContinue.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -361,10 +442,10 @@ onActivated(async () => {
|
|||||||
updateNavBar();
|
updateNavBar();
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeRouteLeave(() => navBarStore.clearRight());
|
onBeforeRouteLeave(() => clearPageNavBarRight());
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
window.clearTimeout(keywordTimer);
|
window.clearTimeout(keywordTimer);
|
||||||
requestToken += 1;
|
requestToken += 1;
|
||||||
productDetailToken += 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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<t-navbar
|
||||||
|
fixed
|
||||||
|
:z-index="20"
|
||||||
|
title="库存详情"
|
||||||
|
left-arrow
|
||||||
|
@left-click="$router.back()"
|
||||||
|
/>
|
||||||
<div v-can="permissionCodes.productStock.read" class="product-stock-detail">
|
<div v-can="permissionCodes.productStock.read" class="product-stock-detail">
|
||||||
<t-loading v-if="isLoading" class="loading" size="32px" />
|
<t-loading v-if="isLoading" class="loading" size="32px" />
|
||||||
<template v-else-if="product && sku && stock">
|
<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 ProductProfile from "@/pages/product/component/ProductProfile.vue";
|
||||||
import ProductStockPackageSummary from "@/pages/product/component/ProductStockPackageSummary.vue";
|
import ProductStockPackageSummary from "@/pages/product/component/ProductStockPackageSummary.vue";
|
||||||
import ProductStockOperationPopup from "@/pages/product/component/ProductStockOperationPopup.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 { getErrorMessage } from "@/utils/error";
|
||||||
import { convertBaseQuantityToPackageQuantity } from "@/utils/package";
|
import { convertBaseQuantityToPackageQuantity } from "@/utils/package";
|
||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { permissionCodes } from "@/utils/permission";
|
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">;
|
type ManualStockOperation = Extract<StockOperationType, "MANUAL_IN" | "MANUAL_OUT" | "STOCKTAKE_GAIN" | "STOCKTAKE_LOSS">;
|
||||||
|
|
||||||
defineOptions({ name: "ProductStockDetail" });
|
defineOptions({ name: "ProductStockDetail" });
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const product = ref<Product>();
|
const product = ref<Product>();
|
||||||
const sku = ref<ProductSku>();
|
const sku = ref<ProductSku>();
|
||||||
@@ -245,7 +251,6 @@ function openOperation(type: ManualStockOperation): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navBarStore.clearRight();
|
|
||||||
try {
|
try {
|
||||||
await loadAll();
|
await loadAll();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -253,7 +258,6 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
|
|||||||
@@ -1,63 +1,110 @@
|
|||||||
<template>
|
<template>
|
||||||
<div ref="productStockListRef" v-can="permissionCodes.productStock.read" class="product-stock-list">
|
<div class="page-layout navbar product-stock-list">
|
||||||
<div class="filters glass">
|
<t-navbar
|
||||||
<t-input
|
fixed
|
||||||
v-model="keyword"
|
:z-index="20"
|
||||||
class="keyword"
|
title="选择产品"
|
||||||
type="search"
|
left-arrow
|
||||||
borderless
|
@left-click="$router.back()"
|
||||||
clearable
|
|
||||||
placeholder="搜索产品名称(拼音)或编码"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<t-pull-down-refresh
|
|
||||||
class="list-wrap empty-cell-title-margin"
|
|
||||||
v-model="isRefreshing"
|
|
||||||
:refresh-timeout="30000"
|
|
||||||
@refresh="refresh"
|
|
||||||
@scrolltolower="loadMore"
|
|
||||||
>
|
>
|
||||||
<t-cell-group v-if="productList.length" theme="card" class="list fix-last-cell-line">
|
<template #right>
|
||||||
<t-cell
|
<div
|
||||||
class="item"
|
v-if="pageNavBarRight.icon || pageNavBarRight.text"
|
||||||
v-for="item in productList"
|
class="nav-right-slot"
|
||||||
:key="item.productId"
|
|
||||||
:title="item.productName || '未命名产品'"
|
|
||||||
arrow
|
|
||||||
v-entrance-transition="{ step: 30 }"
|
|
||||||
@click="toSkuList(item)"
|
|
||||||
>
|
>
|
||||||
<template #leftIcon>
|
<t-badge
|
||||||
<t-image
|
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined"
|
||||||
v-if="getProductPhotoURL(item)"
|
class="badge"
|
||||||
:src="getProductPhotoURL(item)"
|
:count="pageNavBarRight.badge"
|
||||||
:alt="item.productName || '产品图片'"
|
:max-count="99"
|
||||||
fit="cover"
|
:show-zero="false"
|
||||||
class="avatar"
|
>
|
||||||
/>
|
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
|
||||||
<div v-else class="avatar fallback" v-text="(item.productName || '产').slice(0, 1)" />
|
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
|
||||||
</template>
|
</button>
|
||||||
<template #description>
|
</t-badge>
|
||||||
<div class="stock">
|
<button
|
||||||
<span class="on-hand">
|
v-else-if="pageNavBarRight.icon"
|
||||||
<span>库存</span>
|
class="button"
|
||||||
<strong v-text="getProductQuantityText(item.onHandQuantity)" />
|
type="button"
|
||||||
</span>
|
:disabled="pageNavBarRight.disabled"
|
||||||
<span class="available">
|
@click="handlePageNavBarRightAction"
|
||||||
<span>可用</span>
|
>
|
||||||
<strong v-text="getProductQuantityText(item.availableQuantity)" />
|
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
|
||||||
</span>
|
</button>
|
||||||
<span class="reserved">
|
<button
|
||||||
<span>预占</span>
|
v-else
|
||||||
<strong v-text="getProductQuantityText(item.reservedQuantity)" />
|
class="nav-text"
|
||||||
</span>
|
type="button"
|
||||||
</div>
|
:disabled="pageNavBarRight.disabled"
|
||||||
</template>
|
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
|
||||||
</t-cell>
|
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
|
||||||
</t-cell-group>
|
@click="handlePageNavBarRightAction"
|
||||||
<div v-else class="center-tips" v-text="emptyText" />
|
v-text="pageNavBarRight.text"
|
||||||
<div v-if="productList.length" class="center-tips" v-text="isLoading ? '正在加载更多' : isNoMore ? '已经到底了' : '上拉加载更多'" />
|
/>
|
||||||
</t-pull-down-refresh>
|
</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>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -66,8 +113,6 @@ import { useUserStore } from "timi-web-api";
|
|||||||
import { onBeforeRouteLeave } from "vue-router";
|
import { onBeforeRouteLeave } from "vue-router";
|
||||||
import ProductAPI from "@/api/ProductAPI";
|
import ProductAPI from "@/api/ProductAPI";
|
||||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
import { useProductStockBatchStore } from "@/store/productStockBatchStore";
|
|
||||||
import type { ProductStockProduct } from "@/types/Product";
|
import type { ProductStockProduct } from "@/types/Product";
|
||||||
import { getErrorMessage } from "@/utils/error";
|
import { getErrorMessage } from "@/utils/error";
|
||||||
import { getProductPhotoURL, getProductQuantityText } from "@/utils/product";
|
import { getProductPhotoURL, getProductQuantityText } from "@/utils/product";
|
||||||
@@ -76,12 +121,44 @@ import { Message } from "@/utils/message";
|
|||||||
import { permissionCodes } from "@/utils/permission";
|
import { permissionCodes } from "@/utils/permission";
|
||||||
import { getCurrentStoreId } from "@/utils/store";
|
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" });
|
defineOptions({ name: "ProductStockList" });
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const productStockListRef = ref<HTMLElement | null>(null);
|
const productStockListRef = ref<HTMLElement | null>(null);
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const currentStoreStore = useCurrentStoreStore();
|
const currentStoreStore = useCurrentStoreStore();
|
||||||
const productStockBatchStore = useProductStockBatchStore();
|
const productStockBatchStore = useProductStockBatchStore();
|
||||||
@@ -141,9 +218,9 @@ function getCurrentRouteDepth(): number {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateNavBar(): void {
|
function updateNavBar(): void {
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
if (canBatchIn.value) {
|
if (canBatchIn.value) {
|
||||||
navBarStore.setRightText("批量入库", "var(--td-brand-color)", openBatchIn);
|
setPageNavBarRightText("批量入库", "var(--td-brand-color)", openBatchIn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -334,14 +411,14 @@ watch(keyword, () => {
|
|||||||
|
|
||||||
onBeforeRouteLeave(() => {
|
onBeforeRouteLeave(() => {
|
||||||
savePageScrollPosition();
|
savePageScrollPosition();
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
isDisposed = true;
|
isDisposed = true;
|
||||||
unregisterProductStockListEvent?.();
|
unregisterProductStockListEvent?.();
|
||||||
unregisterProductStockListEvent = undefined;
|
unregisterProductStockListEvent = undefined;
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
window.clearTimeout(keywordTimer);
|
window.clearTimeout(keywordTimer);
|
||||||
requestToken += 1;
|
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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,11 @@
|
|||||||
<template>
|
<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">
|
<div v-can="permissionCodes.productStock.read" class="product-stock-record-detail">
|
||||||
<t-loading v-if="isLoading" class="loading" size="32px" />
|
<t-loading v-if="isLoading" class="loading" size="32px" />
|
||||||
<template v-else-if="record">
|
<template v-else-if="record">
|
||||||
@@ -139,8 +146,6 @@ import { useUserStore, type Attachment } from "timi-web-api";
|
|||||||
import ProductAPI from "@/api/ProductAPI";
|
import ProductAPI from "@/api/ProductAPI";
|
||||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
||||||
import ProductSkuTags from "@/components/ProductSkuTags.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 type { StockBizType, StockRecord } from "@/types/Product";
|
||||||
import { getAttachmentReadURL } from "@/utils/attachment";
|
import { getAttachmentReadURL } from "@/utils/attachment";
|
||||||
import { getErrorMessage } from "@/utils/error";
|
import { getErrorMessage } from "@/utils/error";
|
||||||
@@ -150,10 +155,11 @@ import { Message } from "@/utils/message";
|
|||||||
import { permissionCodes } from "@/utils/permission";
|
import { permissionCodes } from "@/utils/permission";
|
||||||
import { uploadPhotoList } from "@/utils/photo";
|
import { uploadPhotoList } from "@/utils/photo";
|
||||||
|
|
||||||
|
import type { PhotoItem } from "@/types/Photo";
|
||||||
|
|
||||||
defineOptions({ name: "ProductStockRecordDetail" });
|
defineOptions({ name: "ProductStockRecordDetail" });
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const record = ref<StockRecord>();
|
const record = ref<StockRecord>();
|
||||||
@@ -317,7 +323,6 @@ async function loadData(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navBarStore.clearRight();
|
|
||||||
await loadData();
|
await loadData();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -327,7 +332,6 @@ watch(() => String(route.params.id || ""), async (id, previousId) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
|
|||||||
@@ -1,198 +1,208 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-can="permissionCodes.productStock.read" class="product-stock-record-list">
|
<div class="page-layout navbar product-stock-record-list">
|
||||||
<div class="filters glass">
|
<t-navbar
|
||||||
<div class="search-row">
|
fixed
|
||||||
<t-input
|
:z-index="20"
|
||||||
v-model="keyword"
|
title="库存流水"
|
||||||
class="keyword"
|
left-arrow
|
||||||
type="search"
|
@left-click="handleNavBarBack"
|
||||||
borderless
|
/>
|
||||||
clearable
|
<main v-can="permissionCodes.productStock.read" class="page-content scroll list">
|
||||||
placeholder="搜索产品名称(拼音)或编码"
|
<t-pull-down-refresh
|
||||||
>
|
class="pull-refresh"
|
||||||
<template #suffix-icon>
|
v-model="isRefreshing"
|
||||||
<div class="actions">
|
:refresh-timeout="30000"
|
||||||
<t-button
|
@refresh="refresh"
|
||||||
size="extra-small"
|
@scrolltolower="loadMore"
|
||||||
theme="primary"
|
>
|
||||||
variant="outline"
|
<div class="filters glass">
|
||||||
content="选择产品"
|
<div class="search-row">
|
||||||
@click.stop="productSelectorVisible = true"
|
<t-input
|
||||||
/>
|
v-model="keyword"
|
||||||
</div>
|
class="keyword"
|
||||||
</template>
|
type="search"
|
||||||
</t-input>
|
borderless
|
||||||
</div>
|
clearable
|
||||||
<t-dropdown-menu class="menus">
|
placeholder="搜索产品名称(拼音)或编码"
|
||||||
<t-dropdown-item
|
>
|
||||||
v-model="dateFilterType"
|
<template #suffix-icon>
|
||||||
:label="dateFilterLabel"
|
<div class="actions">
|
||||||
:options="dateOptions"
|
<t-button
|
||||||
@change="selectDateFilter"
|
size="extra-small"
|
||||||
/>
|
theme="primary"
|
||||||
<t-dropdown-item v-model="operationType" :label="operationFilterLabel" :options="operationOptions" @change="selectOperationType" />
|
variant="outline"
|
||||||
<t-dropdown-item v-model="direction" :label="directionFilterLabel" :options="directionOptions" @change="selectDirection" />
|
content="选择产品"
|
||||||
</t-dropdown-menu>
|
@click.stop="productSelectorVisible = true"
|
||||||
</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>
|
</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>
|
</template>
|
||||||
</t-cell>
|
<template v-if="filteredSku">
|
||||||
</t-cell-group>
|
<t-cell title="累计入库" :note="getStockSummaryText(inBaseQuantityTotal)" />
|
||||||
<div v-else class="center-tips" v-text="emptyText" />
|
<t-cell title="累计出库" :note="getStockSummaryText(outBaseQuantityTotal)" />
|
||||||
<div v-if="recordList.length" class="center-tips" v-text="loadStateText" />
|
</template>
|
||||||
</div>
|
</t-cell-group>
|
||||||
</t-pull-down-refresh>
|
<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>
|
</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>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
@@ -202,8 +212,6 @@ import { UserAPI } from "timi-web-api";
|
|||||||
import { onBeforeRouteLeave } from "vue-router";
|
import { onBeforeRouteLeave } from "vue-router";
|
||||||
import ProductAPI from "@/api/ProductAPI";
|
import ProductAPI from "@/api/ProductAPI";
|
||||||
import ProductSelectPopup from "@/components/productSelector/ProductSelectPopup.vue";
|
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 type { ProductSkuSelectionValue } from "@/types/ProductSkuSelection";
|
||||||
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
|
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
|
||||||
import { getErrorMessage } from "@/utils/error";
|
import { getErrorMessage } from "@/utils/error";
|
||||||
@@ -213,6 +221,8 @@ import { permissionCodes } from "@/utils/permission";
|
|||||||
import { getCustomerPhotoURL } from "@/utils/customer";
|
import { getCustomerPhotoURL } from "@/utils/customer";
|
||||||
import { buildFallbackAvatar } from "@/utils/avatar";
|
import { buildFallbackAvatar } from "@/utils/avatar";
|
||||||
|
|
||||||
|
import type { Product, ProductSelection, ProductSku, StockOperationType, StockRecord, StockRecordDirection } from "@/types/Product";
|
||||||
|
|
||||||
defineOptions({ name: "ProductStockRecordList" });
|
defineOptions({ name: "ProductStockRecordList" });
|
||||||
|
|
||||||
type DateFilterType = "today" | "yesterday" | "thisWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
|
type DateFilterType = "today" | "yesterday" | "thisWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
|
||||||
@@ -221,8 +231,8 @@ type DirectionFilter = "ALL" | StockRecordDirection;
|
|||||||
|
|
||||||
const pageSize = 15;
|
const pageSize = 15;
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
const pageNavBarBackTo = ref<string>();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const recordList = ref<StockRecord[]>([]);
|
const recordList = ref<StockRecord[]>([]);
|
||||||
const inBaseQuantityTotal = ref<number>();
|
const inBaseQuantityTotal = ref<number>();
|
||||||
const outBaseQuantityTotal = 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> {
|
async function reload(): Promise<void> {
|
||||||
pageIndex.value = 0;
|
pageIndex.value = 0;
|
||||||
recordList.value = [];
|
recordList.value = [];
|
||||||
@@ -620,8 +641,7 @@ async function refresh(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navBarStore.setBackTo(returnToProductTab ? "/product" : undefined);
|
pageNavBarBackTo.value = returnToProductTab ? "/product" : undefined;
|
||||||
navBarStore.clearRight();
|
|
||||||
try {
|
try {
|
||||||
await Promise.all([loadSkuFilter(), reload()]);
|
await Promise.all([loadSkuFilter(), reload()]);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -629,7 +649,7 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeRouteLeave(() => navBarStore.setBackTo(undefined));
|
onBeforeRouteLeave(() => pageNavBarBackTo.value = undefined);
|
||||||
|
|
||||||
watch(keyword, () => {
|
watch(keyword, () => {
|
||||||
if (skipNextKeywordChange) {
|
if (skipNextKeywordChange) {
|
||||||
@@ -647,8 +667,7 @@ watch(keyword, () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
navBarStore.setBackTo(undefined);
|
pageNavBarBackTo.value = undefined;
|
||||||
navBarStore.clearRight();
|
|
||||||
window.clearTimeout(keywordTimer);
|
window.clearTimeout(keywordTimer);
|
||||||
requestToken += 1;
|
requestToken += 1;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,114 +1,122 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-can="permissionCodes.productStock.read" class="product-stock-sku-list">
|
<div class="page-layout navbar product-stock-sku-list">
|
||||||
<div class="filters glass">
|
<t-navbar
|
||||||
<t-input
|
fixed
|
||||||
v-model="keyword"
|
:z-index="20"
|
||||||
class="keyword"
|
title="选择 SKU"
|
||||||
type="search"
|
left-arrow
|
||||||
borderless
|
@left-click="$router.back()"
|
||||||
clearable
|
/>
|
||||||
placeholder="搜索 SKU 名称、编码或规格"
|
<main v-can="permissionCodes.productStock.read" class="page-content scroll list">
|
||||||
/>
|
<t-pull-down-refresh
|
||||||
</div>
|
class="list-wrap empty-cell-title-margin pull-refresh"
|
||||||
<t-pull-down-refresh
|
v-model="isRefreshing"
|
||||||
class="list-wrap empty-cell-title-margin"
|
:refresh-timeout="30000"
|
||||||
v-model="isRefreshing"
|
@refresh="refresh"
|
||||||
:refresh-timeout="30000"
|
@scrolltolower="loadMore"
|
||||||
@refresh="refresh"
|
>
|
||||||
@scrolltolower="loadMore"
|
<div class="filters glass">
|
||||||
>
|
<t-input
|
||||||
<div class="content">
|
v-model="keyword"
|
||||||
<t-cell-group theme="card">
|
class="keyword"
|
||||||
<t-cell title="产品" :note="product?.name" />
|
type="search"
|
||||||
</t-cell-group>
|
borderless
|
||||||
<t-cell-group
|
clearable
|
||||||
v-if="skuStockList.length"
|
placeholder="搜索 SKU 名称、编码或规格"
|
||||||
theme="card"
|
/>
|
||||||
class="list fix-last-cell-line empty-cell-title-margin"
|
</div>
|
||||||
>
|
<div class="content">
|
||||||
<t-cell
|
<t-cell-group theme="card">
|
||||||
class="item"
|
<t-cell title="产品" :note="product?.name" />
|
||||||
v-for="item in skuStockList"
|
</t-cell-group>
|
||||||
:key="item.skuId || item.id"
|
<t-cell-group
|
||||||
arrow
|
v-if="skuStockList.length"
|
||||||
v-entrance-transition="{ step: 30 }"
|
theme="card"
|
||||||
@click="toDetail(item)"
|
class="list fix-last-cell-line empty-cell-title-margin"
|
||||||
>
|
>
|
||||||
<template #title>
|
<t-cell
|
||||||
<div class="title">
|
class="item"
|
||||||
<strong v-text="item.sku?.name || '未命名 SKU 明细'" />
|
v-for="item in skuStockList"
|
||||||
<div
|
:key="item.skuId || item.id"
|
||||||
v-if="getUnitList(item).length"
|
arrow
|
||||||
class="unit-options"
|
v-entrance-transition="{ step: 30 }"
|
||||||
role="group"
|
@click="toDetail(item)"
|
||||||
:aria-label="`切换${item.sku?.name || 'SKU'}库存单位`"
|
>
|
||||||
>
|
<template #title>
|
||||||
<t-button
|
<div class="title">
|
||||||
v-for="unit in getUnitList(item)"
|
<strong v-text="item.sku?.name || '未命名 SKU 明细'" />
|
||||||
:key="unit.id"
|
<div
|
||||||
size="extra-small"
|
v-if="getUnitList(item).length"
|
||||||
:theme="getSelectedUnit(item)?.id === unit.id ? 'primary' : 'default'"
|
class="unit-options"
|
||||||
:variant="getSelectedUnit(item)?.id === unit.id ? 'base' : 'outline'"
|
role="group"
|
||||||
:aria-label="`切换到${unit.name || '未命名单位'}`"
|
:aria-label="`切换${item.sku?.name || 'SKU'}库存单位`"
|
||||||
:aria-pressed="getSelectedUnit(item)?.id === unit.id"
|
|
||||||
@click.stop="selectUnit(item, unit.id || '')"
|
|
||||||
>
|
>
|
||||||
<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>
|
||||||
</div>
|
</template>
|
||||||
</template>
|
<template #leftIcon>
|
||||||
<template #leftIcon>
|
<t-image
|
||||||
<t-image
|
v-if="getSkuPhotoURL(item)"
|
||||||
v-if="getSkuPhotoURL(item)"
|
:src="getSkuPhotoURL(item)"
|
||||||
:src="getSkuPhotoURL(item)"
|
:alt="item.sku?.name || 'SKU 图片'"
|
||||||
:alt="item.sku?.name || 'SKU 图片'"
|
fit="cover"
|
||||||
fit="cover"
|
class="avatar"
|
||||||
class="avatar"
|
/>
|
||||||
/>
|
<div v-else class="avatar fallback" v-text="(item.sku?.name || 'S').slice(0, 1)" />
|
||||||
<div v-else class="avatar fallback" v-text="(item.sku?.name || 'S').slice(0, 1)" />
|
</template>
|
||||||
</template>
|
<template #description>
|
||||||
<template #description>
|
<div class="stock">
|
||||||
<div class="stock">
|
<span class="on-hand">
|
||||||
<span class="on-hand">
|
<span>库存</span>
|
||||||
<span>库存</span>
|
<strong v-text="getStockQuantityText(item, item.onHandQuantity)" />
|
||||||
<strong v-text="getStockQuantityText(item, item.onHandQuantity)" />
|
</span>
|
||||||
</span>
|
<span class="available">
|
||||||
<span class="available">
|
<span>可用</span>
|
||||||
<span>可用</span>
|
<strong v-text="getStockQuantityText(item, item.availableQuantity)" />
|
||||||
<strong v-text="getStockQuantityText(item, item.availableQuantity)" />
|
</span>
|
||||||
</span>
|
<span class="reserved">
|
||||||
<span class="reserved">
|
<span>预占</span>
|
||||||
<span>预占</span>
|
<strong v-text="getStockQuantityText(item, item.reservedQuantity)" />
|
||||||
<strong v-text="getStockQuantityText(item, item.reservedQuantity)" />
|
</span>
|
||||||
</span>
|
</div>
|
||||||
</div>
|
</template>
|
||||||
</template>
|
</t-cell>
|
||||||
</t-cell>
|
</t-cell-group>
|
||||||
</t-cell-group>
|
<div v-else class="center-tips" v-text="emptyText" />
|
||||||
<div v-else class="center-tips" v-text="emptyText" />
|
<div v-if="skuStockList.length" class="center-tips" v-text="isLoading ? '正在加载更多' : isNoMore ? '已经到底了' : '上拉加载更多'" />
|
||||||
<div v-if="skuStockList.length" class="center-tips" v-text="isLoading ? '正在加载更多' : isNoMore ? '已经到底了' : '上拉加载更多'" />
|
</div>
|
||||||
</div>
|
</t-pull-down-refresh>
|
||||||
</t-pull-down-refresh>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useUserStore } from "timi-web-api";
|
import { useUserStore } from "timi-web-api";
|
||||||
import ProductAPI from "@/api/ProductAPI";
|
import ProductAPI from "@/api/ProductAPI";
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
import type { Product, ProductSkuUnit, ProductStock } from "@/types/Product";
|
|
||||||
import { getErrorMessage } from "@/utils/error";
|
import { getErrorMessage } from "@/utils/error";
|
||||||
import { convertBaseQuantityToPackageQuantity } from "@/utils/package";
|
import { convertBaseQuantityToPackageQuantity } from "@/utils/package";
|
||||||
import { getProductPhotoURL, getProductQuantityText } from "@/utils/product";
|
import { getProductPhotoURL, getProductQuantityText } from "@/utils/product";
|
||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { permissionCodes } from "@/utils/permission";
|
import { permissionCodes } from "@/utils/permission";
|
||||||
|
|
||||||
|
import type { Product, ProductSkuUnit, ProductStock } from "@/types/Product";
|
||||||
|
|
||||||
defineOptions({ name: "ProductStockSkuList" });
|
defineOptions({ name: "ProductStockSkuList" });
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const keyword = ref("");
|
const keyword = ref("");
|
||||||
const product = ref<Product>();
|
const product = ref<Product>();
|
||||||
@@ -278,7 +286,6 @@ async function toDetail(item: ProductStock): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navBarStore.clearRight();
|
|
||||||
if (!userStore.hasPermissions(permissionCodes.productStock.read)) {
|
if (!userStore.hasPermissions(permissionCodes.productStock.read)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -308,7 +315,6 @@ watch(keyword, () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
navBarStore.clearRight();
|
|
||||||
window.clearTimeout(keywordTimer);
|
window.clearTimeout(keywordTimer);
|
||||||
requestToken += 1;
|
requestToken += 1;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,173 +1,183 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-can="permissionCodes.salesOrder.read" class="consumption-record-list">
|
<div class="page-layout navbar consumption-record-list">
|
||||||
<div class="filters glass">
|
<t-navbar
|
||||||
<t-input
|
fixed
|
||||||
class="keyword"
|
:z-index="20"
|
||||||
:value="customerDisplayText"
|
title="消费记录"
|
||||||
readonly
|
left-arrow
|
||||||
borderless
|
@left-click="$router.back()"
|
||||||
placeholder="选择或扫码客户"
|
/>
|
||||||
@click="customerSelectorVisible = true"
|
<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="filters glass">
|
||||||
<div class="actions">
|
<t-input
|
||||||
<t-button
|
class="keyword"
|
||||||
v-if="customerId"
|
:value="customerDisplayText"
|
||||||
shape="circle"
|
readonly
|
||||||
theme="danger"
|
borderless
|
||||||
variant="text"
|
placeholder="选择或扫码客户"
|
||||||
size="extra-small"
|
@click="customerSelectorVisible = true"
|
||||||
aria-label="清除客户选择"
|
>
|
||||||
@click.stop="clearCustomer"
|
<template #suffix-icon>
|
||||||
>
|
<div class="actions">
|
||||||
<t-icon name="close" size="1rem" />
|
<t-button
|
||||||
</t-button>
|
v-if="customerId"
|
||||||
<t-button
|
shape="circle"
|
||||||
size="extra-small"
|
theme="danger"
|
||||||
theme="primary"
|
variant="text"
|
||||||
variant="outline"
|
size="extra-small"
|
||||||
:content="scannerVisible ? '关闭扫码' : '扫码'"
|
aria-label="清除客户选择"
|
||||||
@click.stop="toggleScanner"
|
@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>
|
</div>
|
||||||
</template>
|
<t-cell-group class="summary" theme="card">
|
||||||
</t-input>
|
<t-cell
|
||||||
<t-dropdown-menu class="menus">
|
v-if="dateFilterType !== 'all'"
|
||||||
<t-dropdown-item
|
title="开始时间"
|
||||||
v-model="dateFilterType"
|
:note="dateRange[0] || '-'"
|
||||||
:label="dateFilterLabel"
|
arrow
|
||||||
:options="dateOptions"
|
@click="openStartTime"
|
||||||
@change="selectDateFilter"
|
/>
|
||||||
/>
|
<t-cell
|
||||||
<t-dropdown-item
|
v-if="dateFilterType !== 'all'"
|
||||||
v-model="sourceType"
|
title="结束时间"
|
||||||
label="消费来源"
|
:note="dateRange[1] || '-'"
|
||||||
:options="sourceTypeOptions"
|
arrow
|
||||||
@change="reloadRecords"
|
@click="openEndTime"
|
||||||
/>
|
/>
|
||||||
<t-dropdown-item
|
<t-cell title="记录数" :note="`共 ${total} 条`" />
|
||||||
v-model="status"
|
<t-cell title="消费金额合计" :note="`¥${formatPackageAmount(amountTotal)}`" />
|
||||||
label="消费状态"
|
</t-cell-group>
|
||||||
:options="statusOptions"
|
<t-cell-group v-if="recordList.length" class="empty-cell-title-margin" theme="card">
|
||||||
@change="reloadRecords"
|
<t-cell
|
||||||
/>
|
class="item"
|
||||||
</t-dropdown-menu>
|
v-for="item in recordList"
|
||||||
</div>
|
:key="item.id"
|
||||||
<t-pull-down-refresh
|
:arrow="canOpenSource(item)"
|
||||||
v-model="isRefreshing"
|
v-entrance-transition="{ step: 30 }"
|
||||||
:refresh-timeout="30000"
|
@click="openSource(item)"
|
||||||
@refresh="reloadRecords"
|
>
|
||||||
@scrolltolower="loadRecords"
|
<template #leftIcon>
|
||||||
>
|
<t-image
|
||||||
<div class="list-wrap">
|
v-if="getCustomerPhotoURL(item.customer, 64)"
|
||||||
<div v-if="scannerVisible" class="scanner-wrap">
|
:src="getCustomerPhotoURL(item.customer, 64)"
|
||||||
<code-scanner
|
:alt="getCustomerText(item)"
|
||||||
visible
|
fit="cover"
|
||||||
:status-text="scanStatus"
|
class="avatar"
|
||||||
active-text="正在识别客户编码,请将条码或二维码移入取景框。"
|
/>
|
||||||
@decode="handleDecodedText"
|
<div v-else class="avatar fallback" v-text="getCustomerText(item).slice(0, 1)" />
|
||||||
@status-change="handleScanStatusChange"
|
</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>
|
</div>
|
||||||
<t-cell-group class="summary" theme="card">
|
</t-pull-down-refresh>
|
||||||
<t-cell
|
<customer-selector
|
||||||
v-if="dateFilterType !== 'all'"
|
v-model="customerId"
|
||||||
title="开始时间"
|
v-model:visible="customerSelectorVisible"
|
||||||
:note="dateRange[0] || '-'"
|
:enable-scan="false"
|
||||||
arrow
|
@change="handleCustomerChange"
|
||||||
@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-popup>
|
<t-popup v-model="startVisible" placement="bottom">
|
||||||
<t-popup v-model="endVisible" placement="bottom">
|
<t-date-time-picker
|
||||||
<t-date-time-picker
|
v-if="startVisible"
|
||||||
v-if="endVisible"
|
v-model="startDraft"
|
||||||
v-model="endDraft"
|
format="YYYY-MM-DD HH:mm"
|
||||||
format="YYYY-MM-DD HH:mm"
|
:mode="['date', 'minute']"
|
||||||
:mode="['date', 'minute']"
|
title="开始时间"
|
||||||
title="结束时间"
|
:default-value="dateRange[0]"
|
||||||
:default-value="dateRange[1]"
|
@cancel="cancelStartTime"
|
||||||
@cancel="cancelEndTime"
|
@confirm="confirmStartTime"
|
||||||
@confirm="confirmEndTime"
|
/>
|
||||||
/>
|
</t-popup>
|
||||||
</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>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -179,8 +189,6 @@ import ConsumptionRecordAPI from "@/api/ConsumptionRecordAPI";
|
|||||||
import CustomerAPI from "@/api/CustomerAPI";
|
import CustomerAPI from "@/api/CustomerAPI";
|
||||||
import CodeScanner from "@/components/CodeScanner.vue";
|
import CodeScanner from "@/components/CodeScanner.vue";
|
||||||
import CustomerSelector from "@/components/CustomerSelector.vue";
|
import CustomerSelector from "@/components/CustomerSelector.vue";
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
import type { Customer } from "@/types/Customer";
|
|
||||||
import type {
|
import type {
|
||||||
ConsumptionRecord,
|
ConsumptionRecord,
|
||||||
ConsumptionRecordPage,
|
ConsumptionRecordPage,
|
||||||
@@ -194,6 +202,8 @@ import { Message } from "@/utils/message";
|
|||||||
import { formatPackageAmount } from "@/utils/package";
|
import { formatPackageAmount } from "@/utils/package";
|
||||||
import { permissionCodes } from "@/utils/permission";
|
import { permissionCodes } from "@/utils/permission";
|
||||||
|
|
||||||
|
import type { Customer } from "@/types/Customer";
|
||||||
|
|
||||||
defineOptions({ name: "ConsumptionRecordList" });
|
defineOptions({ name: "ConsumptionRecordList" });
|
||||||
|
|
||||||
type DateFilterType = "today" | "yesterday" | "thisWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
|
type DateFilterType = "today" | "yesterday" | "thisWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
|
||||||
@@ -201,7 +211,6 @@ type DateFilterType = "today" | "yesterday" | "thisWeek" | "thisMonth" | "lastMo
|
|||||||
const pageSize = 20;
|
const pageSize = 20;
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const dateOptions: Array<{ label: string; value: DateFilterType }> = [
|
const dateOptions: Array<{ label: string; value: DateFilterType }> = [
|
||||||
{ label: "全部时间", value: "all" },
|
{ label: "全部时间", value: "all" },
|
||||||
@@ -454,7 +463,6 @@ async function openSource(record: ConsumptionRecord): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navBarStore.clearRight();
|
|
||||||
applyRouteQuery();
|
applyRouteQuery();
|
||||||
await loadSelectedCustomer();
|
await loadSelectedCustomer();
|
||||||
await reloadRecords();
|
await reloadRecords();
|
||||||
|
|||||||
@@ -1,4 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<t-navbar
|
||||||
|
fixed
|
||||||
|
:z-index="20"
|
||||||
|
title="资金记录详情"
|
||||||
|
left-arrow
|
||||||
|
@left-click="$router.back()"
|
||||||
|
/>
|
||||||
<div v-can="pageAccess" class="package-record-detail">
|
<div v-can="pageAccess" class="package-record-detail">
|
||||||
<template v-if="record">
|
<template v-if="record">
|
||||||
<section class="hero" v-entrance-transition>
|
<section class="hero" v-entrance-transition>
|
||||||
@@ -125,8 +132,6 @@ import { PassTimeLabel, Text } from "timi-web";
|
|||||||
import { useUserStore } from "timi-web-api";
|
import { useUserStore } from "timi-web-api";
|
||||||
import SalesOrderAPI from "@/api/SalesOrderAPI";
|
import SalesOrderAPI from "@/api/SalesOrderAPI";
|
||||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
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 type { PhotoItem } from "@/types/Photo";
|
||||||
import { getAttachmentReadURL } from "@/utils/attachment";
|
import { getAttachmentReadURL } from "@/utils/attachment";
|
||||||
import { getErrorMessage } from "@/utils/error";
|
import { getErrorMessage } from "@/utils/error";
|
||||||
@@ -136,6 +141,8 @@ import { getFundOperationText, getFundStatusText } from "@/utils/salesOrder";
|
|||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { permissionCodes } from "@/utils/permission";
|
import { permissionCodes } from "@/utils/permission";
|
||||||
|
|
||||||
|
import type { FundRecord, FundRecordStatus } from "@/types/SalesOrder";
|
||||||
|
|
||||||
type ReasonAction = "reject" | "cancel";
|
type ReasonAction = "reject" | "cancel";
|
||||||
|
|
||||||
defineOptions({ name: "FundRecordDetail" });
|
defineOptions({ name: "FundRecordDetail" });
|
||||||
@@ -144,7 +151,6 @@ defineOptions({ name: "FundRecordDetail" });
|
|||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const isOperating = ref(false);
|
const isOperating = ref(false);
|
||||||
|
|
||||||
// ---------- 资金记录 ----------
|
// ---------- 资金记录 ----------
|
||||||
@@ -329,7 +335,6 @@ async function toRevoke(): Promise<void> {
|
|||||||
// ---------- 生命周期 ----------
|
// ---------- 生命周期 ----------
|
||||||
|
|
||||||
onMounted(loadData);
|
onMounted(loadData);
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
|
|||||||
@@ -1,171 +1,186 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-can="pageAccess" class="sales-order-record-list">
|
<div class="page-layout navbar sales-order-record-list">
|
||||||
<div class="filters glass">
|
<t-navbar
|
||||||
<t-input
|
fixed
|
||||||
class="customer"
|
:z-index="20"
|
||||||
v-model.trim="customerSearchKeyword"
|
title="资金流水"
|
||||||
borderless
|
left-arrow
|
||||||
placeholder="输入客户编码或姓名"
|
@left-click="$router.back()"
|
||||||
@enter="applyCustomerSearch"
|
/>
|
||||||
|
<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="filters glass">
|
||||||
<div class="actions">
|
<t-input
|
||||||
<t-button
|
class="customer"
|
||||||
v-if="customerId"
|
v-model.trim="customerSearchKeyword"
|
||||||
shape="circle"
|
borderless
|
||||||
theme="danger"
|
placeholder="输入客户编码或姓名"
|
||||||
variant="text"
|
@enter="applyCustomerSearch"
|
||||||
size="extra-small"
|
>
|
||||||
aria-label="清除客户选择"
|
<template #suffix-icon>
|
||||||
@click.stop="clearCustomer"
|
<div class="actions">
|
||||||
>
|
<t-button
|
||||||
<t-icon name="close" size="1rem" />
|
v-if="customerId"
|
||||||
</t-button>
|
shape="circle"
|
||||||
<t-button
|
theme="danger"
|
||||||
size="extra-small"
|
variant="text"
|
||||||
theme="primary"
|
size="extra-small"
|
||||||
variant="outline"
|
aria-label="清除客户选择"
|
||||||
content="选择客户"
|
@click.stop="clearCustomer"
|
||||||
@click.stop="customerSelectorVisible = true"
|
>
|
||||||
|
<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>
|
<t-dropdown-item
|
||||||
</template>
|
v-if="!isSelfReceiveOnly"
|
||||||
</t-input>
|
v-model="operationType"
|
||||||
<t-dropdown-menu class="menus">
|
:label="operationFilterLabel"
|
||||||
<t-dropdown-item
|
:options="operationOptions"
|
||||||
v-model="dateFilterType"
|
@change="selectOperation"
|
||||||
: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"
|
|
||||||
/>
|
/>
|
||||||
<div v-else class="avatar fallback" v-text="getCustomerText(item).slice(0, 1)" />
|
<t-dropdown-item
|
||||||
</template>
|
v-model="status"
|
||||||
<template #title>
|
label="状态"
|
||||||
<div class="title">
|
:options="statusOptions"
|
||||||
<span class="customer clip-text" v-text="getCustomerText(item)" />
|
@change="selectStatus"
|
||||||
<span class="type" :class="getOperationClass(item.operationType)" v-text="getFundOperationText(item.operationType)" />
|
/>
|
||||||
<t-tag
|
</t-dropdown-menu>
|
||||||
size="small"
|
</div>
|
||||||
:content="getRecordStatusText(item)"
|
<t-cell-group v-if="isCustomDate" class="date-summary" theme="card">
|
||||||
variant="light-outline"
|
<t-cell
|
||||||
:theme="getRecordStatusTheme(item)"
|
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>
|
<div v-else class="avatar fallback" v-text="getCustomerText(item).slice(0, 1)" />
|
||||||
</template>
|
</template>
|
||||||
<template #description>
|
<template #title>
|
||||||
<div class="description">
|
<div class="title">
|
||||||
<div class="operator">
|
<span class="customer clip-text" v-text="getCustomerText(item)" />
|
||||||
<div class="field">
|
<span class="type" :class="getOperationClass(item.operationType)" v-text="getFundOperationText(item.operationType)" />
|
||||||
<span class="label">发起人</span>
|
<t-tag
|
||||||
<span class="text-bold" v-text="getOperatorText(item)" />
|
size="small"
|
||||||
</div>
|
:content="getRecordStatusText(item)"
|
||||||
<div v-if="item.verifier" class="field">
|
variant="light-outline"
|
||||||
<span class="label">核销人</span>
|
:theme="getRecordStatusTheme(item)"
|
||||||
<span class="text-bold" v-text="getVerifierText(item)" />
|
/>
|
||||||
</div>
|
|
||||||
<pass-time-label :timestamp="item.occurredAt" underline />
|
|
||||||
</div>
|
</div>
|
||||||
<div class="amounts">
|
</template>
|
||||||
<div class="order-amount">
|
<template #description>
|
||||||
<span class="label">订单总价</span>
|
<div class="description">
|
||||||
<span>¥</span>
|
<div class="operator">
|
||||||
<span v-text="formatPackageAmount(item.salesOrderAmount)" />
|
<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>
|
||||||
<div class="unpaid-amount">
|
<div class="amounts">
|
||||||
<span class="label">剩余待收</span>
|
<div class="order-amount">
|
||||||
<span>¥</span>
|
<span class="label">订单总价</span>
|
||||||
<span v-text="formatPackageAmount(item.salesOrderUnpaidAmountSnapshot)" />
|
<span>¥</span>
|
||||||
</div>
|
<span v-text="formatPackageAmount(item.salesOrderAmount)" />
|
||||||
<div class="record-amount">
|
</div>
|
||||||
<span class="label">流水金额</span>
|
<div class="unpaid-amount">
|
||||||
<span class="red">¥</span>
|
<span class="label">剩余待收</span>
|
||||||
<span class="value red" v-text="formatPackageAmount(item.amount)" />
|
<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>
|
</div>
|
||||||
</div>
|
</template>
|
||||||
</template>
|
</t-cell>
|
||||||
</t-cell>
|
</t-cell-group>
|
||||||
</t-cell-group>
|
<div v-else class="empty" v-text="loading ? '正在加载资金流水' : '暂无资金流水'" />
|
||||||
<div v-else class="empty" v-text="loading ? '正在加载资金流水' : '暂无资金流水'" />
|
<div class="center-tips" v-text="loadStateText" />
|
||||||
<div class="center-tips" v-text="loadStateText" />
|
</t-pull-down-refresh>
|
||||||
</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>
|
</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>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
@@ -175,8 +190,6 @@ import { useUserStore } from "timi-web-api";
|
|||||||
import CustomerAPI from "@/api/CustomerAPI";
|
import CustomerAPI from "@/api/CustomerAPI";
|
||||||
import SalesOrderAPI from "@/api/SalesOrderAPI";
|
import SalesOrderAPI from "@/api/SalesOrderAPI";
|
||||||
import CustomerSelector from "@/components/CustomerSelector.vue";
|
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 type { FundOperationType, FundRecord, FundRecordStatus } from "@/types/SalesOrder";
|
||||||
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
|
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
|
||||||
import { getErrorMessage } from "@/utils/error";
|
import { getErrorMessage } from "@/utils/error";
|
||||||
@@ -186,13 +199,14 @@ import { Message } from "@/utils/message";
|
|||||||
import { permissionCodes } from "@/utils/permission";
|
import { permissionCodes } from "@/utils/permission";
|
||||||
import { getCustomerPhotoURL } from "@/utils/customer";
|
import { getCustomerPhotoURL } from "@/utils/customer";
|
||||||
|
|
||||||
|
import type { Customer } from "@/types/Customer";
|
||||||
|
|
||||||
defineOptions({ name: "FundRecordList" });
|
defineOptions({ name: "FundRecordList" });
|
||||||
|
|
||||||
type DateFilterType = "today" | "yesterday" | "thisWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
|
type DateFilterType = "today" | "yesterday" | "thisWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const recordList = ref<FundRecord[]>([]);
|
const recordList = ref<FundRecord[]>([]);
|
||||||
const operationType = ref(route.query.operationType === "RECEIVE" ? "RECEIVE" : "ALL");
|
const operationType = ref(route.query.operationType === "RECEIVE" ? "RECEIVE" : "ALL");
|
||||||
@@ -503,7 +517,6 @@ function getCurrentRouteDepth(): number {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navBarStore.clearRight();
|
|
||||||
try {
|
try {
|
||||||
if (customerId.value) {
|
if (customerId.value) {
|
||||||
selectedCustomer.value = await CustomerAPI.detail(customerId.value);
|
selectedCustomer.value = await CustomerAPI.detail(customerId.value);
|
||||||
@@ -515,7 +528,6 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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">
|
<div v-can="permissionCodes.fund.revoke" class="package-operation-edit">
|
||||||
<t-cell-group v-if="record" title="原资金记录" theme="card" v-entrance-transition>
|
<t-cell-group v-if="record" title="原资金记录" theme="card" v-entrance-transition>
|
||||||
<t-cell title="操作类型" :note="getFundOperationText(record.operationType)" />
|
<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 { useUserStore, type Attachment } from "timi-web-api";
|
||||||
import SalesOrderAPI from "@/api/SalesOrderAPI";
|
import SalesOrderAPI from "@/api/SalesOrderAPI";
|
||||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
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 type { PhotoItem } from "@/types/Photo";
|
||||||
import { createPackageRequestNo, formatPackageAmount } from "@/utils/package";
|
import { createPackageRequestNo, formatPackageAmount } from "@/utils/package";
|
||||||
import { getFundOperationText, getFundStatusText } from "@/utils/salesOrder";
|
import { getFundOperationText, getFundStatusText } from "@/utils/salesOrder";
|
||||||
@@ -117,12 +160,44 @@ import { Message } from "@/utils/message";
|
|||||||
import { permissionCodes } from "@/utils/permission";
|
import { permissionCodes } from "@/utils/permission";
|
||||||
import { uploadPhotoList } from "@/utils/photo";
|
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" });
|
defineOptions({ name: "FundRecordRevoke" });
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const record = ref<FundRecord>();
|
const record = ref<FundRecord>();
|
||||||
const reason = ref("");
|
const reason = ref("");
|
||||||
const remark = ref("");
|
const remark = ref("");
|
||||||
@@ -281,12 +356,12 @@ async function save(): Promise<void> {
|
|||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
if (userStore.hasPermissions(permissionCodes.fund.revoke)) {
|
if (userStore.hasPermissions(permissionCodes.fund.revoke)) {
|
||||||
navBarStore.setRightText("提交", "var(--td-error-color)", save);
|
setPageNavBarRightText("提交", "var(--td-error-color)", save);
|
||||||
}
|
}
|
||||||
await loadData();
|
await loadData();
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
onUnmounted(() => clearPageNavBarRight());
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
@@ -319,4 +394,45 @@ onUnmounted(() => navBarStore.clearRight());
|
|||||||
padding: 1rem;
|
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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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">
|
<div v-can="permissionCodes.salesOrder.cancel" class="sales-order-operation">
|
||||||
<t-notice-bar
|
<t-notice-bar
|
||||||
theme="warning"
|
theme="warning"
|
||||||
@@ -57,18 +102,48 @@
|
|||||||
import { useUserStore } from "timi-web-api";
|
import { useUserStore } from "timi-web-api";
|
||||||
import FulfillmentAPI from "@/api/FulfillmentAPI";
|
import FulfillmentAPI from "@/api/FulfillmentAPI";
|
||||||
import SalesOrderAPI from "@/api/SalesOrderAPI";
|
import SalesOrderAPI from "@/api/SalesOrderAPI";
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
import type { SalesOrder } from "@/types/SalesOrder";
|
|
||||||
import { getErrorMessage } from "@/utils/error";
|
import { getErrorMessage } from "@/utils/error";
|
||||||
import { emitListDataChanged, listDataEventKeys } from "@/utils/listDataEvents";
|
import { emitListDataChanged, listDataEventKeys } from "@/utils/listDataEvents";
|
||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { permissionCodes } from "@/utils/permission";
|
import { permissionCodes } from "@/utils/permission";
|
||||||
import { getSalesOrderStatusText } from "@/utils/salesOrder";
|
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" });
|
defineOptions({ name: "SalesOrderCancel" });
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const order = ref<SalesOrder>();
|
const order = ref<SalesOrder>();
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
@@ -144,10 +219,10 @@ async function save(): Promise<void> {
|
|||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
if (!userStore.hasPermissions(permissionCodes.salesOrder.cancel)) return;
|
if (!userStore.hasPermissions(permissionCodes.salesOrder.cancel)) return;
|
||||||
navBarStore.setRightText("确认", "var(--td-error-color)", save);
|
setPageNavBarRightText("确认", "var(--td-error-color)", save);
|
||||||
await loadData();
|
await loadData();
|
||||||
});
|
});
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
onUnmounted(() => clearPageNavBarRight());
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<t-navbar
|
||||||
|
fixed
|
||||||
|
:z-index="20"
|
||||||
|
title="直接产品下单"
|
||||||
|
left-arrow
|
||||||
|
@left-click="$router.back()"
|
||||||
|
/>
|
||||||
<div v-can="permissionCodes.salesOrder.create" class="sales-order-create">
|
<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 class="form" label-align="left" label-width="5.25rem" v-entrance-transition>
|
||||||
<t-form-item label="客户" required-mark>
|
<t-form-item label="客户" required-mark>
|
||||||
@@ -252,13 +259,12 @@ import { permissionCodes } from "@/utils/permission";
|
|||||||
import { buildProductStockPreview, getProductStockShortageMessage, mergeProductStockRequirements } from "@/utils/productStock";
|
import { buildProductStockPreview, getProductStockShortageMessage, mergeProductStockRequirements } from "@/utils/productStock";
|
||||||
import type { ProductStockPreviewItem } from "@/utils/productStock";
|
import type { ProductStockPreviewItem } from "@/utils/productStock";
|
||||||
import { uploadPhotoList } from "@/utils/photo";
|
import { uploadPhotoList } from "@/utils/photo";
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
import { useSettingStore } from "@/store/settingStore";
|
import { useSettingStore } from "@/store/settingStore";
|
||||||
|
|
||||||
type FormItem = Partial<DirectProductOrderItemRequest> & { clientKey: string; productName: string; unitPriceText: string };
|
type FormItem = Partial<DirectProductOrderItemRequest> & { clientKey: string; productName: string; unitPriceText: string };
|
||||||
defineOptions({ name: "SalesOrderCreate" });
|
defineOptions({ name: "SalesOrderCreate" });
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const settingStore = useSettingStore();
|
const settingStore = useSettingStore();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const canPriceOverride = computed(() => userStore.hasPermissions(permissionCodes.salesOrder.priceOverride));
|
const canPriceOverride = computed(() => userStore.hasPermissions(permissionCodes.salesOrder.priceOverride));
|
||||||
@@ -616,9 +622,7 @@ async function submitOrder(): Promise<void> {
|
|||||||
}
|
}
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
addItem();
|
addItem();
|
||||||
navBarStore.clearRight();
|
|
||||||
});
|
});
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
|
|||||||
@@ -1,4 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<t-navbar
|
||||||
|
fixed
|
||||||
|
:z-index="20"
|
||||||
|
title="销售订单详情"
|
||||||
|
left-arrow
|
||||||
|
@left-click="$router.back()"
|
||||||
|
/>
|
||||||
<div v-can="permissionCodes.salesOrder.read" class="sales-order-detail">
|
<div v-can="permissionCodes.salesOrder.read" class="sales-order-detail">
|
||||||
<template v-if="order">
|
<template v-if="order">
|
||||||
<customer-profile-card
|
<customer-profile-card
|
||||||
@@ -232,8 +239,6 @@ import SalesOrderAPI from "@/api/SalesOrderAPI";
|
|||||||
import CustomerProfileCard from "@/components/CustomerProfileCard.vue";
|
import CustomerProfileCard from "@/components/CustomerProfileCard.vue";
|
||||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
||||||
import ProductSkuTags from "@/components/ProductSkuTags.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 type { PhotoItem } from "@/types/Photo";
|
||||||
import { convertPackageQuantity, formatPackageAmount, getPackageQuantityText } from "@/utils/package";
|
import { convertPackageQuantity, formatPackageAmount, getPackageQuantityText } from "@/utils/package";
|
||||||
import { getAttachmentReadURL } from "@/utils/attachment";
|
import { getAttachmentReadURL } from "@/utils/attachment";
|
||||||
@@ -251,10 +256,11 @@ import { Message } from "@/utils/message";
|
|||||||
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
||||||
import { uploadPhotoList } from "@/utils/photo";
|
import { uploadPhotoList } from "@/utils/photo";
|
||||||
|
|
||||||
|
import type { GaoSalesOrderItem, GaoSalesPaymentStatus, SalesOrder } from "@/types/SalesOrder";
|
||||||
|
|
||||||
defineOptions({ name: "SalesOrderDetail" });
|
defineOptions({ name: "SalesOrderDetail" });
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const order = ref<SalesOrder>();
|
const order = ref<SalesOrder>();
|
||||||
const hasPendingFulfillment = ref(false);
|
const hasPendingFulfillment = ref(false);
|
||||||
@@ -370,7 +376,6 @@ function getItemFulfillmentStatus(item: GaoSalesOrderItem): { text: string; them
|
|||||||
async function loadData(): Promise<void> {
|
async function loadData(): Promise<void> {
|
||||||
const id = String(route.params.id || "");
|
const id = String(route.params.id || "");
|
||||||
isEditing.value = false;
|
isEditing.value = false;
|
||||||
navBarStore.clearRight();
|
|
||||||
if (!id) {
|
if (!id) {
|
||||||
order.value = undefined;
|
order.value = undefined;
|
||||||
hasPendingFulfillment.value = false;
|
hasPendingFulfillment.value = false;
|
||||||
@@ -510,7 +515,6 @@ function getCurrentRouteDepth(): number {
|
|||||||
|
|
||||||
onMounted(loadData);
|
onMounted(loadData);
|
||||||
watch(() => route.params.id, loadData);
|
watch(() => route.params.id, loadData);
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
|
|||||||
@@ -1,106 +1,161 @@
|
|||||||
<template>
|
<template>
|
||||||
<div ref="salesOrderListRef" v-can="permissionCodes.salesOrder.read" class="sales-order-list">
|
<div class="page-layout navbar sales-order-list">
|
||||||
<div class="filters glass">
|
<t-navbar
|
||||||
<div class="search-row">
|
fixed
|
||||||
<t-input
|
:z-index="20"
|
||||||
v-model.trim="keyword"
|
title="销售订单"
|
||||||
class="keyword"
|
left-arrow
|
||||||
type="text"
|
@left-click="$router.back()"
|
||||||
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="items">
|
<template #right>
|
||||||
<sales-order-summary
|
<div
|
||||||
v-if="customerId"
|
class="nav-actions"
|
||||||
ref="customerOrderSummaryRef"
|
v-if="(route.name === 'SalesOrderList' && actions.length) && pageNavBarActionList.length"
|
||||||
:customer="selectedCustomer"
|
>
|
||||||
/>
|
<t-popover
|
||||||
<t-cell-group v-if="packageConfigId" class="selected-package" theme="card">
|
v-model:visible="pageNavBarActionVisible"
|
||||||
<t-cell title="套餐" :note="selectedPackageName">
|
placement="bottom-right"
|
||||||
<template #left-icon>
|
:show-arrow="false"
|
||||||
<t-icon name="layers" />
|
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>
|
||||||
</t-cell>
|
</t-popover>
|
||||||
</t-cell-group>
|
</div>
|
||||||
<sales-order-filter-summary
|
</template>
|
||||||
:filter="appliedFilter"
|
</t-navbar>
|
||||||
:total="total"
|
<main ref="salesOrderListRef" v-can="permissionCodes.salesOrder.read" class="page-content scroll list">
|
||||||
:package-config-id="packageConfigId"
|
<t-pull-down-refresh
|
||||||
@confirm="confirmFilter"
|
class="list-wrap pull-refresh"
|
||||||
/>
|
v-model="refreshing"
|
||||||
<sales-order-list-cell
|
:refresh-timeout="30000"
|
||||||
v-for="item in list"
|
@refresh="refresh"
|
||||||
:key="item.id"
|
@scrolltolower="loadMore"
|
||||||
class="item"
|
>
|
||||||
:order="item"
|
<div class="filters glass">
|
||||||
:can-receive="canReceive"
|
<div class="search-row">
|
||||||
:can-fulfill="canCreateFulfillment"
|
<t-input
|
||||||
:can-cancel="canCancel"
|
v-model.trim="keyword"
|
||||||
:can-refund="canRefund"
|
class="keyword"
|
||||||
:can-store-manager="canStoreManager"
|
type="text"
|
||||||
v-entrance-transition="{ step: 30 }"
|
enterkeyhint="search"
|
||||||
@click="toDetail(item)"
|
clearable
|
||||||
@cancel="toCancel(item)"
|
borderless
|
||||||
@receive="toPayment(item)"
|
placeholder="订单号或客户"
|
||||||
@fulfill="toFulfillment(item)"
|
>
|
||||||
@refund="toRefund(item)"
|
<template #suffix-icon>
|
||||||
@confirm-no-refund="toNoRefund(item)"
|
<div class="actions">
|
||||||
/>
|
<t-button
|
||||||
<div v-if="!list.length" class="empty" v-text="loading ? '正在加载销售订单' : '暂无销售订单'" />
|
size="extra-small"
|
||||||
</div>
|
theme="primary"
|
||||||
<div class="center-tips" v-text="loading ? '正在加载' : noMore ? '已经到底了' : '上拉加载更多'" />
|
variant="outline"
|
||||||
</t-pull-down-refresh>
|
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>
|
</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>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import type { NavBarAction } from "@/types/NavBarAction";
|
||||||
import { Toolkit } from "timi-web";
|
import { Toolkit } from "timi-web";
|
||||||
import { useUserStore } from "timi-web-api";
|
import { useUserStore } from "timi-web-api";
|
||||||
import { onBeforeRouteLeave } from "vue-router";
|
import { onBeforeRouteLeave } from "vue-router";
|
||||||
@@ -108,14 +163,10 @@ import CustomerAPI from "@/api/CustomerAPI";
|
|||||||
import PackageAPI from "@/api/PackageAPI";
|
import PackageAPI from "@/api/PackageAPI";
|
||||||
import SalesOrderAPI from "@/api/SalesOrderAPI";
|
import SalesOrderAPI from "@/api/SalesOrderAPI";
|
||||||
import CustomerSelector from "@/components/CustomerSelector.vue";
|
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 SalesOrderFilterSummary from "@/pages/salesOrder/components/SalesOrderFilterSummary.vue";
|
||||||
import SalesOrderListCell from "@/pages/salesOrder/components/SalesOrderListCell.vue";
|
import SalesOrderListCell from "@/pages/salesOrder/components/SalesOrderListCell.vue";
|
||||||
import SalesOrderSummary from "@/pages/salesOrder/components/SalesOrderSummary.vue";
|
import SalesOrderSummary from "@/pages/salesOrder/components/SalesOrderSummary.vue";
|
||||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
import type { Customer } from "@/types/Customer";
|
|
||||||
import type { GaoPackageConfig } from "@/types/Package";
|
import type { GaoPackageConfig } from "@/types/Package";
|
||||||
import type {
|
import type {
|
||||||
GaoSalesOrderStatus,
|
GaoSalesOrderStatus,
|
||||||
@@ -138,6 +189,17 @@ import { events, isCurrentStoreEvent, listDataEventKeys, type ListDataChangedPay
|
|||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
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" });
|
defineOptions({ name: "SalesOrderList" });
|
||||||
|
|
||||||
const SALES_ORDER_FILTER_STORAGE_KEY = "gao-customer-h5:sales-order-filter";
|
const SALES_ORDER_FILTER_STORAGE_KEY = "gao-customer-h5:sales-order-filter";
|
||||||
@@ -145,7 +207,6 @@ const route = useRoute();
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const salesOrderListRef = ref<HTMLElement | null>(null);
|
const salesOrderListRef = ref<HTMLElement | null>(null);
|
||||||
const currentStoreStore = useCurrentStoreStore();
|
const currentStoreStore = useCurrentStoreStore();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const canCreate = computed(() => userStore.hasPermissions(permissionCodes.salesOrder.create));
|
const canCreate = computed(() => userStore.hasPermissions(permissionCodes.salesOrder.create));
|
||||||
const canCreatePackageOrder = computed(() => userStore.hasPermissions(permissionCodes.customerPackage.create));
|
const canCreatePackageOrder = computed(() => userStore.hasPermissions(permissionCodes.customerPackage.create));
|
||||||
@@ -701,8 +762,7 @@ watch(() => currentStoreStore.currentStoreId, async (value, oldValue) => {
|
|||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
unregisterSalesOrderListEvent = events.register(listDataEventKeys.salesOrderChanged, (payload: ListDataChangedPayload) => requestEventRefresh(payload));
|
unregisterSalesOrderListEvent = events.register(listDataEventKeys.salesOrderChanged, (payload: ListDataChangedPayload) => requestEventRefresh(payload));
|
||||||
syncCachedRouteContext();
|
syncCachedRouteContext();
|
||||||
navBarStore.clearRight();
|
|
||||||
navBarStore.setCustomRightVisible(!!actions.value.length);
|
|
||||||
applyRouteFilters();
|
applyRouteFilters();
|
||||||
lastAppliedRouteFilterKey = routeFilterKey.value;
|
lastAppliedRouteFilterKey = routeFilterKey.value;
|
||||||
try {
|
try {
|
||||||
@@ -731,8 +791,7 @@ onActivated(async () => {
|
|||||||
} else {
|
} else {
|
||||||
restorePageScrollPosition();
|
restorePageScrollPosition();
|
||||||
}
|
}
|
||||||
navBarStore.clearRight();
|
|
||||||
navBarStore.setCustomRightVisible(!!actions.value.length);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
onDeactivated(() => {
|
onDeactivated(() => {
|
||||||
@@ -740,7 +799,6 @@ onDeactivated(() => {
|
|||||||
savePageScrollPosition();
|
savePageScrollPosition();
|
||||||
}
|
}
|
||||||
filterVisible.value = false;
|
filterVisible.value = false;
|
||||||
navBarStore.clearRight();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeRouteLeave(to => {
|
onBeforeRouteLeave(to => {
|
||||||
@@ -756,7 +814,6 @@ onUnmounted(() => {
|
|||||||
isDisposed = true;
|
isDisposed = true;
|
||||||
unregisterSalesOrderListEvent?.();
|
unregisterSalesOrderListEvent?.();
|
||||||
unregisterSalesOrderListEvent = undefined;
|
unregisterSalesOrderListEvent = undefined;
|
||||||
navBarStore.clearRight();
|
|
||||||
search.cancel();
|
search.cancel();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@@ -831,4 +888,46 @@ onUnmounted(() => {
|
|||||||
text-align: center;
|
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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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">
|
<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-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">
|
<t-form v-if="order" class="form" label-align="left" label-width="6rem">
|
||||||
@@ -11,15 +56,46 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useUserStore } from "timi-web-api";
|
import { useUserStore } from "timi-web-api";
|
||||||
import SalesOrderAPI from "@/api/SalesOrderAPI";
|
import SalesOrderAPI from "@/api/SalesOrderAPI";
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
import type { SalesOrder } from "@/types/SalesOrder";
|
|
||||||
import { getErrorMessage } from "@/utils/error";
|
import { getErrorMessage } from "@/utils/error";
|
||||||
import { emitListDataChanged, listDataEventKeys } from "@/utils/listDataEvents";
|
import { emitListDataChanged, listDataEventKeys } from "@/utils/listDataEvents";
|
||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { permissionCodes } from "@/utils/permission";
|
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" });
|
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("");
|
const order = ref<SalesOrder>(); const loading = ref(false); const saving = ref(false); const reason = ref("");
|
||||||
async function loadData(): Promise<void> {
|
async function loadData(): Promise<void> {
|
||||||
const id = String(route.params.id || "");
|
const id = String(route.params.id || "");
|
||||||
@@ -42,14 +118,55 @@ async function save(): Promise<void> {
|
|||||||
}
|
}
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
if (!userStore.hasPermissions(permissionCodes.fund.refund)) return;
|
if (!userStore.hasPermissions(permissionCodes.fund.refund)) return;
|
||||||
navBarStore.setRightText("确认提交", "var(--td-brand-color)", save);
|
setPageNavBarRightText("确认提交", "var(--td-brand-color)", save);
|
||||||
await loadData();
|
await loadData();
|
||||||
});
|
});
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
onUnmounted(() => clearPageNavBarRight());
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
.sales-order-operation { gap: 1rem; padding: calc(var(--app-nav-height) + 1rem) 1rem 2rem; display: flex; flex-direction: column;
|
.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; }
|
.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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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">
|
<div v-can="permissionCodes.fundReceive.create" class="sales-order-operation">
|
||||||
<t-cell-group
|
<t-cell-group
|
||||||
v-if="order"
|
v-if="order"
|
||||||
@@ -96,8 +141,6 @@ import { useUserStore, type Attachment } from "timi-web-api";
|
|||||||
import { Time } from "timi-web";
|
import { Time } from "timi-web";
|
||||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
||||||
import SalesOrderAPI from "@/api/SalesOrderAPI";
|
import SalesOrderAPI from "@/api/SalesOrderAPI";
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
import type { SalesOrder } from "@/types/SalesOrder";
|
|
||||||
import type { PhotoItem } from "@/types/Photo";
|
import type { PhotoItem } from "@/types/Photo";
|
||||||
import { createPackageRequestNo, formatPackageAmount, formatPackageAmountInput, parsePackageAmount } from "@/utils/package";
|
import { createPackageRequestNo, formatPackageAmount, formatPackageAmountInput, parsePackageAmount } from "@/utils/package";
|
||||||
import { getErrorMessage } from "@/utils/error";
|
import { getErrorMessage } from "@/utils/error";
|
||||||
@@ -106,10 +149,42 @@ import { Message } from "@/utils/message";
|
|||||||
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
||||||
import { uploadPhotoList } from "@/utils/photo";
|
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" });
|
defineOptions({ name: "SalesOrderPayment" });
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const order = ref<SalesOrder>();
|
const order = ref<SalesOrder>();
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
@@ -216,10 +291,10 @@ async function save(): Promise<void> {
|
|||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
if (!userStore.hasPermissions(permissionCodes.fundReceive.create)) return;
|
if (!userStore.hasPermissions(permissionCodes.fundReceive.create)) return;
|
||||||
navBarStore.setRightText("提交", "var(--td-brand-color)", save);
|
setPageNavBarRightText("提交", "var(--td-brand-color)", save);
|
||||||
await loadData();
|
await loadData();
|
||||||
});
|
});
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
onUnmounted(() => clearPageNavBarRight());
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
@@ -245,4 +320,45 @@ onUnmounted(() => navBarStore.clearRight());
|
|||||||
padding: 0 1rem;
|
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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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">
|
<div v-can="permissionCodes.fund.refund" class="sales-order-operation">
|
||||||
<t-cell-group
|
<t-cell-group
|
||||||
v-if="order"
|
v-if="order"
|
||||||
@@ -118,8 +163,6 @@ import { Time } from "timi-web";
|
|||||||
import { useUserStore, type Attachment } from "timi-web-api";
|
import { useUserStore, type Attachment } from "timi-web-api";
|
||||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
||||||
import SalesOrderAPI from "@/api/SalesOrderAPI";
|
import SalesOrderAPI from "@/api/SalesOrderAPI";
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
import type { SalesOrder } from "@/types/SalesOrder";
|
|
||||||
import type { PhotoItem } from "@/types/Photo";
|
import type { PhotoItem } from "@/types/Photo";
|
||||||
import { createPackageRequestNo, formatPackageAmount, formatPackageAmountInput, parsePackageAmount } from "@/utils/package";
|
import { createPackageRequestNo, formatPackageAmount, formatPackageAmountInput, parsePackageAmount } from "@/utils/package";
|
||||||
import { getErrorMessage } from "@/utils/error";
|
import { getErrorMessage } from "@/utils/error";
|
||||||
@@ -128,10 +171,42 @@ import { Message } from "@/utils/message";
|
|||||||
import { permissionCodes } from "@/utils/permission";
|
import { permissionCodes } from "@/utils/permission";
|
||||||
import { uploadPhotoList } from "@/utils/photo";
|
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" });
|
defineOptions({ name: "SalesOrderRefund" });
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const order = ref<SalesOrder>();
|
const order = ref<SalesOrder>();
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
@@ -252,10 +327,10 @@ async function save(): Promise<void> {
|
|||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
if (!userStore.hasPermissions(permissionCodes.fund.refund)) return;
|
if (!userStore.hasPermissions(permissionCodes.fund.refund)) return;
|
||||||
navBarStore.setRightText("提交", "var(--td-error-color)", save);
|
setPageNavBarRightText("提交", "var(--td-error-color)", save);
|
||||||
await loadData();
|
await loadData();
|
||||||
});
|
});
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
onUnmounted(() => clearPageNavBarRight());
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
@@ -290,4 +365,45 @@ onUnmounted(() => navBarStore.clearRight());
|
|||||||
padding: 0 1rem;
|
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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<t-navbar
|
||||||
|
fixed
|
||||||
|
:z-index="20"
|
||||||
|
title="关于"
|
||||||
|
left-arrow
|
||||||
|
@left-click="$router.back()"
|
||||||
|
/>
|
||||||
<div class="about-page">
|
<div class="about-page">
|
||||||
<section class="brand" v-entrance-transition>
|
<section class="brand" v-entrance-transition>
|
||||||
<logo @click="handleLogoClick" />
|
<logo @click="handleLogoClick" />
|
||||||
|
|||||||
@@ -1,4 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<t-navbar
|
||||||
|
fixed
|
||||||
|
:z-index="20"
|
||||||
|
:title="routeNavBarTitle"
|
||||||
|
left-arrow
|
||||||
|
@left-click="$router.back()"
|
||||||
|
/>
|
||||||
<div class="agreement-page">
|
<div class="agreement-page">
|
||||||
<template v-if="article">
|
<template v-if="article">
|
||||||
<header class="header" v-entrance-transition>
|
<header class="header" v-entrance-transition>
|
||||||
@@ -34,6 +41,21 @@ defineOptions({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const route = useRoute();
|
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 article = ref<Article>();
|
||||||
const isLoading = ref(false);
|
const isLoading = ref(false);
|
||||||
let loadToken = 0;
|
let loadToken = 0;
|
||||||
|
|||||||
@@ -1,4 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<t-navbar
|
||||||
|
fixed
|
||||||
|
:z-index="20"
|
||||||
|
title="应用设置"
|
||||||
|
left-arrow
|
||||||
|
@left-click="$router.back()"
|
||||||
|
/>
|
||||||
<div class="settings-page">
|
<div class="settings-page">
|
||||||
<t-cell-group title="显示" theme="card" v-entrance-transition>
|
<t-cell-group title="显示" theme="card" v-entrance-transition>
|
||||||
<t-cell class="theme" title="显示模式">
|
<t-cell class="theme" title="显示模式">
|
||||||
|
|||||||
@@ -1,4 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<t-navbar
|
||||||
|
fixed
|
||||||
|
:z-index="20"
|
||||||
|
title="使用说明"
|
||||||
|
left-arrow
|
||||||
|
@left-click="$router.back()"
|
||||||
|
/>
|
||||||
<div class="help-page empty-cell-title-margin">
|
<div class="help-page empty-cell-title-margin">
|
||||||
<div class="filters glass">
|
<div class="filters glass">
|
||||||
<t-input
|
<t-input
|
||||||
|
|||||||
@@ -1,4 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<t-navbar
|
||||||
|
fixed
|
||||||
|
:z-index="20"
|
||||||
|
:title="pageNavBarTitle"
|
||||||
|
left-arrow
|
||||||
|
@left-click="$router.back()"
|
||||||
|
/>
|
||||||
<div class="help-article-page">
|
<div class="help-article-page">
|
||||||
<template v-if="article">
|
<template v-if="article">
|
||||||
<article-view
|
<article-view
|
||||||
@@ -19,16 +26,20 @@
|
|||||||
import { onBeforeRouteLeave } from "vue-router";
|
import { onBeforeRouteLeave } from "vue-router";
|
||||||
import { type Article, ArticleAPI, AttachmentAPI } from "timi-web-api";
|
import { type Article, ArticleAPI, AttachmentAPI } from "timi-web-api";
|
||||||
import { ArticleView } from "timi-tdesign-mobile";
|
import { ArticleView } from "timi-tdesign-mobile";
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
import { getErrorMessage } from "@/utils/error";
|
|
||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
|
|
||||||
|
import { getErrorMessage } from "@/utils/error";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "HelpArticle"
|
name: "HelpArticle"
|
||||||
});
|
});
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const navBarStore = useNavBarStore();
|
const pageNavBarTitle = ref("");
|
||||||
|
|
||||||
|
function setPageNavBarTitle(value?: string): void {
|
||||||
|
pageNavBarTitle.value = value || "";
|
||||||
|
}
|
||||||
const article = ref<Article>();
|
const article = ref<Article>();
|
||||||
const isLoading = ref(false);
|
const isLoading = ref(false);
|
||||||
let loadToken = 0;
|
let loadToken = 0;
|
||||||
@@ -37,15 +48,15 @@ function resolveAttachmentUrl(attachmentId: string): string {
|
|||||||
return AttachmentAPI.getReadURL(attachmentId);
|
return AttachmentAPI.getReadURL(attachmentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRouteNavBarTitle(): string {
|
function getFallbackPageTitle(): string {
|
||||||
return typeof route.meta.navBarTitle === "string" ? route.meta.navBarTitle : "";
|
return "使用说明";
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadArticle(): Promise<void> {
|
async function loadArticle(): Promise<void> {
|
||||||
const requestToken = loadToken + 1;
|
const requestToken = loadToken + 1;
|
||||||
loadToken = requestToken;
|
loadToken = requestToken;
|
||||||
article.value = undefined;
|
article.value = undefined;
|
||||||
navBarStore.setTitle(getRouteNavBarTitle());
|
setPageNavBarTitle(getFallbackPageTitle());
|
||||||
const articleId = String(route.params.id || "").trim();
|
const articleId = String(route.params.id || "").trim();
|
||||||
if (!articleId) {
|
if (!articleId) {
|
||||||
return;
|
return;
|
||||||
@@ -58,7 +69,7 @@ async function loadArticle(): Promise<void> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
article.value = result;
|
article.value = result;
|
||||||
navBarStore.setTitle(result.title?.trim() || getRouteNavBarTitle());
|
setPageNavBarTitle(result.title?.trim() || getFallbackPageTitle());
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
Message.error(getErrorMessage(error, "使用说明加载失败"));
|
Message.error(getErrorMessage(error, "使用说明加载失败"));
|
||||||
} finally {
|
} finally {
|
||||||
@@ -74,7 +85,7 @@ watch(() => route.params.id, async () => {
|
|||||||
|
|
||||||
onBeforeRouteLeave(() => {
|
onBeforeRouteLeave(() => {
|
||||||
loadToken += 1;
|
loadToken += 1;
|
||||||
navBarStore.setTitle(getRouteNavBarTitle());
|
setPageNavBarTitle(getFallbackPageTitle());
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<t-navbar
|
||||||
|
fixed
|
||||||
|
:z-index="20"
|
||||||
|
title="营业日管理"
|
||||||
|
left-arrow
|
||||||
|
@left-click="$router.back()"
|
||||||
|
/>
|
||||||
<div
|
<div
|
||||||
v-if="store"
|
v-if="store"
|
||||||
v-can="permissionCodes.store.read"
|
v-can="permissionCodes.store.read"
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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">
|
<div v-can="permissionCodes.storeDiary.read" class="store-diary-detail">
|
||||||
<template v-if="article">
|
<template v-if="article">
|
||||||
<header class="header" v-entrance-transition>
|
<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 StoreDiaryAPI from "@/api/StoreDiaryAPI";
|
||||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
||||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
import type { StoreDiary } from "@/types/StoreDiary";
|
|
||||||
import type { PhotoItem } from "@/types/Photo";
|
import type { PhotoItem } from "@/types/Photo";
|
||||||
import { getAttachmentReadURL } from "@/utils/attachment";
|
import { getAttachmentReadURL } from "@/utils/attachment";
|
||||||
import { buildFallbackAvatar } from "@/utils/avatar";
|
import { buildFallbackAvatar } from "@/utils/avatar";
|
||||||
@@ -82,13 +125,45 @@ import { getErrorMessage } from "@/utils/error";
|
|||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { permissionCodes } from "@/utils/permission";
|
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({
|
defineOptions({
|
||||||
name: "StoreDiaryDetail"
|
name: "StoreDiaryDetail"
|
||||||
});
|
});
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const currentStoreStore = useCurrentStoreStore();
|
const currentStoreStore = useCurrentStoreStore();
|
||||||
const canUpdate = computed(() => userStore.hasPermissions(permissionCodes.storeDiary.update));
|
const canUpdate = computed(() => userStore.hasPermissions(permissionCodes.storeDiary.update));
|
||||||
@@ -129,17 +204,17 @@ async function prepareStoreScope(): Promise<void> {
|
|||||||
|
|
||||||
function setRightAction(): void {
|
function setRightAction(): void {
|
||||||
if (article.value?.id && canUpdate.value) {
|
if (article.value?.id && canUpdate.value) {
|
||||||
navBarStore.setRightText("编辑", "var(--td-brand-color)", toEdit);
|
setPageNavBarRightText("编辑", "var(--td-brand-color)", toEdit);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadArticle(): Promise<void> {
|
async function loadArticle(): Promise<void> {
|
||||||
const requestToken = loadToken + 1;
|
const requestToken = loadToken + 1;
|
||||||
loadToken = requestToken;
|
loadToken = requestToken;
|
||||||
article.value = undefined;
|
article.value = undefined;
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
const id = String(route.params.id || "");
|
const id = String(route.params.id || "");
|
||||||
if (!id) {
|
if (!id) {
|
||||||
return;
|
return;
|
||||||
@@ -192,7 +267,7 @@ async function confirmDelete(): Promise<void> {
|
|||||||
async onConfirm() {
|
async onConfirm() {
|
||||||
dialog.destroy();
|
dialog.destroy();
|
||||||
isDeleting.value = true;
|
isDeleting.value = true;
|
||||||
navBarStore.clearRight();
|
clearPageNavBarRight();
|
||||||
try {
|
try {
|
||||||
await StoreDiaryAPI.remove(diaryId);
|
await StoreDiaryAPI.remove(diaryId);
|
||||||
Message.success("门店日记已删除");
|
Message.success("门店日记已删除");
|
||||||
@@ -209,7 +284,7 @@ async function confirmDelete(): Promise<void> {
|
|||||||
|
|
||||||
onMounted(loadArticle);
|
onMounted(loadArticle);
|
||||||
|
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
onUnmounted(() => clearPageNavBarRight());
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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">
|
<div v-can="pageAccess" class="store-diary-edit">
|
||||||
<t-form class="form" label-align="left" label-width="5rem" v-entrance-transition>
|
<t-form class="form" label-align="left" label-width="5rem" v-entrance-transition>
|
||||||
<t-form-item label="日记标题" required-mark>
|
<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 StoreDiaryAPI from "@/api/StoreDiaryAPI";
|
||||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
||||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
import type { StoreDiary } from "@/types/StoreDiary";
|
|
||||||
import type { PhotoItem } from "@/types/Photo";
|
import type { PhotoItem } from "@/types/Photo";
|
||||||
import { getErrorMessage } from "@/utils/error";
|
import { getErrorMessage } from "@/utils/error";
|
||||||
import { compressUploadImage, compressUploadImageList } from "@/utils/imageCompression";
|
import { compressUploadImage, compressUploadImageList } from "@/utils/imageCompression";
|
||||||
@@ -93,13 +136,56 @@ import { Message } from "@/utils/message";
|
|||||||
import { permissionCodes } from "@/utils/permission";
|
import { permissionCodes } from "@/utils/permission";
|
||||||
import { saveCapturedFilesFromInput } from "@/utils/twaBridge";
|
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({
|
defineOptions({
|
||||||
name: "StoreDiaryEdit"
|
name: "StoreDiaryEdit"
|
||||||
});
|
});
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
|
const routeNavBarTitle = computed(() => {
|
||||||
|
switch (route.name) {
|
||||||
|
case "StoreDiaryCreate":
|
||||||
|
return "新增门店日记";
|
||||||
|
case "StoreDiaryEdit":
|
||||||
|
return "编辑门店日记";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
});
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const currentStoreStore = useCurrentStoreStore();
|
const currentStoreStore = useCurrentStoreStore();
|
||||||
const routeId = computed(() => String(route.params.id || ""));
|
const routeId = computed(() => String(route.params.id || ""));
|
||||||
@@ -383,7 +469,7 @@ async function loadArticle(): Promise<void> {
|
|||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
if (userStore.hasPermissions(savePermissionCode.value)) {
|
if (userStore.hasPermissions(savePermissionCode.value)) {
|
||||||
navBarStore.setRightText("保存", "var(--td-brand-color)", save);
|
setPageNavBarRightText("保存", "var(--td-brand-color)", save);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await loadArticle();
|
await loadArticle();
|
||||||
@@ -392,7 +478,7 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
onUnmounted(() => clearPageNavBarRight());
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<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>
|
</style>
|
||||||
|
|||||||
@@ -1,103 +1,166 @@
|
|||||||
<template>
|
<template>
|
||||||
<t-pull-down-refresh
|
<div class="page-layout navbar store-diary-list">
|
||||||
v-can="permissionCodes.storeDiary.read"
|
<t-navbar
|
||||||
class="store-diary-list"
|
fixed
|
||||||
v-model="isRefreshing"
|
:z-index="20"
|
||||||
:refresh-timeout="30000"
|
title="门店日记"
|
||||||
@refresh="refresh"
|
left-arrow
|
||||||
@scrolltolower="loadMore"
|
@left-click="$router.back()"
|
||||||
>
|
>
|
||||||
<div class="content">
|
<template #right>
|
||||||
<section class="calendar" v-entrance-transition>
|
<div
|
||||||
<t-calendar
|
class="nav-actions"
|
||||||
:key="calendarRenderKey"
|
v-if="(canShowActionMenu) && pageNavBarActionList.length"
|
||||||
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" />
|
<t-popover
|
||||||
<template v-if="canDelete" #right>
|
v-model:visible="pageNavBarActionVisible"
|
||||||
|
placement="bottom-right"
|
||||||
|
:show-arrow="false"
|
||||||
|
theme="light"
|
||||||
|
>
|
||||||
<t-button
|
<t-button
|
||||||
class="swipe-cell-button"
|
class="trigger"
|
||||||
theme="danger"
|
variant="text"
|
||||||
:loading="isDeleting && deletingId === item.id"
|
:aria-label="'更多操作'"
|
||||||
@click.stop="confirmDelete(item)"
|
type="button"
|
||||||
>
|
>
|
||||||
删除
|
<template #icon>
|
||||||
|
<t-icon name="ellipsis" />
|
||||||
|
</template>
|
||||||
</t-button>
|
</t-button>
|
||||||
</template>
|
<template #content>
|
||||||
</t-swipe-cell>
|
<div class="menu">
|
||||||
</t-cell-group>
|
<t-button
|
||||||
<div class="center-tips" v-text="loadStateText" />
|
v-for="action in pageNavBarActionList"
|
||||||
</div>
|
:key="action.key"
|
||||||
</t-pull-down-refresh>
|
class="menu-item"
|
||||||
<nav-bar-action-menu v-if="canShowActionMenu" :actions="actionList" />
|
variant="text"
|
||||||
<bottom-popup
|
type="button"
|
||||||
v-model="diaryPopupVisible"
|
:theme="action.theme"
|
||||||
:title="`${selectedDateText} 门店日记`"
|
:loading="action.loading"
|
||||||
height="min(80vh, 40rem)"
|
:disabled="action.disabled || action.loading"
|
||||||
left-button-text="关闭"
|
@click="handlePageNavBarAction(action)"
|
||||||
right-button-text=""
|
>
|
||||||
@left-button-click="closeDiaryPopup"
|
<template v-if="action.icon" #icon>
|
||||||
>
|
<t-icon :name="action.icon" />
|
||||||
<div class="diary-popup">
|
</template>
|
||||||
<t-cell-group v-if="selectedDateDiaries.length">
|
<span v-text="action.text" />
|
||||||
<store-diary-list-item
|
</t-button>
|
||||||
v-for="(item, index) in selectedDateDiaries"
|
</div>
|
||||||
:key="item.id || index"
|
</template>
|
||||||
:diary="item"
|
</t-popover>
|
||||||
hover
|
</div>
|
||||||
@select="toSelectedDiary"
|
</template>
|
||||||
/>
|
</t-navbar>
|
||||||
</t-cell-group>
|
<main class="page-content scroll list">
|
||||||
<div v-else class="popup-empty" v-text="'该日期暂无门店日记'" />
|
<t-pull-down-refresh
|
||||||
</div>
|
v-can="permissionCodes.storeDiary.read"
|
||||||
</bottom-popup>
|
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>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import type { NavBarAction } from "@/types/NavBarAction";
|
||||||
import { BottomPopup } from "timi-tdesign-mobile";
|
import { BottomPopup } from "timi-tdesign-mobile";
|
||||||
import { type CalendarProps, DialogPlugin, type TDate } from "tdesign-mobile-vue";
|
import { type CalendarProps, DialogPlugin, type TDate } from "tdesign-mobile-vue";
|
||||||
import { type PageResult, useUserStore } from "timi-web-api";
|
import { type PageResult, useUserStore } from "timi-web-api";
|
||||||
import { Time } from "timi-web";
|
import { Time } from "timi-web";
|
||||||
import StoreDiaryAPI, { type StoreDiaryListOptions } from "@/api/StoreDiaryAPI";
|
import StoreDiaryAPI, { type StoreDiaryListOptions } from "@/api/StoreDiaryAPI";
|
||||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
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 type { StoreDiary } from "@/types/StoreDiary";
|
||||||
import { getErrorMessage } from "@/utils/error";
|
import { getErrorMessage } from "@/utils/error";
|
||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { permissionCodes } from "@/utils/permission";
|
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({
|
defineOptions({
|
||||||
name: "StoreDiaryList"
|
name: "StoreDiaryList"
|
||||||
});
|
});
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const currentStoreStore = useCurrentStoreStore();
|
const currentStoreStore = useCurrentStoreStore();
|
||||||
const canCreate = computed(() => userStore.hasPermissions(permissionCodes.storeDiary.create));
|
const canCreate = computed(() => userStore.hasPermissions(permissionCodes.storeDiary.create));
|
||||||
@@ -418,8 +481,7 @@ async function preparePage(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navBarStore.clearRight();
|
|
||||||
navBarStore.setCustomRightVisible(canShowActionMenu.value);
|
|
||||||
try {
|
try {
|
||||||
await preparePage();
|
await preparePage();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -427,7 +489,6 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => navBarStore.clearRight());
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<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>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,49 @@
|
|||||||
<template>
|
<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">
|
<div v-can="savePermissionCode" class="store-edit">
|
||||||
<t-form class="form" label-align="left" v-entrance-transition>
|
<t-form class="form" label-align="left" v-entrance-transition>
|
||||||
<t-form-item v-if="!isStoreManagerScope" label="编码">
|
<t-form-item v-if="!isStoreManagerScope" label="编码">
|
||||||
@@ -60,18 +105,59 @@ import { useUserStore } from "timi-web-api";
|
|||||||
import StoreAPI from "@/api/StoreAPI";
|
import StoreAPI from "@/api/StoreAPI";
|
||||||
import StoreRemoveDialog from "@/components/StoreRemoveDialog.vue";
|
import StoreRemoveDialog from "@/components/StoreRemoveDialog.vue";
|
||||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
|
||||||
import type { Store, StoreStatus } from "@/types/Store";
|
|
||||||
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
||||||
import { Message } from "@/utils/message.ts";
|
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({
|
defineOptions({
|
||||||
name: "StoreEdit"
|
name: "StoreEdit"
|
||||||
});
|
});
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
|
const routeNavBarTitle = computed(() => {
|
||||||
|
switch (route.name) {
|
||||||
|
case "StoreCreate":
|
||||||
|
return "新增门店";
|
||||||
|
case "StoreEdit":
|
||||||
|
return "编辑门店";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
});
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const currentStoreStore = useCurrentStoreStore();
|
const currentStoreStore = useCurrentStoreStore();
|
||||||
const routeId = computed(() => String(route.params.id || ""));
|
const routeId = computed(() => String(route.params.id || ""));
|
||||||
@@ -144,7 +230,7 @@ function validateForm(): boolean {
|
|||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
if (userStore.hasPermissions(savePermissionCode.value)) {
|
if (userStore.hasPermissions(savePermissionCode.value)) {
|
||||||
navBarStore.setRightText("保存", "var(--td-brand-color)", doSave);
|
setPageNavBarRightText("保存", "var(--td-brand-color)", doSave);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (!routeId.value) {
|
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>
|
</style>
|
||||||
|
|||||||
+157
-56
@@ -1,80 +1,141 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-can="permissionCodes.store.read" class="store-list">
|
<div class="page-layout navbar store-list">
|
||||||
<t-pull-down-refresh
|
<t-navbar
|
||||||
class="list-wrapper"
|
fixed
|
||||||
v-model="isRefreshing"
|
:z-index="20"
|
||||||
:refresh-timeout="30000"
|
title="门店管理"
|
||||||
@refresh="refresh"
|
left-arrow
|
||||||
@scrolltolower="fetch"
|
@left-click="$router.back()"
|
||||||
>
|
>
|
||||||
<t-cell-group theme="card" class="fix-last-cell-line">
|
<template #right>
|
||||||
<t-swipe-cell
|
<div
|
||||||
v-entrance-transition="{ step: 30 }"
|
class="nav-actions"
|
||||||
v-for="item in pageResult.list"
|
v-if="(canShowActionMenu) && pageNavBarActionList.length"
|
||||||
:key="item.id"
|
|
||||||
class="item"
|
|
||||||
>
|
>
|
||||||
<t-cell
|
<t-popover
|
||||||
class="cell"
|
v-model:visible="pageNavBarActionVisible"
|
||||||
arrow
|
placement="bottom-right"
|
||||||
@click="toEdit(item)"
|
: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
|
<t-button
|
||||||
class="delete"
|
class="trigger"
|
||||||
theme="danger"
|
variant="text"
|
||||||
:loading="isRemoving && removingStoreId === item.id"
|
:aria-label="'更多操作'"
|
||||||
@click.stop="openRemoveDialog(item)"
|
type="button"
|
||||||
>
|
>
|
||||||
删除
|
<template #icon>
|
||||||
|
<t-icon name="ellipsis" />
|
||||||
|
</template>
|
||||||
</t-button>
|
</t-button>
|
||||||
</template>
|
<template #content>
|
||||||
</t-swipe-cell>
|
<div class="menu">
|
||||||
</t-cell-group>
|
<t-button
|
||||||
<div v-if="!pageResult.list.length" class="center-tips" v-text="isLoading ? '正在加载门店' : '暂无门店'" />
|
v-for="action in pageNavBarActionList"
|
||||||
<div v-if="pageResult.list.length" class="center-tips" v-text="isNoMore ? '已加载全部门店' : '上拉加载更多'" />
|
:key="action.key"
|
||||||
</t-pull-down-refresh>
|
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>
|
</div>
|
||||||
<store-remove-dialog
|
|
||||||
v-model:visible="removeDialogVisible"
|
|
||||||
:store="removeTarget"
|
|
||||||
:loading="isRemoving"
|
|
||||||
@confirm="removeStore"
|
|
||||||
/>
|
|
||||||
<nav-bar-action-menu v-if="canShowActionMenu" :actions="actionList" />
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import type { NavBarAction } from "@/types/NavBarAction";
|
||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { Time, WebToolkit } from "timi-web";
|
import { Time, WebToolkit } from "timi-web";
|
||||||
import { type Page, type PageResult, useUserStore } from "timi-web-api";
|
import { type Page, type PageResult, useUserStore } from "timi-web-api";
|
||||||
import StoreAPI from "@/api/StoreAPI";
|
import StoreAPI from "@/api/StoreAPI";
|
||||||
import StoreRemoveDialog from "@/components/StoreRemoveDialog.vue";
|
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 { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
||||||
import { getStoreStatusText, getStoreStatusTheme } from "@/utils/store";
|
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({
|
defineOptions({
|
||||||
name: "StoreList"
|
name: "StoreList"
|
||||||
});
|
});
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const navBarStore = useNavBarStore();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const isStoreManagerScope = computed(() => userStore.hasRoles(gaoRoleCodes.storeManager) && !userStore.hasRoles(gaoRoleCodes.globalManager));
|
const isStoreManagerScope = computed(() => userStore.hasRoles(gaoRoleCodes.storeManager) && !userStore.hasRoles(gaoRoleCodes.globalManager));
|
||||||
const canCreateStore = computed(() => userStore.hasPermissions(permissionCodes.store.create));
|
const canCreateStore = computed(() => userStore.hasPermissions(permissionCodes.store.create));
|
||||||
@@ -234,8 +295,7 @@ async function removeStore(store: Store): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
navBarStore.clearRight();
|
|
||||||
navBarStore.setCustomRightVisible(canShowActionMenu.value);
|
|
||||||
try {
|
try {
|
||||||
await fetch();
|
await fetch();
|
||||||
} catch {
|
} catch {
|
||||||
@@ -244,7 +304,6 @@ onMounted(async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
navBarStore.clearRight();
|
|
||||||
});
|
});
|
||||||
</script>
|
</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>
|
</style>
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user