mali-applet-ui 1.0.84 → 1.0.86

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,5 @@
1
1
  <template>
2
- <view class="ml-list-select-page" :class="[className || '', {'is-border': border}]" @tap="tapEvent">
2
+ <view class="ml-list-select-page" :class="[className || '', {'is-border': border, 'is-disabled': disabled}]" @tap="tapEvent">
3
3
  <view class="ml-list-select-page-warpper">
4
4
  <view v-if="hasEmpty" class="ml-list-select-page-placeholder">{{ placeholder }}</view>
5
5
  <view v-else>
@@ -38,6 +38,7 @@ export default {
38
38
  type: String,
39
39
  default: '请选择'
40
40
  },
41
+ disabled: Boolean,
41
42
  border: Boolean,
42
43
  clearable: Boolean,
43
44
  className: String
@@ -64,17 +65,20 @@ export default {
64
65
  return XEUtils.eqNull(this.value) || this.value === ''
65
66
  },
66
67
  selectLabel () {
68
+ let rest = []
67
69
  if (this.type === 'checkbox') {
68
- return this.dataList.filter(item => this.value.includes(item[this.optValueField])).map(item => item[this.optLabelField]).join(', ')
70
+ rest = this.dataList.filter(item => this.value.includes(item[this.optValueField]))
71
+ } else if (this.type === 'radio') {
72
+ rest = this.dataList.filter(item => this.value === item[this.optValueField])
69
73
  }
70
- if (this.type === 'radio') {
71
- return this.dataList.filter(item => this.value === item[this.optValueField]).map(item => item[this.optLabelField]).join(', ')
72
- }
73
- return ''
74
+ return rest.map(item => item[this.optLabelField]).join(',')
74
75
  }
75
76
  },
