修复价格管理中的 channel_type 类型转换问题

- 在提交价格表单时,将 channel_type 显式转换为数字类型
- 确保批量添加价格和单个价格提交时 channel_type 正确处理
- 修复可能由于类型不匹配导致的数据提交错误
This commit is contained in:
wood chen 2025-03-12 15:50:00 +08:00
parent 37ded8ffae
commit e037eaafef

View File

@ -697,10 +697,17 @@ const handleQuickEdit = (row) => {
const submitForm = async () => {
try {
form.value.created_by = props.user.username
// channel_type
const formToSubmit = { ...form.value }
if (formToSubmit.channel_type) {
formToSubmit.channel_type = parseInt(formToSubmit.channel_type, 10)
}
let response
if (editingPrice.value) {
//
response = await axios.put(`/api/prices/${editingPrice.value.id}`, form.value)
response = await axios.put(`/api/prices/${editingPrice.value.id}`, formToSubmit)
} else {
//
const existingPrice = prices.value?.find(p =>
@ -717,7 +724,7 @@ const submitForm = async () => {
type: 'warning',
}
).then(async () => {
response = await axios.put(`/api/prices/${existingPrice.id}`, form.value)
response = await axios.put(`/api/prices/${existingPrice.id}`, formToSubmit)
handleSubmitResponse(response)
}).catch(() => {
//
@ -725,7 +732,7 @@ const submitForm = async () => {
return
}
//
response = await axios.post('/api/prices', form.value)
response = await axios.post('/api/prices', formToSubmit)
}
handleSubmitResponse(response)
} catch (error) {
@ -896,7 +903,12 @@ const submitBatchForms = async () => {
try {
//
for (const form of batchForms.value) {
await axios.post('/api/prices', form)
// channel_type
const formToSubmit = { ...form }
if (formToSubmit.channel_type) {
formToSubmit.channel_type = parseInt(formToSubmit.channel_type, 10)
}
await axios.post('/api/prices', formToSubmit)
}
await loadPrices()
@ -961,7 +973,7 @@ const handleImport = () => {
return {
model,
billing_type,
channel_type: provider.id.toString(),
channel_type: parseInt(provider.id, 10), //
currency: currencyCode,
input_price: parseFloat(inputPrice),
output_price: parseFloat(outputPrice),