From f7854bb9253e422cd56275fc1e4b5fde98adcabd Mon Sep 17 00:00:00 2001 From: MSuMshk <2039814060@qq.com> Date: Wed, 18 Feb 2026 10:04:59 +0800 Subject: [PATCH] feat(project): wire quick business status toggle in store list --- apps/web-antd/src/api/store/index.ts | 15 +++++ .../store/list/components/StoreListTable.vue | 63 +++++++++++++++++++ .../store-list-page/drawer-actions.ts | 41 +++++++++++- .../list/composables/useStoreListPage.ts | 18 +++--- apps/web-antd/src/views/store/list/index.vue | 2 + 5 files changed, 129 insertions(+), 10 deletions(-) diff --git a/apps/web-antd/src/api/store/index.ts b/apps/web-antd/src/api/store/index.ts index abbe35a..f938733 100644 --- a/apps/web-antd/src/api/store/index.ts +++ b/apps/web-antd/src/api/store/index.ts @@ -76,6 +76,14 @@ export interface SaveStoreDto { serviceTypes?: ServiceType[]; } +/** 快速切换门店营业状态参数 */ +export interface ToggleStoreBusinessStatusDto { + storeId: string; + businessStatus: StoreBusinessStatus; + closureReason?: number; + closureReasonText?: string; +} + /** 获取门店列表 */ export async function getStoreListApi(params: StoreListQuery) { return requestClient.get>('/store/list', { @@ -102,3 +110,10 @@ export async function updateStoreApi(data: SaveStoreDto) { export async function deleteStoreApi(id: string) { return requestClient.post('/store/delete', { id }); } + +/** 快速切换门店营业状态 */ +export async function toggleStoreBusinessStatusApi( + data: ToggleStoreBusinessStatusDto, +) { + return requestClient.post('/store/toggle-business-status', data); +} diff --git a/apps/web-antd/src/views/store/list/components/StoreListTable.vue b/apps/web-antd/src/views/store/list/components/StoreListTable.vue index e59f2f8..8e13401 100644 --- a/apps/web-antd/src/views/store/list/components/StoreListTable.vue +++ b/apps/web-antd/src/views/store/list/components/StoreListTable.vue @@ -14,6 +14,11 @@ import type { StoreListItemDto } from '#/api/store'; import { Button, Card, Popconfirm, Table, Tag } from 'ant-design-vue'; +import { + StoreAuditStatus as StoreAuditStatusEnum, + StoreBusinessStatus as StoreBusinessStatusEnum, +} from '#/api/store'; + interface Props { auditStatusMap: Record; businessStatusMap: Record; @@ -30,6 +35,7 @@ const props = defineProps(); const emit = defineEmits<{ (event: 'delete', record: StoreListItemDto): void; (event: 'edit', record: StoreListItemDto): void; + (event: 'toggleBusinessStatus', record: StoreListItemDto): void; (event: 'tableChange', pagination: TablePagination): void; }>(); @@ -56,6 +62,51 @@ function emitDelete(record: unknown) { if (!isStoreRecord(record)) return; emit('delete', record); } + +/** 当前门店是否允许快速切换营业状态。 */ +function canQuickToggleBusinessStatus(record: unknown) { + if (!isStoreRecord(record)) return false; + return ( + record.auditStatus === StoreAuditStatusEnum.Approved && + record.businessStatus !== StoreBusinessStatusEnum.ForceClosed + ); +} + +/** 获取快速切换按钮文案。 */ +function getToggleBusinessStatusText(record: unknown) { + if (!isStoreRecord(record)) return '不可切换'; + const status = record.businessStatus; + if (status === StoreBusinessStatusEnum.Operating) { + return '设为休息'; + } + if (status === StoreBusinessStatusEnum.Resting) { + return '恢复营业'; + } + return '不可切换'; +} + +/** 安全触发营业状态切换事件。 */ +function emitToggleBusinessStatus(record: unknown) { + if (!isStoreRecord(record)) return; + emit('toggleBusinessStatus', record); +} + +/** 创建时间格式化为 yyyy-MM-dd。 */ +function formatCreatedDate(value: string) { + if (!value) return '--'; + const isoDateMatch = /^(\d{4}-\d{2}-\d{2})/.exec(value.trim()); + if (isoDateMatch) { + return isoDateMatch[1] ?? '--'; + } + const date = new Date(value); + if (Number.isNaN(date.getTime())) { + return value.slice(0, 10) || '--'; + } + const year = date.getFullYear(); + const month = String(date.getMonth() + 1).padStart(2, '0'); + const day = String(date.getDate()).padStart(2, '0'); + return `${year}-${month}-${day}`; +} + +