后台管理功能进行一些优化

This commit is contained in:
xiaowang
2026-02-28 14:32:28 +08:00
parent 36e2950a99
commit 725cb07fcf
23 changed files with 2297 additions and 92 deletions
+98
View File
@@ -52,6 +52,9 @@
</template>
<template v-else-if="column.key === 'actions'">
<a-space>
<a-button v-if="hasPermission('shop:view')" type="link" size="small" @click="showViewModal(record)">
查看
</a-button>
<a-button v-if="hasPermission('shop:edit')" type="link" size="small" @click="showEditModal(record)">
编辑
</a-button>
@@ -122,6 +125,50 @@
</a-form-item>
</a-form>
</a-modal>
<!-- 查看店铺详情模态框 -->
<a-modal
v-model:open="viewModalVisible"
title="查看店铺详情"
width="600px"
@cancel="handleViewModalCancel"
>
<a-form
:model="viewFormState"
:label-col="{ span: 5 }"
:wrapper-col="{ span: 18 }"
>
<a-form-item label="店铺名称">
<a-input v-model:value="viewFormState.shopName" :disabled="true" />
</a-form-item>
<a-form-item label="店铺描述">
<a-textarea
v-model:value="viewFormState.description"
:rows="3"
:disabled="true"
/>
</a-form-item>
<a-form-item label="店铺地址">
<a-input v-model:value="viewFormState.address" :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="店铺图片">
<div class="shop-images">
<a-image
v-for="(url, index) in viewImageUrls"
:key="index"
:width="80"
:height="80"
:src="url"
style="object-fit: cover; border-radius: 4px; margin-right: 8px; margin-bottom: 8px;"
:preview="false"
/>
</div>
</a-form-item>
</a-form>
</a-modal>
</div>
</template>
@@ -140,6 +187,7 @@ const loading = ref(false)
const searchText = ref('')
const shopList = ref<Shop[]>([])
const modalVisible = ref(false)
const viewModalVisible = ref(false)
const modalLoading = ref(false)
const isEdit = ref(false)
const formRef = ref<FormInstance>()
@@ -151,9 +199,19 @@ const imageFileList = ref<any[]>([])
const uploadedFileIds = ref<string[]>([])
const imageIdCache = ref<Record<string, string>>({})
const shopImageUrls = ref<Record<number, string[]>>({})
const viewImageUrls = ref<string[]>([])
const previewVisible = ref(false)
const previewImage = ref('')
// 查看店铺相关状态
const viewFormState = reactive({
shopName: '',
description: '',
address: '',
businessHours: '',
imageFileIds: ''
})
const pagination = reactive({
current: 1,
pageSize: 10,
@@ -387,6 +445,46 @@ const showEditModal = async (record: Shop) => {
modalVisible.value = true
}
const showViewModal = async (record: Shop) => {
Object.assign(viewFormState, {
shopName: record.shopName,
description: record.description,
address: record.address,
businessHours: record.businessHours,
imageFileIds: record.imageFileIds
})
// 加载图片URL
if (record.imageFileIds) {
const ids = record.imageFileIds.split(',')
const urls: string[] = []
for (const id of ids) {
try {
// 检查缓存
if (!imageIdCache.value[id]) {
const signedUrl = await adminFileApi.getSignedUrl(Number(id))
imageIdCache.value[id] = signedUrl
}
urls.push(imageIdCache.value[id])
} catch (error) {
console.error('获取签名链接失败:', error)
urls.push(DEFAULT_SHOP_IMAGE)
}
}
viewImageUrls.value = urls
} else {
viewImageUrls.value = [DEFAULT_SHOP_IMAGE]
}
viewModalVisible.value = true
}
const handleViewModalCancel = () => {
viewModalVisible.value = false
viewImageUrls.value = []
}
const handleModalOk = async () => {
try {
await formRef.value?.validate()