Browse Source

feat:修复输入框主题切换问题

liu.shiyi 1 year ago
parent
commit
a7d2ea859d
1 changed files with 12 additions and 10 deletions
  1. 12 10
      data-room-ui/packages/BasicComponents/Input/index.vue

+ 12 - 10
data-room-ui/packages/BasicComponents/Input/index.vue

@@ -51,18 +51,18 @@ export default {
     return { }
     return { }
   },
   },
   watch: {
   watch: {
-    customTheme: {
+    'config.customize': {
       handler () {
       handler () {
-        this.changeStyle(this.config)
-      }
+        this.changeStyle(this.config, true)
+      },
+      deep: true
     }
     }
   },
   },
   mounted () {
   mounted () {
     this.chartInit()
     this.chartInit()
-    // this.changeStyle()
   },
   },
   methods: {
   methods: {
-    changeStyle (config) {
+    changeStyle (config, isUpdateTheme) {
       config = { ...this.config, ...config }
       config = { ...this.config, ...config }
       const input = document.querySelector(`#el-input-${config.code}`)
       const input = document.querySelector(`#el-input-${config.code}`)
       // const inputIcon = input.querySelector(`.${this.config.customize.icon.name}`)
       // const inputIcon = input.querySelector(`.${this.config.customize.icon.name}`)
@@ -79,11 +79,13 @@ export default {
         inputIcon.style.fontSize = config.customize.inputStyle.fontSize + 'px'
         inputIcon.style.fontSize = config.customize.inputStyle.fontSize + 'px'
       }
       }
       // 样式改变时更新主题配置
       // 样式改变时更新主题配置
-      config.theme = settingToTheme(_.cloneDeep(config), this.customTheme)
-      this.changeChartConfig(config)
-      // if (config.code === this.activeCode) {
-      //   this.changeActiveItemConfig(config)
-      // }
+      if (!isUpdateTheme) {
+        config.theme = settingToTheme(_.cloneDeep(config), this.customTheme)
+        this.changeChartConfig(config)
+        if (config.code === this.activeCode) {
+          this.changeActiveItemConfig(config)
+        }
+      }
     }
     }
   }
   }
 }
 }