Răsfoiți Sursa

feat: preserve pagination page when editing products

- ProductManage.vue: pass current page number when navigating to edit page
- ProductEdit.vue: read page from route query and redirect back with preserved page
- Fixes issue where editing a product on page 2 would redirect back to page 1 after save
Sisyphus 1 zi în urmă
părinte
comite
2bd344dc4c

+ 3 - 1
cfc-web/src/views/admin/ProductEdit.vue

@@ -1082,6 +1082,7 @@ async loadGiftRule(productId) {
           }
           if (res.code === 200) {
             // Save dimension weights
+            if (productId && Array.isArray(dimensionWeights)) {
             if (productId && Array.isArray(dimensionWeights)) {
               try {
                 await saveDimensionWeights('product', productId, dimensionWeights)
@@ -1148,7 +1149,8 @@ async loadGiftRule(productId) {
               }
             }
             this.$message.success(this.isEdit ? '保存成功' : '创建成功')
-            this.$router.push('/product-manage')
+            const page = this.$route.query.page || 1
+            this.$router.push(`/product-manage?page=${page}`)
           } else {
             this.$message.error(res.message || '操作失败')
           }

+ 1 - 1
cfc-web/src/views/admin/ProductManage.vue

@@ -194,7 +194,7 @@
           </el-table-column>
           <el-table-column label="操作" width="176" fixed="right" align="left">
             <template slot-scope="{ row }">
-              <el-button type="text" size="small" @click="$router.push('/product-edit?id=' + row.id)">编辑</el-button>
+              <el-button type="text" size="small" @click="$router.push('/product-edit?id=' + row.id + '&page=' + this.pagination.page)">编辑</el-button>
               <el-button type="text" size="small" @click="showInventoryDialog(row)">库存</el-button>
               <el-dropdown trigger="click" @command="(cmd) => handleActionCmd(row, cmd)">
                 <el-button type="text" size="small">