22 <!-- 情况一:添加/修改 -->
33 <el-table
44 v-if =" !isDetail && !isActivityComponent"
5- :data =" isBatch ? skuList : formData!.skus"
5+ :data =" isBatch ? skuList : formData!.skus! "
66 border
77 class =" tabNumWidth"
88 max-height =" 500"
113113 <!-- 情况二:详情 -->
114114 <el-table
115115 v-if =" isDetail"
116- :data =" formData!.skus"
116+ ref =" activitySkuListRef"
117+ :data =" formData!.skus!"
117118 border
118119 max-height =" 500"
119120 size =" small"
194195 <!-- 情况三:作为活动组件 -->
195196 <el-table
196197 v-if =" isActivityComponent"
197- :data =" formData!.skus"
198+ :data =" formData!.skus! "
198199 border
199200 max-height =" 500"
200201 size =" small"
@@ -259,7 +260,8 @@ import { UploadImg } from '@/components/UploadFile'
259260import type { Property , Sku , Spu } from ' @/api/mall/product/spu'
260261import { createImageViewer } from ' @/components/ImageViewer'
261262import { RuleConfig } from ' @/views/mall/product/spu/components/index'
262- import { Properties } from ' ./index'
263+ import { PropertyAndValues } from ' ./index'
264+ import { ElTable } from ' element-plus'
263265
264266defineOptions ({ name: ' SkuList' })
265267const message = useMessage () // 消息弹窗
@@ -270,7 +272,7 @@ const props = defineProps({
270272 default : () => {}
271273 },
272274 propertyList: {
273- type: Array as PropType <Properties []>,
275+ type: Array as PropType <PropertyAndValues []>,
274276 default : () => []
275277 },
276278 ruleConfig: {
@@ -480,7 +482,7 @@ const build = (propertyValuesList: Property[][]) => {
480482/** 监听属性列表,生成相关参数和表头 */
481483watch (
482484 () => props .propertyList ,
483- (propertyList : Properties []) => {
485+ (propertyList : PropertyAndValues []) => {
484486 // 如果不是多规格则结束
485487 if (! formData .value ! .specType ) {
486488 return
@@ -514,7 +516,6 @@ watch(
514516 // name加属性项index区分属性值
515517 tableHeaders .value .push ({ prop: ` name${index } ` , label: item .name })
516518 })
517-
518519 // 如果回显的 sku 属性和添加的属性一致则不处理
519520 if (validateData (propertyList )) {
520521 return
@@ -531,6 +532,10 @@ watch(
531532 immediate: true
532533 }
533534)
535+ const activitySkuListRef = ref <InstanceType <typeof ElTable >>()
536+ const clearSelection = () => {
537+ activitySkuListRef .value .clearSelection ()
538+ }
534539// 暴露出生成 sku 方法,给添加属性成功时调用
535- defineExpose ({ generateTableData , validateSku })
540+ defineExpose ({ generateTableData , validateSku , clearSelection })
536541 </script >
0 commit comments