@cloudbase/weda-ui-mp 3.26.2 → 3.27.0

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.
@@ -130,7 +130,7 @@ class EchartBar extends EchartBase {
130
130
  if (this.config.series.length > 0 && setColor && setColor.length > 0) {
131
131
  let i = 0;
132
132
  this.config.series.forEach((itemSeries) => {
133
- itemSeries.itemStyle.color = setColor[i % 6];
133
+ itemSeries.itemStyle.color = setColor[i % (setColor?.length || 1)];
134
134
  i = i + 1;
135
135
  });
136
136
  }
@@ -128,7 +128,7 @@ class EchartLine extends EchartBase {
128
128
  if (this.config.series.length > 0 && setColor && setColor.length > 0) {
129
129
  let i = 0;
130
130
  this.config.series.forEach((itemSeries) => {
131
- lodashSet(itemSeries, 'itemStyle.color', setColor[i % 6]);
131
+ lodashSet(itemSeries, 'itemStyle.color', setColor[i % (setColor?.length || 1)]);
132
132
  i = i + 1;
133
133
  });
134
134
  }
@@ -105,7 +105,7 @@ export function transform(chartType, dataInput, chartInput) {
105
105
  chartType === 'pie'
106
106
  ? undefined
107
107
  : {
108
- color: chartInput?.setColor?.[idx % 6] ?? null,
108
+ color: chartInput?.setColor?.[idx % (chartInput?.setColor?.length || 1)] ?? null,
109
109
  },
110
110
  data:
111
111
  chartType === 'pie'
@@ -165,7 +165,7 @@ export function transform(chartType, dataInput, chartInput) {
165
165
  chartType === 'pie'
166
166
  ? undefined
167
167
  : {
168
- color: chartInput?.setColor?.[idx % 6] ?? null,
168
+ color: chartInput?.setColor?.[idx % (chartInput?.setColor?.length || 1)] ?? null,
169
169
  },
170
170
  data: [],
171
171
  });
@@ -1,8 +1,10 @@
1
1
  import { callDataSource, callWedaApi } from '../../../utils/tcb';
2
+ import { commonCompBehavior } from '../../../utils/common-behavior';
2
3
 
3
4
  const DEFAULT_VAL = 1000;
4
5
 
5
6
  Component({
7
+ behaviors: [commonCompBehavior],
6
8
  properties: {
7
9
  className: {
8
10
  type: String,
@@ -62,8 +64,18 @@ Component({
62
64
  },
63
65
  data: {
64
66
  count: DEFAULT_VAL,
67
+ value: DEFAULT_VAL,
65
68
  },
66
69
  methods: {
70
+ updateWidgetAPI: function () {
71
+ const { label, unit, count, value } = this.data;
72
+ this.setReadonlyAttributes?.({
73
+ label,
74
+ unit,
75
+ calculatedValue: count,
76
+ value,
77
+ });
78
+ },
67
79
  scientificToNumber: function (num) {
68
80
  const str = num;
69
81
  const reg = /^([-]?\d+\.?\d*)(e)([-|+]?\d+)$/;
@@ -206,17 +218,20 @@ Component({
206
218
  count: this.properties.isShowUnit
207
219
  ? this.formatNumber(val / this.properties.unit, this.properties.decimalDigits)
208
220
  : val,
221
+ value: val,
209
222
  });
210
223
  } else {
211
224
  // 返回数据为空 使用 0
212
225
  this.setData({
213
226
  count: this.formatNumber(0, this.properties.decimalDigits),
227
+ value: 0,
214
228
  });
215
229
  }
216
230
  } else {
217
231
  // 没有配置数据使用默认数据
218
232
  this.setData({
219
233
  count: this.formatNumber(DEFAULT_VAL, this.properties.decimalDigits),
234
+ value: DEFAULT_VAL,
220
235
  });
221
236
  }
222
237
  },
@@ -224,15 +239,20 @@ Component({
224
239
  lifetimes: {
225
240
  attached() {
226
241
  this._fetchData();
242
+ this.updateWidgetAPI();
227
243
  },
228
244
  },
229
245
  attached() {
230
246
  this._fetchData();
247
+ this.updateWidgetAPI();
231
248
  },
232
249
  observers: {
233
250
  // 当参数变化时
234
251
  'datasource,filterData,field,operationType,label,isCountEmpty,isShowUnit,unit,decimalDigits,suffix': function () {
235
252
  this._fetchData();
236
253
  },
254
+ 'unit,label,count,value': function () {
255
+ this.updateWidgetAPI();
256
+ },
237
257
  },
238
258
  });
@@ -563,7 +563,10 @@ Component({
563
563
  value,
564
564
  ) {
565
565
  const isDataModel = !['connector', 'custom-connector', 'expression'].includes(datasourceType);
566
- if (isDataModel && formTypeWithInitValue && _id && !equal(_id, this.data._preDataId)) {
566
+ if (isDataModel && !formTypeWithInitValue.includes(formType)) {
567
+ this.setData({ _preDataId: undefined });
568
+ }
569
+ if (isDataModel && formTypeWithInitValue.includes(formType) && _id && !equal(_id, this.data._preDataId)) {
567
570
  this.setData({ isLoadingData: true });
568
571
  }
569
572
  clearTimeout(this.data._delayRef.current.initTimer);
@@ -576,7 +579,7 @@ Component({
576
579
  }
577
580
  }
578
581
  if (isDataModel) {
579
- if (_id && !equal(_id, this.data._preDataId)) {
582
+ if (formTypeWithInitValue.includes(formType) && _id && !equal(_id, this.data._preDataId)) {
580
583
  this.setData({ _preDataId: _id });
581
584
  this._initValue();
582
585
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "miniprogram": "./",
4
4
  "packageManager": "yarn@3.0.2",
5
5
  "dependencies": {},
6
- "version": "3.26.2",
6
+ "version": "3.27.0",
7
7
  "main": "./",
8
8
  "publishConfig": {
9
9
  "access": "public"