remove store filter
This commit is contained in:
@@ -18,9 +18,6 @@
|
|||||||
</template>
|
</template>
|
||||||
</t-input>
|
</t-input>
|
||||||
</t-form-item>
|
</t-form-item>
|
||||||
<t-form-item v-if="isGlobalManager" label="门店" required-mark arrow @click="openStorePicker">
|
|
||||||
<div class="picker-text" v-text="selectedStoreName" />
|
|
||||||
</t-form-item>
|
|
||||||
<div v-if="scannerVisible && scannerTarget === 'code'" class="code-scanner-wrapper">
|
<div v-if="scannerVisible && scannerTarget === 'code'" class="code-scanner-wrapper">
|
||||||
<code-scanner
|
<code-scanner
|
||||||
visible
|
visible
|
||||||
@@ -162,15 +159,6 @@
|
|||||||
@change="handleTagSelected"
|
@change="handleTagSelected"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<t-popup v-model="storePickerVisible" placement="bottom">
|
|
||||||
<t-picker
|
|
||||||
v-model="storePickerDraft"
|
|
||||||
:columns="storePickerColumns"
|
|
||||||
title="选择门店"
|
|
||||||
@cancel="storePickerVisible = false"
|
|
||||||
@confirm="confirmStorePicker"
|
|
||||||
/>
|
|
||||||
</t-popup>
|
|
||||||
<bottom-popup
|
<bottom-popup
|
||||||
v-model="bodyAreaPickerVisible"
|
v-model="bodyAreaPickerVisible"
|
||||||
title="选择调理部位"
|
title="选择调理部位"
|
||||||
@@ -203,8 +191,6 @@ import { normalizeBodyAreaValue } from "@/utils/customer";
|
|||||||
import { corePermissionCodes, gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
import { corePermissionCodes, gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
||||||
import { compressUploadImage } from "@/utils/imageCompression";
|
import { compressUploadImage } from "@/utils/imageCompression";
|
||||||
|
|
||||||
type PickerValue = string | number;
|
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "CustomerEdit"
|
name: "CustomerEdit"
|
||||||
});
|
});
|
||||||
@@ -371,56 +357,17 @@ function openPhotoPicker(target: CustomerAttachmentType): void {
|
|||||||
photoInputRef.value?.click();
|
photoInputRef.value?.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
const canSubmit = computed(() => formData.name?.trim() && formData.storeId);
|
const canSubmit = computed(() => formData.name?.trim() && currentStoreStore.currentStoreId);
|
||||||
|
|
||||||
// ---------- 门店选择 ----------
|
|
||||||
|
|
||||||
const storePickerVisible = ref(false);
|
|
||||||
const storePickerDraft = ref<PickerValue[]>([]);
|
|
||||||
const storePickerColumns = computed(() => [
|
|
||||||
currentStoreStore.storeList.map(item => ({
|
|
||||||
label: item.name || item.code || "未命名门店",
|
|
||||||
value: item.id || ""
|
|
||||||
})).filter(item => item.value)
|
|
||||||
]);
|
|
||||||
const selectedStoreName = computed(() => {
|
|
||||||
const store = currentStoreStore.storeList.find(item => item.id === formData.storeId);
|
|
||||||
return store?.name || store?.code || "请选择门店";
|
|
||||||
});
|
|
||||||
|
|
||||||
function openStorePicker(): void {
|
|
||||||
if (!currentStoreStore.storeList.length) {
|
|
||||||
Toast.warning("暂无可选门店");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
storePickerDraft.value = [formData.storeId || ""];
|
|
||||||
storePickerVisible.value = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function confirmStorePicker(): void {
|
|
||||||
const storeId = String(storePickerDraft.value[0] || "");
|
|
||||||
if (!storeId) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
formData.storeId = storeId;
|
|
||||||
currentStoreStore.selectStore(storeId);
|
|
||||||
storePickerVisible.value = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function prepareStoreScope(): Promise<void> {
|
async function prepareStoreScope(): Promise<void> {
|
||||||
if (isGlobalManager.value) {
|
if (isGlobalManager.value) {
|
||||||
await currentStoreStore.loadStoreList();
|
await currentStoreStore.loadStoreList();
|
||||||
const queryStoreId = String(route.query.storeId || "");
|
formData.storeId = currentStoreStore.currentStoreId;
|
||||||
formData.storeId = currentStoreStore.storeList.some(item => item.id === queryStoreId)
|
|
||||||
? queryStoreId
|
|
||||||
: currentStoreStore.currentStoreId;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const store = await currentStoreStore.loadLoginStore();
|
await currentStoreStore.loadLoginStore();
|
||||||
formData.storeId = store?.id || "";
|
formData.storeId = currentStoreStore.currentStoreId;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadDetail() {
|
async function loadDetail() {
|
||||||
@@ -434,8 +381,8 @@ async function loadDetail() {
|
|||||||
try {
|
try {
|
||||||
const customer = await CustomerAPI.detail(id);
|
const customer = await CustomerAPI.detail(id);
|
||||||
Object.assign(formData, customer);
|
Object.assign(formData, customer);
|
||||||
|
formData.storeId = currentStoreStore.currentStoreId;
|
||||||
await loadCustomerTags(id);
|
await loadCustomerTags(id);
|
||||||
formData.storeId = customer.storeId || formData.storeId;
|
|
||||||
photoItemList.value = (customer.attachmentList || [])
|
photoItemList.value = (customer.attachmentList || [])
|
||||||
.filter(item => !!item.id)
|
.filter(item => !!item.id)
|
||||||
.map(item => ({
|
.map(item => ({
|
||||||
@@ -579,7 +526,7 @@ async function doSubmit(): Promise<void> {
|
|||||||
Toast.warning("请填写姓名");
|
Toast.warning("请填写姓名");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Toast.warning("请选择门店");
|
Toast.warning("当前门店未设置");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!validateCustomerPhotoList()) {
|
if (!validateCustomerPhotoList()) {
|
||||||
@@ -589,6 +536,7 @@ async function doSubmit(): Promise<void> {
|
|||||||
isSubmitting.value = true;
|
isSubmitting.value = true;
|
||||||
try {
|
try {
|
||||||
const payload: Customer = { ...formData };
|
const payload: Customer = { ...formData };
|
||||||
|
payload.storeId = currentStoreStore.currentStoreId;
|
||||||
payload.conditioningPart = selectedAreas.value;
|
payload.conditioningPart = selectedAreas.value;
|
||||||
payload.introducerCustomerId = introducerCustomerId.value || "";
|
payload.introducerCustomerId = introducerCustomerId.value || "";
|
||||||
payload.attachmentList = buildAttachmentList();
|
payload.attachmentList = buildAttachmentList();
|
||||||
|
|||||||
@@ -1,14 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-can="permissionCodes.customer.read" class="customer-list">
|
<div v-can="permissionCodes.customer.read" class="customer-list">
|
||||||
<div class="filter bg-white">
|
<div class="filter bg-white">
|
||||||
<t-dropdown-menu v-if="isGlobalManager" class="store">
|
|
||||||
<t-dropdown-item
|
|
||||||
v-model="selectedStoreId"
|
|
||||||
:label="storeFilterLabel"
|
|
||||||
:options="storeOptions"
|
|
||||||
@change="selectStoreFilter"
|
|
||||||
/>
|
|
||||||
</t-dropdown-menu>
|
|
||||||
<t-input
|
<t-input
|
||||||
v-model.trim="keyword"
|
v-model.trim="keyword"
|
||||||
class="search"
|
class="search"
|
||||||
@@ -107,7 +99,6 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Toast } from "tdesign-mobile-vue";
|
import { Toast } from "tdesign-mobile-vue";
|
||||||
import { type DropdownValue } from "tdesign-mobile-vue";
|
|
||||||
import { type Page, type PageResult, Time, Toolkit, useUserStore } from "timi-web";
|
import { type Page, type PageResult, Time, Toolkit, useUserStore } from "timi-web";
|
||||||
import CustomerAPI from "@/api/CustomerAPI";
|
import CustomerAPI from "@/api/CustomerAPI";
|
||||||
import GenderIcon from "@/components/GenderIcon.vue";
|
import GenderIcon from "@/components/GenderIcon.vue";
|
||||||
@@ -132,28 +123,6 @@ const isExporting = ref(false);
|
|||||||
const isGlobalManager = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
|
const isGlobalManager = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
|
||||||
const canReadTag = computed(() => userStore.hasPermissions(corePermissionCodes.tag.read));
|
const canReadTag = computed(() => userStore.hasPermissions(corePermissionCodes.tag.read));
|
||||||
|
|
||||||
// ---------- 门店筛选 ----------
|
|
||||||
|
|
||||||
const selectedStoreId = ref(currentStoreStore.currentStoreId);
|
|
||||||
const storeOptions = computed(() => currentStoreStore.storeList
|
|
||||||
.map(item => ({
|
|
||||||
label: item.name || item.code || "未命名门店",
|
|
||||||
value: item.id || ""
|
|
||||||
}))
|
|
||||||
.filter(item => item.value));
|
|
||||||
const storeFilterLabel = computed(() => storeOptions.value.find(item => item.value === selectedStoreId.value)?.label || "选择门店");
|
|
||||||
|
|
||||||
async function selectStoreFilter(value: DropdownValue): Promise<void> {
|
|
||||||
if (Array.isArray(value)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const storeId = String(value);
|
|
||||||
selectedStoreId.value = storeId;
|
|
||||||
currentStoreStore.selectStore(storeId);
|
|
||||||
await refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------- 标签筛选 ----------
|
// ---------- 标签筛选 ----------
|
||||||
|
|
||||||
const selectedTagList = ref<Tag[]>([]);
|
const selectedTagList = ref<Tag[]>([]);
|
||||||
@@ -196,7 +165,7 @@ const fetch = Toolkit.debounce(async () => {
|
|||||||
const result = await CustomerAPI.list({
|
const result = await CustomerAPI.list({
|
||||||
...page,
|
...page,
|
||||||
keyword: keyword.value,
|
keyword: keyword.value,
|
||||||
storeId: selectedStoreId.value,
|
storeId: currentStoreStore.currentStoreId,
|
||||||
tagIdList: selectedTagIdList.value
|
tagIdList: selectedTagIdList.value
|
||||||
});
|
});
|
||||||
pageResult.total = result.total;
|
pageResult.total = result.total;
|
||||||
@@ -221,7 +190,6 @@ async function refresh(): Promise<void> {
|
|||||||
async function loadData(): Promise<void> {
|
async function loadData(): Promise<void> {
|
||||||
if (isGlobalManager.value) {
|
if (isGlobalManager.value) {
|
||||||
await currentStoreStore.loadStoreList();
|
await currentStoreStore.loadStoreList();
|
||||||
selectedStoreId.value = currentStoreStore.currentStoreId;
|
|
||||||
} else {
|
} else {
|
||||||
await currentStoreStore.loadLoginStore();
|
await currentStoreStore.loadLoginStore();
|
||||||
}
|
}
|
||||||
@@ -254,7 +222,7 @@ onUnmounted(() => {
|
|||||||
async function toCreate(): Promise<void> {
|
async function toCreate(): Promise<void> {
|
||||||
await router.push({
|
await router.push({
|
||||||
path: "/management/customers/create",
|
path: "/management/customers/create",
|
||||||
query: isGlobalManager.value && selectedStoreId.value ? { storeId: selectedStoreId.value } : undefined
|
query: isGlobalManager.value && currentStoreStore.currentStoreId ? { storeId: currentStoreStore.currentStoreId } : undefined
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -291,13 +259,6 @@ async function doExport(): Promise<void> {
|
|||||||
box-shadow: var(--td-shadow-1);
|
box-shadow: var(--td-shadow-1);
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
||||||
.store {
|
|
||||||
|
|
||||||
&:after {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.search {
|
.search {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border: 1px solid rgba(148, 163, 184, .28);
|
border: 1px solid rgba(148, 163, 184, .28);
|
||||||
|
|||||||
@@ -1,20 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
v-can="{ value: [permissionCodes.event.read, permissionCodes.user.read], mode: 'and' }"
|
v-can="{ value: [permissionCodes.event.read, permissionCodes.user.read], mode: 'and' }"
|
||||||
:class="{ 'has-filter': hasFilter }"
|
|
||||||
class="registration-event-list"
|
class="registration-event-list"
|
||||||
>
|
>
|
||||||
<div v-if="hasFilter" class="filter-menu">
|
|
||||||
<t-dropdown-menu>
|
|
||||||
<t-dropdown-item
|
|
||||||
v-if="isGlobalManager"
|
|
||||||
v-model="selectedStoreId"
|
|
||||||
:label="storeFilterLabel"
|
|
||||||
:options="storeOptions"
|
|
||||||
@change="selectStoreFilter"
|
|
||||||
/>
|
|
||||||
</t-dropdown-menu>
|
|
||||||
</div>
|
|
||||||
<t-pull-down-refresh
|
<t-pull-down-refresh
|
||||||
v-model="isRefreshing"
|
v-model="isRefreshing"
|
||||||
:refresh-timeout="30000"
|
:refresh-timeout="30000"
|
||||||
@@ -75,7 +63,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Toast, type DropdownValue } from "tdesign-mobile-vue";
|
import { Toast } from "tdesign-mobile-vue";
|
||||||
import { type Page, type PageResult, type Role, useUserStore } from "timi-web";
|
import { type Page, type PageResult, type Role, useUserStore } from "timi-web";
|
||||||
import EventAPI from "@/api/EventAPI";
|
import EventAPI from "@/api/EventAPI";
|
||||||
import ManagedUserAPI from "@/api/ManagedUserAPI";
|
import ManagedUserAPI from "@/api/ManagedUserAPI";
|
||||||
@@ -95,31 +83,7 @@ const userStore = useUserStore();
|
|||||||
const currentStoreStore = useCurrentStoreStore();
|
const currentStoreStore = useCurrentStoreStore();
|
||||||
|
|
||||||
const isGlobalManager = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
|
const isGlobalManager = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
|
||||||
const hasFilter = computed(() => isGlobalManager.value);
|
const eventListOptions = computed(() => ({ storeId: currentStoreStore.currentStoreId }));
|
||||||
|
|
||||||
// ---------- 门店筛选 ----------
|
|
||||||
|
|
||||||
const allStoreFilterValue = "__ALL_STORES__";
|
|
||||||
const selectedStoreId = ref(allStoreFilterValue);
|
|
||||||
const loginStoreId = ref("");
|
|
||||||
const storeOptions = computed(() => [
|
|
||||||
{ label: "全部门店", value: allStoreFilterValue },
|
|
||||||
...currentStoreStore.storeList
|
|
||||||
.map(item => ({
|
|
||||||
label: item.name || item.code || "未命名门店",
|
|
||||||
value: item.id || ""
|
|
||||||
}))
|
|
||||||
.filter(item => item.value)
|
|
||||||
]);
|
|
||||||
const storeFilterLabel = computed(() => storeOptions.value.find(item => item.value === selectedStoreId.value)?.label || "全部门店");
|
|
||||||
const eventListOptions = computed(() => {
|
|
||||||
if (isGlobalManager.value) {
|
|
||||||
return selectedStoreId.value === allStoreFilterValue
|
|
||||||
? { allStores: true }
|
|
||||||
: { storeId: selectedStoreId.value };
|
|
||||||
}
|
|
||||||
return { storeId: loginStoreId.value };
|
|
||||||
});
|
|
||||||
|
|
||||||
// ---------- 列表数据 ----------
|
// ---------- 列表数据 ----------
|
||||||
|
|
||||||
@@ -233,8 +197,7 @@ async function loadStoreScope(): Promise<void> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const store = await currentStoreStore.loadLoginStore();
|
await currentStoreStore.loadLoginStore();
|
||||||
loginStoreId.value = store?.id || "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetch(): Promise<void> {
|
async function fetch(): Promise<void> {
|
||||||
@@ -279,21 +242,10 @@ async function loadData(): Promise<void> {
|
|||||||
isNoMore.value = pageResult.list.length >= pageResult.total || pageResult.list.length < page.size;
|
isNoMore.value = pageResult.list.length >= pageResult.total || pageResult.list.length < page.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function selectStoreFilter(value: DropdownValue): Promise<void> {
|
|
||||||
if (Array.isArray(value)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
selectedStoreId.value = String(value);
|
|
||||||
await refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
async function toCreate(): Promise<void> {
|
async function toCreate(): Promise<void> {
|
||||||
await router.push({
|
await router.push({
|
||||||
path: "/management/registration-events/create",
|
path: "/management/registration-events/create",
|
||||||
query: isGlobalManager.value && selectedStoreId.value !== allStoreFilterValue
|
query: currentStoreStore.currentStoreId ? { storeId: currentStoreStore.currentStoreId } : undefined
|
||||||
? { storeId: selectedStoreId.value }
|
|
||||||
: undefined
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,19 +272,6 @@ onUnmounted(() => {
|
|||||||
.registration-event-list {
|
.registration-event-list {
|
||||||
padding: calc(var(--app-nav-height) + 1rem) 0 6rem 0;
|
padding: calc(var(--app-nav-height) + 1rem) 0 6rem 0;
|
||||||
|
|
||||||
&.has-filter {
|
|
||||||
padding-top: calc(var(--app-nav-height) + 4rem);
|
|
||||||
}
|
|
||||||
|
|
||||||
.filter-menu {
|
|
||||||
top: var(--app-nav-height);
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
z-index: 20;
|
|
||||||
position: fixed;
|
|
||||||
background: var(--td-bg-color-container);
|
|
||||||
}
|
|
||||||
|
|
||||||
.item {
|
.item {
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
|
|||||||
@@ -2,15 +2,6 @@
|
|||||||
<div v-can="permissionCodes.point.accountRead" class="point-account">
|
<div v-can="permissionCodes.point.accountRead" class="point-account">
|
||||||
<div class="header bg-white">
|
<div class="header bg-white">
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<t-button
|
|
||||||
v-if="isGlobalManager"
|
|
||||||
class="selector"
|
|
||||||
size="small"
|
|
||||||
theme="primary"
|
|
||||||
variant="outline"
|
|
||||||
:content="selectedStoreName"
|
|
||||||
@click="openStorePicker"
|
|
||||||
/>
|
|
||||||
<t-button
|
<t-button
|
||||||
class="selector"
|
class="selector"
|
||||||
size="small"
|
size="small"
|
||||||
@@ -91,15 +82,6 @@
|
|||||||
v-model:visible="selectorVisible"
|
v-model:visible="selectorVisible"
|
||||||
@change="handleCustomerChange"
|
@change="handleCustomerChange"
|
||||||
/>
|
/>
|
||||||
<t-popup v-model="storePickerVisible" placement="bottom">
|
|
||||||
<t-picker
|
|
||||||
v-model="storePickerDraft"
|
|
||||||
:columns="storePickerColumns"
|
|
||||||
title="选择门店"
|
|
||||||
@cancel="storePickerVisible = false"
|
|
||||||
@confirm="confirmStorePicker"
|
|
||||||
/>
|
|
||||||
</t-popup>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -117,8 +99,6 @@ import type { Customer } from "@/types/Customer";
|
|||||||
import type { PointAccount as PointAccountData } from "@/types/Point";
|
import type { PointAccount as PointAccountData } from "@/types/Point";
|
||||||
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
||||||
|
|
||||||
type PickerValue = string | number;
|
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "PointAccount"
|
name: "PointAccount"
|
||||||
});
|
});
|
||||||
@@ -132,52 +112,13 @@ const settingStore = useSettingStore();
|
|||||||
// ---------- 门店 ----------
|
// ---------- 门店 ----------
|
||||||
|
|
||||||
const isGlobalManager = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
|
const isGlobalManager = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
|
||||||
const selectedStoreId = ref(String(route.query.storeId || ""));
|
|
||||||
const storePickerVisible = ref(false);
|
|
||||||
const storePickerDraft = ref<PickerValue[]>([]);
|
|
||||||
const storePickerColumns = computed(() => [
|
|
||||||
currentStoreStore.storeList
|
|
||||||
.map(item => ({ label: item.name || item.code || "未命名门店", value: item.id || "" }))
|
|
||||||
.filter(item => item.value)
|
|
||||||
]);
|
|
||||||
const selectedStoreName = computed(() => currentStoreStore.storeList.find(item => item.id === selectedStoreId.value)?.name || "请选择门店");
|
|
||||||
|
|
||||||
async function prepareStoreScope(): Promise<void> {
|
async function prepareStoreScope(): Promise<void> {
|
||||||
if (isGlobalManager.value) {
|
if (isGlobalManager.value) {
|
||||||
await currentStoreStore.loadStoreList();
|
await currentStoreStore.loadStoreList();
|
||||||
selectedStoreId.value = currentStoreStore.storeList.some(item => item.id === selectedStoreId.value)
|
|
||||||
? selectedStoreId.value
|
|
||||||
: currentStoreStore.currentStoreId || currentStoreStore.storeList[0]?.id || "";
|
|
||||||
if (selectedStoreId.value) {
|
|
||||||
currentStoreStore.selectStore(selectedStoreId.value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function openStorePicker(): void {
|
|
||||||
if (!storePickerColumns.value[0]?.length) {
|
|
||||||
Toast.warning("暂无可选门店");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
storePickerDraft.value = [selectedStoreId.value];
|
await currentStoreStore.loadLoginStore();
|
||||||
storePickerVisible.value = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function confirmStorePicker(value: Array<string | number>): Promise<void> {
|
|
||||||
const storeId = String(value[0] || "");
|
|
||||||
if (storeId) {
|
|
||||||
selectedStoreId.value = storeId;
|
|
||||||
currentStoreStore.selectStore(storeId);
|
|
||||||
await router.replace({
|
|
||||||
name: "PointAccount",
|
|
||||||
query: {
|
|
||||||
...(selectedCustomerId.value ? { customerId: selectedCustomerId.value } : {}),
|
|
||||||
storeId
|
|
||||||
}
|
|
||||||
});
|
|
||||||
await loadAccount();
|
|
||||||
}
|
|
||||||
storePickerVisible.value = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------- 客户与账户 ----------
|
// ---------- 客户与账户 ----------
|
||||||
@@ -194,7 +135,7 @@ async function handleCustomerChange(value: string | string[]): Promise<void> {
|
|||||||
selectedCustomerId.value = Array.isArray(value) ? String(value[0] || "") : value;
|
selectedCustomerId.value = Array.isArray(value) ? String(value[0] || "") : value;
|
||||||
await router.replace({
|
await router.replace({
|
||||||
name: "PointAccount",
|
name: "PointAccount",
|
||||||
query: selectedCustomerId.value ? { customerId: selectedCustomerId.value, storeId: selectedStoreId.value } : undefined
|
query: selectedCustomerId.value ? { customerId: selectedCustomerId.value } : undefined
|
||||||
});
|
});
|
||||||
await loadAccount();
|
await loadAccount();
|
||||||
}
|
}
|
||||||
@@ -215,10 +156,7 @@ async function loadCustomerByCode(code: string): Promise<void> {
|
|||||||
customer.value = matched;
|
customer.value = matched;
|
||||||
await router.replace({
|
await router.replace({
|
||||||
name: "PointAccount",
|
name: "PointAccount",
|
||||||
query: {
|
query: { customerId: selectedCustomerId.value }
|
||||||
customerId: selectedCustomerId.value,
|
|
||||||
storeId: selectedStoreId.value
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
await loadAccount();
|
await loadAccount();
|
||||||
} catch {
|
} catch {
|
||||||
@@ -238,7 +176,7 @@ async function loadAccount(): Promise<void> {
|
|||||||
try {
|
try {
|
||||||
customer.value = await CustomerAPI.detail(customerId);
|
customer.value = await CustomerAPI.detail(customerId);
|
||||||
try {
|
try {
|
||||||
account.value = await PointAPI.accountDetail(customerId, selectedStoreId.value || undefined);
|
account.value = await PointAPI.accountDetail(customerId, currentStoreStore.currentStoreId || undefined);
|
||||||
} catch {
|
} catch {
|
||||||
account.value = undefined;
|
account.value = undefined;
|
||||||
}
|
}
|
||||||
@@ -292,7 +230,6 @@ async function toLedger(): Promise<void> {
|
|||||||
query: {
|
query: {
|
||||||
customerId: selectedCustomerId.value,
|
customerId: selectedCustomerId.value,
|
||||||
accountId: account.value?.id || "",
|
accountId: account.value?.id || "",
|
||||||
storeId: selectedStoreId.value,
|
|
||||||
transitionDepth: String(getCurrentRouteDepth() + 1)
|
transitionDepth: String(getCurrentRouteDepth() + 1)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -315,7 +252,7 @@ async function toAdjust(): Promise<void> {
|
|||||||
}
|
}
|
||||||
await router.push({
|
await router.push({
|
||||||
name: "PointAdjust",
|
name: "PointAdjust",
|
||||||
query: { customerId: selectedCustomerId.value, storeId: selectedStoreId.value }
|
query: { customerId: selectedCustomerId.value }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -338,12 +275,10 @@ function formatSignedPoints(value?: number): string {
|
|||||||
return pointValue < 0 ? `扣除 ${Math.abs(pointValue).toLocaleString("zh-CN")} 分` : `增加 ${pointValue.toLocaleString("zh-CN")} 分`;
|
return pointValue < 0 ? `扣除 ${Math.abs(pointValue).toLocaleString("zh-CN")} 分` : `增加 ${pointValue.toLocaleString("zh-CN")} 分`;
|
||||||
}
|
}
|
||||||
|
|
||||||
watch([() => route.query.customerId, () => route.query.storeId], async ([customerIdValue, storeIdValue]) => {
|
watch(() => route.query.customerId, async customerIdValue => {
|
||||||
const customerId = String(customerIdValue || "");
|
const customerId = String(customerIdValue || "");
|
||||||
const storeId = String(storeIdValue || "");
|
if (customerId !== selectedCustomerId.value) {
|
||||||
if (customerId !== selectedCustomerId.value || storeId !== selectedStoreId.value) {
|
|
||||||
selectedCustomerId.value = customerId;
|
selectedCustomerId.value = customerId;
|
||||||
selectedStoreId.value = storeId || selectedStoreId.value;
|
|
||||||
await loadAccount();
|
await loadAccount();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,14 +6,6 @@
|
|||||||
content="人工调整会追加一条不可修改的 ADJUST 流水,请填写真实、明确的调整原因。"
|
content="人工调整会追加一条不可修改的 ADJUST 流水,请填写真实、明确的调整原因。"
|
||||||
/>
|
/>
|
||||||
<t-form class="form" label-align="left" label-width="7rem">
|
<t-form class="form" label-align="left" label-width="7rem">
|
||||||
<t-form-item v-if="isGlobalManager" label="门店" required-mark>
|
|
||||||
<t-button
|
|
||||||
class="picker-button"
|
|
||||||
variant="outline"
|
|
||||||
:content="selectedStoreName"
|
|
||||||
@click="openStorePicker"
|
|
||||||
/>
|
|
||||||
</t-form-item>
|
|
||||||
<t-form-item label="客户" required-mark>
|
<t-form-item label="客户" required-mark>
|
||||||
<div class="customer-actions">
|
<div class="customer-actions">
|
||||||
<t-button
|
<t-button
|
||||||
@@ -76,15 +68,6 @@
|
|||||||
v-model:visible="selectorVisible"
|
v-model:visible="selectorVisible"
|
||||||
@change="handleCustomerChange"
|
@change="handleCustomerChange"
|
||||||
/>
|
/>
|
||||||
<t-popup v-model="storePickerVisible" placement="bottom">
|
|
||||||
<t-picker
|
|
||||||
v-model="storePickerDraft"
|
|
||||||
:columns="storePickerColumns"
|
|
||||||
title="选择门店"
|
|
||||||
@cancel="storePickerVisible = false"
|
|
||||||
@confirm="confirmStorePicker"
|
|
||||||
/>
|
|
||||||
</t-popup>
|
|
||||||
<t-popup v-model="pointActionPickerVisible" placement="bottom">
|
<t-popup v-model="pointActionPickerVisible" placement="bottom">
|
||||||
<t-picker
|
<t-picker
|
||||||
v-model="pointActionPickerDraft"
|
v-model="pointActionPickerDraft"
|
||||||
@@ -113,8 +96,6 @@ import type { PointAccount } from "@/types/Point";
|
|||||||
import { getErrorMessage } from "@/utils/error";
|
import { getErrorMessage } from "@/utils/error";
|
||||||
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
||||||
|
|
||||||
type PickerValue = string | number;
|
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "PointAdjust"
|
name: "PointAdjust"
|
||||||
});
|
});
|
||||||
@@ -128,52 +109,14 @@ const settingStore = useSettingStore();
|
|||||||
// ---------- 权限与门店 ----------
|
// ---------- 权限与门店 ----------
|
||||||
|
|
||||||
const isGlobalManager = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
|
const isGlobalManager = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
|
||||||
const selectedStoreId = ref(String(route.query.storeId || ""));
|
|
||||||
const storePickerVisible = ref(false);
|
|
||||||
const storePickerDraft = ref<PickerValue[]>([]);
|
|
||||||
const storePickerColumns = computed(() => [
|
|
||||||
currentStoreStore.storeList
|
|
||||||
.map(item => ({
|
|
||||||
label: item.name || item.code || "未命名门店",
|
|
||||||
value: item.id || ""
|
|
||||||
}))
|
|
||||||
.filter(item => item.value)
|
|
||||||
]);
|
|
||||||
const selectedStoreName = computed(() => currentStoreStore.storeList.find(item => item.id === selectedStoreId.value)?.name || "请选择门店");
|
|
||||||
|
|
||||||
async function prepareStoreScope(): Promise<void> {
|
async function prepareStoreScope(): Promise<void> {
|
||||||
if (isGlobalManager.value) {
|
if (isGlobalManager.value) {
|
||||||
await currentStoreStore.loadStoreList();
|
await currentStoreStore.loadStoreList();
|
||||||
if (!currentStoreStore.storeList.some(item => item.id === selectedStoreId.value)) {
|
|
||||||
selectedStoreId.value = currentStoreStore.currentStoreId || currentStoreStore.storeList[0]?.id || "";
|
|
||||||
}
|
|
||||||
if (selectedStoreId.value) {
|
|
||||||
currentStoreStore.selectStore(selectedStoreId.value);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const store = await currentStoreStore.loadLoginStore();
|
await currentStoreStore.loadLoginStore();
|
||||||
selectedStoreId.value = store?.id || "";
|
|
||||||
}
|
|
||||||
|
|
||||||
function openStorePicker(): void {
|
|
||||||
if (!currentStoreStore.storeList.length) {
|
|
||||||
Toast.warning("暂无可选门店");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
storePickerDraft.value = [selectedStoreId.value];
|
|
||||||
storePickerVisible.value = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function confirmStorePicker(value: Array<string | number>): void {
|
|
||||||
const storeId = String(value[0] || "");
|
|
||||||
if (storeId) {
|
|
||||||
selectedStoreId.value = storeId;
|
|
||||||
currentStoreStore.selectStore(storeId);
|
|
||||||
}
|
|
||||||
storePickerVisible.value = false;
|
|
||||||
void loadCustomerAccount();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------- 客户与账户 ----------
|
// ---------- 客户与账户 ----------
|
||||||
@@ -222,7 +165,7 @@ async function loadCustomerAccount(): Promise<void> {
|
|||||||
selectedCustomer.value = await CustomerAPI.detail(selectedCustomerId.value);
|
selectedCustomer.value = await CustomerAPI.detail(selectedCustomerId.value);
|
||||||
if (userStore.hasPermissions(permissionCodes.point.accountRead)) {
|
if (userStore.hasPermissions(permissionCodes.point.accountRead)) {
|
||||||
try {
|
try {
|
||||||
account.value = await PointAPI.accountDetail(selectedCustomerId.value, selectedStoreId.value || undefined);
|
account.value = await PointAPI.accountDetail(selectedCustomerId.value, currentStoreStore.currentStoreId || undefined);
|
||||||
} catch {
|
} catch {
|
||||||
account.value = undefined;
|
account.value = undefined;
|
||||||
}
|
}
|
||||||
@@ -277,7 +220,7 @@ const pointActionPickerColumns = [[
|
|||||||
const remark = ref("");
|
const remark = ref("");
|
||||||
const adjustRequestId = ref(generateRequestId());
|
const adjustRequestId = ref(generateRequestId());
|
||||||
const isSaving = ref(false);
|
const isSaving = ref(false);
|
||||||
const canSubmit = computed(() => !!selectedCustomerId.value && !!selectedStoreId.value && !!parsePointDelta() && !!remark.value.trim());
|
const canSubmit = computed(() => !!selectedCustomerId.value && !!currentStoreStore.currentStoreId && !!parsePointDelta() && !!remark.value.trim());
|
||||||
|
|
||||||
function parsePointDelta(): number {
|
function parsePointDelta(): number {
|
||||||
const value = Number(pointDeltaText.value);
|
const value = Number(pointDeltaText.value);
|
||||||
@@ -303,8 +246,8 @@ async function submitAdjust(): Promise<void> {
|
|||||||
Toast.warning("请选择客户");
|
Toast.warning("请选择客户");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!selectedStoreId.value) {
|
if (!currentStoreStore.currentStoreId) {
|
||||||
Toast.warning("请选择门店");
|
Toast.warning("当前门店未设置");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!pointDelta) {
|
if (!pointDelta) {
|
||||||
@@ -324,7 +267,7 @@ async function submitAdjust(): Promise<void> {
|
|||||||
try {
|
try {
|
||||||
await PointAPI.adjust({
|
await PointAPI.adjust({
|
||||||
adjustRequestId: adjustRequestId.value,
|
adjustRequestId: adjustRequestId.value,
|
||||||
storeId: selectedStoreId.value,
|
storeId: currentStoreStore.currentStoreId,
|
||||||
customerId: selectedCustomerId.value,
|
customerId: selectedCustomerId.value,
|
||||||
pointDelta,
|
pointDelta,
|
||||||
remark: remark.value.trim()
|
remark: remark.value.trim()
|
||||||
@@ -332,10 +275,7 @@ async function submitAdjust(): Promise<void> {
|
|||||||
Toast.success("积分调整已提交");
|
Toast.success("积分调整已提交");
|
||||||
await router.replace({
|
await router.replace({
|
||||||
name: "PointLedgerList",
|
name: "PointLedgerList",
|
||||||
query: {
|
query: { customerId: selectedCustomerId.value }
|
||||||
customerId: selectedCustomerId.value,
|
|
||||||
storeId: selectedStoreId.value
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
Toast.error(getErrorMessage(error, "积分调整失败"));
|
Toast.error(getErrorMessage(error, "积分调整失败"));
|
||||||
|
|||||||
@@ -32,13 +32,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="filters">
|
<div class="filters">
|
||||||
<t-dropdown-menu>
|
<t-dropdown-menu>
|
||||||
<t-dropdown-item
|
|
||||||
v-if="isGlobalManager"
|
|
||||||
v-model="selectedStoreId"
|
|
||||||
:label="selectedStoreName"
|
|
||||||
:options="storeOptions"
|
|
||||||
@change="selectStore"
|
|
||||||
/>
|
|
||||||
<t-dropdown-item
|
<t-dropdown-item
|
||||||
v-model="changeTypeFilter"
|
v-model="changeTypeFilter"
|
||||||
label="流水类型"
|
label="流水类型"
|
||||||
@@ -175,7 +168,6 @@ import { getCustomerPhotoURL } from "@/utils/customer";
|
|||||||
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
||||||
|
|
||||||
type DateFilter = "all" | "today" | "last7" | "last30" | "custom";
|
type DateFilter = "all" | "today" | "last7" | "last30" | "custom";
|
||||||
const allStoresValue = "__ALL_STORES__";
|
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "PointLedgerList"
|
name: "PointLedgerList"
|
||||||
@@ -190,7 +182,6 @@ const settingStore = useSettingStore();
|
|||||||
// ---------- 筛选 ----------
|
// ---------- 筛选 ----------
|
||||||
|
|
||||||
const isGlobalManager = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
|
const isGlobalManager = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
|
||||||
const selectedStoreId = ref(String(route.query.storeId || allStoresValue));
|
|
||||||
const selectedCustomerId = ref(String(route.query.customerId || ""));
|
const selectedCustomerId = ref(String(route.query.customerId || ""));
|
||||||
const selectedAccountId = ref(String(route.query.accountId || ""));
|
const selectedAccountId = ref(String(route.query.accountId || ""));
|
||||||
const customer = ref<Customer>();
|
const customer = ref<Customer>();
|
||||||
@@ -213,16 +204,6 @@ const dateFilterOptions = [
|
|||||||
{ label: "近 30 天", value: "last30" },
|
{ label: "近 30 天", value: "last30" },
|
||||||
{ label: "自定义", value: "custom" }
|
{ label: "自定义", value: "custom" }
|
||||||
];
|
];
|
||||||
const storeOptions = computed(() => [
|
|
||||||
{ label: "全部门店", value: allStoresValue },
|
|
||||||
...currentStoreStore.storeList
|
|
||||||
.map(item => ({
|
|
||||||
label: item.name || item.code || "未命名门店",
|
|
||||||
value: item.id || ""
|
|
||||||
}))
|
|
||||||
.filter(item => item.value)
|
|
||||||
]);
|
|
||||||
const selectedStoreName = computed(() => storeOptions.value.find(item => item.value === selectedStoreId.value)?.label || "全部门店");
|
|
||||||
const customerFilterText = computed(() => customer.value?.name || customer.value?.code || "全部客户");
|
const customerFilterText = computed(() => customer.value?.name || customer.value?.code || "全部客户");
|
||||||
const dateFilterLabel = computed(() => dateFilterOptions.find(item => item.value === dateFilter.value)?.label || "时间范围");
|
const dateFilterLabel = computed(() => dateFilterOptions.find(item => item.value === dateFilter.value)?.label || "时间范围");
|
||||||
const isCustomDate = computed(() => dateFilter.value === "custom");
|
const isCustomDate = computed(() => dateFilter.value === "custom");
|
||||||
@@ -257,17 +238,6 @@ async function loadCustomerByCode(code: string): Promise<void> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function selectStore(value: DropdownValue): Promise<void> {
|
|
||||||
if (Array.isArray(value)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
selectedStoreId.value = String(value);
|
|
||||||
if (selectedStoreId.value !== allStoresValue) {
|
|
||||||
currentStoreStore.selectStore(selectedStoreId.value);
|
|
||||||
}
|
|
||||||
await reload();
|
|
||||||
}
|
|
||||||
|
|
||||||
async function selectChangeType(value: DropdownValue): Promise<void> {
|
async function selectChangeType(value: DropdownValue): Promise<void> {
|
||||||
if (Array.isArray(value)) {
|
if (Array.isArray(value)) {
|
||||||
return;
|
return;
|
||||||
@@ -403,11 +373,8 @@ function buildRequest(): PointLedgerPage {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildListOptions(): { allStores?: boolean; storeId?: string } | undefined {
|
function buildListOptions(): { storeId: string } {
|
||||||
if (!isGlobalManager.value) {
|
return { storeId: currentStoreStore.currentStoreId };
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return selectedStoreId.value === allStoresValue ? { allStores: true } : { storeId: selectedStoreId.value };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------- 展示与导航 ----------
|
// ---------- 展示与导航 ----------
|
||||||
@@ -463,8 +430,7 @@ async function toAdjust(): Promise<void> {
|
|||||||
await router.push({
|
await router.push({
|
||||||
name: "PointAdjust",
|
name: "PointAdjust",
|
||||||
query: {
|
query: {
|
||||||
customerId: selectedCustomerId.value,
|
customerId: selectedCustomerId.value
|
||||||
storeId: selectedStoreId.value === allStoresValue ? "" : selectedStoreId.value
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -509,14 +475,8 @@ function toTimestamp(value: string, isEnd: boolean): number {
|
|||||||
async function preparePage(): Promise<void> {
|
async function preparePage(): Promise<void> {
|
||||||
if (isGlobalManager.value) {
|
if (isGlobalManager.value) {
|
||||||
await currentStoreStore.loadStoreList();
|
await currentStoreStore.loadStoreList();
|
||||||
const routeStoreId = String(route.query.storeId || "");
|
|
||||||
if (routeStoreId && routeStoreId !== allStoresValue && currentStoreStore.storeList.some(item => item.id === routeStoreId)) {
|
|
||||||
selectedStoreId.value = routeStoreId;
|
|
||||||
currentStoreStore.selectStore(routeStoreId);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
const store = await currentStoreStore.loadLoginStore();
|
await currentStoreStore.loadLoginStore();
|
||||||
selectedStoreId.value = store?.id || "";
|
|
||||||
}
|
}
|
||||||
if (selectedCustomerId.value) {
|
if (selectedCustomerId.value) {
|
||||||
customer.value = await CustomerAPI.detail(selectedCustomerId.value);
|
customer.value = await CustomerAPI.detail(selectedCustomerId.value);
|
||||||
|
|||||||
@@ -2,13 +2,6 @@
|
|||||||
<div v-can="permissionCodes.pointRule.read" class="point-rule-list">
|
<div v-can="permissionCodes.pointRule.read" class="point-rule-list">
|
||||||
<div class="filter-menu">
|
<div class="filter-menu">
|
||||||
<t-dropdown-menu>
|
<t-dropdown-menu>
|
||||||
<t-dropdown-item
|
|
||||||
v-if="isGlobalManager"
|
|
||||||
v-model="selectedStoreId"
|
|
||||||
:label="selectedStoreName"
|
|
||||||
:options="storeOptions"
|
|
||||||
@change="selectStore"
|
|
||||||
/>
|
|
||||||
<t-dropdown-item
|
<t-dropdown-item
|
||||||
v-model="statusFilter"
|
v-model="statusFilter"
|
||||||
label="规则状态"
|
label="规则状态"
|
||||||
@@ -79,8 +72,6 @@ import type { PointRule, PointRuleStatus } from "@/types/Point";
|
|||||||
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
||||||
import { type Page, type PageResult, useUserStore } from "timi-web";
|
import { type Page, type PageResult, useUserStore } from "timi-web";
|
||||||
|
|
||||||
const allStoresValue = "__ALL_STORES__";
|
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "PointRuleList"
|
name: "PointRuleList"
|
||||||
});
|
});
|
||||||
@@ -90,11 +81,10 @@ const navBarStore = useNavBarStore();
|
|||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const currentStoreStore = useCurrentStoreStore();
|
const currentStoreStore = useCurrentStoreStore();
|
||||||
|
|
||||||
// ---------- 筛选与门店 ----------
|
// ---------- 筛选 ----------
|
||||||
|
|
||||||
const isGlobalManager = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
|
const isGlobalManager = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
|
||||||
const canUpdate = computed(() => userStore.hasPermissions(permissionCodes.pointRule.update));
|
const canUpdate = computed(() => userStore.hasPermissions(permissionCodes.pointRule.update));
|
||||||
const selectedStoreId = ref(allStoresValue);
|
|
||||||
const statusFilter = ref("ALL");
|
const statusFilter = ref("ALL");
|
||||||
const statusOptions = [
|
const statusOptions = [
|
||||||
{ label: "全部状态", value: "ALL" },
|
{ label: "全部状态", value: "ALL" },
|
||||||
@@ -103,25 +93,6 @@ const statusOptions = [
|
|||||||
{ label: "停用", value: "INACTIVE" },
|
{ label: "停用", value: "INACTIVE" },
|
||||||
{ label: "已删除", value: "DELETED" }
|
{ label: "已删除", value: "DELETED" }
|
||||||
];
|
];
|
||||||
const storeOptions = computed(() => [
|
|
||||||
{ label: "全部门店", value: allStoresValue },
|
|
||||||
...currentStoreStore.storeList
|
|
||||||
.map(item => ({
|
|
||||||
label: item.name || item.code || "未命名门店",
|
|
||||||
value: item.id || ""
|
|
||||||
}))
|
|
||||||
.filter(item => item.value)
|
|
||||||
]);
|
|
||||||
const selectedStoreName = computed(() => storeOptions.value.find(item => item.value === selectedStoreId.value)?.label || "全部门店");
|
|
||||||
|
|
||||||
async function selectStore(value: DropdownValue): Promise<void> {
|
|
||||||
if (Array.isArray(value)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
selectedStoreId.value = String(value);
|
|
||||||
await loadEventList();
|
|
||||||
await reload();
|
|
||||||
}
|
|
||||||
|
|
||||||
async function selectStatus(value: DropdownValue): Promise<void> {
|
async function selectStatus(value: DropdownValue): Promise<void> {
|
||||||
if (Array.isArray(value)) {
|
if (Array.isArray(value)) {
|
||||||
@@ -205,11 +176,8 @@ function buildRequest(): Page<PointRule> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildListOptions(): { allStores?: boolean; storeId?: string } | undefined {
|
function buildListOptions(): { storeId: string } {
|
||||||
if (!isGlobalManager.value) {
|
return { storeId: currentStoreStore.currentStoreId };
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return selectedStoreId.value === allStoresValue ? { allStores: true } : { storeId: selectedStoreId.value };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------- 事件名称 ----------
|
// ---------- 事件名称 ----------
|
||||||
@@ -275,7 +243,7 @@ function getStatusTheme(status?: PointRuleStatus): "default" | "success" | "warn
|
|||||||
async function toCreate(): Promise<void> {
|
async function toCreate(): Promise<void> {
|
||||||
await router.push({
|
await router.push({
|
||||||
name: "PointRuleCreate",
|
name: "PointRuleCreate",
|
||||||
query: selectedStoreId.value === allStoresValue ? undefined : { storeId: selectedStoreId.value }
|
query: currentStoreStore.currentStoreId ? { storeId: currentStoreStore.currentStoreId } : undefined
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,10 +257,8 @@ async function toEdit(rule: PointRule): Promise<void> {
|
|||||||
async function preparePage(): Promise<void> {
|
async function preparePage(): Promise<void> {
|
||||||
if (isGlobalManager.value) {
|
if (isGlobalManager.value) {
|
||||||
await currentStoreStore.loadStoreList();
|
await currentStoreStore.loadStoreList();
|
||||||
selectedStoreId.value = allStoresValue;
|
|
||||||
} else {
|
} else {
|
||||||
const store = await currentStoreStore.loadLoginStore();
|
await currentStoreStore.loadLoginStore();
|
||||||
selectedStoreId.value = store?.id || "";
|
|
||||||
}
|
}
|
||||||
await loadEventList();
|
await loadEventList();
|
||||||
await reload();
|
await reload();
|
||||||
|
|||||||
@@ -2,18 +2,7 @@
|
|||||||
<div
|
<div
|
||||||
v-can="permissionCodes.user.read"
|
v-can="permissionCodes.user.read"
|
||||||
class="user-list"
|
class="user-list"
|
||||||
:class="{ 'has-store-filter': isGlobalManager }"
|
|
||||||
>
|
>
|
||||||
<div v-if="isGlobalManager" class="store-menu">
|
|
||||||
<t-dropdown-menu v-if="isGlobalManager">
|
|
||||||
<t-dropdown-item
|
|
||||||
v-model="selectedStoreId"
|
|
||||||
:label="storeFilterLabel"
|
|
||||||
:options="storeOptions"
|
|
||||||
@change="selectStoreFilter"
|
|
||||||
/>
|
|
||||||
</t-dropdown-menu>
|
|
||||||
</div>
|
|
||||||
<t-pull-down-refresh
|
<t-pull-down-refresh
|
||||||
v-model="isRefreshing"
|
v-model="isRefreshing"
|
||||||
:refresh-timeout="30000"
|
:refresh-timeout="30000"
|
||||||
@@ -50,11 +39,11 @@
|
|||||||
<t-button v-can="permissionCodes.user.create" theme="primary" type="button" @click="inviteVisible = true">邀请注册</t-button>
|
<t-button v-can="permissionCodes.user.create" theme="primary" type="button" @click="inviteVisible = true">邀请注册</t-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<user-invite v-model:visible="inviteVisible" :store-id="selectedStoreId === allStoreFilterValue ? undefined : selectedStoreId" />
|
<user-invite v-model:visible="inviteVisible" :store-id="currentStoreStore.currentStoreId || undefined" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Toast, type DropdownValue } from "tdesign-mobile-vue";
|
import { Toast } from "tdesign-mobile-vue";
|
||||||
import { type Page, type PageResult, UserAPI, type User, useUserStore } from "timi-web";
|
import { type Page, type PageResult, UserAPI, type User, useUserStore } from "timi-web";
|
||||||
import ManagedUserAPI from "@/api/ManagedUserAPI";
|
import ManagedUserAPI from "@/api/ManagedUserAPI";
|
||||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||||
@@ -77,29 +66,7 @@ const inviteVisible = ref(false);
|
|||||||
|
|
||||||
const isGlobalManager = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
|
const isGlobalManager = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
|
||||||
|
|
||||||
// ---------- 门店筛选 ----------
|
const userListOptions = computed(() => ({ storeId: currentStoreStore.currentStoreId }));
|
||||||
|
|
||||||
const allStoreFilterValue = "__ALL_STORES__";
|
|
||||||
const selectedStoreId = ref(allStoreFilterValue);
|
|
||||||
const loginStoreId = ref("");
|
|
||||||
const storeOptions = computed(() => [
|
|
||||||
{ label: "全部门店", value: allStoreFilterValue },
|
|
||||||
...currentStoreStore.storeList
|
|
||||||
.map(item => ({
|
|
||||||
label: item.name || item.code || "未命名门店",
|
|
||||||
value: item.id || ""
|
|
||||||
}))
|
|
||||||
.filter(item => item.value)
|
|
||||||
]);
|
|
||||||
const storeFilterLabel = computed(() => storeOptions.value.find(item => item.value === selectedStoreId.value)?.label || "全部门店");
|
|
||||||
const userListOptions = computed(() => {
|
|
||||||
if (isGlobalManager.value) {
|
|
||||||
return selectedStoreId.value === allStoreFilterValue
|
|
||||||
? { allStores: true }
|
|
||||||
: { storeId: selectedStoreId.value };
|
|
||||||
}
|
|
||||||
return { storeId: loginStoreId.value };
|
|
||||||
});
|
|
||||||
|
|
||||||
// ---------- 列表数据 ----------
|
// ---------- 列表数据 ----------
|
||||||
|
|
||||||
@@ -143,8 +110,7 @@ async function loadStoreScope(): Promise<void> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const store = await currentStoreStore.loadLoginStore();
|
await currentStoreStore.loadLoginStore();
|
||||||
loginStoreId.value = store?.id || "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadData(): Promise<void> {
|
async function loadData(): Promise<void> {
|
||||||
@@ -189,21 +155,12 @@ async function fetch(): Promise<void> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function selectStoreFilter(value: DropdownValue): Promise<void> {
|
|
||||||
if (Array.isArray(value)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
selectedStoreId.value = String(value);
|
|
||||||
await refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------- 导航 ----------
|
// ---------- 导航 ----------
|
||||||
|
|
||||||
async function toCreate(): Promise<void> {
|
async function toCreate(): Promise<void> {
|
||||||
await router.push({
|
await router.push({
|
||||||
path: "/management/users/create",
|
path: "/management/users/create",
|
||||||
query: selectedStoreId.value === allStoreFilterValue ? undefined : { storeId: selectedStoreId.value }
|
query: currentStoreStore.currentStoreId ? { storeId: currentStoreStore.currentStoreId } : undefined
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,19 +187,6 @@ onMounted(async () => {
|
|||||||
display: grid;
|
display: grid;
|
||||||
gap: .75rem;
|
gap: .75rem;
|
||||||
|
|
||||||
&.has-store-filter {
|
|
||||||
padding-top: calc(var(--app-nav-height) + 4rem);
|
|
||||||
}
|
|
||||||
|
|
||||||
.store-menu {
|
|
||||||
top: var(--app-nav-height);
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
z-index: 20;
|
|
||||||
position: fixed;
|
|
||||||
background: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.item {
|
.item {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user