潘超林 4 月之前
父节点
当前提交
9cc45c312a

+ 27 - 0
src/api/manage/product.js

@@ -57,4 +57,31 @@ export function getGoodsDraftByUserId(query) {
         method: 'post',
         data: query
     })
+}
+
+
+export function deleteGoodsDraft(query) {
+    return request({
+        url: '/system/goods/deleteGoodsDraft',
+        method: 'post',
+        data: query
+    })
+}
+
+
+export function getGoodsDraftById(query) {
+    return request({
+        url: '/system/goods/getGoodsDraftById',
+        method: 'post',
+        data: query
+    })
+}
+
+
+export function updateGoods(query) {
+    return request({
+        url: '/system/goods/updateGoods',
+        method: 'post',
+        data: query
+    })
 }

+ 1 - 1
src/views/manage/active.vue

@@ -347,7 +347,7 @@
 
 <script>
 import { promotionList, promotionSku, spuList, spuRemove } from "@/api/active/index";
-import productList from "../product/index.vue";
+import productList from "../product/list/allProduct.vue";
 import moment from "moment";
 export default {
   components: { productList },

+ 5 - 2
src/views/product/createProduct.vue

@@ -245,6 +245,7 @@ export default {
       });
     },
     submitForm() {
+      console.log(this.form);
       if (this.form.scope === "") {
         this.$message.error(`经营区域不能为空!`);
         return;
@@ -287,6 +288,10 @@ export default {
           return;
         }
       }
+
+      if (this.form.bannerList?.length > 0) {
+        this.form.bannerList.shift();
+      }
       publishGoods(this.form).then((res) => {
         if (res.code == 200) {
           this.$message.success(`发布成功!`);
@@ -298,7 +303,6 @@ export default {
     updateValue(val) {
       console.log(val);
       this.form = { ...this.form, ...val };
-
       this.headerImg = [];
       if (val.vid || this.form.vid) {
         this.headerImg.push({
@@ -308,7 +312,6 @@ export default {
         });
       }
       if (this.form?.bannerList && this.form?.bannerList.length > 0) {
-        this.form.bannerList.shift();
         this.form.bannerList.forEach((e, index) => {
           this.headerImg.push({
             type: "img",

+ 175 - 116
src/views/product/list/allProduct.vue

@@ -59,15 +59,23 @@
             >发布商品</el-button
           >
         </el-col>
-        <el-dropdown>
+        <el-col :span="1.5">
+          <el-button type="primary" plain size="mini" @click="handleExportAll"
+            >导出全部</el-button
+          >
+        </el-col>
+
+        <el-dropdown :hide-on-click="false" trigger="click">
           <el-button type="primary" plain size="mini">
             更多批量操作<i class="el-icon-arrow-down el-icon--right"></i>
           </el-button>
           <el-dropdown-menu slot="dropdown">
-            <el-dropdown-item style="color: red">批量删除</el-dropdown-item>
-            <el-dropdown-item>批量加入活动</el-dropdown-item>
-            <el-dropdown-item>批量导出</el-dropdown-item>
-            <el-dropdown-item>批量下架</el-dropdown-item>
+            <el-dropdown-item style="color: red" @click.native="BatchRemove"
+              >批量删除</el-dropdown-item
+            >
+            <el-dropdown-item @click.native="handleEvents">批量加入活动</el-dropdown-item>
+            <el-dropdown-item @click.native="handleExport">批量导出</el-dropdown-item>
+            <el-dropdown-item @click.native="handleDelist">批量下架</el-dropdown-item>
           </el-dropdown-menu>
         </el-dropdown>
       </template>
@@ -234,125 +242,43 @@
 
     <lookProduct ref="lookProductRefs"></lookProduct>
     <el-dialog
-      title="编辑"
+      title="活动列表"
       :visible.sync="dialogVisible"
-      width="60%"
       :before-close="dialogVisible == false"
     >
-      <el-table :data="dataTable.skuList" style="width: 100%; margin-top: 20px">
-        <el-table-column prop="name" label="规格名称" width="160">
-          <template slot-scope="scope">
-            <el-input
-              v-model="scope.row.skuSpecsList[0].specsName"
-              placeholder="请输入规格名称"
-              clearable
-              @input="passValue"
-            />
-          </template>
-        </el-table-column>
-        <el-table-column prop="address" label="规格内容" width="160">
-          <template slot-scope="scope">
-            <el-input
-              v-model="scope.row.skuSpecsList[0].specsValue"
-              placeholder="规格内容"
-              clearable
-              @input="passValue"
-            />
-          </template>
-        </el-table-column>
-        <el-table-column prop="name" label="库存" width="160">
-          <template slot-scope="scope">
-            <el-input
-              v-model="scope.row.stock"
-              placeholder="库存"
-              clearable
-              @input="passValue"
-            >
-              <template slot="suffix"> {{ unit }} </template>
-            </el-input>
-          </template>
-        </el-table-column>
-        <el-table-column prop="address" label="起批量" width="160">
-          <template slot-scope="scope">
-            <el-input
-              v-model="scope.row.minPurchase"
-              placeholder="起批量"
-              clearable
-              @input="passValue"
-            >
-              <template slot="suffix">
-                {{ unit }}
-              </template>
-            </el-input>
-          </template>
-        </el-table-column>
-        <el-table-column prop="address" label="收购价" width="160">
-          <template slot-scope="scope">
-            <el-input
-              v-model="scope.row.skuCost.purchaseFee"
-              placeholder="收购价"
-              clearable
-              @input="passValue"
-            >
-              <template slot="suffix"> {{ unit }}/元 </template>
-            </el-input>
-          </template>
-        </el-table-column>
-        <el-table-column prop="address" label="人工费" width="160">
-          <template slot-scope="scope">
-            <el-input
-              v-model="scope.row.skuCost.laborFee"
-              placeholder="人工费"
-              clearable
-              @input="passValue"
-            >
-              <template slot="suffix"> {{ unit }}/元 </template>
-            </el-input>
-          </template>
-        </el-table-column>
-        <el-table-column prop="address" label="代办费" width="160">
+      <el-table
+        :data="eventList"
+        row-key="id"
+        @current-change="eventsChange"
+        highlight-current-row
+      >
+        <el-table-column label width="45">
           <template slot-scope="scope">
-            <el-input
-              v-model="scope.row.skuCost.agencyFee"
-              placeholder="代办费"
-              clearable
-              @input="passValue"
-            >
-              <template slot="suffix"> {{ unit }}/元 </template>
-            </el-input>
+            <el-radio :label="scope.row.id" v-model="radioId"><span></span></el-radio>
           </template>
         </el-table-column>
-        <el-table-column prop="address" label="材料费" width="160">
+        <el-table-column prop="title" label="活动名称"> </el-table-column>
+        <el-table-column prop="intro" label="活动介绍"> </el-table-column>
+        <el-table-column prop="startTime" label="开始时间"> </el-table-column>
+        <el-table-column prop="endTime" label="结束时间"> </el-table-column>
+        <el-table-column prop="tag" label="是否使用代金券">
           <template slot-scope="scope">
-            <el-input
-              @input="passValue"
-              v-model="scope.row.skuCost.materialFee"
-              placeholder="材料费"
-              clearable
-            >
-              <template slot="suffix"> {{ unit }}/元 </template>
-            </el-input>
+            <el-tag>
+              {{ scope.row.useVoucher == 1 ? "是" : "否" }}
+            </el-tag>
           </template>
         </el-table-column>
-        <el-table-column prop="address" label="商品单价" width="80">
+        <el-table-column prop="tag" label="备注" width="160">
           <template slot-scope="scope">
-            {{ computePrice(scope.row) }}元/{{ unit }}
+            <el-tag>
+              {{ scope.row.tag == 1 ? "年货节" : "" }}
+            </el-tag>
           </template>
         </el-table-column>
-        <!-- <el-table-column prop="address" label="操作" width="160">
-            <template slot-scope="scope">
-              <el-button
-                type="text"
-                style="color: red"
-                @click="removeSpecification(scope, scope.$index)"
-                >删除</el-button
-              >
-            </template>
-          </el-table-column> -->
       </el-table>
       <span slot="footer" class="dialog-footer">
         <el-button @click="dialogVisible = false">取 消</el-button>
-        <el-button type="primary" @click="submitGg">确 定</el-button>
+        <el-button type="primary" @click="eventsSubmit">确 定</el-button>
       </span>
     </el-dialog>
   </div>
@@ -366,8 +292,11 @@ import {
   editGoods,
   goodsRemove,
 } from "@/api/manage/product";
+
+import { promotionList, promotionSku } from "@/api/active/index";
 import { getClassificationListPage } from "@/api/common/index";
 import lookProduct from "../lookProduct.vue";
+import { getStoreInfo } from "@/api/common/index";
 export default {
   components: { lookProduct },
   name: "product",
@@ -406,15 +335,60 @@ export default {
       dataTable: {},
       unit: "",
       skuId: "",
+      eventList: [],
+      radioId: "",
     };
   },
   mounted() {
     this.getList();
   },
   methods: {
+    eventsSubmit() {
+      let ids = [];
+      this.multipleSelection.forEach((e) => {
+        ids.push({
+          spuId: e.id,
+        });
+      });
+      let params = {
+        promotionId: this.radioId,
+        skuList: ids,
+        type: 1,
+      };
+      promotionSku(params).then((res) => {
+        if (res.code == 200) {
+          this.dialogVisible = false;
+          this.$message.success("添加成功!");
+          this.getList();
+        }
+      });
+    },
+    eventsChange(val) {
+      console.log(val);
+      this.radioId = val.id;
+    },
+    /**
+     * 批量加入活动
+     */
+    handleEvents() {
+      if (this.multipleSelection.length < 1) {
+        this.$message.error("请选择要参与活动的商品!");
+        return;
+      }
+      this.dialogVisible = true;
+      promotionList({
+        pageNo: 1,
+        pageSize: 10,
+      }).then((res) => {
+        if (res.code == 200) {
+          this.eventList = res.data.records;
+        }
+      });
+    },
     back() {
       this.toggle = true;
     },
+
     handleDelete(record) {
       this.$confirm("是否确认删除该商品?", "提示", {
         confirmButtonText: "确定",
@@ -423,7 +397,7 @@ export default {
       })
         .then(() => {
           goodsRemove({
-            spuId: record.id,
+            spuIds: record.id,
           }).then((res) => {
             if (res.code == 200) {
               this.$message.success(`删除成功!`);
@@ -446,10 +420,6 @@ export default {
         spuId: this.skuId,
         skuList: this.dataTable.skuList,
       };
-      // this.dataTable.skuList.forEach((e) => {
-      //   params.skuPriceList.push(e.skuPriceList[0]);
-      //   params.skuSpecsList.push(e.skuSpecsList[0]);
-      // });
       editGoods(params).then((res) => {
         if (res.code == 200) {
           this.$message.success("编辑成功");
@@ -474,6 +444,97 @@ export default {
     handleSelectionChange(val) {
       this.multipleSelection = val;
     },
+    handleDelist() {
+      if (this.multipleSelection.length < 1) {
+        this.$message.error("请选择要导出的商品!");
+        return;
+      }
+      let ids = [];
+      this.multipleSelection.forEach((e) => {
+        ids.push(e.id);
+      });
+      this.$confirm("是否批量下架商品?", "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      })
+        .then(() => {
+          GoodsUpOrDown({
+            spuId: ids.toString(),
+            spuStatus: 1,
+          }).then((res) => {
+            if (res.code == 200) {
+              this.$message.success(`操作成功!`);
+              this.getList();
+            }
+          });
+        })
+        .catch(() => {
+          this.$message({
+            type: "info",
+            message: "已取消操作",
+          });
+        });
+    },
+    handleExportAll() {
+      this.download(
+        "system/goods/export",
+        {
+          ...this.queryParams,
+        },
+        `商品信息_${new Date().getTime()}.xlsx`
+      );
+    },
+    handleExport() {
+      if (this.multipleSelection.length < 1) {
+        this.$message.error("请选择要导出的商品!");
+        return;
+      }
+      let ids = [];
+      this.multipleSelection.forEach((e) => {
+        ids.push(e.id);
+      });
+      this.queryParams.spuId = ids.toString();
+      this.download(
+        "system/goods/export",
+        {
+          ...this.queryParams,
+        },
+        `商品信息_${new Date().getTime()}.xlsx`
+      );
+    },
+    BatchRemove() {
+      console.log(this.multipleSelection);
+      if (this.multipleSelection.length < 1) {
+        this.$message.error("请选择要删除的商品!");
+        return;
+      }
+      let ids = [];
+      this.multipleSelection.forEach((e) => {
+        ids.push(e.id);
+      });
+      this.$confirm("是否确认批量删除商品?", "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      })
+        .then(() => {
+          goodsRemove({
+            spuIds: ids.toString(),
+          }).then((res) => {
+            if (res.code == 200) {
+              this.$message.success(`批量删除成功!`);
+              this.getList();
+            }
+          });
+        })
+        .catch(() => {
+          this.$message({
+            type: "info",
+            message: "已取消操作",
+          });
+        });
+    },
     /** 查询参数列表 */
     getList() {
       this.loading = true;
@@ -551,7 +612,6 @@ export default {
         }
       });
     },
-
     handleUpdate(record) {
       getGoodsInfo({ spuId: record.id }).then((res) => {
         if (res.code == 200) {
@@ -587,7 +647,6 @@ export default {
         }
       });
     },
-
     cascaderChange(val) {
       if (val.length == 1) {
         this.queryParams.categoryId = val[0];

+ 20 - 6
src/views/product/list/draftProduct.vue

@@ -66,6 +66,18 @@
           {{ scope.row.goodsDto.skuList[0].stock }}{{ scope.row.goodsDto.unit }}
         </template>
       </el-table-column>
+      <el-table-column label="经营区域" align="center">
+        <template slot-scope="scope">
+          {{
+            scope.row.goodsDto.scope == 0
+              ? "全国"
+              : scope.row.goodsDto.scope == 1
+              ? "同城"
+              : "特价"
+          }}
+        </template>
+      </el-table-column>
+
       <el-table-column label="销售模式" align="center">
         <template slot-scope="scope">
           {{
@@ -77,7 +89,7 @@
           }}
         </template>
       </el-table-column>
-      <el-table-column label="销售方式" align="center">
+      <!-- <el-table-column label="销售方式" align="center">
         <template slot-scope="scope">
           {{
             scope.row.goodsDto.saleType == 0
@@ -91,7 +103,7 @@
               : ""
           }}
         </template>
-      </el-table-column>
+      </el-table-column> -->
       <el-table-column
         label="操作"
         align="center"
@@ -128,7 +140,9 @@ import {
   getGoodsInfo,
   GoodsUpOrDown,
   editGoods,
+  getGoodsDraftById,
   goodsRemove,
+  deleteGoodsDraft,
   getGoodsDraftByUserId,
 } from "@/api/manage/product";
 export default {
@@ -167,8 +181,8 @@ export default {
         type: "warning",
       })
         .then(() => {
-          goodsRemove({
-            spuId: record.id,
+          deleteGoodsDraft({
+            id: record.id,
           }).then((res) => {
             if (res.code == 200) {
               this.$message.success(`删除成功!`);
@@ -210,9 +224,9 @@ export default {
       this.handleQuery();
     },
     handleUpdate(record) {
-      getGoodsInfo({ spuId: record.id }).then((res) => {
+      getGoodsDraftById({ id: record.id }).then((res) => {
         if (res.code == 200) {
-          let params = res.data;
+          let params = res.data.goodsDto;
           this.$router.push({
             path: "/product/product/updateProduct",
             query: { params },

+ 49 - 37
src/views/product/module/basic-info.vue

@@ -22,11 +22,16 @@
         <el-form-item>
           <span slot="label"><span class="required">*</span> 销售方式</span>
           <el-radio-group v-model="form.saleType" @change="passValue">
-            <el-radio :label="0" v-if="shopInfo.scope == 0">整车</el-radio>
-            <el-radio :label="2" v-if="shopInfo.scope == 0">拼车</el-radio>
+            <el-radio
+              :label="0"
+              :value="0"
+              v-if="shopInfo.scope == 0 || shopInfo.scope == 1"
+              >整车</el-radio
+            >
+            <el-radio :label="2" :value="2" v-if="shopInfo.scope == 0">拼车</el-radio>
             <!-- <el-radio :label="3">预售</el-radio> -->
-            <el-radio :label="4" v-if="shopInfo.scope == 1">礼包</el-radio>
-            <el-radio :label="1" v-if="shopInfo.scope == 1">同城商品</el-radio>
+            <el-radio :label="4" :value="4" v-if="shopInfo.scope == 1">礼包</el-radio>
+            <!-- <el-radio :label="1" :value="1" v-if="shopInfo.scope == 1">一键代发</el-radio> -->
           </el-radio-group>
         </el-form-item>
       </el-col>
@@ -61,7 +66,7 @@
           <el-cascader
             v-model="form.categoryId"
             ref="formCascader"
-            placeholder="请选择分类"
+            :placeholder="categoryName ? categoryName : '请选择分类'"
             :props="categoryprops"
             @change="cascaderChange"
           />
@@ -113,24 +118,6 @@
           </el-upload>
         </el-form-item>
       </el-col>
-      <!-- <el-col :span="24">
-          <el-form-item>
-            <span slot="label"><span class="required">*</span> 商品封面图</span>
-            <span class="tips">商品的封面展示图</span>
-            <el-upload
-              list-type="picture-card"
-              :http-request="(data) => requestUpload(data, 'image')"
-              :show-file-list="false"
-              :limit="1"
-              action="#"
-              accept=".png,.jpg,.jpeg"
-              ref="files"
-            >
-              <img v-if="form.pic" :src="form.pic" style="width: 60px; height: 60px" />
-              <i v-else class="el-icon-plus avatar-uploader-icon"></i>
-            </el-upload>
-          </el-form-item>
-        </el-col> -->
       <el-col :span="24">
         <el-form-item prop="bannerList">
           <span slot="label"><span class="required">*</span> 商品图</span>
@@ -187,7 +174,19 @@ export default {
   data() {
     return {
       form: {
+        scope: "",
+        saleType: undefined,
+        saleModel: undefined,
+        categoryId: "",
+        title: "",
+        giftDesc: "",
+        vid: "",
         bannerList: [],
+        pic: "",
+        categoryName: "",
+        categoryIds: [],
+        presaleStartTime: "",
+        presaleEndTime: "",
       },
       bannerList: [],
       headers: { Auth: "Bearer " + getToken(), "Content-type": "multipart/form-data" },
@@ -210,6 +209,7 @@ export default {
       index: 0,
       shopInfo: {},
       datePicker: [],
+      categoryName: "",
     };
   },
   watch: {
@@ -217,18 +217,27 @@ export default {
     data: {
       handler(newVal, oldVal) {
         //监听info对象变化
-        console.log("newVal", newVal);
-        if (this.newVal) {
-          console.log("xxxx", this.newVal);
+        if (newVal) {
           for (const key in this.form) {
-            this.form[key] = this.newVal[key];
+            this.form[key] = newVal[key];
           }
-          this.datePicker = [this.newVal.presaleStartTime, this.newVal.presaleEndTime];
-          this.form.bannerList.forEach((e) => {
-            this.bannerList.push({
-              url: e.fileUrl,
+          this.bannerList = [];
+          this.form.bannerList = [];
+          this.datePicker = [newVal.presaleStartTime, newVal.presaleEndTime];
+          if (this.form.bannerList?.length > 0) {
+            this.form.bannerList.forEach((e) => {
+              this.bannerList.push({
+                url: e.fileUrl,
+              });
             });
-          });
+          }
+          if (this.form.pic) {
+            this.bannerList.unshift({
+              url: this.form.pic,
+            });
+          }
+          this.categoryName = this.form.categoryName;
+          console.log("111", this.form);
         }
       },
       deep: true, //深度监听
@@ -236,16 +245,16 @@ export default {
     },
   },
 
-  mounted() {
+  created() {
     this.getInfo();
   },
+
   methods: {
     removeImg(index) {
       this.bannerList.splice(index, 1);
       this.passValue();
     },
     picker() {
-      console.log(this.datePicker);
       this.form.presaleStartTime = this.datePicker[0];
       this.form.presaleEndTime = this.datePicker[1];
       this.passValue();
@@ -264,7 +273,7 @@ export default {
 
     passValue() {
       this.form.bannerList = [];
-      console.log("111", this.bannerList);
+
       for (let index = 0; index < this.bannerList.length; index++) {
         this.form.bannerList.push({
           fileUrl: this.bannerList[index].url,
@@ -273,11 +282,15 @@ export default {
       }
       this.form.pic = this.bannerList[0].url;
 
+      if (this.form.scope == 1) {
+        this.form.saleType = 0;
+        this.form.saleModel = 1;
+      }
+
       this.$emit("updateValue", this.form);
     },
 
     requestRemove(val, list, index) {
-      console.log(val);
       this.bannerList.forEach((e, index) => {
         if (e.uid == val.uid) {
           this.bannerList.splice(index, 1);
@@ -301,7 +314,6 @@ export default {
     categoryLazyLoad(node, resolve) {
       let that = this;
       let level = node.level;
-      console.log(node);
       if (!node.data) {
         getClassificationListPage({ parentId: 0 }).then((res) => {
           //接口

+ 43 - 7
src/views/product/module/product-info.vue

@@ -53,6 +53,16 @@
           </el-upload>
         </el-form-item>
       </el-col>
+      <!-- <el-col :span="24">
+        <el-form-item>
+          <span slot="label"><span class="required">*</span> 发布状态</span>
+          <el-radio-group v-model="form.">
+    <el-radio :label="3">备选项</el-radio>
+    <el-radio :label="6">备选项</el-radio>
+    <el-radio :label="9">备选项</el-radio>
+  </el-radio-group>
+        </el-form-item>
+      </el-col> -->
     </el-row>
   </el-form>
 </template>
@@ -67,6 +77,7 @@ export default {
       form: {
         spuDetailList: [],
         specialList: [],
+        spuDesc: "",
       },
       headers: { Auth: "Bearer " + getToken(), "Content-type": "multipart/form-data" },
       spuDetailList: [],
@@ -75,12 +86,39 @@ export default {
       index1: 0,
     };
   },
-  mounted() {
-    console.log("base", this.data);
-    if (this.data) {
-      this.form = this.data;
-    }
+  watch: {
+    //监听info对象
+    data: {
+      handler(newVal, oldVal) {
+        //监听info对象变化
+        if (newVal) {
+          this.form.spuDesc = newVal.spuDesc;
+
+          if (newVal.spuDetailList) {
+            newVal.spuDetailList.forEach((e) => {
+              this.spuDetailList.push({
+                url: e.fileUrl,
+                id: e.id,
+                sort: e.sort,
+              });
+            });
+          }
+          if (newVal.spuDetailList) {
+            newVal.spuDetailList.forEach((e) => {
+              this.spuDetailList.push({
+                url: e.fileUrl,
+                id: e.id,
+                sort: e.sort,
+              });
+            });
+          }
+        }
+      },
+      deep: true, //深度监听
+      immediate: true,
+    },
   },
+
   methods: {
     passValue() {
       if (this.specialList) {
@@ -104,7 +142,6 @@ export default {
       this.$emit("updateValue", this.form);
     },
     requestRemove1(val) {
-      console.log(val);
       this.specialList.forEach((e, index) => {
         if (e.uid == val.uid) {
           this.specialList.splice(index, 1);
@@ -113,7 +150,6 @@ export default {
       this.passValue();
     },
     requestRemove(val) {
-      console.log(val);
       this.spuDetailList.forEach((e, index) => {
         if (e.uid == val.uid) {
           this.spuDetailList.splice(index, 1);

+ 46 - 10
src/views/product/module/sales-info.vue

@@ -374,9 +374,19 @@ export default {
       form: {
         unit: "斤",
         props: [],
-        shippingAddrBean: {},
+        shippingAddrBean: {
+          addr: "",
+          addrDetail: "",
+          cityCode: "",
+          countyCode: "",
+          latitude: "",
+          longitude: "",
+          provinceCode: "",
+        },
         shippingAddr: "",
         skuList: [],
+        packing: "",
+        shippingTimeDesc: "",
       },
       addr: "",
       measure: [],
@@ -394,10 +404,40 @@ export default {
   mounted() {
     this.getInfo();
     this.getdictImpl();
-    if (this.data) {
-      this.form = this.data;
-      this.$forceUpdate();
-    }
+  },
+  watch: {
+    //监听info对象
+    data: {
+      handler(newVal, oldVal) {
+        //监听info对象变化
+        if (newVal) {
+          this.addr = newVal.shippingAddr;
+          this.form.shippingAddrBean = {
+            addr: newVal.shippingAddr,
+            addrDetail: newVal.shippingAddrString
+              ? newVal.shippingAddrString.split(newVal.shippingAddr)[1]
+              : "",
+            cityCode: newVal.cityCode,
+            countyCode: newVal.countyCode,
+            latitude: newVal.latitude,
+            longitude: newVal.longitude,
+            provinceCode: newVal.provinceCode,
+          };
+          this.form.props = newVal.props;
+          this.form.unit = newVal.unit;
+          this.form.shippingAddr = newVal.shippingAddr;
+          this.form.packing = newVal.packing;
+          this.form.shippingTimeDesc = newVal.shippingTimeDesc;
+          this.form.freeShipping = newVal.freeShipping;
+          this.form.skuList = newVal.skuList;
+          if (this.shopInfo.scope == 0) {
+            this.form.freeShipping = newVal.freeShipping;
+          }
+        }
+      },
+      deep: true, //深度监听
+      immediate: true,
+    },
   },
   methods: {
     getInfo() {
@@ -439,7 +479,6 @@ export default {
       }
     },
     passValue() {
-      console.log(this.form);
       if (this.shopInfo.scope == 0) {
         this.form.skuList.forEach((e) => {
           e.skuPriceList.forEach((a) => {
@@ -455,13 +494,10 @@ export default {
           });
         });
       }
-
-      console.log("pppppp", this.form);
       this.$emit("updateValue", this.form);
     },
 
     Mapaddress(data) {
-      console.log("map", data);
       this.form.shippingAddr = data.pname + data.cityname + data.adname;
       this.form.shippingAddrBean.addr = data.pname + data.cityname + data.adname;
       // this.form.shippingAddrBean.addrDetail = data.name ? data.name : undefined;
@@ -472,7 +508,7 @@ export default {
         this.form.shippingAddrBean.longitude = data.location.lng;
       }
       this.form.shippingAddrBean.provinceCode = data.pcode;
-      console.log("this.form", this.form);
+      this.form.skuList = [];
       this.addr = data.address;
       this.$refs.mapOpen.closeMap();
       this.passValue();

+ 7 - 5
src/views/product/updateProduct.vue

@@ -7,6 +7,7 @@
           <basicInfo @updateValue="updateValue" :data="form"></basicInfo>
           <el-descriptions title="销售信息" column="1"> </el-descriptions>
           <salesInfo @updateValue="updateValue" :data="form"></salesInfo>
+
           <el-descriptions title="商品详情" column="1"> </el-descriptions>
           <productInfo @updateValue="updateValue" :data="form"></productInfo>
           <div class="dialog-footer" style="text-align: center">
@@ -219,7 +220,7 @@
 
 <script>
 import { publishGoods } from "@/api/publish/index";
-import { saveGoodsDraft } from "@/api/manage/product";
+import { saveGoodsDraft, updateGoods } from "@/api/manage/product";
 import basicInfo from "./module/basic-info.vue";
 import productInfo from "./module/product-info.vue";
 import salesInfo from "./module/sales-info.vue";
@@ -237,6 +238,8 @@ export default {
     if (this.$route.query.params) {
       this.form = this.$route.query.params;
       this.headerImg = [];
+      console.log(1);
+
       if (this.form.vid) {
         this.headerImg.push({
           type: "video",
@@ -252,7 +255,7 @@ export default {
         });
       }
       this.headerImg = this.unique(this.headerImg);
-      if (this.form.bannerList) {
+      if (this.form.bannerList?.length > 0) {
         this.form.bannerList.forEach((e, index) => {
           this.headerImg.push({
             type: "img",
@@ -317,16 +320,15 @@ export default {
           return;
         }
       }
-      publishGoods(this.form).then((res) => {
+      updateGoods(this.form).then((res) => {
         if (res.code == 200) {
-          this.$message.success(`发布成功!`);
+          this.$message.success(`编辑成功!`);
           this.$store.dispatch("tagsView/delView", this.$route); //关闭当前页
           this.$router.replace({ path: "/product/product/index" });
         }
       });
     },
     updateValue(val) {
-      console.log(val);
       this.form = { ...this.form, ...val };
       console.log(this.form);
       this.headerImg = [];