瀏覽代碼

上架下架按钮,规格添加图片,默认选择

YY 2 年之前
父節點
當前提交
0b828e70eb
共有 2 個文件被更改,包括 39 次插入1 次删除
  1. 37 0
      src/views/selfShop/goods/index.vue
  2. 2 1
      src/views/selfShop/goods/spec.vue

+ 37 - 0
src/views/selfShop/goods/index.vue

@@ -16,6 +16,8 @@
         :limit="limit"
         @query="search"
         @edit="toEdit"
+        @puton="toPuton"
+        @lower="toLower"
         @delete="toDelete"
         @spec="toSpec"
       ></data-table>
@@ -70,6 +72,8 @@ export default {
       ],
       opera: [
         { label: '修改', method: 'edit' },
+        { label: '上架', method: 'puton' },
+        { label: '下架', method: 'lower' },
         { label: '库存管理', method: 'spec' },
         { label: '删除', method: 'delete', confirm: true, type: 'danger' },
       ],
@@ -173,6 +177,39 @@ export default {
       }
       return arr.join(';');
     },
+    // 上架
+    async toPuton({ data }) {
+      this.$confirm('是否确认上架该商品?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning',
+      }).then(async () => {
+        data.status = '1';
+        let res;
+        if (data.id) res = await this.update(data);
+        if (this.$checkRes(res)) {
+          this.$message({ type: `success`, message: `上架成功` });
+        }
+        this.search();
+      });
+    },
+    // 下架
+    async toLower({ data }) {
+      this.$confirm('是否确认下架该商品?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning',
+      }).then(async () => {
+        data.status = '0';
+        let res;
+        if (data._id) res = await this.update(data);
+        if (this.$checkRes(res)) {
+          console.log(res.data);
+          this.$message({ type: `success`, message: `下架成功` });
+        }
+        this.search();
+      });
+    },
     toSpec({ data }) {
       this.$router.push({ path: `/selfShop/spec/${data._id}` });
     },

+ 2 - 1
src/views/selfShop/goods/spec.vue

@@ -95,6 +95,7 @@ export default {
         { label: '是否可以团购', model: 'can_group', type: 'select' },
         { label: '团购金额', model: 'money', type: 'number' },
         { label: '开团人数', model: 'need_person', type: 'number' },
+        { label: '图片', model: 'file', type: 'upload', url: '/files/point/goodsSpec/upload' },
       ],
       rules: {},
       form: {},
@@ -120,7 +121,7 @@ export default {
     ...mapActions(['query', 'fetch', 'update', 'delete', 'create']),
     ...methodUtil,
     initAddData() {
-      const obj = { goods: this.goods, status: '0', can_group: '0' };
+      const obj = { goods: this.goods, status: '0', can_group: '1' };
       this.$set(this, 'form', obj);
     },
     async toSave({ data }) {