diff --git a/components/AiDvRender.vue b/components/AiDvRender.vue index e4831feb..8e9880ae 100644 --- a/components/AiDvRender.vue +++ b/components/AiDvRender.vue @@ -37,6 +37,7 @@ :stripe="data.stripe" :theme="theme" :isShowIndex="data.isShowIndex" + :config="dvTableConfig" :data="values"> v.data.type }, watch: { - data: { + values: { immediate: true, deep: true, handler() { if (this.currentType == 'map') { // this.renderMap() } + + if (this.currentType === 'AiDvTable') { + this.dvTableConfig = this.data[this.data.dataType].map((v, i) => { + return { + color: this.data.config[i] ? (this.data.config[i].color || '') : '', + width: this.data.config[i] ? (this.data.config[i].width || '') : '', + align: this.data.config[i] ? (this.data.config[i].align || '') : '' + } + }) + + this.data.config = this.dvTableConfig + } } } }, diff --git a/components/AiDvViewer.vue b/components/AiDvViewer.vue index c3230889..08491be3 100644 --- a/components/AiDvViewer.vue +++ b/components/AiDvViewer.vue @@ -85,7 +85,7 @@ export default { this.dashboard = JSON.parse(res.data.config).dashboard this.componentList.forEach((item, index) => { - if (item.dataType !== 'staticData' && ((item.type.indexOf('Chart') > -1) || ['display', 'table', 'map', 'summary'].includes(item.type))) { + if (item.dataType !== 'staticData' && ((item.type.indexOf('Chart') > -1) || ['display', 'table', 'map', 'summary', 'AiRanking', 'AiDvTable'].includes(item.type))) { this.getSourceData(item, index) } if (item.type === 'monitor' && item.monitorType === 'cmcc') { diff --git a/components/AiEchart/template/bar/barChart5.js b/components/AiEchart/template/bar/barChart5.js index 2a7358d8..8be592fa 100644 --- a/components/AiEchart/template/bar/barChart5.js +++ b/components/AiEchart/template/bar/barChart5.js @@ -8,16 +8,15 @@ export default { left: 50, right: 0 }, tooltip: { - // trigger: 'axis', backgroundColor: 'rgba(14, 51, 111, 0.9)', borderColor: '#1A6ABC', + trigger: 'axis', backgroundColor: 'rgba(14, 51, 111, 0.9)', borderColor: '#1A6ABC', textStyle: {color: '#fff'} }, yAxis: { nameGap: 23, minInterval: 1, - // splitLine: {lineStyle: {color: 'rgba(255,255,255,.2)', type: 'dashed'}}, + splitLine: {lineStyle: {color: 'rgba(255,255,255,.2)', type: 'dashed'}}, axisLabel: {color: '#fff'}, axisPointer: {show: false} }, axisPointer: { type: 'none', show: true, triggerTooltip: false, }, - daemon: {type: 'bar', barWidth: 12, stack: 'stack'} } diff --git a/components/layout/AiDvTable/AiDvTable.vue b/components/layout/AiDvTable/AiDvTable.vue index 1888d704..95584d01 100644 --- a/components/layout/AiDvTable/AiDvTable.vue +++ b/components/layout/AiDvTable/AiDvTable.vue @@ -5,9 +5,9 @@ v-for="(item, index) in header" :key="index" :style="{ - width: item.width + 'px', - textAlign: item.align, - flex: item.width ? 'inherit' : 1 + width: config[index].width ? config[index].width + 'px' : '', + textAlign: config[index].align, + flex: config[index].width ? 'inherit' : 1 }"> {{ item.v }} @@ -18,10 +18,10 @@ v-for="(column, i) in item" :key="i" :style="{ - color: column.color, - textAlign: column.align, - width: column.width + 'px', - flex: column.width ? 'inherit' : 1 + color: config[i].color, + textAlign: config[i].align, + width: config[i].width ? config[i].width + 'px' : '', + flex: config[i].width ? 'inherit' : 1 }"> {{ index + 1 }} {{ column.v }} @@ -54,6 +54,11 @@ theme: { type: String, default: '0' + }, + + config: { + type: Array, + default: () => [] } }, @@ -80,6 +85,7 @@ methods: { init (value) { + console.log(this.config) if (!value.length) { this.header = [] this.body = [] diff --git a/packages/bigscreen/designer/components/Layout.vue b/packages/bigscreen/designer/components/Layout.vue index c6c73ff3..0be89a2e 100644 --- a/packages/bigscreen/designer/components/Layout.vue +++ b/packages/bigscreen/designer/components/Layout.vue @@ -396,6 +396,7 @@ export default { }) }, clone(e) { + console.log(this.deepClone(e)) this.componentList.push(this.deepClone(e)) }, @@ -405,31 +406,42 @@ export default { } }, - deepClone(data, hash = new WeakMap()) { - if (typeof data !== 'object' || data === null) { - throw new TypeError('传入参数不是对象') - } - if (hash.has(data)) { - return hash.get(data) - } - let newData = {} - const dataKeys = Object.keys(data) - dataKeys.forEach(value => { - const currentDataValue = data[value] - if (typeof currentDataValue !== "object" || currentDataValue === null) { - newData[value] = currentDataValue - } else if (Array.isArray(currentDataValue)) { - newData[value] = [...currentDataValue] - } else if (currentDataValue instanceof Set) { - newData[value] = new Set([...currentDataValue]) - } else if (currentDataValue instanceof Map) { - newData[value] = new Map([...currentDataValue]) + deepClone(obj) { + if (obj instanceof Object) { + let newObj = {} + + if (Array.isArray(obj)) { + let arr = [] + obj.forEach(item => { + arr.push(this.deepClone(item)) + }) + return arr + } else if (typeof obj == 'function') { + newObj = obj.bind(newObj) } else { - hash.set(data, data) - newData[value] = this.deepClone(currentDataValue, hash) + for (let key in obj) { + let value = obj[key] + if (typeof value == 'function') { + newObj[key] = value.bind(newObj) + } else if (typeof value == 'object') { + if (Array.isArray(value)) { + newObj[key] = [] + value.forEach(item => { + newObj[key].push(this.deepClone(item)) + }) + } else { + newObj[key] = this.deepClone(value) + } + } else { + newObj[key] = value + } + } } - }) - return newData + + return newObj + } else { + return obj + } }, onContextmenu(e, index) { diff --git a/packages/bigscreen/designer/components/form/componentConfig.vue b/packages/bigscreen/designer/components/form/componentConfig.vue index bc1acae5..4d274764 100644 --- a/packages/bigscreen/designer/components/form/componentConfig.vue +++ b/packages/bigscreen/designer/components/form/componentConfig.vue @@ -110,7 +110,7 @@ -
+
@@ -119,7 +119,7 @@ - +
@@ -213,23 +213,8 @@ export default { tableStatus: [ {label: '是', value: '1'}, {label: '否', value: '0'} - ], - data: [] + ] } - }, - - watch: { - config: { - handler (v) { - this.data = v[v.dataType] - }, - deep: true, - immediate: true - } - }, - - created() { - } } diff --git a/packages/bigscreen/designer/config.js b/packages/bigscreen/designer/config.js index d4ec490e..87298cee 100644 --- a/packages/bigscreen/designer/config.js +++ b/packages/bigscreen/designer/config.js @@ -505,7 +505,23 @@ const components = [ isShowIndex: '1', sourceDataId: '', api: '', - config: [], + config: [ + { + width: '', + color: '', + align: '' + }, + { + width: '', + color: '', + align: '' + }, + { + width: '', + color: '', + align: '' + } + ], apiData: [], dataType: 'staticData', dynamicData: [],