mali-applet-ui 0.1.5 → 0.1.7

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,18 +2,22 @@
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
- <input
6
- v-else
7
- class="ml-amount-input"
8
- v-model="inpVal"
9
- type="digit"
10
- :class="[{'is-right': align === 'right', 'is-border': border}, className]"
11
- autocomplete="off"
12
- :placeholder="placeholder"
13
- :maxlength="maxLength"
14
- :disabled="disabled"
15
- @blur="blurEvent"
16
- @input="inputEvent" />
5
+ <view v-else class="ml-amount-input" :class="[{'is-right': align === 'right', 'is-border': border}, className]">
6
+ <view v-if="showTip" class="ml-amount-tip">
7
+ <view>首位:</view>
8
+ <view class="ml-amount-tip-label">{{ firstNumLabel }}</view>
9
+ </view>
10
+ <input
11
+ v-model="inpVal"
12
+ type="digit"
13
+ class="ml-amount-input-inp"
14
+ autocomplete="off"
15
+ :placeholder="placeholder"
16
+ :maxlength="maxLength"
17
+ :disabled="disabled"
18
+ @blur="blurEvent"
19
+ @input="inputEvent" />
20
+ </view>
17
21
  </template>
18
22
 
19
23
  <script>
@@ -26,7 +30,7 @@ export default {
26
30
  virtualHost: true
27
31
  },
