feat: saveProductAttributes传递categoryId以便自动计算公式属性
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -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}` : ''
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user