@@ -53,144 +198,3 @@
-
-
diff --git a/apps/web-ele/src/views/mall/product/spu/components/product-property-add-form.vue b/apps/web-ele/src/views/mall/product/spu/components/product-property-add-form.vue
index e74826645..48189d5c3 100644
--- a/apps/web-ele/src/views/mall/product/spu/components/product-property-add-form.vue
+++ b/apps/web-ele/src/views/mall/product/spu/components/product-property-add-form.vue
@@ -1,26 +1,25 @@
-
+
+
+
+
+
+
+
+
+
+
+ {{ row.properties?.[index]?.valueName }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 批量添加
+
+
+删除
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ row.properties?.[index]?.valueName }}
+
+
+
+
+
+
+ {{ row.barCode }}
+
+
+
+
+ {{ formatToFraction(row.price) }}
+
+
+
+
+ {{ formatToFraction(row.marketPrice) }}
+
+
+
+
+ {{ formatToFraction(row.costPrice) }}
+
+
+
+
+ {{ row.stock }}
+
+
+
+
+
+.includes(propertyId!)) {
+ skuPropertyIds.push(propertyId!);
+ }
+ }),
+ );
+ const propertyIds = propertyList.map((item) => item.id);
+ return skuPropertyIds.length === propertyIds.length;
+};
+
+/** 构建所有排列组合 */
+const build = (
+ propertyValuesList: MallSpuApi.Property[][],
+): MallSpuApi.Property[] | MallSpuApi.Property[][] => {
+ if (!propertyValuesList || propertyValuesList.length === 0) {
+ return [];
+ } else if (propertyValuesList.length === 1) {
+ return propertyValuesList[0] || [];
+ } else {
+ const result: MallSpuApi.Property[][] = [];
+ const rest = build(propertyValuesList.slice(1));
+ if (propertyValuesList[0] && Array.isArray(rest)) {
+ for (let i = 0; i < propertyValuesList[0].length; i++) {
+ for (const restItem of rest) {
+ const currentItem = propertyValuesList[0][i];
+ // 第一次不是数组结构,后面的都是数组结构
+ if (Array.isArray(restItem)) {
+ result.push([currentItem!, ...restItem]);
+ } else if (restItem) {
+ // 确保restItem不是undefined,并进行类型断言
+ result.push([currentItem!, restItem as MallSpuApi.Property]);
+ }
+ }
+ }
+ }
+ return result;
+ }
+};
+
+/** 监听属性列表,生成相关参数和表头 */
+watch(
+ () => props.propertyList,
+ (propertyList: PropertyAndValues[]) => {
+ // 如果不是多规格则结束
+ if (!formData.value!.specType) {
+ return;
+ }
+ // 如果当前组件作为批量添加数据使用,则重置表数据
+ if (props.isBatch) {
+ skuList.value = [
+ {
+ price: 0,
+ marketPrice: 0,
+ costPrice: 0,
+ barCode: '',
+ picUrl: '',
+ stock: 0,
+ weight: 0,
+ volume: 0,
+ firstBrokeragePrice: 0,
+ secondBrokeragePrice: 0,
+ },
+ ];
+ }
+
+ // 判断代理对象是否为空
+ if (JSON.stringify(propertyList) === '[]') {
+ return;
+ }
+ // 重置表头
+ tableHeaders.value = [];
+ // 生成表头
+ propertyList.forEach((item, index) => {
+ // name加属性项index区分属性值
+ tableHeaders.value.push({ prop: `name${index}`, label: item.name });
+ });
+ // 如果回显的 sku 属性和添加的属性一致则不处理
+ if (validateData(propertyList)) {
+ return;
+ }
+ // 添加新属性没有属性值也不做处理
+ if (propertyList.some((item) => !item.values || isEmpty(item.values))) {
+ return;
+ }
+ // 生成 table 数据,即 sku 列表
+ generateTableData(propertyList);
+ },
+ {
+ deep: true,
+ immediate: true,
+ },
+);
+const activitySkuListRef = ref>();
+
+const getSkuTableRef = () => {
+ return activitySkuListRef.value;
+};
+// 暴露出生成 sku 方法,给添加属性成功时调用
+defineExpose({ generateTableData, validateSku, getSkuTableRef });
+
+
+
+
-
+
-
-
+
-
diff --git a/apps/web-ele/src/views/mall/product/spu/modules/form.vue b/apps/web-ele/src/views/mall/product/spu/modules/form.vue
index a1619905a..38871d39e 100644
--- a/apps/web-ele/src/views/mall/product/spu/modules/form.vue
+++ b/apps/web-ele/src/views/mall/product/spu/modules/form.vue
@@ -1,16 +1,19 @@