YY před 2 roky
rodič
revize
f98c65d817

+ 27 - 5
src/views/platmanag/goods/index.vue

@@ -21,8 +21,9 @@
     </template>
     <template v-else>
       <el-row>
-        <el-col :span="24">
-          <el-button type="primary" size="mini" @click="toBack()">返回</el-button>
+        <el-col :span="24" style="margin: 0 0 10px 0">
+          <el-col :span="2"><el-button type="primary" size="mini" @click="toBack()">返回</el-button></el-col>
+          <el-col :span="2"><el-button type="primary" size="mini" @click="onSubmit(form)">保存</el-button></el-col>
         </el-col>
         <el-col :span="24">
           <data-form :fields="infoFields" :rules="rules" v-model="form" labelWidth="150px" @save="toSave">
@@ -156,9 +157,11 @@ export default {
       const res = await this.fetch(data._id);
       if (this.$checkRes(res)) {
         if (data.shop) {
+          let list = [];
           let res = await this.shopFetch(data.shop._id);
           if (this.$checkRes(res)) {
-            this.shopList.push(res.data);
+            list.push(res.data);
+            this.$set(this, 'shopList', list);
           }
         }
         this.$set(this, `form`, res.data);
@@ -256,10 +259,29 @@ export default {
       return arr.join(';');
     },
     // 保存
+    async onSubmit(data) {
+      let res;
+      if (data.id) {
+        data.shop = this.user.shop.id;
+        res = await this.update(data);
+      } else {
+        res = await this.create(data);
+      }
+      if (this.$checkRes(res)) {
+        this.$message({ type: `success`, message: `维护信息成功` });
+        this.toBack();
+        this.search();
+      }
+    },
+    // 保存
     async toSave({ data }) {
       let res;
-      if (data.id) res = await this.update(data);
-      else res = await this.create(data);
+      if (data.id) {
+        data.shop = this.user.shop.id;
+        res = await this.update(data);
+      } else {
+        res = await this.create(data);
+      }
       if (this.$checkRes(res)) {
         this.$message({ type: `success`, message: `维护信息成功` });
         this.toBack();

+ 23 - 6
src/views/selfShop/goods/index.vue

@@ -25,8 +25,9 @@
     </template>
     <template v-else>
       <el-row>
-        <el-col :span="24">
-          <el-button type="primary" size="mini" @click="toBack()">返回</el-button>
+        <el-col :span="24" style="margin: 0 0 10px 0">
+          <el-col :span="2"><el-button type="primary" size="mini" @click="toBack()">返回</el-button></el-col>
+          <el-col :span="2"><el-button type="primary" size="mini" @click="onSubmit(form)">保存</el-button></el-col>
         </el-col>
         <el-col :span="24">
           <data-form :fields="infoFields" :rules="rules" v-model="form" labelWidth="150px" @save="toSave">
@@ -139,7 +140,7 @@ export default {
     initAddData() {
       const obj = {
         status: '1',
-        shop: _.get(this.shop, '_id'),
+        shop: _.get(this.user.shop, '_id'),
       };
       this.$set(this, 'form', obj);
     },
@@ -201,11 +202,27 @@ export default {
       return arr.join(';');
     },
     // 保存
+    async onSubmit(data) {
+      let res;
+      if (data.id) {
+        res = await this.update(data);
+      } else {
+        res = await this.create(data);
+      }
+      if (this.$checkRes(res)) {
+        this.$message({ type: `success`, message: `维护信息成功` });
+        this.toBack();
+        this.search();
+      }
+    },
+    // 保存
     async toSave({ data }) {
-      data.shop = this.user.shop.id;
       let res;
-      if (data.id) res = await this.update(data);
-      else res = await this.create(data);
+      if (data.id) {
+        res = await this.update(data);
+      } else {
+        res = await this.create(data);
+      }
       if (this.$checkRes(res)) {
         this.$message({ type: `success`, message: `维护信息成功` });
         this.toBack();