mirror of
https://github.com/woodchen-ink/aimodels-prices.git
synced 2025-07-18 05:32:00 +08:00
修复价格管理中的 channel_type 类型转换问题
- 在提交价格表单时,将 channel_type 显式转换为数字类型 - 确保批量添加价格和单个价格提交时 channel_type 正确处理 - 修复可能由于类型不匹配导致的数据提交错误
This commit is contained in:
parent
37ded8ffae
commit
e037eaafef
@ -697,10 +697,17 @@ const handleQuickEdit = (row) => {
|
|||||||
const submitForm = async () => {
|
const submitForm = async () => {
|
||||||
try {
|
try {
|
||||||
form.value.created_by = props.user.username
|
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
|
let response
|
||||||
if (editingPrice.value) {
|
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 {
|
} else {
|
||||||
// 检查模型是否已存在
|
// 检查模型是否已存在
|
||||||
const existingPrice = prices.value?.find(p =>
|
const existingPrice = prices.value?.find(p =>
|
||||||
@ -717,7 +724,7 @@ const submitForm = async () => {
|
|||||||
type: 'warning',
|
type: 'warning',
|
||||||
}
|
}
|
||||||
).then(async () => {
|
).then(async () => {
|
||||||
response = await axios.put(`/api/prices/${existingPrice.id}`, form.value)
|
response = await axios.put(`/api/prices/${existingPrice.id}`, formToSubmit)
|
||||||
handleSubmitResponse(response)
|
handleSubmitResponse(response)
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
// 用户取消更新
|
// 用户取消更新
|
||||||
@ -725,7 +732,7 @@ const submitForm = async () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 创建新价格
|
// 创建新价格
|
||||||
response = await axios.post('/api/prices', form.value)
|
response = await axios.post('/api/prices', formToSubmit)
|
||||||
}
|
}
|
||||||
handleSubmitResponse(response)
|
handleSubmitResponse(response)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -896,7 +903,12 @@ const submitBatchForms = async () => {
|
|||||||
try {
|
try {
|
||||||
// 逐个提交数据
|
// 逐个提交数据
|
||||||
for (const form of batchForms.value) {
|
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()
|
await loadPrices()
|
||||||
@ -961,7 +973,7 @@ const handleImport = () => {
|
|||||||
return {
|
return {
|
||||||
model,
|
model,
|
||||||
billing_type,
|
billing_type,
|
||||||
channel_type: provider.id.toString(),
|
channel_type: parseInt(provider.id, 10), // 确保是数字类型
|
||||||
currency: currencyCode,
|
currency: currencyCode,
|
||||||
input_price: parseFloat(inputPrice),
|
input_price: parseFloat(inputPrice),
|
||||||
output_price: parseFloat(outputPrice),
|
output_price: parseFloat(outputPrice),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user