fetch(modify):修复BUG
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 3m27s
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 3m27s
This commit is contained in:
@@ -140,12 +140,15 @@
|
||||
/>
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="成本价(分)" prop="cost_price">
|
||||
<ElFormItem label="成本价(元)" prop="cost_price">
|
||||
<ElInputNumber
|
||||
v-model="form.cost_price"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
:step="0.01"
|
||||
:controls="false"
|
||||
style="width: 100%"
|
||||
placeholder="请输入成本价"
|
||||
/>
|
||||
</ElFormItem>
|
||||
</ElForm>
|
||||
@@ -290,7 +293,7 @@
|
||||
validator: (rule: any, value: any, callback: any) => {
|
||||
if (value === undefined || value === null || value === '') {
|
||||
callback(new Error('请输入成本价'))
|
||||
} else if (form.package_base_price && value < form.package_base_price) {
|
||||
} else if (form.package_base_price && value < form.package_base_price / 100) {
|
||||
callback(
|
||||
new Error(`成本价不能低于套餐价格 ¥${(form.package_base_price / 100).toFixed(2)}`)
|
||||
)
|
||||
@@ -617,7 +620,7 @@
|
||||
form.id = row.id
|
||||
form.package_id = row.package_id
|
||||
form.shop_id = row.shop_id
|
||||
form.cost_price = row.cost_price
|
||||
form.cost_price = row.cost_price / 100 // 转换为元显示
|
||||
form.package_base_price = 0
|
||||
} else {
|
||||
form.id = 0
|
||||
@@ -639,9 +642,9 @@
|
||||
// 从套餐选项中找到选中的套餐
|
||||
const selectedPackage = packageOptions.value.find((pkg) => pkg.id === packageId)
|
||||
if (selectedPackage) {
|
||||
// 将套餐的价格设置为成本价
|
||||
form.cost_price = selectedPackage.price
|
||||
form.package_base_price = selectedPackage.price
|
||||
// 将套餐的价格(分)转换为元显示
|
||||
form.cost_price = selectedPackage.price / 100
|
||||
form.package_base_price = selectedPackage.price // 保持原始值(分)用于验证
|
||||
}
|
||||
} else {
|
||||
// 清空时重置成本价
|
||||
@@ -695,10 +698,13 @@
|
||||
if (valid) {
|
||||
submitLoading.value = true
|
||||
try {
|
||||
// 将元转换为分提交给后端
|
||||
const costPriceInCents = Math.round(form.cost_price * 100)
|
||||
|
||||
const data = {
|
||||
package_id: form.package_id,
|
||||
shop_id: form.shop_id,
|
||||
cost_price: form.cost_price
|
||||
cost_price: costPriceInCents
|
||||
}
|
||||
|
||||
if (dialogType.value === 'add') {
|
||||
@@ -706,7 +712,7 @@
|
||||
ElMessage.success('新增成功')
|
||||
} else {
|
||||
await ShopPackageAllocationService.updateShopPackageAllocation(form.id, {
|
||||
cost_price: form.cost_price
|
||||
cost_price: costPriceInCents
|
||||
})
|
||||
ElMessage.success('修改成功')
|
||||
}
|
||||
|
||||
@@ -50,12 +50,18 @@
|
||||
>
|
||||
<ElForm ref="formRef" :model="form" :rules="rules" label-width="120px">
|
||||
<ElFormItem label="套餐编码" prop="package_code">
|
||||
<ElInput
|
||||
v-model="form.package_code"
|
||||
placeholder="请输入套餐编码"
|
||||
:disabled="dialogType === 'edit'"
|
||||
clearable
|
||||
/>
|
||||
<div style="display: flex; gap: 8px;">
|
||||
<ElInput
|
||||
v-model="form.package_code"
|
||||
placeholder="请输入套餐编码或点击生成"
|
||||
:disabled="dialogType === 'edit'"
|
||||
clearable
|
||||
style="flex: 1;"
|
||||
/>
|
||||
<ElButton v-if="dialogType === 'add'" @click="handleGeneratePackageCode">
|
||||
生成编码
|
||||
</ElButton>
|
||||
</div>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="套餐名称" prop="package_name">
|
||||
<ElInput v-model="form.package_name" placeholder="请输入套餐名称" clearable />
|
||||
@@ -165,7 +171,7 @@
|
||||
<script setup lang="ts">
|
||||
import { h } from 'vue'
|
||||
import { PackageManageService, PackageSeriesService } from '@/api/modules'
|
||||
import { ElMessage, ElMessageBox, ElTag, ElSwitch } from 'element-plus'
|
||||
import { ElMessage, ElMessageBox, ElTag, ElSwitch, ElButton } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import type { PackageResponse, SeriesSelectOption } from '@/types/api'
|
||||
import type { SearchFormItem } from '@/types'
|
||||
@@ -186,6 +192,7 @@
|
||||
getDataTypeTag,
|
||||
getShelfStatusText
|
||||
} from '@/config/constants'
|
||||
import { generatePackageCode } from '@/utils/codeGenerator'
|
||||
|
||||
defineOptions({ name: 'PackageList' })
|
||||
|
||||
@@ -651,6 +658,12 @@
|
||||
})
|
||||
}
|
||||
|
||||
// 生成套餐编码
|
||||
const handleGeneratePackageCode = () => {
|
||||
form.package_code = generatePackageCode()
|
||||
ElMessage.success('编码生成成功')
|
||||
}
|
||||
|
||||
// 处理弹窗关闭事件
|
||||
const handleDialogClosed = () => {
|
||||
// 清除表单验证状态
|
||||
|
||||
@@ -49,12 +49,18 @@
|
||||
>
|
||||
<ElForm ref="formRef" :model="form" :rules="rules" label-width="120px">
|
||||
<ElFormItem label="系列编码" prop="series_code">
|
||||
<ElInput
|
||||
v-model="form.series_code"
|
||||
placeholder="请输入系列编码"
|
||||
:disabled="dialogType === 'edit'"
|
||||
clearable
|
||||
/>
|
||||
<div style="display: flex; gap: 8px;">
|
||||
<ElInput
|
||||
v-model="form.series_code"
|
||||
placeholder="请输入系列编码或点击生成"
|
||||
:disabled="dialogType === 'edit'"
|
||||
clearable
|
||||
style="flex: 1;"
|
||||
/>
|
||||
<ElButton v-if="dialogType === 'add'" @click="handleGenerateSeriesCode">
|
||||
生成编码
|
||||
</ElButton>
|
||||
</div>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="系列名称" prop="series_name">
|
||||
<ElInput v-model="form.series_name" placeholder="请输入系列名称" clearable />
|
||||
@@ -87,7 +93,7 @@
|
||||
<script setup lang="ts">
|
||||
import { h } from 'vue'
|
||||
import { PackageSeriesService } from '@/api/modules'
|
||||
import { ElMessage, ElMessageBox, ElTag, ElSwitch } from 'element-plus'
|
||||
import { ElMessage, ElMessageBox, ElTag, ElSwitch, ElButton } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import type { PackageSeriesResponse } from '@/types/api'
|
||||
import type { SearchFormItem } from '@/types'
|
||||
@@ -100,6 +106,7 @@
|
||||
frontendStatusToApi,
|
||||
apiStatusToFrontend
|
||||
} from '@/config/constants'
|
||||
import { generateSeriesCode } from '@/utils/codeGenerator'
|
||||
|
||||
defineOptions({ name: 'PackageSeries' })
|
||||
|
||||
@@ -338,6 +345,12 @@
|
||||
})
|
||||
}
|
||||
|
||||
// 生成系列编码
|
||||
const handleGenerateSeriesCode = () => {
|
||||
form.series_code = generateSeriesCode()
|
||||
ElMessage.success('编码生成成功')
|
||||
}
|
||||
|
||||
// 删除套餐系列
|
||||
const deleteSeries = (row: PackageSeriesResponse) => {
|
||||
ElMessageBox.confirm(`确定删除套餐系列 ${row.series_name} 吗?`, '删除确认', {
|
||||
|
||||
Reference in New Issue
Block a user