@cloudbase/weda-ui-mp 3.14.2 → 3.15.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.
Files changed (48) hide show
  1. package/components/chart/bar/index.js +4 -20
  2. package/components/chart/bar/index.wxml +1 -1
  3. package/components/chart/common/data-transform.js +6 -16
  4. package/components/chart/ec-canvas/ec-canvas.js +35 -37
  5. package/components/chart/ec-canvas/ec-canvas.wxml +1 -1
  6. package/components/chart/line/index.js +4 -20
  7. package/components/chart/line/index.wxml +1 -1
  8. package/components/chart/pie/index.js +4 -20
  9. package/components/chart/pie/index.wxml +1 -1
  10. package/components/form/form/wd-form.wxss +15 -0
  11. package/components/form/select/dropdown-select/index.js +41 -58
  12. package/components/form/select/dropdown-select/index.wxml +1 -1
  13. package/components/form/select/dropdown-select/index.wxss +1 -2
  14. package/components/form/select/index.js +1 -1
  15. package/components/form/selectMultiple/dropdown-select/index.js +10 -20
  16. package/components/form/selectMultiple/dropdown-select/index.wxss +2 -6
  17. package/components/form/selectMultiple/index.js +94 -45
  18. package/components/form/uploader/index.js +7 -15
  19. package/components/form/uploaderFile/index.js +3 -2
  20. package/components/formdetail/index.js +9 -28
  21. package/components/listView/index.js +1 -1
  22. package/components/listView/index.wxml +5 -5
  23. package/components/listView/index.wxss +20 -67
  24. package/components/qrcode/index.js +3 -4
  25. package/components/wd-form/index.js +72 -163
  26. package/components/wd-form/wd-form.wxss +15 -0
  27. package/components/wd-form-item/wd-form-item.wxss +15 -0
  28. package/components/wd-form-item-obj/wd-form-item.wxss +15 -0
  29. package/components/wd-input/inner-input/index.js +22 -56
  30. package/components/wd-input/inner-input/index.wxml +6 -2
  31. package/components/wd-input/inner-input/wd-input.wxss +15 -0
  32. package/components/wd-progress/wd-progress.wxss +15 -0
  33. package/components/wd-rating/wd-rating.wxss +15 -0
  34. package/components/wd-select/index.js +14 -10
  35. package/components/wd-select/index.json +1 -1
  36. package/components/wd-select/index.wxml +3 -0
  37. package/components/wd-select/select/formats-util.js +9 -0
  38. package/components/wd-select/select/index.js +545 -0
  39. package/components/wd-select/select/index.json +8 -0
  40. package/components/wd-select/select/index.wxml +26 -0
  41. package/components/wd-select/select/index.wxss +5 -0
  42. package/components/wd-select-multiple/index.js +13 -5
  43. package/components/wd-select-multiple/index.wxml +3 -0
  44. package/components/wd-switch/wd-switch.wxss +15 -0
  45. package/components/wd-tag-select/wd-tag-select.wxss +15 -0
  46. package/package.json +1 -1
  47. package/utils/getModelParams.js +27 -1
  48. package/utils/tcb.js +11 -2
