feat:业务组件代码重构

main
liu.shiyi 2 years ago
parent d51817697c
commit 4148b10425

@ -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.settingconfig.settingconfig.optionoptionField // config.settingconfig.settingconfig.optionoptionField
config.setting.forEach(set => { config.setting.forEach(set => {

@ -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 }) => { this.changeDataByCode()
if (data.success) {
//
config = this.buildOption(config, data)
this.changeChartConfig(config)
}
})
} 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.settingconfig.settingconfig.optionoptionField // config.settingconfig.settingconfig.optionoptionField
config.setting.forEach(set => { config.setting.forEach(set => {

Loading…
Cancel
Save