diff --git a/data-room-ui/packages/BigScreenDesign/index.vue b/data-room-ui/packages/BigScreenDesign/index.vue index 9e76d54b..d1ebeb5c 100644 --- a/data-room-ui/packages/BigScreenDesign/index.vue +++ b/data-room-ui/packages/BigScreenDesign/index.vue @@ -134,6 +134,7 @@ import { mapActions, mapMutations, mapState } from 'vuex' import SketchDesignRuler from 'data-room-ui/BigScreenDesign/RulerTool/SketchRuler.vue' import multipleSelectMixin from 'data-room-ui/js/mixins/multipleSelectMixin' import { getScreenInfo } from 'data-room-ui/js/api/bigScreenApi' +import plotSettings from 'data-room-ui/G2Plots/settings' import MouseSelect from './MouseSelect/index.vue' import cloneDeep from 'lodash/cloneDeep' import { randomString } from '../js/utils' @@ -297,7 +298,29 @@ export default { getScreenInfo(component.code).then(res => { res.chartList.forEach((item) => { if (!item.border) { - item.border={type:'',titleHeight:60,fontSize:30,isTitle:true,padding:[16,16,16,16]} + item.border={type:'',titleHeight:60,fontSize:30,isTitle:true,padding:[0,0,0,0]} + } + if(!item.border.padding){ + item.border.padding=[0,0,0,0] + } + if (item.type == 'customComponent'){ + plotSettings[Symbol.iterator]=function*(){ + let keys=Object.keys(plotSettings) + for(let k of keys){ + yield [k,plotSettings[k]] + } + } + for(let [key,value] of plotSettings){ + if (item.name == value.name) { + const settings=JSON.parse(JSON.stringify(value.setting)) + item.setting=settings.map((x)=>{ + const index=item.setting.findIndex(y=>y.field==x.field) + x.field = item.setting[index].field + x.value=item.setting[index].value + return x + }) + } + } } }) // 给组件库导入的组件加入统一的前缀 diff --git a/data-room-ui/packages/G2Plots/settings.js b/data-room-ui/packages/G2Plots/settings.js new file mode 100644 index 00000000..818f4762 --- /dev/null +++ b/data-room-ui/packages/G2Plots/settings.js @@ -0,0 +1,15 @@ +const files = require.context('./', true, /[\u4e00-\u9fa5]+.js$/) +const plotSettings = [] +// 获取plot配置 + files.keys().forEach((key) => { + // ./折线图/基础折线图.js + // 取到 "基础折线图" + const config = files(key).default + plotSettings.push({ + setting: config.setting, + name: config.name, + }) + }) +export default plotSettings + + diff --git a/data-room-ui/packages/js/api/bigScreenApi.js b/data-room-ui/packages/js/api/bigScreenApi.js index 206abebc..85688029 100644 --- a/data-room-ui/packages/js/api/bigScreenApi.js +++ b/data-room-ui/packages/js/api/bigScreenApi.js @@ -5,7 +5,16 @@ export function getScreenInfo (code) { } // 保存更新大屏 -export function saveScreen (data) { +export function saveScreen(data) { + data.chartList.forEach((item) => { + if (item.type == 'customComponent') { + console.log(item) + item.setting=item.setting.map((x) => { + const {field,value,...obj}=x + return {field,value} + }) + } + }) return Vue.prototype.$dataRoomAxios.post('/bigScreen/design/update', data) } diff --git a/data-room-ui/packages/js/store/actions.js b/data-room-ui/packages/js/store/actions.js index e341159f..3fdf1c19 100644 --- a/data-room-ui/packages/js/store/actions.js +++ b/data-room-ui/packages/js/store/actions.js @@ -3,6 +3,7 @@ import cloneDeep from 'lodash/cloneDeep' import { setModules, dataModules } from 'data-room-ui/js/utils/configImport' import { getScreenInfo, getDataSetDetails, getDataByDataSetId } from '../api/bigScreenApi' +import plotSettings from 'data-room-ui/G2Plots/settings' import { stringToFunction } from '../utils/evalFunctions' import { EventBus } from '../utils/eventBus' import plotList from 'data-room-ui/G2Plots/plotList' @@ -16,7 +17,29 @@ export default { // 兼容边框配置 data.chartList.forEach((item) => { if (!item.border) { - item.border={type:'',titleHeight:60,fontSize:30,isTitle:true,padding:[16,16,16,16]} + item.border={type:'',titleHeight:60,fontSize:30,isTitle:true,padding:[0,0,0,0]} + } + if(!item.border.padding){ + item.border.padding=[0,0,0,0] + } + if (item.type == 'customComponent'){ + plotSettings[Symbol.iterator]=function*(){ + let keys=Object.keys(plotSettings) + for(let k of keys){ + yield [k,plotSettings[k]] + } + } + for(let [key,value] of plotSettings){ + if (item.name == value.name) { + const settings=JSON.parse(JSON.stringify(value.setting)) + item.setting=settings.map((x)=>{ + const index=item.setting.findIndex(y=>y.field==x.field) + x.field = item.setting[index].field + x.value=item.setting[index].value + return x + }) + } + } } }) const pageInfo = handleResData(data)