功能:完善门店能力与用户安全配置
This commit is contained in:
@@ -89,6 +89,14 @@
|
||||
@change="(checked: any) => handleStatusChange(record, checked === true)"
|
||||
/>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'authorization'">
|
||||
<a-space direction="vertical" size="small">
|
||||
<a-tag :color="record.authorizationExpired ? 'red' : 'green'">
|
||||
{{ record.authorizationStatusText || (record.authorizationExpired ? '已到期' : '有效') }}
|
||||
</a-tag>
|
||||
<span>{{ formatAuthorizationExpireTime(record.authorizationExpireTime) }}</span>
|
||||
</a-space>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'shopName'">
|
||||
<div style="max-width: 180px;">
|
||||
<TableEllipsisText :text="record.shopName" />
|
||||
@@ -200,11 +208,20 @@
|
||||
<a-form-item label="店铺地址" name="address">
|
||||
<a-input v-model:value="formState.address" placeholder="请输入店铺地址" />
|
||||
</a-form-item>
|
||||
<a-form-item label="地图位置">
|
||||
<div class="map-picker-row">
|
||||
<a-input v-model:value="formState.longitude" placeholder="经度" />
|
||||
<a-input v-model:value="formState.latitude" placeholder="纬度" />
|
||||
<a-button @click="openTencentLocationPicker">腾讯地图选点</a-button>
|
||||
</div>
|
||||
<div class="map-picker-tip">选点和展示使用腾讯地图;保存经纬度后,用户端可跳转腾讯地图或高德地图导航。</div>
|
||||
</a-form-item>
|
||||
<a-form-item label="营业时间" name="businessHours">
|
||||
<div class="business-hours-picker">
|
||||
<a-date-picker
|
||||
v-model:value="businessStartTime"
|
||||
picker="time"
|
||||
popup-class-name="yumi-date-picker-panel yumi-time-panel"
|
||||
value-format="HH:mm"
|
||||
format="HH:mm"
|
||||
placeholder="开始时间"
|
||||
@@ -216,6 +233,7 @@
|
||||
<a-date-picker
|
||||
v-model:value="businessEndTime"
|
||||
picker="time"
|
||||
popup-class-name="yumi-date-picker-panel yumi-time-panel"
|
||||
value-format="HH:mm"
|
||||
format="HH:mm"
|
||||
placeholder="结束时间"
|
||||
@@ -225,6 +243,17 @@
|
||||
/>
|
||||
</div>
|
||||
</a-form-item>
|
||||
<a-form-item label="授权有效期" name="authorizationExpireTime">
|
||||
<a-date-picker
|
||||
v-model:value="formState.authorizationExpireTime"
|
||||
show-time
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
format="YYYY-MM-DD HH:mm"
|
||||
placeholder="为空表示长期有效"
|
||||
:disabled="!isAdmin"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="Banner图片">
|
||||
<div class="upload-tip">首页轮播图,建议尺寸 750x300 像素</div>
|
||||
<a-upload
|
||||
@@ -295,9 +324,18 @@
|
||||
<a-form-item label="店铺地址">
|
||||
<a-input v-model:value="viewFormState.address" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item label="地图位置">
|
||||
<a-input :value="formatLocation(viewFormState.longitude, viewFormState.latitude)" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item label="营业时间">
|
||||
<a-input v-model:value="viewFormState.businessHours" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item label="授权状态">
|
||||
<a-input :value="viewFormState.authorizationStatusText || '有效'" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item label="授权有效期">
|
||||
<a-input :value="formatAuthorizationExpireTime(viewFormState.authorizationExpireTime)" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item label="Banner图片">
|
||||
<div class="shop-images">
|
||||
<a-image
|
||||
@@ -345,6 +383,10 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* ShopsView page script.
|
||||
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
|
||||
*/
|
||||
import { computed, ref, reactive, onMounted } from 'vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import type { FormInstance } from 'ant-design-vue'
|
||||
@@ -352,7 +394,7 @@ import { PlusOutlined } from '@ant-design/icons-vue'
|
||||
import DraftActions from '@/components/DraftActions.vue'
|
||||
import TableEllipsisText from '@/components/TableEllipsisText.vue'
|
||||
import { DEFAULT_SHOP_IMAGE } from '@/constants'
|
||||
import { adminShopApi, adminFileApi, type Shop } from '@/api/admin'
|
||||
import { adminShopApi, adminFileApi, adminSystemParameterConfigApi, type Shop } from '@/api/admin'
|
||||
import { createChunkUploadTask, type ChunkUploadTask } from '@/utils/chunk-upload'
|
||||
import { buildDraftStorageKey, clearDraftRecord, loadDraftRecord, saveDraftRecord } from '@/utils/form-draft'
|
||||
import { usePermission } from '@/utils/permission'
|
||||
@@ -365,21 +407,30 @@ import AdminResponsiveModal from '@/components/admin/AdminResponsiveModal.vue'
|
||||
const { hasPermission, loadUserPermissions } = usePermission()
|
||||
const { isMobile } = useAdminViewport()
|
||||
|
||||
/** loading is a reactive state variable used by the template and event handlers. */
|
||||
const loading = ref(false)
|
||||
/** searchText is a reactive state variable used by the template and event handlers. */
|
||||
const searchText = ref('')
|
||||
const shopList = ref<Shop[]>([])
|
||||
/** modalVisible is a reactive state variable used by the template and event handlers. */
|
||||
const modalVisible = ref(false)
|
||||
/** 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. */
|
||||
const modalLoading = ref(false)
|
||||
/** isEdit is a reactive state variable used by the template and event handlers. */
|
||||
const isEdit = ref(false)
|
||||
const formRef = ref<FormInstance>()
|
||||
const currentShop = ref<Shop | null>(null)
|
||||
/** isAdmin is a reactive state variable used by the template and event handlers. */
|
||||
const isAdmin = ref(false)
|
||||
|
||||
// Banner图片相关
|
||||
const bannerFileList = ref<any[]>([])
|
||||
const uploadedBannerIds = ref<string[]>([])
|
||||
/** bannerPreviewVisible is a reactive state variable used by the template and event handlers. */
|
||||
const bannerPreviewVisible = ref(false)
|
||||
/** bannerPreviewImage is a reactive state variable used by the template and event handlers. */
|
||||
const bannerPreviewImage = ref('')
|
||||
|
||||
// 店铺图片相关
|
||||
@@ -390,12 +441,18 @@ const shopImageUrls = ref<Record<string, string[]>>({})
|
||||
const shopBannerUrls = ref<Record<string, string[]>>({})
|
||||
const viewImageUrls = ref<string[]>([])
|
||||
const viewBannerUrls = ref<string[]>([])
|
||||
/** previewVisible is a reactive state variable used by the template and event handlers. */
|
||||
const previewVisible = ref(false)
|
||||
/** previewImage is a reactive state variable used by the template and event handlers. */
|
||||
const previewImage = ref('')
|
||||
/** businessStartTime is a reactive state variable used by the template and event handlers. */
|
||||
const businessStartTime = ref('')
|
||||
/** businessEndTime is a reactive state variable used by the template and event handlers. */
|
||||
const businessEndTime = ref('')
|
||||
const uploadTaskMap = new Map<string, ChunkUploadTask<any>>()
|
||||
/** activeUploadCount is a reactive state variable used by the template and event handlers. */
|
||||
const activeUploadCount = ref(0)
|
||||
/** isUploadPending is a reactive state variable used by the template and event handlers. */
|
||||
const isUploadPending = computed(() => activeUploadCount.value > 0)
|
||||
const draftSavedAt = ref<number | null>(null)
|
||||
|
||||
@@ -404,8 +461,13 @@ const viewFormState = reactive({
|
||||
shopName: '',
|
||||
description: '',
|
||||
address: '',
|
||||
mapProvider: 'TENCENT',
|
||||
longitude: '',
|
||||
latitude: '',
|
||||
businessHours: '',
|
||||
status: 1,
|
||||
authorizationExpireTime: '',
|
||||
authorizationStatusText: '',
|
||||
coverImageFileId: '',
|
||||
imageFileIds: ''
|
||||
})
|
||||
@@ -423,8 +485,12 @@ const formState = reactive({
|
||||
shopName: '',
|
||||
description: '',
|
||||
address: '',
|
||||
mapProvider: 'TENCENT',
|
||||
longitude: '',
|
||||
latitude: '',
|
||||
businessHours: '',
|
||||
status: 1,
|
||||
authorizationExpireTime: '',
|
||||
coverImageFileId: '',
|
||||
imageFileIds: ''
|
||||
})
|
||||
@@ -455,10 +521,12 @@ const columns = [
|
||||
{ title: '店铺地址', dataIndex: 'address', key: 'address' },
|
||||
{ title: '营业时间', dataIndex: 'businessHours', key: 'businessHours' },
|
||||
{ title: '状态', key: 'status', width: 120 },
|
||||
{ title: '授权', key: 'authorization', width: 180 },
|
||||
{ title: '创建时间', dataIndex: 'createTime', key: 'createTime' },
|
||||
{ title: '操作', key: 'actions', width: 150, fixed: 'right' as const }
|
||||
]
|
||||
|
||||
/** getCurrentUserInfo is a local helper used by this page script. */
|
||||
const getCurrentUserInfo = () => {
|
||||
try {
|
||||
const userInfoStr = localStorage.getItem('adminUserInfo')
|
||||
@@ -474,6 +542,7 @@ const getCurrentUserInfo = () => {
|
||||
return null
|
||||
}
|
||||
|
||||
/** loadImageUrls is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const loadImageUrls = async (shops: Shop[]) => {
|
||||
for (const shop of shops) {
|
||||
// 加载店铺图片
|
||||
@@ -538,6 +607,7 @@ const loadImageUrls = async (shops: Shop[]) => {
|
||||
}
|
||||
}
|
||||
|
||||
/** getShopImages is a local helper used by this page script. */
|
||||
const getShopImages = (shop: Shop | Record<string, any>): string[] => {
|
||||
const shopId = 'id' in shop ? shop.id : (shop as any).id
|
||||
if (shopId !== undefined) {
|
||||
@@ -546,6 +616,7 @@ const getShopImages = (shop: Shop | Record<string, any>): string[] => {
|
||||
return []
|
||||
}
|
||||
|
||||
/** getShopBannerImages is a local helper used by this page script. */
|
||||
const getShopBannerImages = (shop: Shop | Record<string, any>): string[] => {
|
||||
const shopId = 'id' in shop ? shop.id : (shop as any).id
|
||||
if (shopId !== undefined) {
|
||||
@@ -554,6 +625,52 @@ const getShopBannerImages = (shop: Shop | Record<string, any>): string[] => {
|
||||
return []
|
||||
}
|
||||
|
||||
/** formatAuthorizationExpireTime is a local helper used by this page script. */
|
||||
const formatAuthorizationExpireTime = (value?: string) => {
|
||||
if (!value) {
|
||||
return '长期有效'
|
||||
}
|
||||
return value.replace('T', ' ').slice(0, 16)
|
||||
}
|
||||
|
||||
const formatLocation = (longitude?: string | number, latitude?: string | number) => {
|
||||
return longitude && latitude ? `${longitude}, ${latitude}` : '未设置地图坐标'
|
||||
}
|
||||
|
||||
const openTencentLocationPicker = async () => {
|
||||
const response = await adminSystemParameterConfigApi.getTencentMapKey()
|
||||
const key = response?.key || ''
|
||||
if (!key) {
|
||||
message.warning('请先在参数管理中配置腾讯位置服务 Key')
|
||||
return
|
||||
}
|
||||
|
||||
const keyword = encodeURIComponent(formState.address || formState.shopName || '')
|
||||
const url = `https://apis.map.qq.com/tools/locpicker?search=1&type=1&key=${key}&referer=yuminail&keyword=${keyword}`
|
||||
const picker = window.open(url, 'yuminailTencentLocationPicker', 'width=900,height=680')
|
||||
const handleMessage = (event: MessageEvent) => {
|
||||
const data = event.data || {}
|
||||
const location = data.loclatlng || data.latlng || data.location
|
||||
if (!location) {
|
||||
return
|
||||
}
|
||||
formState.latitude = String(location.lat || location.latitude || '')
|
||||
formState.longitude = String(location.lng || location.longitude || '')
|
||||
formState.mapProvider = 'TENCENT'
|
||||
if (data.poiaddress || data.addr || data.address) {
|
||||
formState.address = data.poiaddress || data.addr || data.address
|
||||
}
|
||||
if (data.poiname && !formState.shopName) {
|
||||
formState.shopName = data.poiname
|
||||
}
|
||||
message.success('已选择腾讯地图位置')
|
||||
window.removeEventListener('message', handleMessage)
|
||||
picker?.close()
|
||||
}
|
||||
window.addEventListener('message', handleMessage)
|
||||
}
|
||||
|
||||
/** fetchShopList is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const fetchShopList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
@@ -582,17 +699,20 @@ const fetchShopList = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
/** handleSearch is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const handleSearch = async () => {
|
||||
pagination.current = 1
|
||||
await runWithGlobalLoading(() => fetchShopList())
|
||||
}
|
||||
|
||||
/** handleTableChange is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const handleTableChange = async (pag: any) => {
|
||||
pagination.current = pag.current
|
||||
pagination.pageSize = pag.pageSize
|
||||
await runWithGlobalLoading(() => fetchShopList())
|
||||
}
|
||||
|
||||
/** beforeUpload is a local helper used by this page script. */
|
||||
const beforeUpload = (file: File) => {
|
||||
const isImage = file.type.startsWith('image/')
|
||||
if (!isImage) {
|
||||
@@ -606,6 +726,7 @@ const beforeUpload = (file: File) => {
|
||||
}
|
||||
|
||||
// Banner 与门店环境图分开维护上传任务,便于表单回显和删除时分别同步 fileId 列表。
|
||||
/** handleUploadBanner is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const handleUploadBanner = async (options: any) => {
|
||||
const { file, onSuccess, onError, onProgress } = options
|
||||
const taskKey = `banner:${String(file.uid)}`
|
||||
@@ -645,6 +766,7 @@ const handleUploadBanner = async (options: any) => {
|
||||
}
|
||||
}
|
||||
|
||||
/** handleBannerPreview is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const handleBannerPreview = async (file: any) => {
|
||||
try {
|
||||
const cachedPreviewUrl = getPreviewUrlFromFile(file)
|
||||
@@ -671,6 +793,7 @@ const handleBannerPreview = async (file: any) => {
|
||||
}
|
||||
}
|
||||
|
||||
/** handleBannerRemove is a local helper used by this page script. */
|
||||
const handleBannerRemove = (file: any) => {
|
||||
const task = uploadTaskMap.get(`banner:${String(file.uid)}`)
|
||||
if (task) {
|
||||
@@ -686,6 +809,7 @@ const handleBannerRemove = (file: any) => {
|
||||
}
|
||||
|
||||
// 店铺环境图与 Banner 走同一套分片上传协议,但写入不同业务字段。
|
||||
/** handleUploadImage is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const handleUploadImage = async (options: any) => {
|
||||
const { file, onSuccess, onError, onProgress } = options
|
||||
const taskKey = `image:${String(file.uid)}`
|
||||
@@ -726,6 +850,7 @@ const handleUploadImage = async (options: any) => {
|
||||
}
|
||||
|
||||
// 编辑态下 Upload 里的文件可能只剩 fileId,所以预览时需要兼容本地 URL 与远端签名地址两种来源。
|
||||
/** handlePreview is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const handlePreview = async (file: any) => {
|
||||
try {
|
||||
const cachedPreviewUrl = getPreviewUrlFromFile(file)
|
||||
@@ -752,6 +877,7 @@ const handlePreview = async (file: any) => {
|
||||
}
|
||||
}
|
||||
|
||||
/** handleRemove is a local helper used by this page script. */
|
||||
const handleRemove = (file: any) => {
|
||||
const task = uploadTaskMap.get(`image:${String(file.uid)}`)
|
||||
if (task) {
|
||||
@@ -766,12 +892,14 @@ const handleRemove = (file: any) => {
|
||||
return true
|
||||
}
|
||||
|
||||
/** syncBusinessHoursValue is a local helper used by this page script. */
|
||||
const syncBusinessHoursValue = () => {
|
||||
formState.businessHours = businessStartTime.value && businessEndTime.value
|
||||
? `${businessStartTime.value}-${businessEndTime.value}`
|
||||
: ''
|
||||
}
|
||||
|
||||
/** setBusinessHoursValue is a local helper used by this page script. */
|
||||
const setBusinessHoursValue = (value?: string) => {
|
||||
const matched = (value || '').match(/(\d{2}:\d{2})\s*-\s*(\d{2}:\d{2})/)
|
||||
businessStartTime.value = matched?.[1] || ''
|
||||
@@ -779,11 +907,13 @@ const setBusinessHoursValue = (value?: string) => {
|
||||
syncBusinessHoursValue()
|
||||
}
|
||||
|
||||
/** handleBusinessHoursChange is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const handleBusinessHoursChange = async () => {
|
||||
syncBusinessHoursValue()
|
||||
await formRef.value?.validateFields?.(['businessHours']).catch(() => undefined)
|
||||
}
|
||||
|
||||
/** showAddModal is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const showAddModal = async () => {
|
||||
isEdit.value = false
|
||||
currentShop.value = null
|
||||
@@ -791,8 +921,12 @@ const showAddModal = async () => {
|
||||
shopName: '',
|
||||
description: '',
|
||||
address: '',
|
||||
mapProvider: 'TENCENT',
|
||||
longitude: '',
|
||||
latitude: '',
|
||||
businessHours: '',
|
||||
status: 1,
|
||||
authorizationExpireTime: '',
|
||||
coverImageFileId: '',
|
||||
imageFileIds: ''
|
||||
})
|
||||
@@ -805,6 +939,7 @@ const showAddModal = async () => {
|
||||
modalVisible.value = true
|
||||
}
|
||||
|
||||
/** showEditModal is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const showEditModal = async (record: Shop | Record<string, any>) => {
|
||||
isEdit.value = true
|
||||
currentShop.value = record as Shop
|
||||
@@ -812,8 +947,12 @@ const showEditModal = async (record: Shop | Record<string, any>) => {
|
||||
shopName: 'shopName' in record ? record.shopName : (record as any).shopName,
|
||||
description: 'description' in record ? record.description : (record as any).description,
|
||||
address: 'address' in record ? record.address : (record as any).address,
|
||||
mapProvider: 'TENCENT',
|
||||
longitude: 'longitude' in record ? record.longitude : (record as any).longitude,
|
||||
latitude: 'latitude' in record ? record.latitude : (record as any).latitude,
|
||||
businessHours: 'businessHours' in record ? record.businessHours : (record as any).businessHours,
|
||||
status: 'status' in record ? (record.status ?? 1) : ((record as any).status ?? 1),
|
||||
authorizationExpireTime: 'authorizationExpireTime' in record ? record.authorizationExpireTime : (record as any).authorizationExpireTime,
|
||||
coverImageFileId: 'coverImageFileId' in record ? record.coverImageFileId : (record as any).coverImageFileId,
|
||||
imageFileIds: 'imageFileIds' in record ? record.imageFileIds : (record as any).imageFileIds
|
||||
})
|
||||
@@ -845,13 +984,19 @@ const showEditModal = async (record: Shop | Record<string, any>) => {
|
||||
modalVisible.value = true
|
||||
}
|
||||
|
||||
/** showViewModal is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const showViewModal = async (record: Shop | Record<string, any>) => {
|
||||
Object.assign(viewFormState, {
|
||||
shopName: 'shopName' in record ? record.shopName : (record as any).shopName,
|
||||
description: 'description' in record ? record.description : (record as any).description,
|
||||
address: 'address' in record ? record.address : (record as any).address,
|
||||
mapProvider: 'TENCENT',
|
||||
longitude: 'longitude' in record ? record.longitude : (record as any).longitude,
|
||||
latitude: 'latitude' in record ? record.latitude : (record as any).latitude,
|
||||
businessHours: 'businessHours' in record ? record.businessHours : (record as any).businessHours,
|
||||
status: 'status' in record ? (record.status ?? 1) : ((record as any).status ?? 1),
|
||||
authorizationExpireTime: 'authorizationExpireTime' in record ? record.authorizationExpireTime : (record as any).authorizationExpireTime,
|
||||
authorizationStatusText: 'authorizationStatusText' in record ? record.authorizationStatusText : (record as any).authorizationStatusText,
|
||||
coverImageFileId: 'coverImageFileId' in record ? record.coverImageFileId : (record as any).coverImageFileId,
|
||||
imageFileIds: 'imageFileIds' in record ? record.imageFileIds : (record as any).imageFileIds
|
||||
})
|
||||
@@ -907,25 +1052,33 @@ const showViewModal = async (record: Shop | Record<string, any>) => {
|
||||
viewModalVisible.value = true
|
||||
}
|
||||
|
||||
/** handleViewModalCancel is a local helper used by this page script. */
|
||||
const handleViewModalCancel = () => {
|
||||
viewModalVisible.value = false
|
||||
viewImageUrls.value = []
|
||||
viewBannerUrls.value = []
|
||||
}
|
||||
|
||||
/** cancelAllPendingUploads is a local helper used by this page script. */
|
||||
const cancelAllPendingUploads = () => {
|
||||
uploadTaskMap.forEach(task => task.cancel())
|
||||
}
|
||||
|
||||
/** getDraftKey is a local helper used by this page script. */
|
||||
const getDraftKey = () => buildDraftStorageKey('admin-shops', isEdit.value ? 'edit' : 'create', currentShop.value?.id ?? 'new')
|
||||
|
||||
/** buildDraftPayload is a local helper used by this page script. */
|
||||
const buildDraftPayload = () => ({
|
||||
formState: {
|
||||
shopName: formState.shopName,
|
||||
description: formState.description,
|
||||
address: formState.address,
|
||||
mapProvider: 'TENCENT',
|
||||
longitude: formState.longitude,
|
||||
latitude: formState.latitude,
|
||||
businessHours: formState.businessHours,
|
||||
status: formState.status,
|
||||
authorizationExpireTime: formState.authorizationExpireTime,
|
||||
coverImageFileId: formState.coverImageFileId,
|
||||
imageFileIds: formState.imageFileIds
|
||||
},
|
||||
@@ -935,6 +1088,7 @@ const buildDraftPayload = () => ({
|
||||
uploadedFileIds: [...uploadedFileIds.value]
|
||||
})
|
||||
|
||||
/** buildShopUploadFileList is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const buildShopUploadFileList = async (ids: string[], fileNamePrefix: string) => {
|
||||
const fileList = []
|
||||
for (const [index, id] of ids.entries()) {
|
||||
@@ -964,6 +1118,7 @@ const buildShopUploadFileList = async (ids: string[], fileNamePrefix: string) =>
|
||||
return fileList
|
||||
}
|
||||
|
||||
/** restoreDraft is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const restoreDraft = async () => {
|
||||
const draft = loadDraftRecord<ReturnType<typeof buildDraftPayload>>(getDraftKey())
|
||||
if (!draft) {
|
||||
@@ -982,6 +1137,7 @@ const restoreDraft = async () => {
|
||||
message.success('已恢复暂存内容')
|
||||
}
|
||||
|
||||
/** handleSaveDraft is a local helper used by this page script. */
|
||||
const handleSaveDraft = () => {
|
||||
if (isUploadPending.value) {
|
||||
message.warning('图片上传完成后才能暂存')
|
||||
@@ -992,6 +1148,7 @@ const handleSaveDraft = () => {
|
||||
message.success('已暂存到本地')
|
||||
}
|
||||
|
||||
/** handleClearDraft is a local helper used by this page script. */
|
||||
const handleClearDraft = (showMessage = true) => {
|
||||
clearDraftRecord(getDraftKey())
|
||||
draftSavedAt.value = null
|
||||
@@ -1000,16 +1157,19 @@ const handleClearDraft = (showMessage = true) => {
|
||||
}
|
||||
}
|
||||
|
||||
/** syncUploadedBannerIds is a local helper used by this page script. */
|
||||
const syncUploadedBannerIds = (fileIds: string[]) => {
|
||||
uploadedBannerIds.value = Array.from(new Set(fileIds.filter(id => Boolean(id))))
|
||||
formState.coverImageFileId = uploadedBannerIds.value.join(',')
|
||||
}
|
||||
|
||||
/** syncUploadedFileIds is a local helper used by this page script. */
|
||||
const syncUploadedFileIds = (fileIds: string[]) => {
|
||||
uploadedFileIds.value = Array.from(new Set(fileIds.filter(id => Boolean(id))))
|
||||
formState.imageFileIds = uploadedFileIds.value.join(',')
|
||||
}
|
||||
|
||||
/** getUploadResponse is a local helper used by this page script. */
|
||||
const getUploadResponse = (file: any) => {
|
||||
if (!file || typeof file !== 'object') {
|
||||
return null
|
||||
@@ -1017,6 +1177,7 @@ const getUploadResponse = (file: any) => {
|
||||
return file.response || null
|
||||
}
|
||||
|
||||
/** resolveUploadedFileId is a local helper used by this page script. */
|
||||
const resolveUploadedFileId = (file: any) => {
|
||||
const response = getUploadResponse(file)
|
||||
const responseId = response?.id ?? response?.data?.id ?? file?.fileId
|
||||
@@ -1037,6 +1198,7 @@ const resolveUploadedFileId = (file: any) => {
|
||||
return ''
|
||||
}
|
||||
|
||||
/** getPreviewUrlFromFile is a local helper used by this page script. */
|
||||
const getPreviewUrlFromFile = (file: any) => {
|
||||
const fileUrl = typeof file?.url === 'string' ? file.url : ''
|
||||
if (fileUrl && !/^\d+$/.test(fileUrl)) {
|
||||
@@ -1051,6 +1213,7 @@ const getPreviewUrlFromFile = (file: any) => {
|
||||
return ''
|
||||
}
|
||||
|
||||
/** handleModalOk is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const handleModalOk = async () => {
|
||||
try {
|
||||
if (isUploadPending.value) {
|
||||
@@ -1081,6 +1244,7 @@ const handleModalOk = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
/** handleModalCancel is a local helper used by this page script. */
|
||||
const handleModalCancel = () => {
|
||||
cancelAllPendingUploads()
|
||||
modalVisible.value = false
|
||||
@@ -1092,6 +1256,7 @@ const handleModalCancel = () => {
|
||||
syncUploadedFileIds([])
|
||||
}
|
||||
|
||||
/** handleDelete is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const handleDelete = async (record: Shop | Record<string, any>) => {
|
||||
try {
|
||||
await runWithGlobalLoading(async () => {
|
||||
@@ -1105,6 +1270,7 @@ const handleDelete = async (record: Shop | Record<string, any>) => {
|
||||
}
|
||||
}
|
||||
|
||||
/** handleStatusChange is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const handleStatusChange = async (record: Shop | Record<string, any>, enabled: boolean) => {
|
||||
try {
|
||||
await runWithGlobalLoading(async () => {
|
||||
@@ -1136,6 +1302,19 @@ onMounted(async () => {
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.map-picker-row {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.map-picker-tip {
|
||||
margin-top: 8px;
|
||||
color: #8c8c8c;
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.shop-banner {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
Reference in New Issue
Block a user