mali-applet-ui 1.0.62 → 1.0.64

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.
@@ -138,6 +138,10 @@ export default {
138
138
  errRule = rule
139
139
  break
140
140
  }
141
+ if (rule.pattern && !new RegExp(rule.pattern).test(itemValue)) {
142
+ errRule = rule
143
+ break
144
+ }
141
145
  }
142
146
  }
143
147
  }
@@ -67,9 +67,8 @@ export default {
67
67
 
68
68
  <style lang="scss">
69
69
  .ml-text {
70
- display: inline-block;
70
+ display: inline-flex;
71
71
  padding: 0 4rpx;
72
- vertical-align: middle;
73
72
  &.is-underline {
74
73
  text-decoration: underline;
75
74
  // #ifdef H5
@@ -0,0 +1,155 @@
1
+ <template>
2
+ <view class="ml-tree" :class="[className || '']">
3
+ <view v-if="showCheckbox && (showAllCheckbox || showCheckboxBtn)" class="ml-tree-checkbox-btns">
4
+ <view v-if="showAllCheckbox" class="ml-tree-checkbox-btns-left">
5
+ <ml-checkbox v-model="isAllCheckboxChecked" :indeterminate="isAllCheckboxIndeterminate" @change="toggleCheckboxRow()">全选</ml-checkbox>
6
+ </view>
7
+ <view v-if="showCheckboxBtn" class="ml-tree-checkbox-btns-right">
8
+ <ml-button size="mini" status="primary" @click="setAllTreeExpand(true)">一键展开</ml-button>
9
+ <ml-button size="mini" status="primary" @click="setAllTreeExpand(false)">一键收起</ml-button>
10
+ </view>
11
+ </view>
12
+ <ml-tree-node v-for="(item, index) in data" :key="index" :node-data="item"></ml-tree-node>
13
+ </view>
14
+ </template>
15
+
16
+ <script>
17
+ import XEUtils from 'xe-utils'
18
+
19
+ export default {
20
+ name: 'MlTree',
21
+ props: {
22
+ data: Array,
23
+ height: String,
24
+ checkStrictly: Boolean,
25
+ showRadio: Boolean,
26
+ showCheckbox: Boolean,
27
+ showAllCheckbox: {
28
+ type: Boolean,
29
+ default: true
30
+ },
31
+ indeterminateToChecked: Boolean,
32
+ showCheckboxBtn: Boolean,
33
+ checkRowKeys: Array,
34
+ nodeProps: Object
35
+ },
36
+ provide () {
37
+ return {
38
+ mlTree: this
39
+ }
40
+ },
41
+ data () {
42
+ return {
43
+ isAllCheckboxChecked: false,
44
+ isAllCheckboxIndeterminate: false,
45
+ indeterminateRowKeys: [],
46
+ selectCheckboxRowKeys: [],
47
+ expandRowKeys: []
48
+ }
49
+ },
50
+ computed: {
51
+ styles () {
52
+ return this.height ? `height: ${this.height};` : ''
53
+ },
54
+ nodeOpts () {
55
+ const nodeProps = this.nodeProps || {}
56
+ return {
57
+ title: nodeProps.name || 'name',
58
+ key: nodeProps.key || 'key',
59
+ children: nodeProps.children || 'children'
60
+ }
61
+ },
62
+ titleField () {
63
+ return this.nodeOpts.title
64
+ },
65
+ keyField () {
66
+ return this.nodeOpts.key
67
+ },
68
+ childrenField () {
69
+ return this.nodeOpts.children
70
+ }
71
+ },
72
+ watch: {
73
+ checkRowKeys () {
74
+
75
+ }
76
+ },
77
+ methods: {
78
+ selectCheckboxNodeEvent ({ nodeData, nodeKey }) {
79
+ const nodeIndex = this.selectCheckboxRowKeys.indexOf(nodeKey)
80
+ const checked = nodeIndex === -1
81
+ if (checked) {
82
+ this.selectCheckboxRowKeys.push(nodeKey)
83
+ } else {
84
+ this.selectCheckboxRowKeys.splice(nodeIndex, 1)
85
+ }
86
+ this.$emit('checkbox-change', { row: nodeData, checked, checkedKeys: this.selectCheckboxRowKeys })
87
+ this.$emit('update:checkRowKeys', [...this.selectCheckboxRowKeys])
88
+ },
89
+ expandNodeEvent ({ nodeData, nodeKey }) {
90
+ const nodeIndex = this.expandRowKeys.indexOf(nodeKey)
91
+ const expanded = nodeIndex === -1
92
+ if (expanded) {
93
+ this.expandRowKeys.push(nodeKey)
94
+ } else {
95
+ this.expandRowKeys.splice(nodeIndex, 1)
96
+ }
97
+ this.$emit('expand-change', { row: nodeData, expanded, expandedKeys: this.expandRowKeys })
98
+ },
99
+ setCheckboxRow (row) {
100
+ // let rows = row
101
+ // if (!XEUtils.isArray(row)) {
102
+ // rows = [row]
103
+ // }
104
+ },
105
+ toggleCheckboxRow () {
106
+ const { keyField, childrenField } = this
107
+ const rowKeys = []
108
+ if (this.isAllCheckboxChecked) {
109
+ XEUtils.eachTree(this.data, (item) => {
110
+ rowKeys.push(item[keyField])
111
+ }, { children: childrenField })
112
+ }
113
+ this.selectCheckboxRowKeys = rowKeys
114
+ },
115
+ setAllTreeExpand (expanded) {
116
+ const { keyField, childrenField } = this
117
+ const rowKeys = []
118
+ if (expanded) {
119
+ XEUtils.eachTree(this.data, (item) => {
120
+ if (item[childrenField] && item[childrenField].length > 0) {
121
+ rowKeys.push(item[keyField])
122
+ }
123
+ }, { children: childrenField })
124
+ }
125
+ this.expandRowKeys = rowKeys
126
+ }
127
+ }
128
+ }
129
+ </script>
130
+
131
+ <style lang="scss">
132
+ .ml-tree {
133
+ padding-left: 16rpx;
134
+ overflow: auto;
135
+ .ml-tree-checkbox-btns {
136
+ position: sticky;
137
+ left: 0;
138
+ top: 0;
139
+ display: flex;
140
+ flex-direction: row;
141
+ align-items: center;
142
+ height: 80rpx;
143
+ border-bottom: 1px solid #e5e5e5;
144
+ background: #ffffff;
145
+ }
146
+ .ml-tree-checkbox-btns-left {
147
+ flex-grow: 1;
148
+ }
149
+ .ml-tree-checkbox-btns-right {
150
+ display: flex;
151
+ flex-direction: row;
152
+ flex-shrink: 0;
153
+ }
154
+ }
155
+ </style>
@@ -0,0 +1,149 @@
1
+ <template>
2
+ <view class="ml-tree-node" :class="[className || '']">
3
+ <view class="ml-tree-node-warpper">
4
+ <view v-if="showCheckbox" class="ml-tree-node-checkbox" :class="{'is-checked': checkCheckbox}">
5
+ <view class="ml-tree-node-checkbox-icon" @click="changeCheckboxEvent">
6
+ <ml-icon :name="checkCheckbox ? 'checkbox-checked' : (indeterminate ? 'checkbox-indeterminate' : 'checkbox-unchecked')"></ml-icon>
7
+ </view>
8
+ </view>
9
+ <view class="ml-tree-node-expand" :class="{'is-expand': hasExpand}">
10
+ <view v-if="hasChild" class="ml-tree-node-expand-icon" @click="expandEvent">
11
+ <ml-icon name="arrow-right-filling"></ml-icon>
12
+ </view>
13
+ </view>
14
+ <view class="ml-tree-node-name">{{ nodeContent }}</view>
15
+ </view>
16
+ <view v-if="hasChild && hasExpand" class="ml-tree-node-childs">
17
+ <ml-tree-node v-for="(item, index) in nodeChilds" :key="index" :node-data="item"></ml-tree-node>
18
+ </view>
19
+ </view>
20
+ </template>
21
+
22
+ <script>
23
+ import XEUtils from 'xe-utils'
24
+
25
+ export default {
26
+ props: {
27
+ nodeData: Object,
28
+ nodeProps: Object
29
+ },
30
+ inject: {
31
+ tree: {
32
+ from: 'mlTree',
33
+ default: null
34
+ }
35
+ },
36
+ data () {
37
+ return {
38
+ treeData: []
39
+ }
40
+ },
41
+ computed: {
42
+ nodeKey () {
43
+ return this.nodeData ? this.nodeData[this.keyField] : null
44
+ },
45
+ nodeContent () {
46
+ return this.nodeData ? XEUtils.toValueString(this.nodeData[this.titleField]) : ''
47
+ },
48
+ nodeChilds () {
49
+ return this.nodeData ? (this.nodeData[this.childrenField] || []) : []
50
+ },
51
+ titleField () {
52
+ return this.tree ? this.tree.titleField : 'name'
53
+ },
54
+ keyField () {
55
+ return this.tree ? this.tree.keyField : 'key'
56
+ },
57
+ childrenField () {
58
+ return this.tree ? this.tree.childrenField : 'children'
59
+ },
60
+ indeterminateRowKeys () {
61
+ return this.tree ? (this.tree.indeterminateRowKeys || []) : []
62
+ },
63
+ selectCheckboxRowKeys () {
64
+ return this.tree ? (this.tree.selectCheckboxRowKeys || []) : []
65
+ },
66
+ expandRowKeys () {
67
+ return this.tree ? (this.tree.expandRowKeys || []) : []
68
+ },
69
+ showRadio () {
70
+ return this.tree ? this.tree.showRadio : false
71
+ },
72
+ showCheckbox () {
73
+ return this.tree ? this.tree.showCheckbox : false
74
+ },
75
+ hasChild () {
76
+ return this.nodeChilds.length > 0
77
+ },
78
+ hasExpand () {
79
+ return this.expandRowKeys.includes(this.nodeKey)
80
+ },
81
+ indeterminate () {
82
+ return this.showCheckbox ? this.indeterminateRowKeys.includes(this.nodeKey) : false
83
+ },
84
+ checkCheckbox () {
85
+ return this.showCheckbox ? this.selectCheckboxRowKeys.includes(this.nodeKey) : false
86
+ }
87
+ },
88
+ methods: {
89
+ changeCheckboxEvent () {
90
+ if (this.tree) {
91
+ this.tree.selectCheckboxNodeEvent({
92
+ nodeData: this.nodeData,
93
+ nodeKey: this.nodeKey
94
+ })
95
+ }
96
+ },
97
+ expandEvent () {
98
+ if (this.tree) {
99
+ this.tree.expandNodeEvent({
100
+ nodeData: this.nodeData,
101
+ nodeKey: this.nodeKey
102
+ })
103
+ }
104
+ }
105
+ }
106
+ }
107
+ </script>
108
+
109
+ <style lang="scss">
110
+ .ml-tree-node {
111
+ .ml-tree-node-warpper {
112
+ display: flex;
113
+ flex-direction: row;
114
+ align-items: center;
115
+ height: 80rpx;
116
+ border-bottom: 1px solid #e5e5e5;
117
+ }
118
+ .ml-tree-node-checkbox-icon,
119
+ .ml-tree-node-expand-icon {
120
+ font-size: 1.3em;
121
+ }
122
+ .ml-tree-node-checkbox {
123
+ width: 50rpx;
124
+ text-align: center;
125
+ &.is-checked {
126
+ color: $uni-color-primary;
127
+ }
128
+ }
129
+ .ml-tree-node-expand {
130
+ width: 50rpx;
131
+ text-align: center;
132
+ &.is-expand {
133
+ .ml-tree-node-expand-icon {
134
+ transform: rotate(90deg);
135
+ }
136
+ }
137
+ }
138
+ .ml-tree-node-expand-icon {
139
+ display: inline-block;
140
+ width: 40rpx;
141
+ height: 40rpx;
142
+ line-height: 40rpx;
143
+ transition: transform .1s ease-in-out;
144
+ }
145
+ .ml-tree-node-childs {
146
+ padding-left: 24rpx;
147
+ }
148
+ }
149
+ </style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mali-applet-ui",
3
- "version": "1.0.62",
3
+ "version": "1.0.64",
4
4
  "description": "码里云小程序组件库",
5
5
  "files": [
6
6
  "lib",