@@ -220,10 +220,6 @@ Component({
220
220
  },
221
221
  data: {
222
222
  ec: {},
223
- canvas_id: {
224
- type: String,
225
- value: `canvas_line_${Date.now()}_${Math.random() * 100}`,
226
- },
227
223
  },
228
224
  lifetimes: {
229
225
  attached() {
@@ -269,22 +265,11 @@ Component({
269
265
  return options ?? [];
270
266
  } else {
271
267
  if (this.properties.dataSourceType === 'variable') {
272
- const result = transform(
273
- 'bar',
274
- this.properties.datasourceVariable,
275
- this.properties
276
- );
268
+ const result = transform('bar', this.properties.datasourceVariable, this.properties);
277
269
  return result ?? [];
278
270
  } else if (this.properties.dataSourceType === 'custom-connector') {
279
- const { connector, connectorMethod, connectorParams } =
280
- this.properties;
281
- if (
282
- !(
283
- connector?.datasource?.name &&
284
- connectorMethod?.name &&
285
- connectorParams
286
- )
287
- ) {
271
+ const { connector, connectorMethod, connectorParams } = this.properties;
272
+ if (!(connector?.datasource?.name && connectorMethod?.name && connectorParams)) {
288
273
  console.warn('Chart 参数不完整');
289
274
  }
290
275
  const res = await callDataSource({
@@ -299,6 +284,7 @@ Component({
299
284
  },
300
285
  initData() {
301
286
  this.setData({
287
+ id: this.id,
302
288
  ec: {
303
289
  onInit: this.initChart.bind(this),
304
290
  },
@@ -312,7 +298,6 @@ Component({
312
298
  });
313
299
  canvas.setChart(objEchart);
314
300
  const options = await this.getData();
315
- console.log('设置前参数bar', options);
316
301
  objEchart.setOption(options, true);
317
302
  this._chart = objEchart;
318
303
  return objEchart;
@@ -324,7 +309,6 @@ Component({
324
309
  const canvas = this.selectComponent(`#canvas_${this.properties.id}`);
325
310
  canvas?.init();
326
311
  const options = await this.getData();
327
- console.log('设置前参数bar', options);
328
312
  this._chart && this._chart.setOption(options, true);
329
313
  },
330
314
  },
@@ -1 +1 @@
1
- <view wx:if="ec" class="{{className}} ec_container" style="{{style}}" id="{{id}}"> <ec-canvas id="{{'canvas_'+id}}" canvas-id="{{canvas_id}}" ec="{{ ec }}" /> </view>
1
+ <view wx:if="ec" class="{{className}} ec_container" style="{{style}}" id="{{id}}"> <ec-canvas id="{{'canvas_'+id}}" canvasId="{{'canvas_'+id}}" ec="{{ ec }}" /> </view>
@@ -2,10 +2,7 @@ import lodashSet from 'lodash.set';
2
2
  import { isNil } from '../../../utils/lodash';
3
3
 
4
4
  export const checkIsNewData = (props) => {
5
- return (
6
- Object.keys(props.dataSource ?? {}).length === 0 &&
7
- Object.keys(props['dataModel'] ?? {}).length > 0
8
- );
5
+ return Object.keys(props.dataSource ?? {}).length === 0 && Object.keys(props['dataModel'] ?? {}).length > 0;
9
6
  };
10
7
 
11
8
  export function transform(chartType, dataInput, chartInput) {
@@ -56,9 +53,7 @@ export function transform(chartType, dataInput, chartInput) {
56
53
 
57
54
  const finalDataInput = (dataInput ?? [])?.filter((item) => {
58
55
  if (!chartInput.xIsCountEmpty) {
59
- return (
60
- item.XLabel['Value'] !== undefined && item.XLabel['Value'] !== null
61
- );
56
+ return item.XLabel['Value'] !== undefined && item.XLabel['Value'] !== null;
62
57
  }
63
58
 
64
59
  return true;
@@ -100,13 +95,9 @@ export function transform(chartType, dataInput, chartInput) {
100
95
  if (!series[idx]) {
101
96
  series[idx] = {
102
97
  type: chartType,
103
- name:
104
- chartType === 'pie'
105
- ? undefined
106
- : eachYaxis.Cn_Name ?? eachYaxis.Name,
98
+ name: chartType === 'pie' ? undefined : eachYaxis.Cn_Name ?? eachYaxis.Name,
107
99
  stack: chartInput.isPile ? 'pile' : undefined,
108
- showSymbol:
109
- chartType === 'pie' ? undefined : chartInput.isSeriesShowSymbol,
100
+ showSymbol: chartType === 'pie' ? undefined : chartInput.isSeriesShowSymbol,
110
101
  label: {
111
102
  show: chartInput.isSeriesShowSymbol, // 老逻辑这么来的
112
103
  },
@@ -166,8 +157,7 @@ export function transform(chartType, dataInput, chartInput) {
166
157
  type: chartType,
167
158
  name: groupName,
168
159
  stack: chartInput.isPile ? 'pile' : undefined,
169
- showSymbol:
170
- chartType === 'pie' ? undefined : chartInput.isSeriesShowSymbol,
160
+ showSymbol: chartType === 'pie' ? undefined : chartInput.isSeriesShowSymbol,
171
161
  label: {
172
162
  show: chartInput.isSeriesShowSymbol, // 老逻辑这么来的
173
163
  },
@@ -201,7 +191,7 @@ export function transform(chartType, dataInput, chartInput) {
201
191
  });
202
192
  }
203
193
 
204
- console.log(dataInput, chartInput, 'TRANSFORM');
194
+ // console.log(dataInput, chartInput, 'TRANSFORM');
205
195
 
206
196
  if (chartType === 'bar' || chartType === 'line') {
207
197
  const xAxis = {
@@ -48,7 +48,7 @@ Component({
48
48
  data: {
49
49
  isUseNewCanvas: false,
50
50
  },
51
-
51
+ domObserver: null,
52
52
  ready: function () {
53
53
  // Disable prograssive because drawImage doesn't support DOM as parameter
54
54
  // See https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.drawImage.html
@@ -67,14 +67,10 @@ Component({
67
67
  if (!this.data.ec) {
68
68
  console.warn(
69
69
  '组件需绑定 ec 变量,例:<ec-canvas id="mychart-dom-bar" ' +
70
- 'canvas-id="mychart-bar" ec="{{ ec }}"></ec-canvas>'
70
+ 'canvas-id="mychart-bar" ec="{{ ec }}"></ec-canvas>',
71
71
  );
72
72
  return;
73
73
  }
74
-
75
- if (!this.data.ec.lazyLoad) {
76
- this.init();
77
- }
78
74
  },
79
75
 
80
76
  methods: {
@@ -100,13 +96,11 @@ Component({
100
96
  console.error(
101
97
  '微信基础库版本过低,需大于等于 1.9.91。' +
102
98
  '参见:https://github.com/ecomfe/echarts-for-weixin' +
103
- '#%E5%BE%AE%E4%BF%A1%E7%89%88%E6%9C%AC%E8%A6%81%E6%B1%82'
99
+ '#%E5%BE%AE%E4%BF%A1%E7%89%88%E6%9C%AC%E8%A6%81%E6%B1%82',
104
100
  );
105
101
  return;
106
102
  } else {
107
- console.warn(
108
- '建议将微信基础库调整大于等于2.9.0版本。升级后绘图将有更好性能'
109
- );
103
+ console.warn('建议将微信基础库调整大于等于2.9.0版本。升级后绘图将有更好性能');
110
104
  this.initByOldWay(callback);
111
105
  }
112
106
  }
@@ -128,16 +122,8 @@ Component({
128
122
  .boundingClientRect(async (res) => {
129
123
  if (typeof callback === 'function') {
130
124
  this.chart = callback(canvas, res.width, res.height, canvasDpr);
131
- } else if (
132
- this.data.ec &&
133
- typeof this.data.ec.onInit === 'function'
134
- ) {
135
- this.chart = await this.data.ec.onInit(
136
- canvas,
137
- res.width,
138
- res.height,
139
- canvasDpr
140
- );
125
+ } else if (this.data.ec && typeof this.data.ec.onInit === 'function') {
126
+ this.chart = await this.data.ec.onInit(canvas, res.width, res.height, canvasDpr);
141
127
  } else {
142
128
  this.triggerEvent('init', {
143
129
  canvas: canvas,
@@ -154,7 +140,7 @@ Component({
154
140
  // version >= 2.9.0:使用新的方式初始化
155
141
  const query = wx.createSelectorQuery().in(this);
156
142
  query
157
- .select('.ec-canvas')
143
+ .select(`#${this.data.canvasId}`)
158
144
  .fields({ node: true, size: true })
159
145
  .exec(async (res) => {
160
146
  const canvasNode = res[0].node;
@@ -166,28 +152,15 @@ Component({
166
152
 
167
153
  const ctx = canvasNode.getContext('2d');
168
154
 
169
- const canvas = new WxCanvas(
170
- ctx,
171
- this.data.canvasId,
172
- true,
173
- canvasNode
174
- );
155
+ const canvas = new WxCanvas(ctx, this.data.canvasId, true, canvasNode);
175
156
  echarts.setCanvasCreator(() => {
176
157
  return canvas;
177
158
  });
178
159
 
179
160
  if (typeof callback === 'function') {
180
161
  this.chart = callback(canvas, canvasWidth, canvasHeight, canvasDpr);
181
- } else if (
182
- this.data.ec &&
183
- typeof this.data.ec.onInit === 'function'
184
- ) {
185
- this.chart = await this.data.ec.onInit(
186
- canvas,
187
- canvasWidth,
188
- canvasHeight,
189
- canvasDpr
190
- );
162
+ } else if (this.data.ec && typeof this.data.ec.onInit === 'function') {
163
+ this.chart = await this.data.ec.onInit(canvas, canvasWidth, canvasHeight, canvasDpr);
191
164
  } else {
192
165
  this.triggerEvent('init', {
193
166
  canvas: canvas,
@@ -196,6 +169,8 @@ Component({
196
169
  dpr: canvasDpr,
197
170
  });
198
171
  }
172
+
173
+ this.domObserver && this.domObserver.disconnect();
199
174
  });
200
175
  },
201
176
  canvasToTempFilePath(opt) {
@@ -264,6 +239,29 @@ Component({
264
239
  handler.processGesture(wrapTouch(e), 'end');
265
240
  }
266
241
  },
242
+
243
+ // 监听模块曝光
244
+ observeModuleExpose() {
245
+ this.domObserver && this.domObserver.disconnect();
246
+ this.domObserver = wx.createIntersectionObserver(this);
247
+ this.domObserver.relativeToViewport().observe(`#${this.data.canvasId}`, (res) => {
248
+ // 当页面出现图表时再绘制图表,避免出现白屏
249
+ if (res.intersectionRatio) {
250
+ this.init();
251
+ }
252
+ });
253
+ },
254
+ },
255
+ lifetimes: {
256
+ attached() {
257
+ // 在组件实例进入页面节点树时执行
258
+ if (!this.data.ec.lazyLoad) {
259
+ this.observeModuleExpose();
260
+ }
261
+ },
262
+ detached() {
263
+ this.domObserver && this.domObserver.disconnect();
264
+ },
267
265
  },
268
266
  });
269
267
 
@@ -1,4 +1,4 @@
1
1
  <!-- 新的:接口对齐了H5 -->
2
- <canvas wx:if="{{isUseNewCanvas}}" type="2d" class="ec-canvas" canvas-id="{{ canvasId }}" bindinit="init" bindtouchstart="{{ ec.disableTouch ? '' : 'touchStart' }}" bindtouchmove="{{ ec.disableTouch ? '' : 'touchMove' }}" bindtouchend="{{ ec.disableTouch ? '' : 'touchEnd' }}"></canvas>
2
+ <canvas wx:if="{{isUseNewCanvas}}" type="2d" class="ec-canvas" id="{{canvasId}}" canvas-id="{{ canvasId }}" bindinit="init" bindtouchstart="{{ ec.disableTouch ? '' : 'touchStart' }}" bindtouchmove="{{ ec.disableTouch ? '' : 'touchMove' }}" bindtouchend="{{ ec.disableTouch ? '' : 'touchEnd' }}"></canvas>
3
3
  <!-- 旧的 -->
4
4
  <canvas wx:else class="ec-canvas" canvas-id="{{ canvasId }}" bindinit="init" bindtouchstart="{{ ec.disableTouch ? '' : 'touchStart' }}" bindtouchmove="{{ ec.disableTouch ? '' : 'touchMove' }}" bindtouchend="{{ ec.disableTouch ? '' : 'touchEnd' }}"></canvas>
@@ -215,10 +215,6 @@ Component({
215
215
  },
216
216
  data: {
217
217
  ec: {},
218
- canvas_id: {
219
- type: String,
220
- value: `canvas_line_${Date.now()}_${Math.random() * 100}`,
221
- },
222
218
  },
223
219
  lifetimes: {
224
220
  attached() {
@@ -264,22 +260,11 @@ Component({
264
260
  return options ?? [];
265
261
  } else {
266
262
  if (this.properties.dataSourceType === 'variable') {
267
- const result = transform(
268
- 'line',
269
- this.properties.datasourceVariable,
270
- this.properties
271
- );
263
+ const result = transform('line', this.properties.datasourceVariable, this.properties);
272
264
  return result ?? [];
273
265
  } else if (this.properties.dataSourceType === 'custom-connector') {
274
- const { connector, connectorMethod, connectorParams } =
275
- this.properties;
276
- if (
277
- !(
278
- connector?.datasource?.name &&
279
- connectorMethod?.name &&
280
- connectorParams
281
- )
282
- ) {
266
+ const { connector, connectorMethod, connectorParams } = this.properties;
267
+ if (!(connector?.datasource?.name && connectorMethod?.name && connectorParams)) {
283
268
  console.warn('Chart 参数不完整');
284
269
  }
285
270
  const res = await callDataSource({
@@ -294,6 +279,7 @@ Component({
294
279
  },
295
280
  initData() {
296
281
  this.setData({
282
+ id: this.id,
297
283
  ec: {
298
284
  onInit: this.initChart.bind(this),
299
285
  },
@@ -307,7 +293,6 @@ Component({
307
293
  });
308
294
  canvas.setChart(objEchart);
309
295
  const options = await this.getData();
310
- console.log('设置前参数line', options);
311
296
  objEchart.setOption(options, true);
312
297
  this._chart = objEchart;
313
298
  return objEchart;
@@ -319,7 +304,6 @@ Component({
319
304
  const canvas = this.selectComponent(`#canvas_${this.properties.id}`);
320
305
  canvas?.init();
321
306
  const options = await this.getData();
322
- console.log('设置前参数line', options);
323
307
  this._chart && this._chart.setOption(options, true);
324
308
  },
325
309
  },
@@ -1 +1 @@
1
- <view wx:if="ec" class="{{className}} ec_container" style="{{style}}" id="{{id}}"> <ec-canvas id="{{'canvas_'+id}}" canvas-id="{{canvas_id}}" ec="{{ ec }}" /> </view>
1
+ <view wx:if="ec" class="{{className}} ec_container" style="{{style}}" id="{{id}}"> <ec-canvas id="{{'canvas_'+id}}" canvasId="{{'canvas_'+id}}" ec="{{ ec }}" /> </view>
@@ -145,10 +145,6 @@ Component({
145
145
  },
146
146
  data: {
147
147
  ec: {},
148
- canvas_id: {
149
- type: String,
150
- value: `canvas_pie_${Date.now()}_${Math.random() * 100}`,
151
- },
152
148
  },
153
149
  lifetimes: {
154
150
  attached() {
@@ -173,7 +169,6 @@ Component({
173
169
  const canvas = this.selectComponent(`#canvas_${this.properties.id}`);
174
170
  canvas?.init();
175
171
  const options = await this.getData();
176
- console.log('设置前参数pie', options);
177
172
  this._chart && this._chart.setOption(options, true);
178
173
  },
179
174
  },
@@ -204,22 +199,11 @@ Component({
204
199
  return options ?? [];
205
200
  } else {
206
201
  if (this.properties.dataSourceType === 'variable') {
207
- const result = transform(
208
- 'pie',
209
- this.properties.datasourceVariable,
210
- this.properties
211
- );
202
+ const result = transform('pie', this.properties.datasourceVariable, this.properties);
212
203
  return result ?? [];
213
204
  } else if (this.properties.dataSourceType === 'custom-connector') {
214
- const { connector, connectorMethod, connectorParams } =
215
- this.properties;
216
- if (
217
- !(
218
- connector?.datasource?.name &&
219
- connectorMethod?.name &&
220
- connectorParams
221
- )
222
- ) {
205
+ const { connector, connectorMethod, connectorParams } = this.properties;
206
+ if (!(connector?.datasource?.name && connectorMethod?.name && connectorParams)) {
223
207
  console.warn('Chart 参数不完整');
224
208
  }
225
209
  const res = await callDataSource({
@@ -234,6 +218,7 @@ Component({
234
218
  },
235
219
  initData() {
236
220
  this.setData({
221
+ id: this.id,
237
222
  ec: {
238
223
  onInit: this.initChart.bind(this),
239
224
  },
@@ -248,7 +233,6 @@ Component({
248
233
  canvas.setChart(objEchart);
249
234
  const options = await this.getData();
250
235
  // objEchart.clear();
251
- console.log('设置前参数pie', options);
252
236
  objEchart.setOption(options, true);
253
237
  this._chart = objEchart;
254
238
  return objEchart;
@@ -1 +1 @@
1
- <view wx:if="ec" class="{{className}} ec_container" style="{{style}}" id="{{id}}"> <ec-canvas id="{{'canvas_'+id}}" canvas-id="{{canvas_id}}" ec="{{ ec }}" /> </view>
1
+ <view wx:if="ec" class="{{className}} ec_container" style="{{style}}" id="{{id}}"> <ec-canvas id="{{'canvas_'+id}}" canvasId="{{'canvas_'+id}}" ec="{{ ec }}" /> </view>
@@ -1109,4 +1109,19 @@ textarea {
1109
1109
  }
1110
1110
  .wd-mp-form-item-obj .wd-form-item--weui.wd-form-item {
1111
1111
  width: 100%;
1112
+ }
1113
+
1114
+ .wd-input-password-icon {
1115
+ padding: 0 5px;
1116
+ display: flex;
1117
+ cursor: pointer;
1118
+ }
1119
+
1120
+ .wd-pc-input-password-icon {
1121
+ position: absolute;
1122
+ right: -30px;
1123
+ }
1124
+
1125
+ .password-input .wd-form-item-wrap__control-wrap {
1126
+ position: relative;
1112
1127
  }
@@ -59,7 +59,7 @@ Component({
59
59
  searchValue: '',
60
60
  disabledIndex: -1, // 预留参数,暂时无用
61
61
  clickIndex: 0,
62
- index: 0,
62
+ index: -1,
63
63
  status: 0,
64
64
  showOption: [],
65
65
  isFinish: false,
@@ -84,14 +84,7 @@ Component({
84
84
  bindinput: function (event) {
85
85
  const value = event.detail.value;
86
86
 
87
- const {
88
- option,
89
- loadStatus,
90
- isTurnPages,
91
- _needFetch,
92
- ignoreCase,
93
- staticSearchable,
94
- } = this.properties;
87
+ const { option, loadStatus, isTurnPages, _needFetch, ignoreCase, staticSearchable } = this.properties;
95
88
  if (value === '' || value === this.data.searchValue) {
96
89
  this.setData({
97
90
  searchValue: value,
@@ -124,9 +117,7 @@ Component({
124
117
 
125
118
  const searchOption = option.filter((item) => {
126
119
  if (ignoreCase) {
127
- return String(item.label)
128
- .toLowerCase()
129
- .includes(value.toLowerCase());
120
+ return String(item.label).toLowerCase().includes(value.toLowerCase());
130
121
  }
131
122
  return item.label.includes(value);
132
123
  });
@@ -182,7 +173,7 @@ Component({
182
173
  }
183
174
  const { isFinish, searchValue, searchPageNo } = this.data;
184
175
  if (searchValue === '') {
185
- if (this.properties.loadStatus === 1 && isFinish) {
176
+ if (isFinish) {
186
177
  this.setData({
187
178
  pageNo: this.properties.pageNo + 1,
188
179
  isFinish: false,
@@ -193,7 +184,7 @@ Component({
193
184
  });
194
185
  }
195
186
  } else {
196
- if (this.properties.searchStatus === 1 && isFinish) {
187
+ if (isFinish) {
197
188
  this.setData({
198
189
  searchPageNo: this.data.searchPageNo + 1,
199
190
  isFinish: false,
@@ -234,54 +225,46 @@ Component({
234
225
  },
235
226
  },
236
227
  observers: {
237
- 'option, loadStatus, searchOption, searchStatus, _needFetch, staticSearchable':
238
- function (
239
- option,
240
- loadStatus,
241
- searchOption,
242
- searchStatus,
243
- _needFetch,
244
- staticSearchable
245
- ) {
246
- if (this.data.searchValue === '') {
247
- // 初始化会走到这
248
- const { chooseIndexValue } = this.properties;
249
- let index = -1;
250
- if (chooseIndexValue !== '') {
251
- index = option.findIndex((item) => item.value === chooseIndexValue);
252
- } else {
253
- option.some((item, i) => {
254
- if (!item?.disabled) {
255
- index = i;
256
- return true;
257
- }
258
- });
259
- }
228
+ 'option, loadStatus, searchOption, searchStatus, _needFetch, staticSearchable': function (
229
+ option,
230
+ loadStatus,
231
+ searchOption,
232
+ searchStatus,
233
+ _needFetch,
234
+ staticSearchable,
235
+ ) {
236
+ if (this.data.searchValue === '') {
237
+ // 初始化会走到这
238
+ const { chooseIndexValue } = this.properties;
239
+ let index = -1;
240
+ if (chooseIndexValue !== '') {
241
+ index = option.findIndex((item) => item.value === chooseIndexValue);
242
+ }
243
+ this.setData({
244
+ status: loadStatus,
245
+ showOption: option,
246
+ isFinish: true,
247
+ index: index,
248
+ clickIndex: index,
249
+ });
250
+ } else {
251
+ if (_needFetch) {
252
+ // 只有needFetch 才设置searchOption
260
253
  this.setData({
261
- status: loadStatus,
254
+ status: searchStatus,
255
+ showOption: searchOption,
256
+ isFinish: true,
257
+ index: -1,
258
+ });
259
+ } else if (!staticSearchable) {
260
+ this.setData({
261
+ status: searchStatus,
262
262
  showOption: option,
263
263
  isFinish: true,
264
- index: index,
265
- clickIndex: index,
264
+ index: -1,
266
265
  });
267
- } else {
268
- if (_needFetch) {
269
- // 只有needFetch 才设置searchOption
270
- this.setData({
271
- status: searchStatus,
272
- showOption: searchOption,
273
- isFinish: true,
274
- index: -1,
275
- });
276
- } else if (!staticSearchable) {
277
- this.setData({
278
- status: searchStatus,
279
- showOption: option,
280
- isFinish: true,
281
- index: -1,
282
- });
283
- }
284
266
  }
285
- },
267
+ }
268
+ },
286
269
  },
287
270
  });
@@ -26,7 +26,7 @@
26
26
  加载失败
27
27
  <text class="weda-ui-custom-picker__btn weda-ui-custom-picker__btn--link" bindtap="onRetry">重试</text>
28
28
  </view>
29
- <view wx:if="{{status === 3}}" class="weda-ui-custom-picker__status"> 暂无数据 </view>
29
+ <view wx:if="{{status === 3&&!showOption.length}}" class="weda-ui-custom-picker__status"> 暂无数据 </view>
30
30
  </view>
31
31
  </view>
32
32
  </scroll-view>
@@ -280,8 +280,7 @@
280
280
  transform: translateX(0);
281
281
  }
282
282
 
283
- .weda-ui-custom-search.is-focused
284
- .weda-ui-custom-search-box__search-placeholder {
283
+ .weda-ui-custom-search.is-focused .weda-ui-custom-search-box__search-placeholder {
285
284
  display: none;
286
285
  }
287
286
 
@@ -592,7 +592,7 @@ Component({
592
592
  },
593
593
  });
594
594
  const results = data?.records;
595
- console.log(results, param, 'Records');
595
+ // console.log(results, param, 'Records');
596
596
  if (isUpdate && results && results.length > 0) {
597
597
  this.setData({
598
598
  chooseIndexLable: results[0][this.properties.primaryField] || results[0]._id,
@@ -124,10 +124,7 @@ Component({
124
124
  const { selectedCache } = this.data;
125
125
  const index = selectedCache.findIndex((v) => v.value === item.value);
126
126
  if (index > -1) {
127
- return [
128
- ...selectedCache.slice(0, index),
129
- ...selectedCache.slice(index + 1),
130
- ];
127
+ return [...selectedCache.slice(0, index), ...selectedCache.slice(index + 1)];
131
128
  }
132
129
 
133
130
  return [...selectedCache, item];
@@ -182,11 +179,7 @@ Component({
182
179
  },
183
180
  },
184
181
  observers: {
185
- 'option,searchValue,staticSearchable': function (
186
- option,
187
- searchValue,
188
- staticSearchable
189
- ) {
182
+ 'option,searchValue,staticSearchable': function (option, searchValue, staticSearchable) {
190
183
  const { ignoreCase } = this.properties;
191
184
  if (searchValue === '') {
192
185
  this.setData({
@@ -196,11 +189,7 @@ Component({
196
189
  } else if (staticSearchable) {
197
190
  const searchRange = option.filter((item) => {
198
191
  if (ignoreCase) {
199
- return (
200
- String(item.label)
201
- .toLowerCase()
202
- .indexOf(searchValue.toLowerCase()) !== -1
203
- );
192
+ return String(item.label).toLowerCase().indexOf(searchValue.toLowerCase()) !== -1;
204
193
  }
205
194
  return item.label.indexOf(searchValue) !== -1;
206
195
  });
@@ -215,17 +204,18 @@ Component({
215
204
  }
216
205
  },
217
206
  selectedValue: function (selectedValue) {
218
- const data = Array.isArray(selectedValue)
219
- ? selectedValue
220
- : [selectedValue];
207
+ const data = Array.isArray(selectedValue) ? selectedValue : [selectedValue];
221
208
  const optionMap = this.properties.option.reduce((pre, cur) => {
222
209
  pre[cur.value] = cur;
223
210
  return pre;
224
211
  }, {});
225
- const selectedCache = data
226
- .map((d) => optionMap[d])
227
- .filter((item) => !!item);
212
+ const selectedCache = data.map((d) => optionMap[d]).filter((item) => !!item);
228
213
  this.setData({ selectedCache });
229
214
  },
215
+ loadStatus: function (loadStatus) {
216
+ this.setData({
217
+ status: loadStatus,
218
+ });
219
+ },
230
220
  },
231
221
  });