mali-applet-ui 0.1.61 → 0.1.63
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.
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<view v-if="isFromReadonly" class="ml-amount-input is-readonly">
|
|
3
3
|
<view class="ml-amount-input-readonly-content">¥{{ amountLabel }}</view>
|
|
4
4
|
</view>
|
|
5
|
-
<view v-else class="ml-amount-input" :class="[{'is-right': align === 'right', 'is-border': border}, className]">
|
|
5
|
+
<view v-else class="ml-amount-input" :class="[{'is-right': align === 'right', 'is-border': border, 'is-disabled': disabled, 'is-clear': clearable && inpVal}, className]">
|
|
6
6
|
<view v-if="showTip" class="ml-amount-tip">
|
|
7
7
|
<view>首位:</view>
|
|
8
8
|
<view class="ml-amount-tip-label">{{ firstNumLabel }}</view>
|
|
@@ -17,6 +17,9 @@
|
|
|
17
17
|
:disabled="disabled"
|
|
18
18
|
@blur="blurEvent"
|
|
19
19
|
@input="inputEvent" />
|
|
20
|
+
<view v-if="clearable && !disabled && inpVal" class="ml-amount-input-clear-icon" @click.stop="clearEvent">
|
|
21
|
+
<ml-icon name="delete-filling"></ml-icon>
|
|
22
|
+
</view>
|
|
20
23
|
</view>
|
|
21
24
|
</template>
|
|
22
25
|
|
|
@@ -24,6 +27,10 @@
|
|
|
24
27
|
import XEUtils from 'xe-utils'
|
|
25
28
|
import { toAmountString, toWanAmountString } from '../../utils'
|
|
26
29
|
|
|
30
|
+
function eqEmptyNull (value) {
|
|
31
|
+
return value === '' || XEUtils.eqNull(value)
|
|
32
|
+
}
|
|
33
|
+
|
|
27
34
|
export default {
|
|
28
35
|
name: 'MlAmountInput',
|
|
29
36
|
options: {
|
|
@@ -54,6 +61,7 @@ export default {
|
|
|
54
61
|
default: false
|
|
55
62
|
},
|
|
56
63
|
showTip: Boolean,
|
|
64
|
+
clearable: Boolean,
|
|
57
65
|
className: String
|
|
58
66
|
},
|
|
59
67
|
inject: {
|
|
@@ -137,13 +145,17 @@ export default {
|
|
|
137
145
|
}
|
|
138
146
|
},
|
|
139
147
|
created () {
|
|
140
|
-
this.updateValue(this.
|
|
148
|
+
this.updateValue(this.value)
|
|
141
149
|
},
|
|
142
150
|
methods: {
|
|
143
151
|
updateValue (value) {
|
|
144
|
-
this.inpVal =
|
|
152
|
+
this.inpVal = eqEmptyNull(value) ? '' : XEUtils.toFixed(XEUtils.toNumber(value), 2)
|
|
145
153
|
},
|
|
146
154
|
checkValue () {
|
|
155
|
+
// 如果是空值,则不处理
|
|
156
|
+
if (eqEmptyNull(this.inpVal) && eqEmptyNull(this.value)) {
|
|
157
|
+
return { status: false, value: this.inpVal }
|
|
158
|
+
}
|
|
147
159
|
const numVal = XEUtils.toNumber(this.inpVal)
|
|
148
160
|
if (this.minNum !== null && (numVal < this.minNum)) {
|
|
149
161
|
this.$emit('input', this.minNum)
|
|
@@ -163,15 +175,22 @@ export default {
|
|
|
163
175
|
blurEvent () {
|
|
164
176
|
const rest = this.checkValue()
|
|
165
177
|
this.updateModel = rest.status
|
|
166
|
-
|
|
167
|
-
this
|
|
168
|
-
|
|
178
|
+
if (rest.status) {
|
|
179
|
+
this.$nextTick(() => {
|
|
180
|
+
this.updateValue(rest.value)
|
|
181
|
+
})
|
|
182
|
+
}
|
|
169
183
|
this.$emit('blur', { value: this.inpVal })
|
|
170
184
|
},
|
|
171
185
|
inputEvent () {
|
|
172
186
|
const value = this.inpVal
|
|
173
187
|
this.$emit('input', value)
|
|
174
188
|
this.$emit('change', { value })
|
|
189
|
+
},
|
|
190
|
+
clearEvent () {
|
|
191
|
+
this.inpVal = ''
|
|
192
|
+
this.inputEvent()
|
|
193
|
+
this.$emit('clear', { value: this.inpVal })
|
|
175
194
|
}
|
|
176
195
|
}
|
|
177
196
|
}
|
|
@@ -180,6 +199,12 @@ export default {
|
|
|
180
199
|
<style lang="scss">
|
|
181
200
|
.ml-amount-input {
|
|
182
201
|
position: relative;
|
|
202
|
+
flex-grow: 1;
|
|
203
|
+
display: flex;
|
|
204
|
+
flex-direction: row;
|
|
205
|
+
.ml-amount-input-readonly-content {
|
|
206
|
+
padding: 20rpx 4rpx;
|
|
207
|
+
}
|
|
183
208
|
&.is-right {
|
|
184
209
|
.ml-amount-input-inp {
|
|
185
210
|
text-align: right;
|
|
@@ -209,8 +234,19 @@ export default {
|
|
|
209
234
|
height: 70rpx;
|
|
210
235
|
padding: 0 10rpx;
|
|
211
236
|
}
|
|
212
|
-
|
|
213
|
-
.ml-amount-input-
|
|
214
|
-
|
|
237
|
+
.ml-amount-input-inp::-webkit-outer-spin-button,
|
|
238
|
+
.ml-amount-input-inp::-webkit-inner-spin-button {
|
|
239
|
+
-webkit-appearance: none;
|
|
240
|
+
}
|
|
241
|
+
.ml-amount-input-clear-icon {
|
|
242
|
+
width: 60rpx;
|
|
243
|
+
display: flex;
|
|
244
|
+
flex-shrink: 0;
|
|
245
|
+
align-items: center;
|
|
246
|
+
justify-content: center;
|
|
247
|
+
background: #fff;
|
|
248
|
+
color: #c0c4cc;
|
|
249
|
+
border-radius: 0 $ml-border-radius $ml-border-radius 0;
|
|
250
|
+
}
|
|
215
251
|
}
|
|
216
252
|
</style>
|
|
@@ -1,20 +1,32 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<input
|
|
3
|
-
class="ml-number-input"
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
<view v-if="isFromReadonly" class="ml-number-input is-readonly">
|
|
3
|
+
<view class="ml-number-input-readonly-content">{{ inpVal }}</view>
|
|
4
|
+
</view>
|
|
5
|
+
<view v-else class="ml-number-input" :class="[{'is-right': align === 'right', 'is-border': border, 'is-disabled': disabled, 'is-clear': clearable && inpVal}, className]">
|
|
6
|
+
<input
|
|
7
|
+
class="ml-number-input-inp"
|
|
8
|
+
v-model="inpVal"
|
|
9
|
+
:type="type === 'integer' ? 'number' : 'digit'"
|
|
10
|
+
:class="[className || '', {'is-right': align === 'right', 'is-border': border}]"
|
|
11
|
+
autocomplete="off"
|
|
12
|
+
:placeholder="placeholder"
|
|
13
|
+
:maxlength="maxLength"
|
|
14
|
+
:disabled="disabled"
|
|
15
|
+
@blur="blurEvent"
|
|
16
|
+
@input="inputEvent" />
|
|
17
|
+
<view v-if="clearable && !disabled && inpVal" class="ml-number-input-clear-icon" @click.stop="clearEvent">
|
|
18
|
+
<ml-icon name="delete-filling"></ml-icon>
|
|
19
|
+
</view>
|
|
20
|
+
</view>
|
|
13
21
|
</template>
|
|
14
22
|
|
|
15
23
|
<script>
|
|
16
24
|
import XEUtils from 'xe-utils'
|
|
17
25
|
|
|
26
|
+
function eqEmptyNull (value) {
|
|
27
|
+
return value === '' || XEUtils.eqNull(value)
|
|
28
|
+
}
|
|
29
|
+
|
|
18
30
|
export default {
|
|
19
31
|
name: 'MlNumberInput',
|
|
20
32
|
options: {
|
|
@@ -37,6 +49,7 @@ export default {
|
|
|
37
49
|
type: Boolean,
|
|
38
50
|
default: false
|
|
39
51
|
},
|
|
52
|
+
clearable: Boolean,
|
|
40
53
|
className: String
|
|
41
54
|
},
|
|
42
55
|
data () {
|
|
@@ -53,10 +66,17 @@ export default {
|
|
|
53
66
|
}
|
|
54
67
|
},
|
|
55
68
|
created () {
|
|
56
|
-
this.
|
|
69
|
+
this.updateValue(this.value)
|
|
57
70
|
},
|
|
58
71
|
methods: {
|
|
72
|
+
updateValue (value) {
|
|
73
|
+
this.inpVal = eqEmptyNull(value) ? '' : String(XEUtils.toNumber(value))
|
|
74
|
+
},
|
|
59
75
|
checkValue () {
|
|
76
|
+
// 如果是空值,则不处理
|
|
77
|
+
if (eqEmptyNull(this.inpVal) && eqEmptyNull(this.value)) {
|
|
78
|
+
return { status: true, value: this.inpVal }
|
|
79
|
+
}
|
|
60
80
|
const numVal = XEUtils.toNumber(XEUtils.toValueString(this.inpVal).slice(0, this.maxLength))
|
|
61
81
|
if (this.type === 'integer' && !/^[0-9]$/.test(numVal)) {
|
|
62
82
|
const value = XEUtils.toInteger(numVal)
|
|
@@ -80,6 +100,11 @@ export default {
|
|
|
80
100
|
},
|
|
81
101
|
inputEvent () {
|
|
82
102
|
this.$emit('input', this.inpVal)
|
|
103
|
+
},
|
|
104
|
+
clearEvent () {
|
|
105
|
+
this.inpVal = ''
|
|
106
|
+
this.inputEvent()
|
|
107
|
+
this.$emit('clear', { value: this.inpVal })
|
|
83
108
|
}
|
|
84
109
|
}
|
|
85
110
|
}
|
|
@@ -87,10 +112,12 @@ export default {
|
|
|
87
112
|
|
|
88
113
|
<style lang="scss">
|
|
89
114
|
.ml-number-input {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
115
|
+
flex-grow: 1;
|
|
116
|
+
display: flex;
|
|
117
|
+
flex-direction: row;
|
|
118
|
+
.ml-number-input-readonly-content {
|
|
119
|
+
padding: 20rpx 4rpx;
|
|
120
|
+
}
|
|
94
121
|
&.is-right {
|
|
95
122
|
text-align: right;
|
|
96
123
|
}
|
|
@@ -98,5 +125,25 @@ export default {
|
|
|
98
125
|
border: 1px solid #e5e5e5;
|
|
99
126
|
border-radius: $ml-border-radius;
|
|
100
127
|
}
|
|
128
|
+
.ml-number-input-inp {
|
|
129
|
+
font-size: $uni-font-size-base;
|
|
130
|
+
width: 100%;
|
|
131
|
+
height: 70rpx;
|
|
132
|
+
padding: 0 10rpx;
|
|
133
|
+
}
|
|
134
|
+
.ml-number-input-inp::-webkit-outer-spin-button,
|
|
135
|
+
.ml-number-input-inp::-webkit-inner-spin-button {
|
|
136
|
+
-webkit-appearance: none;
|
|
137
|
+
}
|
|
138
|
+
.ml-number-input-clear-icon {
|
|
139
|
+
width: 60rpx;
|
|
140
|
+
display: flex;
|
|
141
|
+
flex-shrink: 0;
|
|
142
|
+
align-items: center;
|
|
143
|
+
justify-content: center;
|
|
144
|
+
background: #fff;
|
|
145
|
+
color: #c0c4cc;
|
|
146
|
+
border-radius: 0 $ml-border-radius $ml-border-radius 0;
|
|
147
|
+
}
|
|
101
148
|
}
|
|
102
149
|
</style>
|
|
@@ -53,6 +53,11 @@ export default {
|
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
55
|
computed: {
|
|
56
|
+
selectTab () {
|
|
57
|
+
return this.tabs ? this.tabs.value : null
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
methods: {
|
|
56
61
|
updateProp (prop) {
|
|
57
62
|
if (this.tabs) {
|
|
58
63
|
const item = this.tabs.tabList.find(item => item.mId === this.mId)
|
|
@@ -60,9 +65,6 @@ export default {
|
|
|
60
65
|
item[prop] = this[prop]
|
|
61
66
|
}
|
|
62
67
|
}
|
|
63
|
-
},
|
|
64
|
-
selectTab () {
|
|
65
|
-
return this.tabs ? this.tabs.value : null
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
70
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mali-applet-ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.63",
|
|
4
4
|
"description": "码里云小程序组件库",
|
|
5
5
|
"files": [
|
|
6
6
|
"components",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"main": "index.js",
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"vuex": "^4.0.2",
|
|
18
|
-
"xe-utils": "3.5.
|
|
18
|
+
"xe-utils": "3.5.7"
|
|
19
19
|
},
|
|
20
20
|
"uni-app": {
|
|
21
21
|
"scripts": {
|