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 () => {
|
||||
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),
|
||||
|
Loading…
x
Reference in New Issue
Block a user