76
77
  methods: {
77
78
  tapEvent () {
79
+ if (this.disabled) {
80
+ return
81
+ }
78
82
  // 打开选择列表页面
79
83
  this.$store.dispatch('openSelectPage', {
80
84
  compName: this.compRender.name, // 指定加载组件名称
@@ -112,6 +116,9 @@ export default {
112
116
  padding: 0 10rpx;
113
117
  height: 70rpx;
114
118
  line-height: 70rpx;
119
+ &.is-disabled {
120
+
121
+ }
115
122
  .ml-list-select-page-warpper {
116
123
  flex-grow: 1;
117
124
  overflow: hidden;
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <view class="ml-tree-box">
2
+ <view class="ml-tree-box" :style="{ height: useHeight }">
3
3
  <view class="ml-tree-tool">
4
4
  <scroll-view :scroll-x="true" class="ml-tree-breadcrumb-scroll" v-if="breadcrumb">
5
5
  <view class="ml-tree-breadcrumb">
@@ -14,33 +14,54 @@
14
14
  </view>
15
15
  </scroll-view>
16
16
  </view>
17
- <view class="ml-tree-content">
18
- <view class="ml-tree-node" v-if="cache && cache.length" @click="handleBack">
19
- <view class="ml-tree-node__title back">
20
- <ml-icon name="direction-left"></ml-icon>
21
- <text class="ml-tree-node__text">返回</text>
22
- </view>
23
- </view>
24
- <view class="ml-tree-node" v-for="(item, index) in showTree" :key="index">
25
- <view class="ml-tree-node__action" v-if="check">
26
- <ml-checkbox
27
- :value="checkKey.indexOf(item[useProps.key]) > -1"
28
- :indeterminate="indeterminate.indexOf(item[useProps.key]) > -1"
29
- v-if="multiple"
30
- @change="handleChangeCheckbox(item)"></ml-checkbox>
31
- <ml-radio :value="checkIndex" :label="item[useProps.key]" v-else @change="handleChangeRadio"></ml-radio>
32
- </view>
33
- <MlTreeIcon :margin-right="15" @click="e => $emit('click-icon', item, 'prefix')" :info="getPrefixIcon(item)" :key="index"></MlTreeIcon>
34
- <view class="ml-tree-node__title" @click="handleIntoChildren(item)">
35
- <view class="nowrap">{{ item[useProps.label] || '' }}</view>
36
- <view class="ml-tree-node__explain" v-if="item[useProps.explain]">{{ item[useProps.explain] }}</view>
17
+ <scroll-view :scroll-y="true" class="ml-tree-container" :style="{ height: useContainerHeight }">
18
+ <view class="ml-tree-content">
19
+ <view class="ml-tree-node" v-if="cache && cache.length" @click="handleBack">
20
+ <view class="ml-tree-node__title back">
21
+ <ml-icon name="direction-left"></ml-icon>
22
+ <text class="ml-tree-node__text">返回</text>
23
+ </view>
37
24
  </view>
38
- <view class="ml-tree-node__extra">
39
- <MlTreeIcon :margin-right="15" @click="e => $emit('click-icon', item, 'suffix')" :info="getSuffixIcon(item)" :key="index"></MlTreeIcon>
40
- <MlTreeIcon :margin-right="15" @click="handleIntoChildren(item)" v-if="(item.children && item.children.length) || (lazy && !item.isLeaf)" :info="{ icon: 'arrow-right' }" :key="index"></MlTreeIcon>
25
+ <view class="ml-tree-node" v-for="(item, index) in showTree" :key="index" @tap="handleClickEvent(item)">
26
+ <view class="ml-tree-node__action" v-if="check">
27
+ <ml-checkbox
28
+ :value="checkKey.indexOf(item[useProps.key]) > -1"
29
+ :indeterminate="indeterminate.indexOf(item[useProps.key]) > -1"
30
+ v-if="multiple"
31
+ @tap.stop
32
+ @change="handleChangeCheckbox(item)"></ml-checkbox>
33
+ <ml-radio
34
+ @tap.stop
35
+ :value="checkIndex"
36
+ :label="item[useProps.key]"
37
+ v-else
38
+ @change="handleChangeRadio"></ml-radio>
39
+ </view>
40
+ <MlTreeIcon
41
+ :margin-right="15"
42
+ @tap-icon.stop="handleClickIcon($event, item)"
43
+ :info="getPrefixIcon(item)"
44
+ />
45
+ <view class="ml-tree-node__title">
46
+ <view class="nowrap">{{ item[useProps.label] || '' }}</view>
47
+ <view class="ml-tree-node__explain" v-if="item[useProps.explain]">{{ item[useProps.explain] }}</view>
48
+ </view>
49
+ <view class="ml-tree-node__extra">
50
+ <MlTreeIcon
51
+ :margin-right="15"
52
+ @tap-icon.stop="handleClickIcon($event, item)"
53
+ :info="getSuffixIcon(item)"
54
+ />
55
+ <MlTreeIcon
56
+ :margin-right="15"
57
+ @tap-icon.stop="handleIntoChildren(item)"
58
+ v-if="(item.children && item.children.length) || (lazy && !item.isLeaf)"
59
+ :info="{ icon: 'arrow-right' }"
60
+ />
61
+ </view>
41
62
  </view>
42
63
  </view>
43
- </view>
64
+ </scroll-view>
44
65
  </view>
45
66
  </template>
46
67
 
@@ -57,6 +78,7 @@ export default {
57
78
  props: {
58
79
  value: [Array, String, Number],
59
80
  check: Boolean,
81
+ height: [String, Number],
60
82
  multiple: Boolean,
61
83
  breadcrumb: Boolean,
62
84
  lazy: Boolean,
@@ -123,12 +145,26 @@ export default {
123
145
  },
124
146
  useProps () {
125
147
  return { ...this.defaultProps, ...this.props }
148
+ },
149
+ useContainerHeight () {
150
+ const { breadcrumb, useHeight: height } = this
151
+ const h = height.indexOf('px') > -1 || height.indexOf('%') > -1 ? height : `${height}rpx`
152
+ if (breadcrumb) {
153
+ return `calc(${h} - 50rpx)`
154
+ }
155
+ return `calc(${h})`
156
+ },
157
+ useHeight () {
158
+ const { height } = this
159
+ if (typeof height === 'string') {
160
+ return height.indexOf('px') > -1 || height.indexOf('%') > -1 ? height : `${height}rpx`
161
+ }
162
+ return `${height}rpx`
126
163
  }
127
164
  },
128
165
  methods: {
129
166
  async handleIntoChildren (item) {
130
- const { lazyLoad, lazy } = this
131
- console.log(this)
167
+ const { lazyLoad, lazy, current } = this
132
168
  if (!(item.children && item.children.length) && lazy && lazyLoad && !item.isLeaf) {
133
169
  // this.lazyLoading = true
134
170
  await lazyLoad.call(this.currVM, item)
@@ -136,6 +172,7 @@ export default {
136
172
  }
137
173
  if (item.children && item.children.length) {
138
174
  this.cache.push(item)
175
+ this.$emit('into', current)
139
176
  }
140
177
  },
141
178
  async reloadLazy () {
@@ -147,8 +184,9 @@ export default {
147
184
  }
148
185
  },
149
186
  handleBack () {
150
- const { cache } = this
187
+ const { cache, current } = this
151
188
  cache.splice(cache.length - 1, 1)
189
+ this.$emit('back', current)
152
190
  },
153
191
  handleToBreadcrumb (index) {
154
192
  const { cache } = this
@@ -176,37 +214,41 @@ export default {
176
214
  }
177
215
  this.handleEvent()
178
216
  },
179
- handleCheckOn (key) {
180
- const { tree, useProps, checkKey } = this
217
+ handleCheckOn (key, down = true) {
218
+ const { tree, useProps, checkKey, strictly, arbitrary } = this
181
219
  const find = findTreeByKey(tree, key, null, useProps)
182
220
  if (find) {
183
221
  const { node, parent } = find
184
222
  this.checkKey.push(key)
185
223
  const children = node.children
186
- if (children && children.length) {
224
+ if (children && children.length && down && !arbitrary) {
187
225
  for (let i = 0; i < children.length; i++) {
188
226
  const item = children[i]
189
227
  const findKey = item[useProps.key]
190
228
  const findIndex = checkKey.findIndex(fd => fd === findKey)
191
229
  if (findIndex === -1) {
192
- this.handleCheckOn(findKey)
230
+ this.handleCheckOn(findKey, true)
193
231
  }
194
232
  }
195
233
  }
196
- if (parent) {
197
- this.handleIndeterminateOn(parent)
234
+ if (parent && !arbitrary) {
235
+ if (strictly) {
236
+ this.handleCheckOn(parent[useProps.key], false)
237
+ } else {
238
+ this.handleIndeterminateOn(parent)
239
+ }
198
240
  }
199
241
  }
200
242
  },
201
243
  handleCheckOff (key) {
202
- const { tree, useProps, checkKey } = this
244
+ const { tree, useProps, checkKey, arbitrary } = this
203
245
  const find = findTreeByKey(tree, key, null, useProps)
204
246
  const { node, parent } = find
205
247
  if (find) {
206
248
  const findIndex = checkKey.findIndex(item => item === key)
207
249
  this.checkKey.splice(findIndex, 1)
208
250
  const children = node.children
209
- if (children && children.length) {
251
+ if (children && children.length && !arbitrary) {
210
252
  this.handleIndeterminateChildrenOff(node)
211
253
  for (let i = 0; i < children.length; i++) {
212
254
  const item = children[i]
@@ -215,7 +257,7 @@ export default {
215
257
  }
216
258
  }
217
259
  }
218
- if (parent) {
260
+ if (parent && !arbitrary) {
219
261
  this.handleIndeterminateParentOff(parent)
220
262
  }
221
263
  },
@@ -229,7 +271,7 @@ export default {
229
271
  const children = node[useProps.children]
230
272
  if (children && children.length && children.every(item => checkKey.indexOf(item[useProps.key]) > -1)) {
231
273
  if (checkKey.findIndex(item => item === key) === -1) {
232
- this.handleCheckOn(key)
274
+ this.handleCheckOn(key, false)
233
275
  }
234
276
  }
235
277
  },
@@ -258,6 +300,21 @@ export default {
258
300
  }
259
301
  }
260
302
  },
303
+ handleClickEvent (row) {
304
+ const { check, handleChangeCheckbox, handleChangeRadio, useProps, multiple } = this
305
+ if (check) {
306
+ if (multiple) {
307
+ handleChangeCheckbox(row)
308
+ } else {
309
+ handleChangeRadio({ value: row[useProps.key] })
310
+ }
311
+ } else {
312
+ this.handleIntoChildren(row)
313
+ }
314
+ },
315
+ handleClickIcon (e, row) {
316
+ this.$emit('click-icon', e.icon, row)
317
+ },
261
318
  handleEvent () {
262
319
  const { tree, multiple, checkKey, checkIndex, useProps } = this
263
320
  if (multiple) {
@@ -315,53 +372,55 @@ export default {
315
372
  <style lang="scss" scoped>
316
373
  .ml-tree-box {
317
374
  background-color: #ffffff;
375
+ .ml-tree-container {
376
+ .ml-tree-content {
377
+ padding: 0 30rpx;
318
378
 
319
- .ml-tree-content {
320
- padding: 0 30rpx;
379
+ .ml-tree-node {
380
+ font-size: 34rpx;
381
+ display: flex;
382
+ align-items: center;
383
+ height: 116rpx;
384
+ border-bottom: 1rpx solid #efefef;
321
385
 
322
- .ml-tree-node {
323
- font-size: 34rpx;
324
- display: flex;
325
- align-items: center;
326
- height: 116rpx;
327
- border-bottom: 1rpx solid #efefef;
386
+ .ml-tree-node__title {
387
+ flex: 1;
388
+ width: 0;
389
+ .nowrap {
390
+ white-space: nowrap;
391
+ overflow: hidden;
392
+ text-overflow: ellipsis;
393
+ }
328
394
 
329
- .ml-tree-node__title {
330
- flex: 1;
331
- width: 0;
332
- .nowrap {
333
- white-space: nowrap;
334
- overflow: hidden;
335
- text-overflow: ellipsis;
336
- }
395
+ &.back {
396
+ color: #6e6e6e;
397
+ font-size: 26rpx;
398
+ }
337
399
 
338
- &.back {
339
- color: #6e6e6e;
340
- font-size: 26rpx;
400
+ .ml-tree-node__text {
401
+ margin: 0 10rpx;
402
+ }
403
+ .ml-tree-node__explain {
404
+ color: #989898;
405
+ font-size: 26rpx;
406
+ }
341
407
  }
342
408
 
343
- .ml-tree-node__text {
344
- margin: 0 10rpx;
409
+ .ml-tree-node__extra {
410
+ display: flex;
411
+ align-items: center;
412
+ padding: 0 0 0 20rpx;
345
413
  }
346
- .ml-tree-node__explain {
347
- color: #989898;
348
- font-size: 26rpx;
349
- }
350
- }
351
414
 
352
- .ml-tree-node__extra {
353
- display: flex;
354
- align-items: center;
355
- padding: 0 0 0 20rpx;
356
- }
357
-
358
- &:last-child {
359
- border-bottom: none;
415
+ &:last-child {
416
+ border-bottom: none;
417
+ }
360
418
  }
361
419
  }
362
420
  }
363
421
 
364
422
  .ml-tree-tool {
423
+ position: sticky;
365
424
  .ml-tree-breadcrumb-scroll {
366
425
  background-color: #f3f3f3;
367
426
  }
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <view class="ml-tree-node__icon" :style="useStyle" v-if="info && info.icon" @click="e => $emit('click', e)">
2
+ <view class="ml-tree-node__icon" :style="useStyle" v-if="info && info.icon" @tap.stop="handleEvent">
3
3
  <ml-icon :name="info.icon"></ml-icon>
4
4
  </view>
5
5
  </template>
@@ -19,6 +19,11 @@ export default {
19
19
  const { info, marginRight } = this
20
20
  return `color: ${info?.color}; font-size: ${Number(info?.fontSize)}rpx; margin-right: ${marginRight}rpx`
21
21
  }
22
+ },
23
+ methods: {
24
+ handleEvent (e) {
25
+ this.$emit('tap-icon', this.info)
26
+ }
22
27
  }
23
28
  }
24
29
  </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mali-applet-ui",
3
- "version": "1.0.84",
3
+ "version": "1.0.86",
4
4
  "description": "码里云小程序组件库",
5
5
  "files": [
6
6
  "lib",