Przeglądaj źródła

修改并完善批量上下架功能

Qukatie 2 miesięcy temu
rodzic
commit
880ab8018f
1 zmienionych plików z 34 dodań i 9 usunięć
  1. 34 9
      src/views/listingManagement/index.vue

+ 34 - 9
src/views/listingManagement/index.vue

@@ -945,6 +945,9 @@ export default {
       }
       if (type === "up") {
         for (let item of this.selectionList) {
+          if (item.upAndDownShelves == 1) {
+            return this.$message.error("请选择未上架的产品");
+          }
           if (item.priceOne == 0 || item.priceTwo == 0) {
             return this.$message.error("请维护所有售价");
           }
@@ -955,25 +958,47 @@ export default {
           cancelButtonText: "取消",
           type: "warning",
         }).then(() => {
-          batchOperationProductLaunch({
-            flag: 1,
-            ids: data.join(","),
-          }).then((res) => {
-            this.onLoad(this.page, this.search);
-          });
+          this.loading = true;
+          productLaunch(this.selectionList)
+            .then((res) => {
+              batchOperationProductLaunch({
+                flag: 1,
+                ids: data.join(","),
+              })
+                .then((res) => {
+                  this.onLoad(this.page, this.search);
+                })
+                .catch(() => {
+                  this.loading = false;
+                });
+            })
+            .catch(() => {
+              this.loading = false;
+            });
         });
       } else if (type === "down") {
+        
+        for (let item of this.selectionList) {
+          if (item.upAndDownShelves == 0) {
+            return this.$message.error("请选择已上架的产品");
+          }
+        }
         this.$confirm("是否确认全部下架?", "提示", {
           confirmButtonText: "确定",
           cancelButtonText: "取消",
           type: "warning",
         }).then(() => {
+          this.loading = true;
           batchOperationProductLaunch({
             flag: 0,
             ids: data.join(","),
-          }).then((res) => {
-            this.onLoad(this.page, this.search);
-          });
+          })
+            .then((res) => {
+              this.onLoad(this.page, this.search);
+            })
+            .catch(() => {
+              this.loading = false;
+            });
         });
       }
     },