@10yun/cv-mobile-ui 0.5.20 → 0.5.21

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 (69) hide show
  1. package/package.json +1 -1
  2. package/ui-cv/components/cv-grid-item/cv-grid-item.vue +1 -1
  3. package/uni-ui/lib/uni-badge/uni-badge.vue +150 -1
  4. package/uni-ui/lib/uni-breadcrumb/uni-breadcrumb.vue +37 -1
  5. package/uni-ui/lib/uni-breadcrumb-item/uni-breadcrumb-item.vue +83 -1
  6. package/uni-ui/lib/uni-calendar/uni-calendar-item.vue +122 -1
  7. package/uni-ui/lib/uni-calendar/uni-calendar.vue +366 -1
  8. package/uni-ui/lib/uni-card/uni-card.vue +124 -1
  9. package/uni-ui/lib/uni-col/uni-col.vue +1 -1
  10. package/uni-ui/lib/uni-collapse/uni-collapse.vue +135 -1
  11. package/uni-ui/lib/uni-collapse-item/uni-collapse-item.vue +266 -1
  12. package/uni-ui/lib/uni-combox/uni-combox.vue +1 -1
  13. package/uni-ui/lib/uni-countdown/uni-countdown.vue +239 -1
  14. package/uni-ui/lib/uni-data-checkbox/uni-data-checkbox.vue +487 -1
  15. package/uni-ui/lib/uni-data-picker/uni-data-picker.vue +530 -1
  16. package/uni-ui/lib/uni-data-pickerview/uni-data-picker.js +157 -150
  17. package/uni-ui/lib/uni-data-pickerview/uni-data-pickerview.vue +166 -1
  18. package/uni-ui/lib/uni-data-select/uni-data-select.vue +289 -1
  19. package/uni-ui/lib/uni-datetime-picker/calendar-item.vue +70 -1
  20. package/uni-ui/lib/uni-datetime-picker/calendar.vue +629 -1
  21. package/uni-ui/lib/uni-datetime-picker/time-picker.vue +741 -1
  22. package/uni-ui/lib/uni-datetime-picker/uni-datetime-picker.vue +847 -1
  23. package/uni-ui/lib/uni-drawer/uni-drawer.vue +115 -1
  24. package/uni-ui/lib/uni-easyinput/uni-easyinput.vue +515 -1
  25. package/uni-ui/lib/uni-fab/uni-fab.vue +257 -1
  26. package/uni-ui/lib/uni-fav/uni-fav.vue +123 -1
  27. package/uni-ui/lib/uni-file-picker/uni-file-picker.vue +642 -1
  28. package/uni-ui/lib/uni-file-picker/upload-file.vue +177 -1
  29. package/uni-ui/lib/uni-file-picker/upload-image.vue +176 -1
  30. package/uni-ui/lib/uni-forms/uni-forms.vue +375 -1
  31. package/uni-ui/lib/uni-forms-item/uni-forms-item.vue +429 -1
  32. package/uni-ui/lib/uni-goods-nav/uni-goods-nav.vue +129 -1
  33. package/uni-ui/lib/uni-grid/uni-grid.vue +115 -1
  34. package/uni-ui/lib/uni-grid-item/uni-grid-item.vue +78 -1
  35. package/uni-ui/lib/uni-group/uni-group.vue +85 -1
  36. package/uni-ui/lib/uni-icons/uni-icons.vue +85 -1
  37. package/uni-ui/lib/uni-indexed-list/uni-indexed-list-item.vue +68 -1
  38. package/uni-ui/lib/uni-indexed-list/uni-indexed-list.vue +294 -1
  39. package/uni-ui/lib/uni-list/uni-list.vue +81 -1
  40. package/uni-ui/lib/uni-list-ad/uni-list-ad.vue +77 -1
  41. package/uni-ui/lib/uni-list-chat/uni-list-chat.vue +294 -1
  42. package/uni-ui/lib/uni-list-item/uni-list-item.vue +346 -1
  43. package/uni-ui/lib/uni-load-more/uni-load-more.vue +172 -1
  44. package/uni-ui/lib/uni-nav-bar/uni-nav-bar.vue +205 -1
  45. package/uni-ui/lib/uni-nav-bar/uni-status-bar.vue +18 -1
  46. package/uni-ui/lib/uni-notice-bar/uni-notice-bar.vue +331 -1
  47. package/uni-ui/lib/uni-number-box/uni-number-box.vue +166 -1
  48. package/uni-ui/lib/uni-pagination/uni-pagination.vue +323 -1
  49. package/uni-ui/lib/uni-popup/uni-popup.vue +1 -1
  50. package/uni-ui/lib/uni-popup-dialog/uni-popup-dialog.vue +173 -1
  51. package/uni-ui/lib/uni-popup-message/uni-popup-message.vue +74 -1
  52. package/uni-ui/lib/uni-popup-share/uni-popup-share.vue +106 -1
  53. package/uni-ui/lib/uni-rate/uni-rate.vue +322 -1
  54. package/uni-ui/lib/uni-row/uni-row.vue +1 -1
  55. package/uni-ui/lib/uni-search-bar/uni-search-bar.vue +236 -1
  56. package/uni-ui/lib/uni-section/uni-section.vue +109 -1
  57. package/uni-ui/lib/uni-segmented-control/uni-segmented-control.vue +103 -1
  58. package/uni-ui/lib/uni-status-bar/uni-status-bar.vue +1 -1
  59. package/uni-ui/lib/uni-steps/uni-steps.vue +120 -1
  60. package/uni-ui/lib/uni-swipe-action-item/uni-swipe-action-item.vue +226 -3
  61. package/uni-ui/lib/uni-swiper-dot/uni-swiper-dot.vue +167 -1
  62. package/uni-ui/lib/uni-table/uni-table.vue +297 -1
  63. package/uni-ui/lib/uni-tag/uni-tag.vue +100 -1
  64. package/uni-ui/lib/uni-td/uni-td.vue +78 -1
  65. package/uni-ui/lib/uni-th/filter-dropdown.vue +1 -1
  66. package/uni-ui/lib/uni-th/uni-th.vue +224 -1
  67. package/uni-ui/lib/uni-thead/uni-thead.vue +77 -1
  68. package/uni-ui/lib/uni-tr/table-checkbox.vue +79 -1
  69. package/uni-ui/lib/uni-tr/uni-tr.vue +135 -1
