YY пре 2 година
родитељ
комит
2698db5857

+ 4 - 0
src/store/module/shop/goods.js

@@ -26,6 +26,10 @@ const actions = {
     const res = await this.$axios.$get(`${api.url}/${payload}`);
     return res;
   },
+  async copy({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.url}/toDuplicate/${payload}`);
+    return res;
+  },
   async update({ commit }, payload) {
     const id = _.get(payload, 'id', _.get(payload, '_id'));
     const res = await this.$axios.$post(`${api.url}/${id}`, payload);

+ 4 - 7
src/views/selfShop/goods/index.vue

@@ -123,7 +123,7 @@ export default {
     ...dictData({ getDict: 'query' }),
     ...actTags({ actQuery: 'query' }),
     ...goodsTags(['tree']),
-    ...goods(['query', 'delete', 'fetch', 'update', 'create']),
+    ...goods(['copy', 'query', 'delete', 'fetch', 'update', 'create']),
     ...methodsUtil,
     async search({ skip = 0, limit = this.limit, ...others } = {}) {
       let query = { skip, limit, ...others, shop: this.user.shop.id };
@@ -141,19 +141,15 @@ export default {
       };
       this.$set(this, 'form', obj);
     },
+    // 复制
     async toCopy({ data }) {
       this.$confirm('是否确认复制该商品?', '提示', {
         confirmButtonText: '确定',
         cancelButtonText: '取消',
         type: 'warning',
       }).then(async () => {
-        delete data.id;
-        delete data._id;
-        delete data.meta;
-        delete data.view_num;
-        delete data.__v;
         let res;
-        res = await this.create(data);
+        res = await this.copy(data.id);
         if (this.$checkRes(res)) {
           this.$message({ type: `success`, message: `复制成功` });
           this.toBack();
@@ -161,6 +157,7 @@ export default {
         }
       });
     },
+    // 查询其他信息
     async searchOthers() {
       let res = await this.tree();
       if (this.$checkRes(res)) this.$set(this, `tagsList`, res.data);

+ 4 - 0
src/views/selfShop/goods/spec.vue

@@ -127,12 +127,14 @@ export default {
       const obj = { goods: this.goods, status: '0', can_group: '1', freight: 0 };
       this.$set(this, 'form', obj);
     },
+    // 复制
     async toCopy({ data }) {
       this.$confirm('是否确认复制该商品?', '提示', {
         confirmButtonText: '确定',
         cancelButtonText: '取消',
         type: 'warning',
       }).then(async () => {
+        data.name = data.name + '-复制';
         delete data.id;
         delete data._id;
         delete data.meta;
@@ -146,6 +148,7 @@ export default {
         }
       });
     },
+    // 保存
     async toSave({ data }) {
       let group_config = {};
       group_config.money = data.money;
@@ -160,6 +163,7 @@ export default {
         this.toBackList();
       }
     },
+    // 修改
     async toEdit({ data }) {
       const res = await this.fetch(data._id);
       if (this.$checkRes(res)) {