lambo-design-bi 0.0.175 → 0.0.177

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  <template>
2
- <LamboChartsFactory v-if="dataX" :height="height" :type="chartsType" :data-x="dataX" :data-y="dataY" :data-dim="dataDim">
2
+ <LamboChartsFactory v-if="dataX" :height="height" :type="chartsType" :data-x="dataX" :data-y="dataY"
3
+ :data-dim="dataDim" :charts-note="chartsNote">
3
4
  </LamboChartsFactory>
4
5
  </template>
5
6
  <script>
@@ -32,7 +33,9 @@ export default {
32
33
  xKey: null,
33
34
  yKey: null,
34
35
  dKey: null,
35
- dataCol: null
36
+ dataCol: null,
37
+ noteApiId: null,
38
+ chartsNote: null
36
39
  }
37
40
  },
38
41
  methods: {
@@ -58,6 +61,7 @@ export default {
58
61
  this.dataCol = this.columns["data_col"]
59
62
  }
60
63
  }
64
+ this.noteApiId = this.widget.options.noteApiId
61
65
  },
62
66
  doSearch() {
63
67
  if (!this.apiId) {
@@ -66,7 +70,7 @@ export default {
66
70
  }
67
71
  getListMapData(this.apiId, this.params).then(res => {
68
72
  if (res.data.code === 0) {
69
- console.error("charts组件调用服务[" + this.widget.options.apiId + "]失败:" + res.data.message)
73
+ console.error("charts数据服务[" + this.widget.options.apiId + "]请求失败:" + res.data.message)
70
74
  } else {
71
75
  if (res.data.data.rows.length > 0) {
72
76
  let rows = res.data.data.rows
@@ -78,21 +82,44 @@ export default {
78
82
  this.dataY = resObj.dataY
79
83
  this.dataDim = resObj.dataDim
80
84
  } else {
81
- console.error("charts组件[" + this.widget.name + "]数据转换失败:" + resObj)
82
- this.$Message.warning("charts组件[" + this.widget.name + "]数据转换失败")
85
+ console.error("charts数据服务[" + this.widget.name + "]数据转换失败:" + resObj)
86
+ this.$Message.warning("charts数据服务[" + this.widget.name + "]数据转换失败")
83
87
  }
84
88
  }
85
89
  } else {
86
- console.warn("charts组件调用服务[" + this.widget.options.apiId + "]数据为空:" + res.data.message)
90
+ console.warn("charts数据服务[" + this.widget.options.apiId + "]请求数据为空:" + res.data.message)
87
91
  this.dataX = []
88
92
  this.dataY = []
89
93
  this.dataDim = []
90
94
  }
91
95
  }
92
96
  }).catch(err => {
93
- console.error("charts的调用服务[" + this.widget.options.apiId + "]异常:", err)
97
+ console.error("charts数据服务[" + this.widget.options.apiId + "]请求异常:", err)
94
98
  })
95
99
 
100
+ if (this.noteApiId) {
101
+ getListMapData(this.noteApiId, this.params).then(res => {
102
+ if (res.data.code === 0) {
103
+ console.error("charts说明服务[" + this.widget.options.apiId + "]请求失败:" + res.data.message)
104
+ } else {
105
+ if (res.data.data.rows.length > 0) {
106
+ let rows = res.data.data.rows
107
+ if (rows && rows.length > 0) {
108
+ let rowData = rows[0]
109
+ if(rowData && Object.prototype.hasOwnProperty.call(rowData, "val")){
110
+ this.chartsNote = rowData["val"]
111
+ }
112
+ }
113
+ } else {
114
+ console.warn("charts说明服务[" + this.widget.options.apiId + "]请求数据为空:" + res.data.message)
115
+ this.chartsNote = null
116
+ }
117
+ }
118
+ }).catch(err => {
119
+ console.error("charts说明服务[" + this.widget.options.apiId + "]请求异常:", err)
120
+ this.chartsNote = null
121
+ })
122
+ }
96
123
  }
97
124
  },