@@ -1 +1,530 @@
1
- <template>
2
1
  <view class="uni-data-tree">
3
2
  <view class="uni-data-tree-input" @click="handleInput">
4
3
  <slot :options="options" :data="inputSelected" :error="errorMessage">
5
4
  <view class="input-value" :class="{ 'input-value-border': border }">
6
5
  <text v-if="errorMessage" class="selected-area error-text">{{ errorMessage }}</text>
7
6
  <view v-else-if="loading && !isOpened" class="selected-area">
8
7
  <uni-load-more class="load-more" :contentText="loadMore" status="loading"></uni-load-more>
9
8
  </view>
10
9
  <scroll-view v-else-if="inputSelected.length" class="selected-area" scroll-x="true">
11
10
  <view class="selected-list">
12
11
  <view class="selected-item" v-for="(item, index) in inputSelected" :key="index">
13
12
  <text class="text-color">{{ item.text }}</text>
14
13
  <text v-if="index < inputSelected.length - 1" class="input-split-line">{{ split }}</text>
15
14
  </view>
16
15
  </view>
17
16
  </scroll-view>
18
17
  <text v-else class="selected-area placeholder">{{ placeholder }}</text>
19
18
  <view v-if="clearIcon && !readonly && inputSelected.length" class="icon-clear" @click.stop="clear">
20
19
  <uni-icons type="clear" color="#c0c4cc" size="24"></uni-icons>
21
20
  </view>
22
21
  <view class="arrow-area" v-if="(!clearIcon || !inputSelected.length) && !readonly">
23
22
  <view class="input-arrow"></view>
24
23
  </view>
25
24
  </view>
26
25
  </slot>
27
26
  </view>
28
27
  <view class="uni-data-tree-cover" v-if="isOpened" @click="handleClose"></view>
29
28
  <view class="uni-data-tree-dialog" v-if="isOpened">
30
29
  <view class="uni-popper__arrow"></view>
31
30
  <view class="dialog-caption">
32
31
  <view class="title-area">
33
32
  <text class="dialog-title">{{ popupTitle }}</text>
34
33
  </view>
35
34
  <view class="dialog-close" @click="handleClose">
36
35
  <view class="dialog-close-plus" data-id="close"></view>
37
36
  <view class="dialog-close-plus dialog-close-rotate" data-id="close"></view>
38
37
  </view>
39
38
  </view>
40
39
  <data-picker-view
41
40
  class="picker-view"
42
41
  ref="pickerView"
43
42
  v-model="dataValue"
44
43
  :localdata="localdata"
45
44
  :preload="preload"
46
45
  :collection="collection"
47
46
  :field="field"
48
47
  :orderby="orderby"
49
48
  :where="where"
50
49
  :step-searh="stepSearh"
51
50
  :self-field="selfField"
52
51
  :parent-field="parentField"
53
52
  :managed-mode="true"
54
53
  :map="map"
55
54
  :ellipsis="ellipsis"
56
55
  @change="onchange"
57
56
  @datachange="ondatachange"
58
57
  @nodeclick="onnodeclick"
59
58
  ></data-picker-view>
60
59
  </view>
61
60
  </view>
62
61
  * DataPicker 级联选择
63
62
  * @description 支持单列、和多列级联选择。列数没有限制,如果屏幕显示不全,顶部tab区域会左右滚动。
64
63
  * @tutorial https://ext.dcloud.net.cn/plugin?id=3796
65
64
  * @property {String} popup-title 弹出窗口标题
66
65
  * @property {Array} localdata 本地数据,参考
67
66
  * @property {Boolean} border = [true|false] 是否有边框
68
67
  * @property {Boolean} readonly = [true|false] 是否仅读
69
68
  * @property {Boolean} preload = [true|false] 是否预加载数据
70
69
  * @value true 开启预加载数据,点击弹出窗口后显示已加载数据
71
70
  * @value false 关闭预加载数据,点击弹出窗口后开始加载数据
72
71
  * @property {Boolean} step-searh = [true|false] 是否分布查询
73
72
  * @value true 启用分布查询,仅查询当前选中节点
