新增
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 5m7s

This commit is contained in:
sexygoat
2026-03-19 18:32:02 +08:00
parent 407287f538
commit f06d8c9133
22 changed files with 2260 additions and 117 deletions

View File

@@ -419,6 +419,49 @@
</div>
</template>
</ElDialog>
<!-- 修改零售价对话框 -->
<ElDialog
v-model="retailPriceDialogVisible"
title="修改零售价"
width="500px"
:close-on-click-modal="false"
@closed="handleCloseRetailPriceDialog"
>
<ElForm
ref="retailPriceFormRef"
:model="retailPriceForm"
:rules="retailPriceRules"
label-width="100px"
>
<ElFormItem label="套餐名称">
<span>{{ retailPriceForm.package_name }}</span>
</ElFormItem>
<ElFormItem label="零售价" prop="retail_price">
<ElInputNumber
v-model="retailPriceForm.retail_price"
:min="0"
:max="999999"
:step="0.01"
:precision="2"
placeholder="请输入零售价"
style="width: 100%"
/>
<div style="margin-top: 5px; font-size: 12px; color: #909399">
单位:元 | 存储值:{{ Math.round(retailPriceForm.retail_price * 100) }} 分
</div>
</ElFormItem>
</ElForm>
<template #footer>
<div class="dialog-footer">
<ElButton @click="retailPriceDialogVisible = false">取消</ElButton>
<ElButton type="primary" @click="handleConfirmUpdateRetailPrice" :loading="retailPriceLoading">
确认修改
</ElButton>
</div>
</template>
</ElDialog>
</ElCard>
</div>
</ArtTableFullScreen>
@@ -428,7 +471,7 @@
import { h } from 'vue'
import { useRouter } from 'vue-router'
import { PackageManageService, PackageSeriesService } from '@/api/modules'
import { ElMessage, ElMessageBox, ElTag, ElSwitch, ElButton } from 'element-plus'
import { ElMessage, ElMessageBox, ElTag, ElSwitch, ElButton, ElInputNumber } from 'element-plus'
import type { FormInstance, FormRules } from 'element-plus'
import type { PackageResponse, SeriesSelectOption } from '@/types/api'
import type { SearchFormItem } from '@/types'
@@ -467,6 +510,22 @@
const seriesOptions = ref<SeriesSelectOption[]>([])
const searchSeriesOptions = ref<SeriesSelectOption[]>([])
// 零售价修改对话框
const retailPriceDialogVisible = ref(false)
const retailPriceLoading = ref(false)
const retailPriceFormRef = ref<FormInstance>()
const retailPriceForm = reactive({
id: 0,
package_name: '',
retail_price: 0
})
const retailPriceRules = reactive<FormRules>({
retail_price: [
{ required: true, message: '请输入零售价', trigger: 'blur' },
{ type: 'number', message: '零售价必须为数字', trigger: 'blur' }
]
})
// 使用表格右键菜单功能
const {
showContextMenuHint,
@@ -784,6 +843,13 @@
})
}
if (hasAuth('package:update_retail_price')) {
items.push({
key: 'update-retail-price',
label: '修改零售价'
})
}
if (hasAuth('package:delete')) {
items.push({
key: 'delete',
@@ -1145,6 +1211,44 @@
contextMenuRef.value?.show(event)
}
// 显示零售价修改对话框
const showRetailPriceDialog = (row: PackageResponse) => {
retailPriceForm.id = row.id
retailPriceForm.package_name = row.package_name
// 将分转换为元显示
retailPriceForm.retail_price = row.retail_price ? row.retail_price / 100 : 0
retailPriceDialogVisible.value = true
}
// 确认修改零售价
const handleConfirmUpdateRetailPrice = () => {
retailPriceFormRef.value?.validate(async (valid) => {
if (!valid) return
retailPriceLoading.value = true
try {
// 将元转换为分
const priceInCents = Math.round(retailPriceForm.retail_price * 100)
const res = await PackageManageService.updateRetailPrice(retailPriceForm.id, priceInCents)
if (res.code === 0) {
ElMessage.success('零售价修改成功')
retailPriceDialogVisible.value = false
loadPackageList()
}
} catch (error: any) {
console.error('修改零售价失败:', error)
} finally {
retailPriceLoading.value = false
}
})
}
// 关闭零售价对话框
const handleCloseRetailPriceDialog = () => {
retailPriceDialogVisible.value = false
retailPriceFormRef.value?.resetFields()
}
// 处理右键菜单选择
const handleContextMenuSelect = (item: MenuItemType) => {
if (!currentRow.value) return
@@ -1153,6 +1257,9 @@
case 'edit':
showDialog('edit', currentRow.value)
break
case 'update-retail-price':
showRetailPriceDialog(currentRow.value)
break
case 'delete':
deletePackage(currentRow.value)
break