98
125
  computed: {
@@ -1,13 +1,13 @@
1
1
  <!-- eslint-disable -->
2
2
  <template>
3
3
  <div>
4
- <template v-for="(item, index) in widget.widgets">
5
- <component :is="getWidgetName(item)" :widget="item" :key="index" :params="params">
4
+ <div v-for="(item, index) in widget.widgets" :key="index">
5
+ <component :is="getWidgetName(item)" :widget="item" :params="params">
6
6
  <template v-for="slot in Object.keys($scopedSlots)" v-slot:[slot]="scope">
7
7
  <slot :name="slot" v-bind="scope" />
8
8
  </template>
9
9
  </component>
10
- </template>
10
+ </div>
11
11
  </div>
12
12
  </template>
13
13
  <script>
@@ -0,0 +1,87 @@
1
+ <template>
2
+ <lambo-text-obj-group-bi :text-obj-list="textList"></lambo-text-obj-group-bi>
3
+ </template>
4
+ <script>
5
+ import LamboTextObjGroupBi from "../../../pub/text/text-obj-group.vue"
6
+ import { getListMapData } from "../api/data"
7
+
8
+ export default {
9
+ name: 'BiTextGroup',
10
+ components: { LamboTextObjGroupBi },
11
+ props: {
12
+ widget: {
13
+ type: Object,
14
+ default: () => ({})
15
+ },
16
+ params: {
17
+ type: Object,
18
+ default: () => ({})
19
+ }
20
+ },
21
+ data() {
22
+ return {
23
+ textList: []
24
+ }
25
+ },
26
+ methods: {
27
+ initConfig() {
28
+ this.textList = this.widget.options.textList || []
29
+ },
30
+ async doSearch() {
31
+ if (!this.textList || this.textList.length < 1) {
32
+ this.$Message.warning("组件[" + this.widget.name + "]未配置全")
33
+ return false
34
+ }
35
+
36
+ let apiIdArr = this.textList.map(item => item.apiId) || []
37
+ const promiseArray = apiIdArr.map((apiId, index) => {
38
+ return getListMapData(apiId, this.params)
39
+ .then(res => {
40
+ return { success: true, data: res, apiId, index }
41
+ })
42
+ .catch(err => {
43
+ return { success: false, error: err, apiId, index }
44
+ })
45
+ })
46
+
47
+ try {
48
+ const results = await Promise.all(promiseArray)
49
+ results.forEach(result => {
50
+ if (result.success) {
51
+ const res = result.data
52
+ if (res.data.code === 0) {
53
+ console.error(`文字卡片的服务[${result.apiId}]调用失败:${res.data.message}`)
54
+ } else {
55
+ if (res.data.data.rows.length > 0) {
56
+ let row = res.data.data.rows[0]
57
+ if (row) {
58
+ this.$set(this.textList[result.index], 'val', row['val'])
59
+ }
60
+ }
61
+ }
62
+ } else {
63
+ console.error(`文字卡片的服务[${result.apiId}]调用异常:`, result.error)
64
+ }
65
+ })
66
+ } catch (error) {
67
+ console.error("文字卡片批量请求异常:", error)
68
+ }
69
+ }
70
+ },
71
+ created() {
72
+ console.log("text-group widget:", this.widget)
73
+ this.initConfig()
74
+ this.doSearch()
75
+ },
76
+ watch: {
77
+ params: {
78
+ handler: function (val, oldVal) {
79
+ console.log('text-group widget watch val,oldVal', val, oldVal)
80
+ this.doSearch()
81
+ },
82
+ deep: true
83
+ }
84
+ }
85
+ }
86
+ </script>
87
+ <style scoped></style>
@@ -8,6 +8,7 @@ import BiRow2 from "../layout/row2.vue"
8
8
  import BiCol from "../layout/col.vue"
9
9
  import BiDetailTable from "../table/detail-table.vue"
10
10
  import BiCharts from "../charts/index.vue"
11
+ import BiTextGroup from '../text/text-group.vue';
11
12
 
12
13
  /**
13
14
  * Strictly define the order to prevent circular references. For component reuse, copy new components instead of direct references.
@@ -18,6 +19,7 @@ export const WIDGET_MAP = {
18
19
  "33": BiCol,
19
20
  "40": BiContainerCard,
20
21
  "41": BiNumIndex,
22
+ "46": BiTextGroup,
21
23
  "50": BiPagingTable,
22
24
  "51": BiDetailTable,
23
25
  "60": BiCharts,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lambo-design-bi",
3
- "version": "0.0.175",
3
+ "version": "0.0.177",
4
4
  "description": "Vue2 BI 数据可视化组件库",
5
5
  "main": "index.js",
6
6
  "author": "finch",
@@ -1,5 +1,8 @@
1
1
  <template>
2
- <div ref="chartContainer" :style="{ width: '100%', height: height }"></div>
2
+ <div class="charts-with-note">
3
+ <div ref="chartContainer" :style="{ width: '100%', height: height }"></div>
4
+ <p v-if="chartsNote" v-html="chartsNote"></p>
5
+ </div>
3
6
  </template>
4
7
  <script>
5
8
  import * as echarts from 'echarts'
@@ -14,6 +17,10 @@ export default {
14
17
  height: {
15
18
  type: String,
16
19
  default: '300px'
20
+ },
21
+ chartsNote: {
22
+ type: String,
23
+ default: ''
17
24
  }
18
25
  },
19
26
  data() {
@@ -27,7 +34,7 @@ export default {
27
34
  watch: {
28
35
  options: {
29
36
  handler(newOptions) {
30
- console.log("watch options newOptions:", newOptions)
37
+ console.log("watch options newOptions:", newOptions)
31
38
  if (this.chart) {
32
39
  this.chart.setOption(newOptions, true)
33
40
  }
@@ -38,13 +45,21 @@ export default {
38
45
  },
39
46
  methods: {
40
47
  initChart() {
41
- if (!this.chart) {
48
+ this.$nextTick(() => {
42
49
  const container = this.$refs.chartContainer
43
50
  if (container) {
44
51
  this.chart = echarts.init(container)
45
52
  this.chart.setOption(this.options || {})
53
+
54
+ this.chart.resize()
55
+ const resizeChart = () => {
56
+ if (this.chart) {
57
+ this.chart.resize();
58
+ }
59
+ }
60
+ window.addEventListener('resize', resizeChart);
46
61
  }
47
- }
62
+ })
48
63
  }
49
64
  },
50
65
  beforeDestroy() {
@@ -55,4 +70,10 @@ export default {
55
70
  }
56
71
  }
57
72
  </script>
58
- <style scoped></style>
73
+ <style scoped>
74
+ .chart-with-note {
75
+ width: 100%;
76
+ display: flex;
77
+ flex-direction: column;
78
+ }
79
+ </style>
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <lambo-charts :options="getOptions" :height="height"></lambo-charts>
2
+ <lambo-charts :options="getOptions" :height="height" :charts-note="chartsNote"></lambo-charts>
3
3
  </template>
4
4
  <script>
5
5
  import LamboCharts from "../echarts.vue"
@@ -28,6 +28,10 @@ export default {
28
28
  height: {
29
29
  type: String,
30
30
  default: '300px'
31
+ },
32
+ chartsNote: {
33
+ type: String,
34
+ default: ''
31
35
  }
32
36
  },
33
37
  data() {
@@ -168,10 +168,7 @@ export function getECharts(type, dataX, dataY, dataDim) {
168
168
  },
169
169
  },
170
170
  grid: {
171
- top: '10%',
172
- left: '2%',
173
- bottom: '1%',
174
- containLabel: true
171
+ top: '5px', left: '0px', right: '10px', bottom: '0px', containLabel: true
175
172
  },
176
173
  xAxis: {
177
174
  type: 'category',
@@ -287,10 +284,7 @@ export function getECharts(type, dataX, dataY, dataDim) {
287
284
  },
288
285
  },
289
286
  grid: {
290
- top: '10%',
291
- left: '2%',
292
- bottom: '1%',
293
- containLabel: true
287
+ top: '5px', left: '0px', right: '10px', bottom: '0px', containLabel: true
294
288
  },
295
289
  xAxis: {
296
290
  type: 'category',
@@ -365,10 +359,7 @@ export function getECharts(type, dataX, dataY, dataDim) {
365
359
  }
366
360
  },
367
361
  grid: {
368
- top: '10%',
369
- left: '2%',
370
- bottom: '1%',
371
- containLabel: true
362
+ top: '5px', left: '0px', right: '10px', bottom: '0px', containLabel: true
372
363
  },
373
364
  calculable: true,
374
365
  xAxis: {
@@ -492,10 +483,7 @@ export function getECharts(type, dataX, dataY, dataDim) {
492
483
  }
493
484
  },
494
485
  grid: {
495
- top: '10%',
496
- left: '2%',
497
- bottom: '1%',
498
- containLabel: true
486
+ top: '5px', left: '0px', right: '10px', bottom: '0px', containLabel: true
499
487
  },
500
488
  legend: {
501
489
  icon: 'roundRect',
@@ -609,10 +597,7 @@ export function getECharts(type, dataX, dataY, dataDim) {
609
597
  data: dataDim
610
598
  },
611
599
  grid: {
612
- top: '10%',
613
- left: '2%',
614
- bottom: '1%',
615
- containLabel: true
600
+ top: '5px', left: '0px', right: '10px', bottom: '0px', containLabel: true
616
601
  },
617
602
  xAxis: {
618
603
  type: 'category',
@@ -722,10 +707,7 @@ export function getECharts(type, dataX, dataY, dataDim) {
722
707
  data: dataDim
723
708
  },
724
709
  grid: {
725
- top: '10%',
726
- left: '2%',
727
- bottom: '1%',
728
- containLabel: true
710
+ top: '5px', left: '0px', right: '10px', bottom: '0px', containLabel: true
729
711
  },
730
712
  xAxis: {
731
713
  type: 'value',
@@ -814,10 +796,7 @@ export function getECharts(type, dataX, dataY, dataDim) {
814
796
  }
815
797
  },
816
798
  grid: {
817
- top: '10%',
818
- left: '2%',
819
- bottom: '1%',
820
- containLabel: true
799
+ top: '5px', left: '0px', right: '10px', bottom: '0px', containLabel: true
821
800
  },
822
801
  legend: {
823
802
  icon: 'roundRect',
@@ -931,10 +910,7 @@ export function getECharts(type, dataX, dataY, dataDim) {
931
910
  data: dataDim
932
911
  },
933
912
  grid: {
934
- top: '10%',
935
- left: '2%',
936
- bottom: '1%',
937
- containLabel: true
913
+ top: '5px', left: '0px', right: '10px', bottom: '0px', containLabel: true
938
914
  },
939
915
  xAxis: {
940
916
  type: 'value',
@@ -1024,10 +1000,7 @@ export function getECharts(type, dataX, dataY, dataDim) {
1024
1000
  data: dataDim
1025
1001
  },
1026
1002
  grid: {
1027
- top: '10%',
1028
- left: '2%',
1029
- bottom: '1%',
1030
- containLabel: true
1003
+ top: '5px', left: '0px', right: '10px', bottom: '0px', containLabel: true
1031
1004
  },
1032
1005
  xAxis: {
1033
1006
  type: 'value',
@@ -1101,6 +1074,9 @@ export function getECharts(type, dataX, dataY, dataDim) {
1101
1074
  trigger: 'item',
1102
1075
  formatter: '{b}:<br/> {d}%<br/>{c}'
1103
1076
  },
1077
+ grid: {
1078
+ top: '5px', left: '0px', right: '10px', bottom: '0px', containLabel: true
1079
+ },
1104
1080
  legend: {
1105
1081
  icon: 'circle',
1106
1082
  itemWidth: 8,
@@ -1399,7 +1375,7 @@ export function getECharts(type, dataX, dataY, dataDim) {
1399
1375
  sum += dataY[0][i]
1400
1376
  }
1401
1377
  let title33 = ''
1402
- if(dataDim && dataDim.length > 0){
1378
+ if (dataDim && dataDim.length > 0) {
1403
1379
  title33 = formatTitle(dataDim[0])
1404
1380
  }
1405
1381
  opt = {
@@ -1523,7 +1499,7 @@ export function getECharts(type, dataX, dataY, dataDim) {
1523
1499
  });
1524
1500
  }
1525
1501
  let title34 = ''
1526
- if(dataDim && dataDim.length > 0){
1502
+ if (dataDim && dataDim.length > 0) {
1527
1503
  title34 = formatTitle(dataDim[0])
1528
1504
  }
1529
1505
  opt = {
@@ -1835,10 +1811,7 @@ export function getECharts(type, dataX, dataY, dataDim) {
1835
1811
  backgroundColor: '#fff',
1836
1812
  color: colors,
1837
1813
  grid: {
1838
- top: '15%',
1839
- bottom: '54%',
1840
- left: "30%",
1841
- containLabel: false
1814
+ top: '5px', left: '0px', right: '10px', bottom: '0px', containLabel: true
1842
1815
  },
1843
1816
  legend: {
1844
1817
  icon: 'circle',
@@ -2016,10 +1989,7 @@ export function getECharts(type, dataX, dataY, dataDim) {
2016
1989
  backgroundColor: '#fff',
2017
1990
  color: colors,
2018
1991
  grid: {
2019
- top: '15%',
2020
- bottom: '54%',
2021
- left: "30%",
2022
- containLabel: false
1992
+ top: '5px', left: '0px', right: '10px', bottom: '0px', containLabel: true
2023
1993
  },
2024
1994
  legend: {
2025
1995
  icon: 'circle',
@@ -0,0 +1,39 @@
1
+ <template>
2
+ <div>
3
+ <div class="text-obj-div" v-for="(item, index) in textObjList" :key="index">
4
+ <lambo-text-obj-bi :title="item.title" :title-style="item.titleStyle || { backgroundColor: defaultTitleColor }"
5
+ :val="item.val" :val-style="item.valStyle || {}"></lambo-text-obj-bi>
6
+ </div>
7
+ </div>
8
+ </template>
9
+ <script>
10
+ import LamboTextObjBi from './text-obj.vue'
11
+ import { BLUE_COLOR1 } from '../theme/color'
12
+
13
+ export default {
14
+ name: 'LamboTextObjGroupBi',
15
+ components: { LamboTextObjBi },
16
+ props: {
17
+ textObjList: {
18
+ type: Array,
19
+ default: () => []
20
+ }
21
+ },
22
+ data() {
23
+ return {
24
+ defaultTitleColor: BLUE_COLOR1
25
+ }
26
+ }
27
+ }
28
+ </script>
29
+ <style scoped>
30
+ .text-obj-div {
31
+ display: flex;
32
+ flex-direction: column;
33
+ margin-bottom: 10px;
34
+ }
35
+
36
+ .text-obj-div:last-child {
37
+ margin-bottom: 0;
38
+ }
39
+ </style>
@@ -0,0 +1,64 @@
1
+ <template>
2
+ <div class="text-obj-container">
3
+ <div v-if="title" class="text-title" :style="titleStyle">
4
+ {{ title }}
5
+ </div>
6
+ <p class="text-content" :style="valStyle || {}" v-html="val">
7
+ </p>
8
+ </div>
9
+ </template>
10
+ <script>
11
+ import { BLUE_COLOR1 } from '../theme/color'
12
+
13
+ export default {
14
+ name: 'LamboTextObjBi',
15
+ props: {
16
+ title: {
17
+ type: String,
18
+ default: ""
19
+ },
20
+ val: {
21
+ type: String,
22
+ default: ""
23
+ },
24
+ // 标题样式对象
25
+ titleStyle: {
26
+ type: Object,
27
+ default: () => ({
28
+ backgroundColor: BLUE_COLOR1
29
+ })
30
+ },
31
+ // 内容样式对象
32
+ valStyle: {
33
+ type: Object,
34
+ default: () => ({})
35
+ }
36
+ }
37
+ }
38
+ </script>
39
+ <style scoped>
40
+ .text-obj-container {
41
+ display: flex;
42
+ flex-direction: column;
43
+ }
44
+
45
+ .text-title {
46
+ width: 150px;
47
+ height: 30px;
48
+ line-height: 30px;
49
+ font-size: 14px;
50
+ font-weight: bold;
51
+ color: #FFFFFF;
52
+ text-align: center;
53
+ border-radius: 6px;
54
+ z-index: 1;
55
+ }
56
+
57
+ .text-content {
58
+ margin-top: -14px;
59
+ padding: 20px 5px 15px 5px;
60
+ border-radius: 5px;
61
+ line-height: 1.6;
62
+ font-size: 14px;
63
+ }
64
+ </style>
@@ -1,3 +1,14 @@
1
1
 
2
2
  // 这个color要根据lambo-design和ant-design去合并修改
3
- export const biColorArr = ['#2D8CF0', '#45D5D0', '#FFBF37', '#FD7336', '#655EF3', '#47D791', '#F85968', '#33BFF3', '#C74EF4', '#F84CEE', '#F5D000', '#B7E518']
3
+ export const biColorArr = ['#57a3f3', '#47cb89', '#FFBF37', '#FD7336', '#655EF3', '#47D791', '#F85968', '#33BFF3', '#C74EF4', '#F84CEE', '#F5D000', '#B7E518']
4
+
5
+ export const PRIMARY_COLOR = '#488aff'
6
+ export const SUCC_COLOR = '#19be6b'
7
+ export const WARNING_COLOR = '#ff9900'
8
+ export const ERR_COLOR = '#ed4014'
9
+
10
+
11
+ export const GREEN_COLOR1 = '#21DA2E'
12
+ export const BLUE_COLOR1 = '#1E58F8'
13
+
14
+ export const LIGHT_BLUE_BG_COLOR1 = '#F3F8FE'