zhaolf пре 3 година
родитељ
комит
d3ed53ab1c
1 измењених фајлова са 44 додато и 1 уклоњено
  1. 44 1
      src/pages/goods/index.vue

+ 44 - 1
src/pages/goods/index.vue

@@ -20,6 +20,7 @@
           <el-button type="text" @click="toEdit(slotData.data.row)" v-if="searchForm.type!='3'">
             {{searchForm.type=='1'?'下架':'上架'}}</el-button>
           <el-button type="text" @click="toView(slotData.data.row)">查看</el-button>
+          <el-button type="text" @click="copy(slotData.data.row)">复制</el-button>
         </div>
       </template>
     </e-table>
@@ -31,7 +32,9 @@
   import {
     list,
     changeStatus,
-    getCountByType
+    getCountByType,
+    detail,
+    authDetail
   } from '@/api/goods'
   import store from '@/store/index'
   export default {
@@ -145,6 +148,46 @@
         this.searchForm.page = 1
         this.getPageList()
       },
+      copy(row) {
+        if(this.searchForm.type==1 || this.searchForm.type==2){
+          detail({outProductId: row.out_product_id}).then(res => {
+            this.copyToAdd(res)
+          })
+        }else{
+          authDetail({outProductId: row.out_product_id}).then(res => {
+            this.copyToAdd(res)
+          })
+        }
+      },
+      copyToAdd(res) {
+        let params = {}
+            params.commodity_id = res.data.commodity_id
+            params.title = res.data.title
+            params.out_product_id = res.data?.auditInfo?.out_product_id
+            params.brand_id=res.data.has_brand==0?'-1':res.data.has_brand
+            params.third=res.data.third_cat_audit==0?res.data.third_cat_id:''
+            params.stock_num = res.data.stock_num
+            params.sale_price = res.data.sale_price
+            params.market_price = res.data.market_price
+            params.path = res.data.path
+            params.third_cat_id =res.data.third_cat_audit==0?'-1':res.data.third_cat_id
+            params.goodsList = [{url: res.data.thumb_img}]
+            params.goodszizhiList = []
+            if (res.data.qualificationImgs.length > 0) {
+                  res.data.qualificationImgs.forEach(element => {
+                    params.goodszizhiList.push({
+                      url: element
+                      })
+                  });
+            }
+            this.$router.push({
+            name: "addGoods",
+            params: {
+              isNew: true,
+              data:JSON.stringify(params)
+            }
+        });
+      },
       toView(row) {
         this.$router.push({
           name: "goodsDetail",