diff --git a/src/api/bst/goods.js b/src/api/bst/goods.js
index 788fdce..0b7a33b 100644
--- a/src/api/bst/goods.js
+++ b/src/api/bst/goods.js
@@ -44,9 +44,9 @@ export function delGoods(id) {
}
// 商品上架/下架
-export function changeStatus(data) {
+export function changeStatusAndSort(data) {
return request({
- url: '/bst/goods/changeStatus',
+ url: '/bst/goods/changeStatusAndSort',
method: 'put',
data: data
})
diff --git a/src/views/bst/goods/components/bf.vue b/src/views/bst/goods/components/bf.vue
index 46d84be..3ee7f3a 100644
--- a/src/views/bst/goods/components/bf.vue
+++ b/src/views/bst/goods/components/bf.vue
@@ -199,7 +199,7 @@
type="primary"
size="small"
@click="applyBatchSetting"
- :disabled="!batchField || !batchValue || selectedSkuRows.length === 0"
+ :disabled="isReadOnly || !batchField || !batchValue || selectedSkuRows.length === 0"
>
应用设置
@@ -210,8 +210,12 @@
-
@@ -449,6 +453,9 @@ export default {
});
this.$message.success(`已批量设置${this.selectedSkuRows.length}个值`);
+ this.selectedSkuRows = [];
+ this.batchValue = '';
+ this.$refs.skuTable.clearSelection();
},
getList() {
this.loading = true;
@@ -627,8 +634,7 @@ export default {
// 失败时使用时间戳作为后备方案
return Date.now().toString();
}
- },
- generateSKU() {
+ },generateSKU() {
// 获取当前所有有效的规格值ID
const currentValueIds = new Set();
this.form.specs.forEach(spec => {
@@ -654,17 +660,15 @@ export default {
const validSpecValues = (sku.specValues || sku.specs || []).filter(id =>
currentValueIds.has(id)
);
- const specKey = [...validSpecValues].sort().join('##');
+ const specKey = validSpecValues.join('##');
validSkuMap.set(specKey, sku);
});
- // 创建新的SKU列表
+ // 创建新的SKU列表(不使用排序)
this.form.skuList = combinations.map(comb => {
- // 提取并排序组合中的规格值ID
- const sortedValueIds = comb
- .map(item => item.id)
- .sort();
- const specKey = sortedValueIds.join('##');
+ // 提取组合中的规格值ID(保持原始顺序)
+ const specIds = comb.map(item => item.id);
+ const specKey = specIds.join('##');
// 从映射表中获取对应的SKU
const matchedSku = validSkuMap.get(specKey);
@@ -673,28 +677,29 @@ export default {
// 保留原有SKU(含ID、价格、库存等数据)
return {
...matchedSku,
- // 更新规格值列表(避免包含无效ID)
- specs: sortedValueIds,
- specValues: sortedValueIds
+ specs: specIds,
+ specValues: specIds
};
} else {
// 新建SKU
return {
id: undefined, // 新SKU的ID将由后端生成
- specs: sortedValueIds,
- specValues: sortedValueIds,
+ specs: specIds,
+ specValues: specIds,
price: 0,
stock: "0",
image: ''
};
}
});
+
+ // 使用原始顺序更新选中的行
const oldSelectedIds = this.selectedSkuRows.map(row =>
- row.specs ? row.specs.sort().join('##') : ''
+ row.specs ? row.specs.join('##') : ''
);
this.selectedSkuRows = this.form.skuList.filter(row => {
- const rowKey = row.specs ? row.specs.sort().join('##') : '';
+ const rowKey = row.specs ? row.specs.join('##') : '';
return oldSelectedIds.includes(rowKey);
});
},
diff --git a/src/views/bst/goods/index.vue b/src/views/bst/goods/index.vue
index 272417b..ffb8ac9 100644
--- a/src/views/bst/goods/index.vue
+++ b/src/views/bst/goods/index.vue
@@ -1,7 +1,19 @@
-
-
+
+
+
+
+
+ {{ d.row.sort }}
+
+
+
+
@@ -135,7 +158,7 @@
size="mini"
type="text"
icon="el-icon-top"
- @click="handleUpdate(scope.row)"
+ @click="handleOnline(scope.row)"
v-has-permi="['bst:goods:edit']"
>上架
下架
+
+