lambo-design-bi 0.0.224 → 0.0.226

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,12 +1,18 @@
1
1
  <template>
2
2
  <lambo-indicator-card-bi
3
- :has-title="(widget.options && widget.options.title && widget.options.title.length > 0) ? true : false">
4
- <template slot="content-title" v-if="(widget.options.title && widget.options.title.length > 0)">
5
- <div>{{ widget.options.title }}</div>
3
+ :has-title="(cardOptions.title && cardOptions.title.length > 0) ? true : false"
4
+ :has-extend="isTabsLayout">
5
+ <template slot="content-title" v-if="(cardOptions.title && cardOptions.title.length > 0)">
6
+ <div>{{ cardOptions.title }}</div>
6
7
  <div class="card-subtitle" v-if="subTitle">{{ subTitle }}</div>
7
8
  </template>
9
+ <template slot="content-extend" v-if="isTabsLayout">
10
+ <RadioGroup v-model="activeWidgetIndex" type="button" size="small" class="card-tabs-radio">
11
+ <Radio v-for="(item, index) in childWidgets" :key="index" :label="index">{{ getWidgetLabel(item, index) }}</Radio>
12
+ </RadioGroup>
13
+ </template>
8
14
  <div :style="containerStyle || {}">
9
- <div v-for="(item, index) in widget.widgets" :key="index">
15
+ <div v-for="(item, index) in visibleWidgets" :key="getWidgetKey(item, index)">
10
16
  <component :is="getWidgetName(item)" :widget="item" :params="params">
11
17
  <template v-for="slot in Object.keys($scopedSlots)" v-slot:[slot]="scope">
12
18
  <slot :name="slot" v-bind="scope" />
@@ -37,18 +43,42 @@ export default {
37
43
  data() {
38
44
  return {
39
45
  containerStyle: {},
40
- subTitle: null
46
+ subTitle: null,
47
+ activeWidgetIndex: 0
48
+ }
49
+ },
50
+ computed: {
51
+ cardOptions() {
52
+ return Object.assign({}, this.widget.options || {}, this.widget.optsion || {})
53
+ },
54
+ isTabsLayout() {
55
+ return this.cardOptions.layout === 'tabs'
56
+ },
57
+ childWidgets() {
58
+ return this.widget.widgets || []
59
+ },
60
+ visibleWidgets() {
61
+ if (!this.isTabsLayout) {
62
+ return this.childWidgets
63
+ }
64
+ return this.childWidgets[this.activeWidgetIndex] ? [this.childWidgets[this.activeWidgetIndex]] : []
41
65
  }
42
66
  },
43
67
  methods: {
44
68
  getWidgetName,
69
+ getWidgetLabel(item, index) {
70
+ return item.name || (item.options && item.options.title) || `组件${index + 1}`
71
+ },
72
+ getWidgetKey(item, index) {
73
+ return this.isTabsLayout ? `${this.activeWidgetIndex}_${item.id || index}` : (item.id || index)
74
+ },
45
75
  initConfig() {
46
- if (this.widget.options) {
47
- if (Object.prototype.hasOwnProperty.call(this.widget.options, "subTitle")) {
48
- this.subTitle = this.widget.options["subTitle"] || ''
76
+ if (this.cardOptions) {
77
+ if (Object.prototype.hasOwnProperty.call(this.cardOptions, "subTitle")) {
78
+ this.subTitle = this.cardOptions["subTitle"] || ''
49
79
  }
50
- if (Object.prototype.hasOwnProperty.call(this.widget.options, "style")) {
51
- this.containerStyle = parseStyleStr(this.widget.options["style"] || {}) || {}
80
+ if (Object.prototype.hasOwnProperty.call(this.cardOptions, "style")) {
81
+ this.containerStyle = parseStyleStr(this.cardOptions["style"] || {}) || {}
52
82
  }
53
83
  }
54
84
  }
@@ -59,6 +89,16 @@ export default {
59
89
  },
60
90
  mounted() {
61
91
 
92
+ },
93
+ watch: {
94
+ 'widget.widgets': {
95
+ handler(val) {
96
+ if (this.activeWidgetIndex >= (val || []).length) {
97
+ this.activeWidgetIndex = 0
98
+ }
99
+ },
100
+ deep: true
101
+ }
62
102
  }
63
103
  }
64
104
  </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lambo-design-bi",
3
- "version": "0.0.224",
3
+ "version": "0.0.226",
4
4
  "description": "Vue2 BI 数据可视化组件库",
5
5
  "main": "index.js",
6
6
  "author": "finch",