28
32
  props: {
29
- value: String,
33
+ value: [String, Number],
30
34
  align: String,
31
35
  border: Boolean,
32
36
  min: {
@@ -35,7 +39,7 @@ export default {
35
39
  },
36
40
  max: {
37
41
  type: [Number, String],
38
- default: 9999999999999
42
+ default: 9999999999
39
43
  },
40
44
  maxLength: {
41
45
  type: Number,
@@ -49,6 +53,7 @@ export default {
49
53
  type: Boolean,
50
54
  default: false
51
55
  },
56
+ showTip: Boolean,
52
57
  className: String
53
58
  },
54
59
  inject: {
@@ -86,11 +91,43 @@ export default {
86
91
  return Number(this.max)
87
92
  }
88
93
  return null
94
+ },
95
+ firstNumLabel () {
96
+ const numVal = XEUtils.toNumber(this.value)
97
+ if (numVal > 999999999999) {
98
+ return '万亿'
99
+ } else if (numVal > 99999999999) {
100
+ return '千亿'
101
+ } else if (numVal > 9999999999) {
102
+ return '百亿'
103
+ } else if (numVal > 999999999) {
104
+ return '十亿'
105
+ } else if (numVal > 99999999) {
106
+ return '亿'
107
+ } else if (numVal > 9999999) {
108
+ return '千万'
109
+ } else if (numVal > 999999) {
110
+ return '百万'
111
+ } else if (numVal > 99999) {
112
+ return '十万'
113
+ } else if (numVal > 9999) {
114
+ return '万'
115
+ } else if (numVal > 999) {
116
+ return '千'
117
+ } else if (numVal > 99) {
118
+ return '百'
119
+ } else if (numVal > 9) {
120
+ return '十'
121
+ }
122
+ return '个'
89
123
  }
90
124
  },
91
125
  watch: {
92
126
  value (val) {
93
- this.inpVal = val
127
+ if (!this.updateModel) {
128
+ this.inpVal = val
129
+ }
130
+ this.updateModel = false
94
131
  },
95
132
  min () {
96
133
  this.checkValue()
@@ -100,28 +137,36 @@ export default {
100
137
  }
101
138
  },
102
139
  created () {
103
- this.inpVal = this.value
140
+ this.updateValue(this.inpVal)
104
141
  },
105
142
  methods: {
143
+ updateValue (value) {
144
+ this.inpVal = value === '' || XEUtils.eqNull(value) ? '' : XEUtils.toFixed(XEUtils.toNumber(value), 2)
145
+ },
106
146
  checkValue () {
107
- if (this.minNum !== null && (Number(this.value) < this.minNum)) {
108
- this.$emit('input', this.minNum)
109
- return { status: false, value: this.minNum }
147
+ const numVal = XEUtils.toNumber(this.inpVal)
148
+ if (this.minNum !== null && (numVal < this.minNum)) {
149
+ this.$emit('input', this.minNum)
150
+ return { status: false, value: this.minNum }
110
151
  }
111
- if (this.maxNum !== null && (Number(this.value) > this.maxNum)) {
112
- this.$emit('input', this.maxNum)
113
- return { status: false, value: this.maxNum }
152
+ if (this.maxNum !== null && (numVal > this.maxNum)) {
153
+ this.$emit('input', this.maxNum)
154
+ return { status: false, value: this.maxNum }
114
155
  }
115
- const val = XEUtils.floor(Number(this.value), 2)
156
+ const val = XEUtils.floor(numVal, 2)
116
157
  if (`${val}` !== `${this.value}`) {
117
158
  this.$emit('input', val)
118
159
  return { status: false, value: val }
119
160
  }
120
- return { status: true, value: 0 }
161
+ return { status: true, value: numVal }
121
162
  },
122
163
  blurEvent () {
123
- this.checkValue()
124
- this.$emit('blur')
164
+ const rest = this.checkValue()
165
+ this.updateModel = rest.status
166
+ this.$nextTick(() => {
167
+ this.updateValue(rest.value)
168
+ })
169
+ this.$emit('blur', { value: this.inpVal })
125
170
  },
126
171
  inputEvent () {
127
172
  const value = this.inpVal
@@ -134,16 +179,35 @@ export default {
134
179
 
135
180
  <style lang="scss">
136
181
  .ml-amount-input {
137
- font-size: $uni-font-size-base;
138
- padding: 0 10rpx;
139
- height: 70rpx;
140
- width: 100%;
182
+ position: relative;
141
183
  &.is-right {
142
- text-align: right;
184
+ .ml-amount-input-inp {
185
+ text-align: right;
186
+ }
143
187
  }
144
188
  &.is-border {
145
- border: 1px solid #e5e5e5;
146
- border-radius: 10rpx;
189
+ .ml-amount-input-inp {
190
+ border: 1px solid #e5e5e5;
191
+ border-radius: 10rpx;
192
+ }
193
+ }
194
+ .ml-amount-tip {
195
+ display: flex;
196
+ flex-direction: row;
197
+ position: absolute;
198
+ top: -60rpx;
199
+ right: 10rpx;
200
+ z-index: 1;
201
+ .ml-amount-tip-label {
202
+ min-width: 60rpx;
203
+ text-align: right;
204
+ }
205
+ }
206
+ .ml-amount-input-inp {
207
+ font-size: $uni-font-size-base;
208
+ width: 100%;
209
+ height: 70rpx;
210
+ padding: 0 10rpx;
147
211
  }
148
212
  }
149
213
  .ml-amount-input-readonly-content {
@@ -93,15 +93,17 @@ export default {
93
93
  &.size-medium {
94
94
  height: 90rpx;
95
95
  line-height: 90rpx;
96
- font-size: $uni-font-size-lg;
96
+ font-size: 36rpx;
97
97
  }
98
98
  &.size-small {
99
99
  height: 70rpx;
100
100
  line-height: 70rpx;
101
+ font-size: 28rpx;
101
102
  }
102
103
  &.size-mini {
103
104
  height: 60rpx;
104
105
  line-height: 60rpx;
106
+ font-size: 24rpx;
105
107
  }
106
108
  &.status-primary {
107
109
  color: #ffffff;
@@ -10,11 +10,12 @@
10
10
  <view class="ml-form-item-content-warpper">
11
11
  <slot>
12
12
  <ml-input v-if="matchComponent('MlInput')" :value="itemValue" border @change="modelEvent"></ml-input>
13
+ <ml-number-input v-if="matchComponent('MlNumberInput')" :value="itemValue" border @change="modelEvent"></ml-number-input>
13
14
  <ml-date-picker v-else-if="matchComponent('MlDatePicker')" :value="itemValue" border @change="modelEvent"></ml-date-picker>
14
15
  <ml-select-picker v-else-if="matchComponent('MlSelectPicker')" :value="itemValue" :options="renderOpts.options" border @change="modelEvent"></ml-select-picker>
15
16
  <ml-textarea v-else-if="matchComponent('MlTextarea')" :value="itemValue" :rows="renderOpts.rows || 3" :showVoice="renderOpts.showVoice || true" border @change="modelEvent"></ml-textarea>
16
17
  <ml-upload v-else-if="matchComponent('MlUpload')" :value="itemValue" :mediatype="renderOpts.mediatype || 'image'" @change="modelEvent"></ml-upload>
17
- <ml-amount-input v-else-if="matchComponent('MlAmountInput')" :value="itemValue" border @change="modelEvent"></ml-amount-input>
18
+ <ml-amount-input v-else-if="matchComponent('MlAmountInput')" :value="itemValue" :showTip="itemVertical" border @change="modelEvent"></ml-amount-input>
18
19
  <ml-amount-text v-else-if="matchComponent('MlAmountText')" :value="itemValue" @change="modelEvent"></ml-amount-text>
19
20
  <text v-else class="ml-form-item-default-content">{{ itemValue }}</text>
20
21
  </slot>
@@ -176,7 +177,6 @@ export default {
176
177
  }
177
178
  .ml-form-item-header {
178
179
  min-height: 70rpx;
179
- color: rgba(0, 0, 0, 0.65);
180
180
  }
181
181
  .ml-form-item-header-asterisk {
182
182
  display: inline;
@@ -192,6 +192,7 @@ export default {
192
192
  &:not(.is-vertical) {
193
193
  .ml-form-item-header {
194
194
  flex-shrink: 0;
195
+ color: rgba(0, 0, 0, 0.65);
195
196
  }
196
197
  }
197
198
  &.title-align-left {
@@ -2,7 +2,7 @@
2
2
  <view v-if="isFromReadonly" class="ml-input is-readonly">
3
3
  <view class="ml-input-readonly-content">{{ inpVal }}</view>
4
4
  </view>
5
- <view v-else class="ml-input" :class="[className || '', {'is-right': align === 'right', 'is-border': border, 'is-prefix': prefixIcon || type === 'search', 'is-suffix': suffixIcon, 'is-disabled': disabled}]">
5
+ <view v-else class="ml-input" :class="[className || '', {'is-right': align === 'right', 'is-border': border, 'is-prefix': prefixIcon || type === 'search', 'is-suffix': suffixIcon, 'is-disabled': disabled, 'is-clear': clearable && inpVal}]">
6
6
  <view v-if="prefixIcon || type === 'search'" class="ml-input-prefix-icon">
7
7
  <ml-icon v-if="prefixIcon" :className="prefixIcon"></ml-icon>
8
8
  <ml-icon v-else name="search"></ml-icon>
@@ -13,8 +13,13 @@
13
13
  class="ml-input-inp"
14
14
  autocomplete="off"
15
15
  :placeholder="placeholder"
16
- @input="inputEvent"
16
+ :maxlength="maxlength"
17
+ @input="inputEvent"
18
+ @blur="blurEvent"
17
19
  @confirm="confirmEvent"/>
20
+ <view v-if="clearable && inpVal" class="ml-input-clear-icon" @click.stop="clearEvent">
21
+ <ml-icon name="delete-filling"></ml-icon>
22
+ </view>
18
23
  <view v-if="suffixIcon" class="ml-input-suffix-icon">
19
24
  <ml-icon :className="suffixIcon"></ml-icon>
20
25
  </view>
@@ -35,10 +40,15 @@ export default {
35
40
  disabled: Boolean,
36
41
  prefixIcon: String,
37
42
  suffixIcon: String,
43
+ clearable: Boolean,
38
44
  placeholder: {
39
45
  type: String,
40
46
  default: '请输入'
41
47
  },
48
+ maxlength: {
49
+ type: [String, Number],
50
+ default: 30
51
+ },
42
52
  className: String
43
53
  },
44
54
  inject: {
@@ -71,9 +81,17 @@ export default {
71
81
  this.$emit('input', value)
72
82
  this.$emit('change', { value })
73
83
  },
84
+ blurEvent () {
85
+ this.$emit('blur', { value: this.inpVal })
86
+ },
74
87
  confirmEvent () {
75
88
  const value = this.inpVal
76
89
  this.$emit('confirm', { value })
90
+ },
91
+ clearEvent () {
92
+ this.inpVal = ''
93
+ this.inputEvent()
94
+ this.$emit('clear', { value: this.inpVal })
77
95
  }
78
96
  }
79
97
  }
@@ -93,6 +111,16 @@ export default {
93
111
  width: 100%;
94
112
  font-size: $uni-font-size-base;
95
113
  }
114
+ .ml-input-clear-icon {
115
+ width: 60rpx;
116
+ display: flex;
117
+ flex-shrink: 0;
118
+ align-items: center;
119
+ justify-content: center;
120
+ background: #fff;
121
+ color: #c0c4cc;
122
+ border-radius: 0 10rpx 10rpx 0;
123
+ }
96
124
  .ml-input-prefix-icon,
97
125
  .ml-input-suffix-icon {
98
126
  min-width: 70rpx;
@@ -118,6 +146,10 @@ export default {
118
146
  &.is-prefix,
119
147
  &.is-suffix,
120
148
  &.is-border {
149
+ .ml-input-clear-icon {
150
+ border: 1px solid #e5e5e5;
151
+ border-left: 0;
152
+ }
121
153
  .ml-input-inp {
122
154
  border: 1px solid #e5e5e5;
123
155
  border-radius: 10rpx;
@@ -133,6 +165,10 @@ export default {
133
165
  }
134
166
  }
135
167
  &.is-suffix {
168
+ .ml-input-clear-icon {
169
+ border-radius: 0;
170
+ border-right: 0;
171
+ }
136
172
  .ml-input-suffix-icon {
137
173
  border-radius: 0 10rpx 10rpx 0;
138
174
  }
@@ -141,6 +177,12 @@ export default {
141
177
  border-radius: 10rpx 0 0 10rpx;
142
178
  }
143
179
  }
180
+ &.is-clear {
181
+ .ml-input-inp {
182
+ padding-right: 0;
183
+ border-right: 0;
184
+ }
185
+ }
144
186
  &.is-prefix.is-suffix {
145
187
  .ml-input-inp {
146
188
  border-radius: 0;
@@ -8,17 +8,20 @@
8
8
  :placeholder="placeholder"
9
9
  :maxlength="maxLength"
10
10
  :disabled="disabled"
11
+ @blur="blurEvent"
11
12
  @input="inputEvent" />
12
13
  </template>
13
14
 
14
15
  <script>
16
+ import XEUtils from 'xe-utils'
17
+
15
18
  export default {
16
19
  name: 'MlNumberInput',
17
20
  options: {
18
21
  virtualHost: true
19
22
  },
20
23
  props: {
21
- value: String,
24
+ value: [String, Number],
22
25
  align: String,
23
26
  border: Boolean,
24
27
  type: String,
@@ -43,13 +46,29 @@ export default {
43
46
  },
44
47
  watch: {
45
48
  value (val) {
46
- this.inpVal = val
49
+ if (!this.updateModel) {
50
+ this.inpVal = val
51
+ }
52
+ this.updateModel = false
47
53
  }
48
54
  },
49
55
  created () {
50
56
  this.inpVal = this.value
51
57
  },
52
58
  methods: {
59
+ checkValue () {
60
+ const numVal = XEUtils.toNumber(this.inpVal)
61
+ if (`${numVal}` !== `${this.value}`) {
62
+ this.$emit('input', numVal)
63
+ return { status: false, value: numVal }
64
+ }
65
+ return { status: true, value: numVal }
66
+ },
67
+ blurEvent () {
68
+ const rest = this.checkValue()
69
+ this.updateModel = rest.status
70
+ this.$emit('blur', { value: this.inpVal })
71
+ },
53
72
  inputEvent () {
54
73
  this.$emit('input', this.inpVal)
55
74
  }
@@ -146,7 +146,7 @@ export default {
146
146
  width: 100%;
147
147
  padding-bottom: 20rpx;
148
148
  transform: translateY(100%);
149
- transition: transform 0.3s ease, transform 0.3s ease;
149
+ transition: transform 0.25s ease, transform 0.3s ease;
150
150
  background: #fff;
151
151
  }
152
152
  .ml-popup-header-title {
@@ -3,12 +3,15 @@
3
3
  <view class="ml-select-picker-readonly-content">{{ selectLabel }}</view>
4
4
  </view>
5
5
  <picker v-else class="ml-select-picker" :style="{width: width || '100%'}" :range="optionList" :range-key="optLabelField" @change="changeEvent">
6
- <view class="ml-select-picker-warpper" :class="[className || '', {'is-border': border}]">
6
+ <view class="ml-select-picker-warpper" :class="[className || '', {'is-border': border, 'is-clear': value !== null}]">
7
7
  <view class="ml-select-picker-text">
8
8
  <text v-if="value !== null">{{ selectLabel }}</text>
9
9
  <text v-else class="picker-placeholder">{{ placeholder }}</text>
10
10
  </view>
11
- <view class="ml-select-picker-icon">
11
+ <view v-if="clearable && value !== null" class="ml-select-clear-icon" @click.stop="clearEvent">
12
+ <ml-icon name="delete-filling"></ml-icon>
13
+ </view>
14
+ <view v-else class="ml-select-picker-icon">
12
15
  <ml-icon name="arrow-down" />
13
16
  </view>
14
17
  </view>
@@ -28,6 +31,7 @@ export default {
28
31
  type: String,
29
32
  default: '请选择'
30
33
  },
34
+ clearable: Boolean,
31
35
  options: Array,
32
36
  optionProps: Object,
33
37
  width: String,
@@ -83,6 +87,12 @@ export default {
83
87
  }
84
88
  this.$emit('input', value)
85
89
  this.$emit('change', { value, option: item })
90
+ },
91
+ clearEvent () {
92
+ const value = null
93
+ this.$emit('input', value)
94
+ this.$emit('change', { value, option: null })
95
+ this.$emit('clear', { value })
86
96
  }
87
97
  }
88
98
  }
@@ -109,11 +119,12 @@ export default {
109
119
  display: flex;
110
120
  flex-direction: row;
111
121
  align-items: center;
112
- padding: 0 10rpx;
122
+ padding: 0 20rpx;
113
123
  height: 70rpx;
114
124
  border-radius: 10rpx;
115
125
  &.is-border {
116
126
  border: 1px solid #e5e5e5;
127
+ background: #fff;
117
128
  }
118
129
  }
119
130
  .ml-select-picker-text {
@@ -123,8 +134,22 @@ export default {
123
134
  text-overflow: ellipsis;
124
135
  white-space: nowrap;
125
136
  }
137
+ .ml-select-clear-icon {
138
+ width: 60rpx;
139
+ display: flex;
140
+ flex-shrink: 0;
141
+ align-items: center;
142
+ justify-content: center;
143
+ background: #fff;
144
+ color: #c0c4cc;
145
+ border-radius: 0 10rpx 10rpx 0;
146
+ }
126
147
  .ml-select-picker-icon {
127
- display: inline;
148
+ width: 60rpx;
149
+ display: flex;
150
+ flex-shrink: 0;
151
+ align-items: center;
152
+ justify-content: center;
128
153
  color: #6a6a6a;
129
154
  }
130
155
  </style>
@@ -7,7 +7,7 @@
7
7
  <view v-else>
8
8
  <textarea class="ml-textarea-inp" v-model="inpVal" :rows="rows" :maxlength="maxLength" :placeholder="placeholder" :show-count="false" @input="inputEvent" :style="{color: fontColor, height: `${rows * 30}rpx`}"></textarea>
9
9
  <view v-if="showWordLimit" class="ml-textarea-word-count">
10
- <VoiceInput v-if="showVoice" v-model="inpVal" @input="inputEvent"></VoiceInput>
10
+ <!-- <VoiceInput v-if="showVoice" v-model="inpVal" @input="inputEvent"></VoiceInput> -->
11
11
  <view class="ml-textarea-word-numbers">{{ value ? value.length : 0 }}/{{ maxLength }}</view>
12
12
  </view>
13
13
  </view>
@@ -37,7 +37,7 @@ export default {
37
37
  },
38
38
  maxLength: {
39
39
  type: Number,
40
- default: 250
40
+ default: 200
41
41
  },
42
42
  placeholder: {
43
43
  type: String,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mali-applet-ui",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "码里云小程序组件库",
5
5
  "files": [
6
6
  "components",