74
73
  * @value false 关闭分布查询,一次查询出所有数据
75
74
  * @property {String|DBFieldString} self-field 分布查询当前字段名称
76
75
  * @property {String|DBFieldString} parent-field 分布查询父字段名称
77
76
  * @property {String|DBCollectionString} collection 表名
78
77
  * @property {String|DBFieldString} field 查询字段,多个字段用 `,` 分割
79
78
  * @property {String} orderby 排序字段及正序倒叙设置
80
79
  * @property {String|JQLString} where 查询条件
81
80
  * @event {Function} popupshow 弹出的选择窗口打开时触发此事件
82
81
  * @event {Function} popuphide 弹出的选择窗口关闭时触发此事件
83
82
  */
84
83
  name: 'UniDataPicker',
85
84
  emits: ['popupopened', 'popupclosed', 'nodeclick', 'input', 'change', 'update:modelValue', 'inputclick'],
86
85
  mixins: [dataPicker],
87
86
  components: {
88
87
  DataPickerView
89
88
  },
90
89
  props: {
91
90
  options: {
92
91
  type: [Object, Array],
93
92
  default() {
94
93
  return {};
95
94
  }
96
95
  },
97
96
  popupTitle: {
98
97
  type: String,
99
98
  default: '请选择'
100
99
  },
101
100
  placeholder: {
102
101
  type: String,
103
102
  default: '请选择'
104
103
  },
105
104
  heightMobile: {
106
105
  type: String,
107
106
  default: ''
108
107
  },
109
108
  readonly: {
110
109
  type: Boolean,
111
110
  default: false
112
111
  },
113
112
  clearIcon: {
114
113
  type: Boolean,
115
114
  default: true
116
115
  },
117
116
  border: {
118
117
  type: Boolean,
119
118
  default: true
120
119
  },
121
120
  split: {
122
121
  type: String,
123
122
  default: '/'
124
123
  },
125
124
  ellipsis: {
126
125
  type: Boolean,
127
126
  default: true
128
127
  }
129
128
  },
130
129
  data() {
131
130
  return {
132
131
  isOpened: false,
133
132
  inputSelected: []
134
133
  };
135
134
  },
136
135
  created() {
137
136
  this.$nextTick(() => {
138
137
  this.load();
139
138
  });
140
139
  },
141
140
  watch: {
142
141
  localdata: {
143
142
  handler() {
144
143
  this.load();
145
144
  },
146
145
  deep: true
147
146
  }
148
147
  },
149
148
  methods: {
150
149
  clear() {
151
150
  this._dispatchEvent([]);
152
151
  },
153
152
  onPropsChange() {
154
153
  this._treeData = [];
155
154
  this.selectedIndex = 0;
156
155
  this.load();
157
156
  },
158
157
  load() {
159
158
  if (this.readonly) {
160
159
  this._processReadonly(this.localdata, this.dataValue);
161
160
  return;
162
161
  }
163
162
  // 回显本地数据
164
163
  if (this.isLocalData) {
165
164
  this.loadData();
166
165
  this.inputSelected = this.selected.slice(0);
167
166
  } else if (this.isCloudDataList || this.isCloudDataTree) {
168
167
  // 回显 Cloud 数据
169
168
  this.loading = true;
170
169
  this.getCloudDataValue()
171
170
  .then((res) => {
172
171
  this.loading = false;
173
172
  this.inputSelected = res;
174
173
  })
175
174
  .catch((err) => {
176
175
  this.loading = false;
177
176
  this.errorMessage = err;
178
177
  });
179
178
  }
180
179
  },
181
180
  show() {
182
181
  this.isOpened = true;
183
182
  setTimeout(() => {
184
183
  this.$refs.pickerView.updateData({
185
184
  treeData: this._treeData,
186
185
  selected: this.selected,
187
186
  selectedIndex: this.selectedIndex
188
187
  });
189
188
  }, 200);
190
189
  this.$emit('popupopened');
191
190
  },
192
191
  hide() {
193
192
  this.isOpened = false;
194
193
  this.$emit('popupclosed');
195
194
  },
196
195
  handleInput() {
197
196
  if (this.readonly) {
198
197
  this.$emit('inputclick');
199
198
  return;
200
199
  }
201
200
  this.show();
202
201
  },
203
202
  handleClose(e) {
204
203
  this.hide();
205
204
  },
206
205
  onnodeclick(e) {
207
206
  this.$emit('nodeclick', e);
208
207
  },
209
208
  ondatachange(e) {
210
209
  this._treeData = this.$refs.pickerView._treeData;
211
210
  },
212
211
  onchange(e) {
213
212
  this.hide();
214
213
  this.$nextTick(() => {
215
214
  this.inputSelected = e;
216
215
  });
217
216
  this._dispatchEvent(e);
218
217
  },
219
218
  _processReadonly(dataList, value) {
220
219
  var isTree = dataList.findIndex((item) => {
221
220
  return item.children;
222
221
  });
223
222
  if (isTree > -1) {
224
223
  let inputValue;
225
224
  if (Array.isArray(value)) {
226
225
  inputValue = value[value.length - 1];
227
226
  if (typeof inputValue === 'object' && inputValue.value) {
228
227
  inputValue = inputValue.value;
229
228
  }
230
229
  } else {
231
230
  inputValue = value;
232
231
  }
233
232
  this.inputSelected = this._findNodePath(inputValue, this.localdata);
234
233
  return;
235
234
  }
236
235
  if (!this.hasValue) {
237
236
  this.inputSelected = [];
238
237
  return;
239
238
  }
240
239
  let result = [];
241
240
  for (let i = 0; i < value.length; i++) {
242
241
  var val = value[i];
243
242
  var item = dataList.find((v) => {
244
243
  return v.value == val;
245
244
  });
246
245
  if (item) {
247
246
  result.push(item);
248
247
  }
249
248
  }
250
249
  if (result.length) {
251
250
  this.inputSelected = result;
252
251
  }
253
252
  },
254
253
  _filterForArray(data, valueArray) {
255
254
  var result = [];
256
255
  for (let i = 0; i < valueArray.length; i++) {
257
256
  var value = valueArray[i];
258
257
  var found = data.find((item) => {
259
258
  return item.value == value;
260
259
  });
261
260
  if (found) {
262
261
  result.push(found);
263
262
  }
264
263
  }
265
264
  return result;
266
265
  },
267
266
  _dispatchEvent(selected) {
268
267
  let item = {};
269
268
  if (selected.length) {
270
269
  var value = new Array(selected.length);
271
270
  for (var i = 0; i < selected.length; i++) {
272
271
  value[i] = selected[i].value;
273
272
  }
274
273
  item = selected[selected.length - 1];
275
274
  } else {
276
275
  item.value = '';
277
276
  }
278
277
  if (this.formItem) {
279
278
  this.formItem.setValue(item.value);
280
279
  }
281
280
  this.$emit('input', item.value);
282
281
  this.$emit('update:modelValue', item.value);
283
282
  this.$emit('change', {
284
283
  detail: {
285
284
  value: selected
286
285
  }
287
286
  });
288
287
  }
289
288
  }
