Ver Fonte

修改前端数据共享的问题

silent há 4 anos atrás
pai
commit
66d5b842ef
1 ficheiros alterados com 13 adições e 19 exclusões
  1. 13 19
      src/views/sing_desk/platformsetting.vue

+ 13 - 19
src/views/sing_desk/platformsetting.vue

@@ -1,8 +1,6 @@
 <template>
 <template>
   <basic-container>
   <basic-container>
-    <avue-tabs :option="tabOption" @change="(data)=>{
-      this.key = data.prop;
-    }">
+    <avue-tabs :option="tabOption" @change="(data)=>tabChange(data.prop)">
     </avue-tabs>
     </avue-tabs>
     <avue-form ref="form" v-model="form" :option="option" @submit="updateSetting">
     <avue-form ref="form" v-model="form" :option="option" @submit="updateSetting">
     </avue-form>
     </avue-form>
@@ -36,35 +34,29 @@ export default {
       key: "",
       key: "",
     }
     }
   },
   },
-  watch: {
-    "key": {
-      handler(value) {
-        this.tabChange(value);
-      }
-    }
-  },
   created() {
   created() {
-    this.key = this.tabOption.column[0].prop;
+    this.tabChange(this.tabOption.column[0].prop);
   },
   },
   methods: {
   methods: {
     /**
     /**
      * 获取平台设置
      * 获取平台设置
      */
      */
     getSetting(key) {
     getSetting(key) {
-      this.form = {};
       getPlatformSetting(key).then(res => {
       getPlatformSetting(key).then(res => {
-        if (res.data.data !== undefined) {
-          this.form = JSON.parse(res.data.data);
-        }
+        this.form = JSON.parse(res.data.data);
       });
       });
     },
     },
     /**
     /**
      * 更新平台设置
      * 更新平台设置
      */
      */
     updateSetting(row, loading) {
     updateSetting(row, loading) {
+      const data = {};
+      this.option.column.forEach(ele=>{
+        data[ele.prop] = this.form[ele.prop];
+      });
       updatePlatformValue({
       updatePlatformValue({
         key: this.key,
         key: this.key,
-        value: JSON.stringify(this.form)
+        value: JSON.stringify(data)
       }).then(() => {
       }).then(() => {
         this.$message.success("修改成功");
         this.$message.success("修改成功");
       }).finally(() => {
       }).finally(() => {
@@ -75,8 +67,9 @@ export default {
      * 选项卡变化
      * 选项卡变化
      */
      */
     tabChange(key) {
     tabChange(key) {
+      this.key = key;
       //活动页面
       //活动页面
-      if (key === "PAGE_INTERFACE_SHOW") {
+      if (this.key === "PAGE_INTERFACE_SHOW") {
         this.option.column = [
         this.option.column = [
           {
           {
             label: "主页标题",
             label: "主页标题",
@@ -163,7 +156,7 @@ export default {
             }
             }
           }
           }
         ]
         ]
-      } else if(key === "ACTIVE_SETTING"){
+      } else if(this.key === "ACTIVE_SETTING"){
         this.option.column = [
         this.option.column = [
           {
           {
             label: "默认活动",
             label: "默认活动",
@@ -209,7 +202,8 @@ export default {
       } else {
       } else {
         this.option.column = [];
         this.option.column = [];
       }
       }
-      this.getSetting(key);
+      this.form = {};
+      this.getSetting(this.key);
     }
     }
   }
   }
 };
 };