@netang/quasar 0.0.24 → 0.0.27

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.
@@ -1,179 +0,0 @@
1
- <template>
2
- <q-input
3
- v-model="currentValue"
4
- @blur="onBlur"
5
- v-bind="$attrs"
6
- >
7
- <template
8
- v-for="slotName in slotNames"
9
- v-slot:[slotName]
10
- >
11
- <slot :name="slotName" />
12
- </template>
13
- </q-input>
14
- </template>
15
-
16
- <script>
17
- import { computed, ref, watch } from 'vue'
18
-
19
- /**
20
- * 金额(元)
21
- */
22
- export default {
23
-
24
- /**
25
- * 标识
26
- */
27
- name: 'NInputPrice',
28
-
29
- /**
30
- * 声明属性
31
- */
32
- props: {
33
- // 值
34
- modelValue: [String, Number],
35
- // 最小值(元)
36
- min: {
37
- type: Number,
38
- default: 1,
39
- },
40
- // 最大值(元)
41
- max: Number,
42
- },
43
-
44
- /**
45
- * 声明事件
46
- */
47
- emits: [
48
- 'update:modelValue',
49
- ],
50
-
51
- /**
52
- * 组合式
53
- */
54
- setup(props, { emit, slots }) {
55
-
56
- // ==========【数据】============================================================================================
57
-
58
- // 当前值
59
- const currentValue = ref(props.modelValue)
60
-
61
- // ==========【计算属性】==========================================================================================
62
-
63
- /**
64
- * 插槽标识数组
65
- */
66
- const slotNames = computed(function() {
67
- if (utils.isValidObject(slots)) {
68
- return Object.keys(slots)
69
- }
70
- return []
71
- })
72
-
73
- // ==========【监听数据】=========================================================================================
74
-
75
- /**
76
- * 监听声明值
77
- */
78
- watch(()=>props.modelValue, function(val) {
79
- currentValue.value = val
80
- })
81
-
82
- // ==========【方法】=============================================================================================
83
-
84
- /**
85
- * 提交值
86
- */
87
- function emitModelValue(newVal) {
88
- // 更新值
89
- emit('update:modelValue', newVal)
90
- }
91
-
92
- /**
93
- * 失去焦点触发
94
- */
95
- function onBlur() {
96
-
97
- if (utils.isValidValue(currentValue.value)) {
98
-
99
- let val = new BigNumber(currentValue.value)
100
-
101
- if (val.isFinite()) {
102
-
103
- // 值是否有更新
104
- let isChange = false
105
-
106
- if (
107
- // 如果值 > 0
108
- val.isGreaterThan(0)
109
- // 如果值精度 > 2
110
- && val.decimalPlaces() > 2
111
- ) {
112
- // 值有更新
113
- isChange = true
114
-
115
- // 将元向下舍入 2 位精度(如 68.345 -> 68.34)
116
- val = val.decimalPlaces(2, BigNumber.ROUND_DOWN)
117
- }
118
-
119
- // 如果值 >= 最大值
120
- if (Number.isFinite(props.max)) {
121
- if (val.isGreaterThanOrEqualTo(props.max)) {
122
-
123
- // 更新当前值
124
- currentValue.value = props.max
125
-
126
- // 提交值
127
- emitModelValue(currentValue.value)
128
- return
129
- }
130
- }
131
-
132
- // 如果值 <= 最小值
133
- if (Number.isFinite(props.min)) {
134
- if (val.isLessThanOrEqualTo(props.min)) {
135
-
136
- // 更新当前值
137
- currentValue.value = props.min
138
-
139
- // 提交值
140
- emitModelValue(currentValue.value)
141
- return
142
- }
143
- }
144
-
145
- // 获取最新值
146
- val = val.toNumber()
147
-
148
- if (isChange) {
149
- // 更新当前值
150
- currentValue.value = val
151
- }
152
-
153
- // 提交值
154
- emitModelValue(val)
155
- return
156
- }
157
- }
158
-
159
- // 更新当前值
160
- currentValue.value = ''
161
-
162
- // 提交值
163
- emitModelValue(currentValue.value)
164
- }
165
-
166
- // ==========【返回】=============================================================================================
167
-
168
- return {
169
- // 当前值
170
- currentValue,
171
- // 插槽标识数组
172
- slotNames,
173
-
174
- // 失去焦点触发
175
- onBlur,
176
- }
177
- },
178
- }
179
- </script>
@@ -1,75 +0,0 @@
1
- <template>
2
- <slot
3
- :filter="filter"
4
- :optionLabel="optionLabel"
5
- />
6
- </template>
7
-
8
- <script>
9
- export default {
10
-
11
- /**
12
- * 标识
13
- */
14
- name: 'NSelectFilter',
15
-
16
- /**
17
- * 声明属性
18
- */
19
- props: {
20
- // 值
21
- modelValue: {
22
- required: true,
23
- },
24
- // 选项标签
25
- optionLabel: {
26
- type: String,
27
- default: 'label',
28
- }
29
- },
30
-
31
- /**
32
- * 声明事件
33
- */
34
- emits: [
35
- 'update:modelValue',
36
- ],
37
-
38
- /**
39
- * 组合式
40
- */
41
- setup(props, { emit }) {
42
-
43
- // ==========【当前值】===========================================================================================
44
-
45
- /**
46
- * 原始值
47
- */
48
- const rawModelValue = props.modelValue
49
-
50
- // ==========【方法】============================================================================================
51
-
52
- /**
53
- * 筛选
54
- */
55
- function filter(value, update) {
56
- update(function() {
57
- // 更新值
58
- emit(
59
- 'update:modelValue',
60
- value === '' ? rawModelValue : utils.collection(rawModelValue)
61
- .where(props.optionLabel, 'like', value)
62
- .toArray()
63
- )
64
- })
65
- }
66
-
67
- // ==========【返回】=============================================================================================
68
-
69
- return {
70
- // 筛选
71
- filter,
72
- }
73
- }
74
- }
75
- </script>