290
289
  flex: 1;
291
290
  position: relative;
292
291
  font-size: 14px;
293
292
  color: #dd524d;
294
293
  /* #ifndef APP-NVUE */
295
294
  display: flex;
296
295
  /* #endif */
297
296
  flex-direction: row;
298
297
  align-items: center;
299
298
  flex-wrap: nowrap;
300
299
  font-size: 14px;
301
300
  /* line-height: 35px; */
302
301
  padding: 0 10px;
303
302
  padding-right: 5px;
304
303
  overflow: hidden;
305
304
  height: 35px;
306
305
  /* #ifndef APP-NVUE */
307
306
  box-sizing: border-box;
308
307
  /* #endif */
309
308
  border: 1px solid #e5e5e5;
310
309
  border-radius: 5px;
311
310
  flex: 1;
312
311
  overflow: hidden;
313
312
  /* #ifndef APP-NVUE */
314
313
  display: flex;
315
314
  /* #endif */
316
315
  flex-direction: row;
317
316
  /* #ifndef APP-NVUE */
318
317
  margin-right: auto;
319
318
  /* #endif */
320
319
  /* #ifdef APP-NVUE */
321
320
  width: 40px;
322
321
  /* #endif */
323
322
  /* #ifndef APP-NVUE */
324
323
  display: flex;
325
324
  /* #endif */
326
325
  flex-direction: row;
327
326
  flex-wrap: nowrap;
328
327
  /* padding: 0 5px; */
329
328
  flex-direction: row;
330
329
  /* padding: 0 1px; */
331
330
  /* #ifndef APP-NVUE */
332
331
  white-space: nowrap;
333
332
  /* #endif */
334
333
  color: #333;
335
334
  color: grey;
336
335
  font-size: 12px;
337
336
  opacity: 0.5;
338
337
  position: relative;
339
338
  width: 20px;
340
339
  /* #ifndef APP-NVUE */
341
340
  margin-bottom: 5px;
342
341
  margin-left: auto;
343
342
  display: flex;
344
343
  /* #endif */
345
344
  justify-content: center;
346
345
  transform: rotate(-45deg);
347
346
  transform-origin: center;
348
347
  width: 7px;
349
348
  height: 7px;
350
349
  border-left: 1px solid #999;
351
350
  border-bottom: 1px solid #999;
352
351
  position: fixed;
353
352
  left: 0;
354
353
  top: 0;
355
354
  right: 0;
356
355
  bottom: 0;
357
356
  background-color: rgba(0, 0, 0, 0.4);
358
357
  /* #ifndef APP-NVUE */
359
358
  display: flex;
360
359
  /* #endif */
361
360
  flex-direction: column;
362
361
  z-index: 100;
363
362
  position: fixed;
364
363
  left: 0;
365
364
  /* #ifndef APP-NVUE */
366
365
  top: 20%;
367
366
  /* #endif */
368
367
  /* #ifdef APP-NVUE */
369
368
  top: 200px;
370
369
  /* #endif */
371
370
  right: 0;
372
371
  bottom: 0;
373
372
  background-color: #ffffff;
374
373
  border-top-left-radius: 10px;
375
374
  border-top-right-radius: 10px;
376
375
  /* #ifndef APP-NVUE */
377
376
  display: flex;
378
377
  /* #endif */
379
378
  flex-direction: column;
