guhongwei 4 år sedan
förälder
incheckning
670578d357
1 ändrade filer med 20 tillägg och 9 borttagningar
  1. 20 9
      src/views/userCenter/myProduct/detail.vue

+ 20 - 9
src/views/userCenter/myProduct/detail.vue

@@ -148,15 +148,26 @@ export default {
     },
     // 提交
     async onSubmit({ data }) {
-      data.type = this.type;
-      data.userid = this.user.uid;
-      let res = await this.productCreate(data);
-      if (this.$checkRes(res)) {
-        this.$notify({
-          message: '保存草稿成功',
-          type: 'success',
-        });
-        this.$router.push({ path: '/userCenter/myProduct/index' });
+      if (data.id) {
+        let res = await this.productUpdate(data);
+        if (this.$checkRes(res)) {
+          this.$notify({
+            message: '修改草稿信息成功',
+            type: 'success',
+          });
+          this.$router.push({ path: '/userCenter/myProduct/index' });
+        }
+      } else {
+        data.type = this.type;
+        data.userid = this.user.uid;
+        let res = await this.productCreate(data);
+        if (this.$checkRes(res)) {
+          this.$notify({
+            message: '保存草稿成功',
+            type: 'success',
+          });
+          this.$router.push({ path: '/userCenter/myProduct/index' });
+        }
       }
     },
     // 监听显示类型