From 2977ef7d81fd061073f09dac4e79429d11b18938 Mon Sep 17 00:00:00 2001 From: Kroytz Date: Sat, 18 Jul 2026 22:40:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=A4=9A=E8=A7=84=E6=A0=BC?= =?UTF-8?q?=E5=95=86=E5=93=81=E6=B7=BB=E5=8A=A0=E6=97=B6=E7=9A=84=E5=AD=90?= =?UTF-8?q?=E9=A1=B9=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mall/product/storeProduct/StoreProductForm.vue | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/yshop-drink-vue3/src/views/mall/product/storeProduct/StoreProductForm.vue b/yshop-drink-vue3/src/views/mall/product/storeProduct/StoreProductForm.vue index 513dd3e..2224f52 100644 --- a/yshop-drink-vue3/src/views/mall/product/storeProduct/StoreProductForm.vue +++ b/yshop-drink-vue3/src/views/mall/product/storeProduct/StoreProductForm.vue @@ -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('请添加属性!') }