feat: 增加店长审核模式与门店经营有效期

This commit is contained in:
2026-10-26 21:12:50 +08:00
parent 0151367333
commit fd9ff73c00
33 changed files with 855 additions and 39 deletions
@@ -131,6 +131,14 @@
<TableEllipsisText :text="record.businessHours" />
</div>
</template>
<template v-else-if="column.key === 'businessExpiry'">
<a-space direction="vertical" size="small">
<a-tag :color="record.businessExpired ? 'red' : 'green'">
{{ record.businessExpired ? '已过期' : record.businessExpireTime ? `剩余 ${record.businessRemainingDays ?? 0} 天` : '未设置' }}
</a-tag>
<span>{{ record.businessExpireTime ? record.businessExpireTime.slice(0, 10) : '未设置' }}</span>
</a-space>
</template>
<template v-else-if="column.key === 'actions'">
<a-space>
<a-button v-if="hasPermission('shop:view')" type="link" size="small" @click="showViewModal(record)">
@@ -139,6 +147,9 @@
<a-button v-if="hasPermission('shop:edit')" type="link" size="small" @click="showEditModal(record)">
编辑
</a-button>
<a-button v-if="hasPermission('shop:edit') && isAdmin" type="link" size="small" @click="openBusinessExpiry(record as Shop)">
有效期
</a-button>
</a-space>
</template>
</template>
@@ -172,10 +183,15 @@
<span>地址</span>
<strong>{{ item.address || '--' }}</strong>
</div>
<div class="admin-mobile-card__row">
<span>经营有效期</span>
<strong :class="{ 'expiry-danger': item.businessExpired }">{{ item.businessExpired ? '已过期' : item.businessExpireTime ? `${item.businessExpireTime.slice(0, 10)} · 剩余 ${item.businessRemainingDays ?? 0} 天` : '未设置' }}</strong>
</div>
</div>
<div class="admin-mobile-card__actions">
<a-button size="small" @click="showViewModal(item)">查看</a-button>
<a-button v-if="hasPermission('shop:edit')" size="small" @click="showEditModal(item)">编辑</a-button>
<a-button v-if="hasPermission('shop:edit') && isAdmin" size="small" @click="openBusinessExpiry(item)">有效期</a-button>
<a-button
v-if="hasPermission('shop:edit')"
size="small"
@@ -559,6 +575,29 @@
</a-form>
</AdminResponsiveModal>
<a-modal
v-model:open="businessExpiryModalVisible"
title="设置门店经营有效期"
ok-text="保存到期日"
cancel-text="取消"
:confirm-loading="savingBusinessExpiry"
:mask-closable="false"
@ok="saveBusinessExpiry"
@cancel="businessExpiryModalVisible = false"
>
<div class="business-expiry-editor">
<strong>{{ expiryShop?.shopName || '门店' }}</strong>
<a-date-picker
v-model:value="businessExpiryDate"
value-format="YYYY-MM-DD"
format="YYYY-MM-DD"
:disabled-date="disablePastExpiryDate"
placeholder="选择到期日期"
/>
<p>到期日期当天 23:59 前仍可新增预约。到期后只限制新增普通预约,不影响补录历史订单和查询。</p>
</div>
</a-modal>
<a-modal
v-model:open="mapPickerVisible"
:title="mapPickerTitle"
@@ -801,6 +840,10 @@ const searchText = ref('')
const shopList = ref<Shop[]>([])
/** modalVisible is a reactive state variable used by the template and event handlers. */
const modalVisible = ref(false)
const businessExpiryModalVisible = ref(false)
const businessExpiryDate = ref<string>()
const savingBusinessExpiry = ref(false)
const expiryShop = ref<Shop | null>(null)
/** viewModalVisible is a reactive state variable used by the template and event handlers. */
const viewModalVisible = ref(false)
/** modalLoading is a reactive state variable used by the template and event handlers. */
@@ -1240,6 +1283,7 @@ const columns = [
{ title: '店铺描述', dataIndex: 'description', key: 'description' },
{ title: '店铺地址', dataIndex: 'address', key: 'address' },
{ title: '营业时间', dataIndex: 'businessHours', key: 'businessHours' },
{ title: '经营有效期', key: 'businessExpiry', width: 180 },
{ title: '状态', key: 'status', width: 120 },
{ title: '创建时间', dataIndex: 'createTime', key: 'createTime' },
{ title: '操作', key: 'actions', width: 150, fixed: 'right' as const }
@@ -1419,6 +1463,36 @@ const formatAuthorizationExpireTime = (value?: string) => {
return value.replace('T', ' ').slice(0, 16)
}
const openBusinessExpiry = (shop: Shop) => {
expiryShop.value = shop
businessExpiryDate.value = shop.businessExpireTime ? shop.businessExpireTime.slice(0, 10) : undefined
businessExpiryModalVisible.value = true
}
const disablePastExpiryDate = (date: any) => {
const today = new Date()
const localToday = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, '0')}-${String(today.getDate()).padStart(2, '0')}`
return date.format('YYYY-MM-DD') < localToday
}
const saveBusinessExpiry = async () => {
if (!expiryShop.value || !businessExpiryDate.value) {
message.warning('请选择门店到期日期')
return
}
savingBusinessExpiry.value = true
try {
await adminShopApi.updateBusinessExpiry(expiryShop.value.id, businessExpiryDate.value)
message.success('门店经营有效期已更新')
businessExpiryModalVisible.value = false
await fetchShopList()
} catch (error) {
message.error(error instanceof Error ? error.message : '有效期更新失败')
} finally {
savingBusinessExpiry.value = false
}
}
/**
* Purpose: formatLocation supports ShopsView.vue by holding or executing the format location page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
@@ -1658,7 +1732,17 @@ const fetchShopList = async () => {
const response = await adminShopApi.listShops(params)
const res = typeof response === 'object' && 'list' in response ? response : (response as any).data
shopList.value = res.list || []
const rows = res.list || []
let expiryById = new Map<string, Awaited<ReturnType<typeof adminShopApi.listBusinessExpiries>>[number]>()
if (rows.length) {
try {
const expiries = await adminShopApi.listBusinessExpiries(rows.map((shop: Shop) => shop.id))
expiryById = new Map(expiries.map(expiry => [String(expiry.shopId), expiry]))
} catch {
message.warning('门店有效期信息暂时不可用,稍后可刷新重试')
}
}
shopList.value = rows.map((shop: Shop) => ({ ...shop, ...expiryById.get(String(shop.id)) }))
pagination.total = res.total || 0
// 预加载所有图片签名链接
@@ -2392,6 +2476,10 @@ onMounted(async () => {
padding: 0;
}
.business-expiry-editor { display: grid; gap: 14px; padding-top: 8px; }
.business-expiry-editor p { margin: 0; color: var(--admin-mobile-muted); font-size: 12px; line-height: 1.6; }
.expiry-danger { color: #a54141; }
.shop-images {
display: flex;
align-items: center;