Эх сурвалжийг харах

feat:业务组件代码重构

liu.shiyi 2 жил өмнө
parent
commit
4148b10425

+ 3 - 3
data-room-ui/packages/BizComponent/Preview.vue

@@ -90,7 +90,7 @@ export default {
         getBizComponentInfo(this.$route.query?.code).then(data => {
         getBizComponentInfo(this.$route.query?.code).then(data => {
           this.vueContentInner = data.vueContent
           this.vueContentInner = data.vueContent
           this.settingContentInner = data.settingContent
           this.settingContentInner = data.settingContent
-          this.buildOption(this.config)
+          this.dataFormatting(this.config)
           this.remoteComponent = remoteVueLoader('data:text/plain,' + encodeURIComponent(this.vueContentInner))
           this.remoteComponent = remoteVueLoader('data:text/plain,' + encodeURIComponent(this.vueContentInner))
         }).finally(() => {
         }).finally(() => {
           this.loading = false
           this.loading = false
@@ -111,7 +111,7 @@ export default {
     // 尝试渲染远程文件或远程字符串
     // 尝试渲染远程文件或远程字符串
     getRemoteComponent () {
     getRemoteComponent () {
       this.loading = true
       this.loading = true
-      this.buildOption(this.config)
+      this.dataFormatting(this.config)
       this.remoteComponent = remoteVueLoader('data:text/plain,' + encodeURIComponent(this.vueContentInner))
       this.remoteComponent = remoteVueLoader('data:text/plain,' + encodeURIComponent(this.vueContentInner))
       this.loading = false
       this.loading = false
     },
     },
@@ -119,7 +119,7 @@ export default {
      * 组件的配置
      * 组件的配置
      * @returns {Promise<unknown>}
      * @returns {Promise<unknown>}
      */
      */
-    buildOption (config, data) {
+    dataFormatting (config, data) {
       config = _.cloneDeep(config)
       config = _.cloneDeep(config)
       // 遍历config.setting,将config.setting中的值赋值给config.option中对应的optionField
       // 遍历config.setting,将config.setting中的值赋值给config.option中对应的optionField
       config.setting.forEach(set => {
       config.setting.forEach(set => {

+ 4 - 10
data-room-ui/packages/RemoteComponents/index.vue

@@ -75,7 +75,7 @@ export default {
           const settingContent = data.settingContent
           const settingContent = data.settingContent
           if (!this.config?.option?.data) {
           if (!this.config?.option?.data) {
             this.resolveStrSetting(settingContent)
             this.resolveStrSetting(settingContent)
-            this.config = this.buildOption(this.config, { success: false })
+            this.config = this.dataFormatting(this.config, { success: false })
           }
           }
 
 
           this.remoteComponent = remoteVueLoader('data:text/plain,' + encodeURIComponent(vueContent))
           this.remoteComponent = remoteVueLoader('data:text/plain,' + encodeURIComponent(vueContent))
@@ -132,22 +132,16 @@ export default {
      */
      */
     updateChart () {
     updateChart () {
       if (this.isPreview) {
       if (this.isPreview) {
-        this.getCurrentOption().then(({ data, config }) => {
-          if (data.success) {
-            // 成功后更新数据
-            config = this.buildOption(config, data)
-            this.changeChartConfig(config)
-          }
-        })
+        this.changeDataByCode()
       } else {
       } else {
-        this.updateChartData(this.config)
+        this.changeData(this.config)
       }
       }
     },
     },
     /**
     /**
      * 组件的配置
      * 组件的配置
      * @returns {Promise<unknown>}
      * @returns {Promise<unknown>}
      */
      */
-    buildOption (config, data) {
+    dataFormatting (config, data) {
       config = _.cloneDeep(config)
       config = _.cloneDeep(config)
       // 遍历config.setting,将config.setting中的值赋值给config.option中对应的optionField
       // 遍历config.setting,将config.setting中的值赋值给config.option中对应的optionField
       config.setting.forEach(set => {
       config.setting.forEach(set => {