Browse Source

一键复制商品.

zhangfufeng 1 month ago
parent
commit
8ad7cca0f3
2 changed files with 48 additions and 2 deletions
  1. 8 0
      src/api/goods.js
  2. 40 2
      src/views/goods/list.vue

+ 8 - 0
src/api/goods.js

@@ -360,3 +360,11 @@ export function deleteGoodsProduct(data) {
         params: data
     })
 }
+
+export function onclickCopy(data) {
+  return request({
+    url: '/goods/onclickCopy',
+    method: 'get',
+    params: data
+  })
+}

+ 40 - 2
src/views/goods/list.vue

@@ -374,6 +374,12 @@
             @click="handleChannelCode(scope.row)"
             >生成渠道码</el-button
           >
+          <el-button
+            type="primary"
+            size="mini"
+            v-permission="['GET /admin/goods/onclickCopy']"
+            @click="onclickCopy(scope.row)"
+          >一键复制商品</el-button>
 
           <!-- <el-button type="success" size="mini" @click="handleFee(scope.row)">商品计提</el-button>
           <el-button type="info" size="mini" @click="handleNoServiceTimeRange(scope.row)">不可约设定</el-button>-->
@@ -550,7 +556,7 @@ import {
   onsale,
   sync2Douyin,
   dyUrl,
-  goodsChannelQrCode
+  goodsChannelQrCode, onclickCopy
 } from "@/api/goods";
 import { listCatL1 } from "@/api/category";
 import BackToTop from "@/components/BackToTop";
@@ -987,7 +993,39 @@ export default {
           this.changeChanneldialog = false;
           this.orderInputForm = {};
         });
-    }
+    },
+    //一键复制商品
+    onclickCopy(val) {
+      console.log("商品信息:", val);
+      this.$confirm("确认复制吗?", "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      })
+        .then(() => {
+          onclickCopy({
+            goodsId:val.id
+          }).then(res => {
+            if (res.data.errno == 0) {
+              this.$message({
+                type: "success",
+                message: "新商品创建成功"
+              });
+              this.$router.push({ path: '/goods/edit?id='+res.data.data });
+            } else {
+              this.$message({
+                type: "info",
+                message: res.data.errmsg
+              });
+            }
+          });
+        }).catch(() => {
+          this.$message({
+            type: "info",
+            message: "新商品创建失败"
+          });
+        });
+    },
   }
 };
 </script>