mali-applet-ui 0.0.6 → 0.0.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.
- package/components/ml-amount-input/ml-amount-input.vue +115 -0
- package/components/ml-amount-text/ml-amount-text.vue +62 -0
- package/components/ml-echarts/echarts.js +45 -0
- package/components/ml-echarts/ml-echarts.vue +239 -0
- package/components/ml-echarts/wx-canvas.js +105 -0
- package/components/ml-input/ml-input.vue +16 -4
- package/components/ml-number-input/ml-number-input.vue +57 -0
- package/components/ml-select-picker/ml-select-picker.vue +106 -0
- package/package.json +6 -5
- package/utils/index.js +157 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<input class="ml-amount-input" v-model="inpVal" type="text" :class="{'is-right': align === 'right', 'is-border': border}" :placeholder="placeholder" :maxlength="maxLength" :disabled="disabled" @blur="blurEvent" @input="inputEvent" />
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script>
|
|
6
|
+
import XEUtils from 'xe-utils'
|
|
7
|
+
import { toNumMoneyToChinese } from '../../utils'
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
name: 'ml-amount-input',
|
|
11
|
+
props: {
|
|
12
|
+
value: String,
|
|
13
|
+
align: String,
|
|
14
|
+
border: Boolean,
|
|
15
|
+
min: {
|
|
16
|
+
type: [Number, String],
|
|
17
|
+
default: 0
|
|
18
|
+
},
|
|
19
|
+
max: {
|
|
20
|
+
type: [Number, String],
|
|
21
|
+
default: 9999999999999
|
|
22
|
+
},
|
|
23
|
+
maxLength: {
|
|
24
|
+
type: Number,
|
|
25
|
+
default: 12
|
|
26
|
+
},
|
|
27
|
+
placeholder: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: '请输入'
|
|
30
|
+
},
|
|
31
|
+
disabled: {
|
|
32
|
+
type: Boolean,
|
|
33
|
+
default: false
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
data () {
|
|
37
|
+
return {
|
|
38
|
+
inpVal: ''
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
computed: {
|
|
42
|
+
currAmountNum () {
|
|
43
|
+
return this.value === '' ? '' : Number(this.value || 0)
|
|
44
|
+
},
|
|
45
|
+
currAmountLabel () {
|
|
46
|
+
return this.currAmountNum === '' ? '无' : toNumMoneyToChinese(this.currAmountNum)
|
|
47
|
+
},
|
|
48
|
+
minNum () {
|
|
49
|
+
if (XEUtils.isNumber(this.min) || this.min) {
|
|
50
|
+
return Number(this.min || 0)
|
|
51
|
+
}
|
|
52
|
+
return null
|
|
53
|
+
},
|
|
54
|
+
maxNum () {
|
|
55
|
+
if (XEUtils.isNumber(this.max) || this.max) {
|
|
56
|
+
return Number(this.max)
|
|
57
|
+
}
|
|
58
|
+
return null
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
watch: {
|
|
62
|
+
value (val) {
|
|
63
|
+
this.inpVal = val
|
|
64
|
+
},
|
|
65
|
+
min () {
|
|
66
|
+
this.checkValue()
|
|
67
|
+
},
|
|
68
|
+
max () {
|
|
69
|
+
this.checkValue()
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
created () {
|
|
73
|
+
this.inpVal = this.value
|
|
74
|
+
},
|
|
75
|
+
methods: {
|
|
76
|
+
checkValue () {
|
|
77
|
+
if (this.minNum !== null && (Number(this.value) < this.minNum)) {
|
|
78
|
+
this.$emit('input', this.minNum)
|
|
79
|
+
return { status: false, value: this.minNum }
|
|
80
|
+
}
|
|
81
|
+
if (this.maxNum !== null && (Number(this.value) > this.maxNum)) {
|
|
82
|
+
this.$emit('input', this.maxNum)
|
|
83
|
+
return { status: false, value: this.maxNum }
|
|
84
|
+
}
|
|
85
|
+
const val = XEUtils.floor(Number(this.value), 2)
|
|
86
|
+
if (`${val}` !== `${this.value}`) {
|
|
87
|
+
this.$emit('input', val)
|
|
88
|
+
return { status: false, value: val }
|
|
89
|
+
}
|
|
90
|
+
return { status: true, value: 0 }
|
|
91
|
+
},
|
|
92
|
+
blurEvent () {
|
|
93
|
+
this.checkValue()
|
|
94
|
+
this.$emit('blur')
|
|
95
|
+
},
|
|
96
|
+
inputEvent () {
|
|
97
|
+
this.$emit('input', this.inpVal)
|
|
98
|
+
this.$emit('change', this.inpVal)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
</script>
|
|
103
|
+
|
|
104
|
+
<style lang="scss">
|
|
105
|
+
.ml-amount-input {
|
|
106
|
+
font-size: $uni-font-size-base;
|
|
107
|
+
padding: 0 10rpx;
|
|
108
|
+
&.is-right {
|
|
109
|
+
text-align: right;
|
|
110
|
+
}
|
|
111
|
+
&.is-border {
|
|
112
|
+
border: 1px solid #e5e5e5;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
</style>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="ml-amount-text">
|
|
3
|
+
<slot name="symbol">
|
|
4
|
+
<view v-if="symbol" class="amount-flag">¥</view>
|
|
5
|
+
</slot>
|
|
6
|
+
<slot>
|
|
7
|
+
<view class="amount-num">{{ amountLabel }}</view>
|
|
8
|
+
</slot>
|
|
9
|
+
<slot name="unit">
|
|
10
|
+
<view v-if="unit" class="amount-unit">{{ amountUnit }}</view>
|
|
11
|
+
</slot>
|
|
12
|
+
</view>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script>
|
|
16
|
+
import { toAmountString, toWanAmountString } from '../../utils'
|
|
17
|
+
|
|
18
|
+
export default {
|
|
19
|
+
name: 'MlAmountText',
|
|
20
|
+
props: {
|
|
21
|
+
value: [String, Number],
|
|
22
|
+
simplify: Boolean,
|
|
23
|
+
symbol: {
|
|
24
|
+
type: Boolean,
|
|
25
|
+
default: true
|
|
26
|
+
},
|
|
27
|
+
unit: {
|
|
28
|
+
type: Boolean,
|
|
29
|
+
default: false
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
computed: {
|
|
33
|
+
amountUnit () {
|
|
34
|
+
if (this.simplify) {
|
|
35
|
+
return '万元'
|
|
36
|
+
}
|
|
37
|
+
return '元'
|
|
38
|
+
},
|
|
39
|
+
amountLabel () {
|
|
40
|
+
if (this.simplify) {
|
|
41
|
+
return toWanAmountString(this.value)
|
|
42
|
+
}
|
|
43
|
+
return toAmountString(this.value)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<style lang="scss">
|
|
50
|
+
.ml-amount-text {
|
|
51
|
+
display: inline;
|
|
52
|
+
.amount-flag,
|
|
53
|
+
.amount-num,
|
|
54
|
+
.amount-unit {
|
|
55
|
+
display: inline;
|
|
56
|
+
}
|
|
57
|
+
.amount-unit {
|
|
58
|
+
font-size: 0.65em;
|
|
59
|
+
color: rgba(39, 42, 48, 0.45);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
</style>
|