feat: saveProductAttributes传递categoryId以便自动计算公式属性
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Agent
2026-03-30 15:00:36 +00:00
parent 0300dfa34b
commit e1a6ec7490
2 changed files with 4 additions and 4 deletions

View File

@@ -124,13 +124,13 @@ export default {
/**
* 保存商品的属性值
*/
saveProductAttributes(productId, attrs) {
saveProductAttributes(productId, categoryId, attrs) {
const token = uni.getStorageSync('token')
return new Promise((resolve, reject) => {
uni.request({
url: `${import.meta.env.VITE_API_BASE_URL}/products/${productId}/attributes`,
method: 'POST',
data: attrs,
data: { categoryId: categoryId, attributes: attrs },
header: {
'Content-Type': 'application/json',
'Authorization': token ? `Bearer ${token}` : ''

View File

@@ -253,7 +253,7 @@ export default {
uni.showToast({ title: '创建成功', icon: 'success' })
}
// 保存商品属性值
// 保存商品属性值(包含公式自动计算)
if (productId && this.categoryAttributes.length > 0) {
const attrs = this.categoryAttributes.map((attr, idx) => ({
attrId: attr.attrId,
@@ -262,7 +262,7 @@ export default {
})).filter(a => a.attrValue)
if (attrs.length > 0) {
await productApi.saveProductAttributes(productId, attrs)
await productApi.saveProductAttributes(productId, this.form.categoryId, attrs)
}
}