380
379
  z-index: 102;
381
380
  overflow: hidden;
382
381
  /* #ifdef APP-NVUE */
383
382
  width: 750rpx;
384
383
  /* #endif */
385
384
  position: relative;
386
385
  /* #ifndef APP-NVUE */
387
386
  display: flex;
388
387
  /* #endif */
389
388
  flex-direction: row;
390
389
  /* border-bottom: 1px solid #f0f0f0; */
391
390
  /* #ifndef APP-NVUE */
392
391
  display: flex;
393
392
  /* #endif */
394
393
  align-items: center;
395
394
  /* #ifndef APP-NVUE */
396
395
  margin: auto;
397
396
  /* #endif */
398
397
  padding: 0 10px;
399
398
  /* font-weight: bold; */
400
399
  line-height: 44px;
401
400
  position: absolute;
402
401
  top: 0;
403
402
  right: 0;
404
403
  bottom: 0;
405
404
  /* #ifndef APP-NVUE */
406
405
  display: flex;
407
406
  /* #endif */
408
407
  flex-direction: row;
409
408
  align-items: center;
410
409
  padding: 0 15px;
411
410
  width: 16px;
412
411
  height: 2px;
413
412
  background-color: #666;
414
413
  border-radius: 2px;
415
414
  transform: rotate(45deg);
416
415
  position: absolute;
417
416
  transform: rotate(-45deg);
418
417
  flex: 1;
419
418
  overflow: hidden;
420
419
  display: flex;
421
420
  align-items: center;
422
421
  .uni-data-tree-cover {
423
422
  background-color: transparent;
424
423
  }
425
424
  .uni-data-tree-dialog {
426
425
  position: absolute;
427
426
  top: 55px;
428
427
  height: auto;
429
428
  min-height: 400px;
430
429
  max-height: 50vh;
431
430
  background-color: #fff;
432
431
  border: 1px solid #ebeef5;
433
432
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
434
433
  border-radius: 4px;
435
434
  overflow: unset;
436
435
  }
437
436
  .dialog-caption {
438
437
  display: none;
439
438
  }
440
439
  .icon-clear {
441
440
  /* margin-right: 5px; */
442
441
  }
443
442
  position: absolute;
444
443
  display: block;
445
444
  width: 0;
446
445
  height: 0;
447
446
  border-color: transparent;
448
447
  border-style: solid;
449
448
  border-width: 6px;
450
449
  filter: drop-shadow(0 2px 12px rgba(0, 0, 0, 0.03));
451
450
  top: -6px;
452
451
  left: 10%;
453
452
  margin-right: 3px;
454
453
  border-top-width: 0;
455
454
  border-bottom-color: #ebeef5;
456
455
  content: ' ';
457
456
  top: 1px;
458
457
  margin-left: -6px;
459
458
  border-top-width: 0;
460
459
  border-bottom-color: #fff;
