修复多规格商品添加时的子项添加
This commit is contained in:
1 parent
2aa950e5f4
commit
2977ef7d81
1 file changed
+9
-1
@@ -740,6 +740,7 @@ const getInfo = (id) => {
|
||||
const route = useRoute()
|
||||
// 立即生成
|
||||
const generate = () => {
|
||||
const previousRows = new Map(manyFormValidate.value.map((item) => [JSON.stringify(item.detail), item]));
|
||||
StoreProductApi.isFormatAttr(formValidate.value.id, { attrs: attrs.value }).then(res => {
|
||||
manyFormValidate.value = res.value;
|
||||
let headerdel = {
|
||||
@@ -759,6 +760,10 @@ const generate = () => {
|
||||
});
|
||||
oneFormBatch.value[0].pic = formValidate.value.image;
|
||||
}
|
||||
manyFormValidate.value = manyFormValidate.value.map((item) => ({
|
||||
...item,
|
||||
...(previousRows.get(JSON.stringify(item.detail)) || {})
|
||||
}));
|
||||
}).catch(res => {
|
||||
console.log('err:'+res)
|
||||
})
|
||||
@@ -818,12 +823,13 @@ const confirm = () => {
|
||||
// 删除规格
|
||||
const handleRemoveRole = (index) => {
|
||||
attrs.value.splice(index, 1);
|
||||
manyFormValidate.value.splice(index, 1);
|
||||
if (manyFormValidate.value.length) generate();
|
||||
}
|
||||
|
||||
// 删除属性
|
||||
const handleRemove2 = (item, index) => {
|
||||
item.splice(index, 1);
|
||||
if (manyFormValidate.value.length) generate();
|
||||
}
|
||||
|
||||
// 添加规则名称
|
||||
@@ -844,6 +850,7 @@ const createAttrName = () =>{
|
||||
clearAttr();
|
||||
showIput.value = false;
|
||||
createBnt.value = true;
|
||||
if (manyFormValidate.value.length) generate();
|
||||
} else {
|
||||
message.warning('请添加完整的规格!')
|
||||
}
|
||||
@@ -857,6 +864,7 @@ const createAttr = (num, idx) => {
|
||||
hash[next] ? '' : hash[next] = true && item.push(next);
|
||||
return item
|
||||
}, [])
|
||||
if (manyFormValidate.value.length) generate();
|
||||
} else {
|
||||
message.warning('请添加属性!')
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user