From cb45ea07537ed867745ad8d73944abf3129af924 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Sun, 30 Apr 2023 17:28:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E7=AE=A1=E7=90=86:=20?= =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=95=86=E5=93=81=E5=B1=9E=E6=80=A7=E6=89=B9?= =?UTF-8?q?=E9=87=8F=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 64f6f67ddd12396d544d2c57f1e1750e22eba425) --- .../management/components/SkuList/index.vue | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/views/mall/product/management/components/SkuList/index.vue b/src/views/mall/product/management/components/SkuList/index.vue index 4018d740..b46e02d0 100644 --- a/src/views/mall/product/management/components/SkuList/index.vue +++ b/src/views/mall/product/management/components/SkuList/index.vue @@ -68,7 +68,9 @@ @@ -81,6 +83,7 @@ import { PropType } from 'vue' import { SpuType } from '@/api/mall/product/management/type/spuType' import { propTypes } from '@/utils/propTypes' import { SkuType } from '@/api/mall/product/management/type/skuType' +import { copyValueToTarget } from '@/utils/object' const props = defineProps({ propFormData: { @@ -131,6 +134,12 @@ const SkuData = ref([ volume: 0 } ]) +/** 批量添加 */ +const batchAdd = () => { + formData.value.skus.forEach((item) => { + copyValueToTarget(item, SkuData.value[0]) + }) +} const tableHeaderList = ref<{ prop: string; label: string }[]>([]) /** * 将传进来的值赋值给SkuData @@ -209,8 +218,21 @@ watch( (data) => { // 如果不是多规格则结束 if (!formData.value.specType) return - // 如果当前组件作为批量添加数据使用则结束 - if (props.isBatch) return + // 如果当前组件作为批量添加数据使用则重置表数据 + if (props.isBatch) { + SkuData.value = [ + { + price: 0, + marketPrice: 0, + costPrice: 0, + barCode: '', + picUrl: '', + stock: 0, + weight: 0, + volume: 0 + } + ] + } // 判断代理对象是否为空 if (JSON.stringify(data) === '[]') return // 重置表头