460
+ <template>
461
+ <view class="uni-data-tree">
462
+ <view class="uni-data-tree-input" @click="handleInput">
463
+ <slot :options="options" :data="inputSelected" :error="errorMessage">
464
+ <view class="input-value" :class="{ 'input-value-border': border }">
465
+ <text v-if="errorMessage" class="selected-area error-text">{{ errorMessage }}</text>
466
+ <view v-else-if="loading && !isOpened" class="selected-area">
467
+ <uni-load-more class="load-more" :contentText="loadMore" status="loading"></uni-load-more>
468
+ </view>
469
+ <scroll-view v-else-if="inputSelected.length" class="selected-area" scroll-x="true">
470
+ <view class="selected-list">
471
+ <view class="selected-item" v-for="(item, index) in inputSelected" :key="index">
472
+ <text class="text-color">{{ item.text }}</text>
473
+ <text v-if="index < inputSelected.length - 1" class="input-split-line">{{ split }}</text>
474
+ </view>
475
+ </view>
476
+ </scroll-view>
477
+ <text v-else class="selected-area placeholder">{{ placeholder }}</text>
478
+ <view v-if="clearIcon && !readonly && inputSelected.length" class="icon-clear" @click.stop="clear">
479
+ <uni-icons type="clear" color="#c0c4cc" size="24"></uni-icons>
480
+ </view>
481
+ <view class="arrow-area" v-if="(!clearIcon || !inputSelected.length) && !readonly">
482
+ <view class="input-arrow"></view>
483
+ </view>
484
+ </view>
485
+ </slot>
486
+ </view>
487
+ <view class="uni-data-tree-cover" v-if="isOpened" @click="handleClose"></view>
488
+ <view class="uni-data-tree-dialog" v-if="isOpened">
489
+ <view class="uni-popper__arrow"></view>
490
+ <view class="dialog-caption">
491
+ <view class="title-area">
492
+ <text class="dialog-title">{{ popupTitle }}</text>
493
+ </view>
494
+ <view class="dialog-close" @click="handleClose">
495
+ <view class="dialog-close-plus" data-id="close"></view>
496
+ <view class="dialog-close-plus dialog-close-rotate" data-id="close"></view>
497
+ </view>
498
+ </view>
499
+ <data-picker-view
500
+ class="picker-view"
501
+ ref="pickerView"
502
+ v-model="dataValue"
503
+ :localdata="localdata"
504
+ :preload="preload"
505
+ :collection="collection"
506
+ :field="field"
507
+ :orderby="orderby"
508
+ :where="where"
509
+ :step-searh="stepSearh"
510
+ :self-field="selfField"
511
+ :parent-field="parentField"
512
+ :managed-mode="true"
513
+ :map="map"
514
+ :ellipsis="ellipsis"
515
+ @change="onchange"
516
+ @datachange="ondatachange"
517
+ @nodeclick="onnodeclick"
518
+ ></data-picker-view>
519
+ </view>
520
+ </view>
521
+ </template>
522
+ <script>
523
+ import dataPicker from '../uni-data-pickerview/uni-data-picker.js';
524
+ import DataPickerView from '../uni-data-pickerview/uni-data-pickerview.vue';
525
+ /**
526
+ * DataPicker 级联选择
527
+ * @description 支持单列、和多列级联选择。列数没有限制,如果屏幕显示不全,顶部tab区域会左右滚动。
528
+ * @tutorial https://ext.dcloud.net.cn/plugin?id=3796
529
+ * @property {String} popup-title 弹出窗口标题
530
+ * @property {Array} localdata 本地数据,参考
531
+ * @property {Boolean} border = [true|false] 是否有边框
532
+ * @property {Boolean} readonly = [true|false] 是否仅读
533
+ * @property {Boolean} preload = [true|false] 是否预加载数据
534
+ * @value true 开启预加载数据,点击弹出窗口后显示已加载数据
535
+ * @value false 关闭预加载数据,点击弹出窗口后开始加载数据
536
+ * @property {Boolean} step-searh = [true|false] 是否分布查询
537
+ * @value true 启用分布查询,仅查询当前选中节点
538
+ * @value false 关闭分布查询,一次查询出所有数据
539
+ * @property {String|DBFieldString} self-field 分布查询当前字段名称
540
+ * @property {String|DBFieldString} parent-field 分布查询父字段名称
541
+ * @property {String|DBCollectionString} collection 表名
542
+ * @property {String|DBFieldString} field 查询字段,多个字段用 `,` 分割
543
+ * @property {String} orderby 排序字段及正序倒叙设置
544
+ * @property {String|JQLString} where 查询条件
545
+ * @event {Function} popupshow 弹出的选择窗口打开时触发此事件
546
+ * @event {Function} popuphide 弹出的选择窗口关闭时触发此事件
547
+ */
548
+ export default {
549
+ name: 'UniDataPicker',
550
+ emits: ['popupopened', 'popupclosed', 'nodeclick', 'input', 'change', 'update:modelValue', 'inputclick'],
551
+ mixins: [dataPicker],
552
+ components: {
553
+ DataPickerView
554
+ },
555
+ props: {
556
+ options: {
557
+ type: [Object, Array],
558
+ default() {
559
+ return {};
560
+ }
561
+ },
562
+ popupTitle: {
563
+ type: String,
564
+ default: '请选择'
565
+ },
566
+ placeholder: {
567
+ type: String,
568
+ default: '请选择'
569
+ },
570
+ heightMobile: {
571
+ type: String,
572
+ default: ''
573
+ },
574
+ readonly: {
575
+ type: Boolean,
576
+ default: false
577
+ },
578
+ clearIcon: {
579
+ type: Boolean,
580
+ default: true
581
+ },
582
+ border: {
583
+ type: Boolean,
584
+ default: true
585
+ },
586
+ split: {
587
+ type: String,
588
+ default: '/'
589
+ },
590
+ ellipsis: {
591
+ type: Boolean,
592
+ default: true
593
+ }
594
+ },
595
+ data() {
596
+ return {
597
+ isOpened: false,
598
+ inputSelected: []
599
+ };
600
+ },
601
+ created() {
602
+ this.$nextTick(() => {
603
+ this.load();
604
+ });
605
+ },
606
+ watch: {
607
+ localdata: {
608
+ handler() {
609
+ this.load();
610
+ },
611
+ deep: true
612
+ }
613
+ },
614
+ methods: {
615
+ clear() {
616
+ this._dispatchEvent([]);
617
+ },
618
+ onPropsChange() {
619
+ this._treeData = [];
620
+ this.selectedIndex = 0;
621
+ this.load();
622
+ },
623
+ load() {
624
+ if (this.readonly) {
625
+ this._processReadonly(this.localdata, this.dataValue);
626
+ return;
627
+ }
628
+ // 回显本地数据
629
+ if (this.isLocalData) {
630
+ this.loadData();
631
+ this.inputSelected = this.selected.slice(0);
632
+ } else if (this.isCloudDataList || this.isCloudDataTree) {
633
+ // 回显 Cloud 数据
634
+ this.loading = true;
635
+ this.getCloudDataValue()
636
+ .then((res) => {
637
+ this.loading = false;
638
+ this.inputSelected = res;
639
+ })
640
+ .catch((err) => {
641
+ this.loading = false;
642
+ this.errorMessage = err;
643
+ });
644
+ }
645
+ },
646
+ show() {
647
+ this.isOpened = true;
648
+ setTimeout(() => {
649
+ this.$refs.pickerView.updateData({
650
+ treeData: this._treeData,
651
+ selected: this.selected,
652
+ selectedIndex: this.selectedIndex
653
+ });
654
+ }, 200);
655
+ this.$emit('popupopened');
656
+ },
657
+ hide() {
658
+ this.isOpened = false;
659
+ this.$emit('popupclosed');
660
+ },
661
+ handleInput() {
662
+ if (this.readonly) {
663
+ this.$emit('inputclick');
664
+ return;
665
+ }
666
+ this.show();
667
+ },
668
+ handleClose(e) {
669
+ this.hide();
670
+ },
671
+ onnodeclick(e) {
672
+ this.$emit('nodeclick', e);
673
+ },
674
+ ondatachange(e) {
675
+ this._treeData = this.$refs.pickerView._treeData;
676
+ },
677
+ onchange(e) {
678
+ this.hide();
679
+ this.$nextTick(() => {
680
+ this.inputSelected = e;
681
+ });
682
+ this._dispatchEvent(e);
683
+ },
684
+ _processReadonly(dataList, value) {
685
+ var isTree = dataList.findIndex((item) => {
686
+ return item.children;
687
+ });
688
+ if (isTree > -1) {
689
+ let inputValue;
690
+ if (Array.isArray(value)) {
691
+ inputValue = value[value.length - 1];
692
+ if (typeof inputValue === 'object' && inputValue.value) {
693
+ inputValue = inputValue.value;
694
+ }
695
+ } else {
696
+ inputValue = value;
697
+ }
698
+ this.inputSelected = this._findNodePath(inputValue, this.localdata);
699
+ return;
700
+ }
701
+ if (!this.hasValue) {
702
+ this.inputSelected = [];
703
+ return;
704
+ }
705
+ let result = [];
706
+ for (let i = 0; i < value.length; i++) {
707
+ var val = value[i];
708
+ var item = dataList.find((v) => {
709
+ return v.value == val;
710
+ });
711
+ if (item) {
712
+ result.push(item);
713
+ }
714
+ }
715
+ if (result.length) {
716
+ this.inputSelected = result;
717
+ }
718
+ },
719
+ _filterForArray(data, valueArray) {
720
+ var result = [];
721
+ for (let i = 0; i < valueArray.length; i++) {
722
+ var value = valueArray[i];
723
+ var found = data.find((item) => {
724
+ return item.value == value;
725
+ });
726
+ if (found) {
727
+ result.push(found);
728
+ }
729
+ }
730
+ return result;
731
+ },
732
+ _dispatchEvent(selected) {
733
+ let item = {};
734
+ if (selected.length) {
735
+ var value = new Array(selected.length);
736
+ for (var i = 0; i < selected.length; i++) {
737
+ value[i] = selected[i].value;
738
+ }
739
+ item = selected[selected.length - 1];
740
+ } else {
741
+ item.value = '';
742
+ }
743
+ if (this.formItem) {
744
+ this.formItem.setValue(item.value);
745
+ }
746
+ this.$emit('input', item.value);
747
+ this.$emit('update:modelValue', item.value);
748
+ this.$emit('change', {
749
+ detail: {
750
+ value: selected
751
+ }
752
+ });
753
+ }
754
+ }
755
+ };
756
+ </script>
757
+ <style>
758
+ .uni-data-tree {
759
+ flex: 1;
760
+ position: relative;
761
+ font-size: 14px;
762
+ }
763
+ .error-text {
764
+ color: #dd524d;
765
+ }
766
+ .input-value {
767
+ /* #ifndef APP-NVUE */
768
+ display: flex;
769
+ /* #endif */
770
+ flex-direction: row;
771
+ align-items: center;
772
+ flex-wrap: nowrap;
773
+ font-size: 14px;
774
+ /* line-height: 35px; */
775
+ padding: 0 10px;
776
+ padding-right: 5px;
777
+ overflow: hidden;
778
+ height: 35px;
779
+ /* #ifndef APP-NVUE */
780
+ box-sizing: border-box;
781
+ /* #endif */
782
+ }
783
+ .input-value-border {
784
+ border: 1px solid #e5e5e5;
785
+ border-radius: 5px;
786
+ }
787
+ .selected-area {
788
+ flex: 1;
789
+ overflow: hidden;
790
+ /* #ifndef APP-NVUE */
791
+ display: flex;
792
+ /* #endif */
793
+ flex-direction: row;
794
+ }
795
+ .load-more {
796
+ /* #ifndef APP-NVUE */
797
+ margin-right: auto;
798
+ /* #endif */
799
+ /* #ifdef APP-NVUE */
800
+ width: 40px;
801
+ /* #endif */
802
+ }
803
+ .selected-list {
804
+ /* #ifndef APP-NVUE */
805
+ display: flex;
806
+ /* #endif */
807
+ flex-direction: row;
808
+ flex-wrap: nowrap;
809
+ /* padding: 0 5px; */
810
+ }
811
+ .selected-item {
812
+ flex-direction: row;
813
+ /* padding: 0 1px; */
814
+ /* #ifndef APP-NVUE */
815
+ white-space: nowrap;
816
+ /* #endif */
817
+ }
818
+ .text-color {
819
+ color: #333;
820
+ }
821
+ .placeholder {
822
+ color: grey;
823
+ font-size: 12px;
824
+ }
825
+ .input-split-line {
826
+ opacity: 0.5;
827
+ }
828
+ .arrow-area {
829
+ position: relative;
830
+ width: 20px;
831
+ /* #ifndef APP-NVUE */
832
+ margin-bottom: 5px;
833
+ margin-left: auto;
834
+ display: flex;
835
+ /* #endif */
836
+ justify-content: center;
837
+ transform: rotate(-45deg);
838
+ transform-origin: center;
839
+ }
840
+ .input-arrow {
841
+ width: 7px;
842
+ height: 7px;
843
+ border-left: 1px solid #999;
844
+ border-bottom: 1px solid #999;
845
+ }
846
+ .uni-data-tree-cover {
847
+ position: fixed;
848
+ left: 0;
849
+ top: 0;
850
+ right: 0;
851
+ bottom: 0;
852
+ background-color: rgba(0, 0, 0, 0.4);
853
+ /* #ifndef APP-NVUE */
854
+ display: flex;
855
+ /* #endif */
856
+ flex-direction: column;
857
+ z-index: 100;
858
+ }
859
+ .uni-data-tree-dialog {
860
+ position: fixed;
861
+ left: 0;
862
+ /* #ifndef APP-NVUE */
863
+ top: 20%;
864
+ /* #endif */
865
+ /* #ifdef APP-NVUE */
866
+ top: 200px;
867
+ /* #endif */
868
+ right: 0;
869
+ bottom: 0;
870
+ background-color: #ffffff;
871
+ border-top-left-radius: 10px;
872
+ border-top-right-radius: 10px;
873
+ /* #ifndef APP-NVUE */
874
+ display: flex;
875
+ /* #endif */
876
+ flex-direction: column;
877
+ z-index: 102;
878
+ overflow: hidden;
879
+ /* #ifdef APP-NVUE */
880
+ width: 750rpx;
881
+ /* #endif */
882
+ }
883
+ .dialog-caption {
884
+ position: relative;
885
+ /* #ifndef APP-NVUE */
886
+ display: flex;
887
+ /* #endif */
888
+ flex-direction: row;
889
+ /* border-bottom: 1px solid #f0f0f0; */
890
+ }
891
+ .title-area {
892
+ /* #ifndef APP-NVUE */
893
+ display: flex;
894
+ /* #endif */
895
+ align-items: center;
896
+ /* #ifndef APP-NVUE */
897
+ margin: auto;
898
+ /* #endif */
899
+ padding: 0 10px;
900
+ }
901
+ .dialog-title {
902
+ /* font-weight: bold; */
903
+ line-height: 44px;
904
+ }
905
+ .dialog-close {
906
+ position: absolute;
907
+ top: 0;
908
+ right: 0;
909
+ bottom: 0;
910
+ /* #ifndef APP-NVUE */
911
+ display: flex;
912
+ /* #endif */
913
+ flex-direction: row;
914
+ align-items: center;
915
+ padding: 0 15px;
916
+ }
917
+ .dialog-close-plus {
918
+ width: 16px;
919
+ height: 2px;
920
+ background-color: #666;
921
+ border-radius: 2px;
922
+ transform: rotate(45deg);
923
+ }
924
+ .dialog-close-rotate {
925
+ position: absolute;
926
+ transform: rotate(-45deg);
927
+ }
928
+ .picker-view {
929
+ flex: 1;
930
+ overflow: hidden;
931
+ }
932
+ .icon-clear {
933
+ display: flex;
934
+ align-items: center;
935
+ }
936
+ /* #ifdef H5 */
937
+ @media all and (min-width: 768px) {
938
+ .uni-data-tree-cover {
939
+ background-color: transparent;
940
+ }
941
+ .uni-data-tree-dialog {
942
+ position: absolute;
943
+ top: 55px;
944
+ height: auto;
945
+ min-height: 400px;
946
+ max-height: 50vh;
947
+ background-color: #fff;
948
+ border: 1px solid #ebeef5;
949
+ box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
950
+ border-radius: 4px;
951
+ overflow: unset;
952
+ }
953
+ .dialog-caption {
954
+ display: none;
955
+ }
956
+ .icon-clear {
957
+ /* margin-right: 5px; */
958
+ }
959
+ }
960
+ /* #endif */
961
+ /* picker 弹出层通用的指示小三角, todo:扩展至上下左右方向定位 */
962
+ /* #ifndef APP-NVUE */
963
+ .uni-popper__arrow,
964
+ .uni-popper__arrow::after {
965
+ position: absolute;
966
+ display: block;
967
+ width: 0;
968
+ height: 0;
969
+ border-color: transparent;
970
+ border-style: solid;
971
+ border-width: 6px;
972
+ }
973
+ .uni-popper__arrow {
974
+ filter: drop-shadow(0 2px 12px rgba(0, 0, 0, 0.03));
975
+ top: -6px;
976
+ left: 10%;
977
+ margin-right: 3px;
978
+ border-top-width: 0;
979
+ border-bottom-color: #ebeef5;
980
+ }
981
+ .uni-popper__arrow::after {
982
+ content: ' ';
983
+ top: 1px;
984
+ margin-left: -6px;
985
+ border-top-width: 0;
986
+ border-bottom-color: #fff;
987
+ }
988
+ /* #endif */
989
+ </style>