后台管理功能进行一些优化
This commit is contained in:
@@ -52,7 +52,10 @@
|
||||
</template>
|
||||
<template v-else-if="column.key === 'actions'">
|
||||
<a-space>
|
||||
<a-button type="link" size="small" @click="showEditModal(record)">
|
||||
<a-button v-if="hasPermission('coupon:view')" type="link" size="small" @click="showViewModal(record)">
|
||||
查看
|
||||
</a-button>
|
||||
<a-button v-if="hasPermission('coupon:edit')" type="link" size="small" @click="showEditModal(record)">
|
||||
编辑
|
||||
</a-button>
|
||||
<a-button v-if="hasPermission('coupon:assign') && record.status === 1" type="link" size="small" @click="showDistributeModal(record)">
|
||||
@@ -199,6 +202,86 @@
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
|
||||
<!-- 查看优惠券详情模态框 -->
|
||||
<a-modal
|
||||
v-model:open="viewModalVisible"
|
||||
title="查看优惠券详情"
|
||||
@cancel="handleViewModalCancel"
|
||||
width="800px"
|
||||
>
|
||||
<a-form
|
||||
:model="viewFormState"
|
||||
:label-col="{ span: 6 }"
|
||||
:wrapper-col="{ span: 16 }"
|
||||
>
|
||||
<a-form-item label="优惠券编码">
|
||||
<a-input v-model:value="viewFormState.couponCode" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item label="优惠券名称">
|
||||
<a-input v-model:value="viewFormState.couponName" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item label="所属店铺">
|
||||
<a-select v-model:value="viewFormState.shopId" :disabled="true">
|
||||
<a-select-option
|
||||
v-for="shop in shops"
|
||||
:key="shop.id"
|
||||
:value="shop.id"
|
||||
>
|
||||
{{ shop.shopName }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item label="优惠券类型">
|
||||
<a-select v-model:value="viewFormState.couponType" :disabled="true">
|
||||
<a-select-option :value="1">折扣券</a-select-option>
|
||||
<a-select-option :value="2">满减券</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item v-if="viewFormState.couponType === 1" label="折扣值">
|
||||
<a-input-number v-model:value="viewFormState.discountValue" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item v-if="viewFormState.couponType === 2" label="最低消费">
|
||||
<a-input-number v-model:value="viewFormState.minAmount" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item v-if="viewFormState.couponType === 2" label="减免金额">
|
||||
<a-input-number v-model:value="viewFormState.reduceAmount" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item label="总数量">
|
||||
<a-input-number v-model:value="viewFormState.totalCount" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item label="开始时间">
|
||||
<a-date-picker v-model:value="viewFormState.startTime" show-time format="YYYY-MM-DD HH:mm:ss" style="width: 100%" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item label="结束时间">
|
||||
<a-date-picker v-model:value="viewFormState.endTime" show-time format="YYYY-MM-DD HH:mm:ss" style="width: 100%" :disabled="true" />
|
||||
</a-form-item>
|
||||
<a-form-item label="可用标签">
|
||||
<a-select
|
||||
v-model:value="viewFormState.availableTagIds"
|
||||
mode="multiple"
|
||||
:disabled="true"
|
||||
style="width: 100%"
|
||||
>
|
||||
<a-select-option v-for="tag in tagList" :key="tag.id" :value="tag.id">
|
||||
{{ tag.tagName }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item label="不可用标签">
|
||||
<a-select
|
||||
v-model:value="viewFormState.unavailableTagIds"
|
||||
mode="multiple"
|
||||
:disabled="true"
|
||||
style="width: 100%"
|
||||
>
|
||||
<a-select-option v-for="tag in tagList" :key="tag.id" :value="tag.id">
|
||||
{{ tag.tagName }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -255,6 +338,7 @@ const getCurrentUserInfo = () => {
|
||||
|
||||
const loading = ref(false)
|
||||
const modalVisible = ref(false)
|
||||
const viewModalVisible = ref(false)
|
||||
const modalLoading = ref(false)
|
||||
const isEdit = ref(false)
|
||||
const searchText = ref('')
|
||||
@@ -267,6 +351,22 @@ const distributeLoading = ref(false)
|
||||
const distributeFormRef = ref<FormInstance>()
|
||||
const currentDistributeCoupon = ref<Coupon | null>(null)
|
||||
|
||||
// 查看优惠券相关状态
|
||||
const viewFormState = reactive({
|
||||
couponCode: '',
|
||||
couponName: '',
|
||||
couponType: 1,
|
||||
discountValue: 9.5,
|
||||
minAmount: 100,
|
||||
reduceAmount: 20,
|
||||
totalCount: 100,
|
||||
startTime: undefined,
|
||||
endTime: undefined,
|
||||
availableTagIds: [] as number[],
|
||||
unavailableTagIds: [] as number[],
|
||||
shopId: undefined as number | undefined
|
||||
})
|
||||
|
||||
const couponList = ref<Coupon[]>([])
|
||||
const tagList = ref<TagVO[]>([])
|
||||
const userList = ref<any[]>([])
|
||||
@@ -453,6 +553,37 @@ const showEditModal = (record: Coupon) => {
|
||||
}
|
||||
}
|
||||
|
||||
const showViewModal = (record: Coupon) => {
|
||||
if (!record) {
|
||||
message.error('优惠券数据不存在')
|
||||
return
|
||||
}
|
||||
try {
|
||||
Object.assign(viewFormState, {
|
||||
couponCode: record.couponCode || '',
|
||||
couponName: record.couponName || '',
|
||||
couponType: record.couponType || 1,
|
||||
discountValue: record.discountValue || 0,
|
||||
minAmount: record.minAmount || 0,
|
||||
reduceAmount: record.reduceAmount || 0,
|
||||
totalCount: record.totalCount || 0,
|
||||
startTime: record.startTime ? dayjs(record.startTime) : undefined,
|
||||
endTime: record.endTime ? dayjs(record.endTime) : undefined,
|
||||
availableTagIds: record.availableTags ? record.availableTags.map(tag => tag.id) : [],
|
||||
unavailableTagIds: record.unavailableTags ? record.unavailableTags.map(tag => tag.id) : [],
|
||||
shopId: record.shopId
|
||||
})
|
||||
viewModalVisible.value = true
|
||||
} catch (error) {
|
||||
console.error('Error in showViewModal:', error)
|
||||
message.error('打开查看模态框失败')
|
||||
}
|
||||
}
|
||||
|
||||
const handleViewModalCancel = () => {
|
||||
viewModalVisible.value = false
|
||||
}
|
||||
|
||||
const handleModalOk = async () => {
|
||||
try {
|
||||
await formRef.value?.validate()
|
||||
@@ -525,8 +656,14 @@ const handleModalOk = async () => {
|
||||
}
|
||||
|
||||
const handleModalCancel = () => {
|
||||
modalVisible.value = false
|
||||
formRef.value?.resetFields()
|
||||
message.confirm({
|
||||
title: '确认关闭',
|
||||
content: '确定要关闭编辑模态框吗?未保存的更改将会丢失。',
|
||||
onOk: () => {
|
||||
modalVisible.value = false
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const handleDelete = (record: Coupon) => {
|
||||
|
||||
Reference in New Issue
Block a user