File tree Expand file tree Collapse file tree 1 file changed +25
-3
lines changed
src/views/mall/product/management/components/SkuList Expand file tree Collapse file tree 1 file changed +25
-3
lines changed Original file line number Diff line number Diff line change 68
68
</template >
69
69
<el-table-column v-if =" formData.specType" align =" center" fixed =" right" label =" 操作" width =" 80" >
70
70
<template #default >
71
- <el-button v-if =" isBatch" link size =" small" type =" primary" >批量添加</el-button >
71
+ <el-button v-if =" isBatch" link size =" small" type =" primary" @click =" batchAdd"
72
+ >批量添加
73
+ </el-button >
72
74
<el-button v-else link size =" small" type =" primary" >删除</el-button >
73
75
</template >
74
76
</el-table-column >
@@ -81,6 +83,7 @@ import { PropType } from 'vue'
81
83
import { SpuType } from ' @/api/mall/product/management/type/spuType'
82
84
import { propTypes } from ' @/utils/propTypes'
83
85
import { SkuType } from ' @/api/mall/product/management/type/skuType'
86
+ import { copyValueToTarget } from ' @/utils/object'
84
87
85
88
const props = defineProps ({
86
89
propFormData: {
@@ -131,6 +134,12 @@ const SkuData = ref<SkuType[]>([
131
134
volume: 0
132
135
}
133
136
])
137
+ /** 批量添加 */
138
+ const batchAdd = () => {
139
+ formData .value .skus .forEach ((item ) => {
140
+ copyValueToTarget (item , SkuData .value [0 ])
141
+ })
142
+ }
134
143
const tableHeaderList = ref <{ prop: string ; label: string }[]>([])
135
144
/**
136
145
* 将传进来的值赋值给SkuData
@@ -209,8 +218,21 @@ watch(
209
218
(data ) => {
210
219
// 如果不是多规格则结束
211
220
if (! formData .value .specType ) return
212
- // 如果当前组件作为批量添加数据使用则结束
213
- if (props .isBatch ) return
221
+ // 如果当前组件作为批量添加数据使用则重置表数据
222
+ if (props .isBatch ) {
223
+ SkuData .value = [
224
+ {
225
+ price: 0 ,
226
+ marketPrice: 0 ,
227
+ costPrice: 0 ,
228
+ barCode: ' ' ,
229
+ picUrl: ' ' ,
230
+ stock: 0 ,
231
+ weight: 0 ,
232
+ volume: 0
233
+ }
234
+ ]
235
+ }
214
236
// 判断代理对象是否为空
215
237
if (JSON .stringify (data ) === ' []' ) return
216
238
// 重置表头
You can’t perform that action at this time.
0 commit comments