mali-applet-ui 1.0.71 → 1.0.73

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.
package/README.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  Mali-Applet-UI 码里云小程序组件库
4
4
 
5
+ ## 组件开发规范
6
+
7
+ ### 命名规范
8
+
9
+ 组件命名以开头 ml-*,全小写,配合 [easycom](https://uniapp.dcloud.net.cn/component/#easycom%E7%BB%84%E4%BB%B6%E8%A7%84%E8%8C%83) 规则按需加载
10
+ 例如,新增按钮组件:src/components/ml-button/ml-button.vue
11
+ 如果是内部组件,使用大写开头驼峰命名
12
+
5
13
  ## 运行项目
6
14
 
7
15
  ```
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <view class="ml-amount-text" :class="[className || '', status ? `ss-${status}` : '', {'is-underline': underline}]">
2
+ <view class="ml-amount-text" :class="[className || '', status ? `ss-${status}` : '', {'is-underline': underline}]" @tap="tapEvent">
3
3
  <slot name="symbol">
4
4
  <view v-if="symbol" class="amount-flag">¥</view>
5
5
  </slot>
@@ -45,6 +45,12 @@ export default {
45
45
  }
46
46
  return toAmountString(this.value)
47
47
  }
48
+ },
49
+ methods: {
50
+ tapEvent () {
51
+ this.$emit('tap', {})
52
+ this.$emit('click', {})
53
+ }
48
54
  }
49
55
  }
50
56
  </script>
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <view class="ml-dict-type" :class="[className || '', (status || showStatus) && selectStatus ? `ss-${selectStatus}` : '', {'is-underline': underline, 'is-border': border, 'is-round': round}]">
2
+ <view class="ml-dict-type" :class="[className || '', (status || showStatus) && selectStatus ? `ss-${selectStatus}` : '', {'is-underline': underline, 'is-border': border, 'is-round': round}]" @tap="tapEvent">
3
3
  <view v-if="prefixIcon && prefixIcon !== 'none'" class="ml-dict-type-left-icon">
4
4
  <ml-icon :className="prefixIcon"></ml-icon>
5
5
  </view>
@@ -56,6 +56,12 @@ export default {
56
56
  optStatusField () {
57
57
  return this.optOptions.status || 'status'
58
58
  }
59
+ },
60
+ methods: {
61
+ tapEvent () {
62
+ this.$emit('tap', {})
63
+ this.$emit('click', {})
64
+ }
59
65
  }
60
66
  }
61
67
  </script>
@@ -28,14 +28,14 @@
28
28
  @change="handleChangeCheckbox(item)"></ml-checkbox>
29
29
  <ml-radio :value="checkIndex" :label="item[useProps.key]" v-else @change="handleChangeRadio"></ml-radio>
30
30
  </view>
31
- <MlTreeIcon @click="e => $emit('click-icon', 'prefix', item)" :info="getPrefixIcon(item)" :key="index"></MlTreeIcon>
31
+ <MlTreeIcon @click="e => $emit('click-icon', item, 'prefix')" :info="getPrefixIcon(item)" :key="index"></MlTreeIcon>
32
32
  <view class="ml-tree-node__title" @click="handleIntoChildren(item)">
33
33
  <view>{{ item[useProps.label] || '' }}</view>
34
34
  <view class="ml-tree-node__explain" v-if="item[useProps.explain]">{{ item[useProps.explain] }}</view>
35
35
  </view>
36
36
  <view class="ml-tree-node__extra">
37
- <MlTreeIcon @click="e => $emit('click-icon', 'suffix', item)" :info="getSuffixIcon(item)" :key="index"></MlTreeIcon>
38
- <MlTreeIcon @click="handleIntoChildren(item)" v-if="item.children && item.children.length" :info="{ icon: 'arrow-right' }" :key="index"></MlTreeIcon>
37
+ <MlTreeIcon @click="e => $emit('click-icon', item, 'suffix')" :info="getSuffixIcon(item)" :key="index"></MlTreeIcon>
38
+ <MlTreeIcon @click="handleIntoChildren(item)" v-if="(item.children && item.children.length) || (lazy && !item.isLeaf)" :info="{ icon: 'arrow-right' }" :key="index"></MlTreeIcon>
39
39
  </view>
40
40
  </view>
41
41
  </view>
@@ -43,8 +43,8 @@
43
43
  </template>
44
44
 
45
45
  <script>
46
- import MlTreeIcon from './ml-tree-icon'
47
- import { findNodesByKeys, findTreeByKey } from '@/components/ml-tree-box/index'
46
+ import MlTreeIcon from './ml-tree-icon.vue'
47
+ import { findNodesByKeys, findTreeByKey } from './utils'
48
48
 
49
49
  export default {
50
50
  name: 'ml-tree-box',
@@ -57,6 +57,8 @@ export default {
57
57
  check: Boolean,
58
58
  multiple: Boolean,
59
59
  breadcrumb: Boolean,
60
+ lazy: Boolean,
61
+ lazyLoad: Function,
60
62
  strictly: Boolean,
61
63
  arbitrary: Boolean,
62
64
  props: {
@@ -91,7 +93,8 @@ export default {
91
93
  label: 'label',
92
94
  children: 'children',
93
95
  explain: 'explain',
94
- user: 'user'
96
+ user: 'user',
97
+ isLeaf: 'isLeaf'
95
98
  }
96
99
  }
97
100
  },
@@ -115,7 +118,13 @@ export default {
115
118
  }
116
119
  },
117
120
  methods: {
118
- handleIntoChildren (item) {
121
+ async handleIntoChildren (item) {
122
+ const { lazyLoad, lazy } = this
123
+ if (lazy && lazyLoad && !item.isLeaf) {
124
+ // this.lazyLoading = true
125
+ await lazyLoad(item)
126
+ // this.lazyLoading = false
127
+ }
119
128
  if (item.children && item.children.length) {
120
129
  this.cache.push(item)
121
130
  }
@@ -25,6 +25,6 @@ export default {
25
25
  <style lang="scss" scoped>
26
26
  .ml-tree-node__icon {
27
27
  display: inline-flex;
28
- margin-right: 10rpx;
28
+ margin-right: 15rpx;
29
29
  }
30
30
  </style>
@@ -0,0 +1,58 @@
1
+ export const findTreeKey = (list, props = { key: 'key', children: 'children' }) => {
2
+ let keys = []
3
+ const { key = 'key', children = 'children' } = props
4
+ for (let i = 0; i < list.length; i++) {
5
+ const item = list[i]
6
+ if (item[key]) {
7
+ keys.push(item[key])
8
+ }
9
+ if (item[children] && item[children].length) {
10
+ const findKeys = findTreeKey(item[children], props)
11
+ keys = [...keys, ...findKeys]
12
+ }
13
+ }
14
+ return keys
15
+ }
16
+
17
+ // 根据节点ID找到对应节点
18
+ export const findTreeByKey = (node, key, parent, props = { key: 'key', children: 'children' }) => {
19
+ const propsKey = props.key || 'key'
20
+ const propsChildren = props.children || 'children'
21
+ for (let i = 0; i < node.length; i++) {
22
+ const item = node[i]
23
+ if (item[propsKey] === key) {
24
+ return {
25
+ node: item,
26
+ parent: parent
27
+ }
28
+ }
29
+ if (item[propsChildren] && item[propsChildren].length) {
30
+ const children = item[propsChildren]
31
+ const findTree = findTreeByKey(children, key, item, props)
32
+ if (findTree) {
33
+ return findTree
34
+ }
35
+ }
36
+ }
37
+ }
38
+
39
+ // 根据节点ID找到对应节点
40
+ export const findNodesByKeys = (node, keys, props = { key: 'key', children: 'children' }) => {
41
+ const propsKey = props.key || 'key'
42
+ const propsChildren = props.children || 'children'
43
+ let list = []
44
+ for (let i = 0; i < node.length; i++) {
45
+ const item = node[i]
46
+ if (keys.indexOf(item[propsKey]) > -1) {
47
+ list.push(item)
48
+ }
49
+ if (item[propsChildren] && item[propsChildren].length) {
50
+ const children = item[propsChildren]
51
+ const findTree = findNodesByKeys(children, keys, props)
52
+ if (findTree && findTree.length) {
53
+ list = [...list, ...findTree]
54
+ }
55
+ }
56
+ }
57
+ return list
58
+ }
@@ -24,8 +24,7 @@ import XEUtils from 'xe-utils'
24
24
 
25
25
  export default {
26
26
  props: {
27
- nodeData: Object,
28
- nodeProps: Object
27
+ nodeData: Object
29
28
  },
30
29
  inject: {
31
30
  tree: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mali-applet-ui",
3
- "version": "1.0.71",
3
+ "version": "1.0.73",
4
4
  "description": "码里云小程序组件库",
5
5
  "files": [
6
6
  "lib",