mali-applet-ui 1.0.76 → 1.0.78
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/config/store.js
CHANGED
|
@@ -56,6 +56,25 @@ const globalStore = {
|
|
|
56
56
|
resultHint: '请检查输入是否正确'
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
|
+
// 分页器
|
|
60
|
+
pager: {
|
|
61
|
+
pageSize: 30,
|
|
62
|
+
pageProp: {
|
|
63
|
+
pageSize: 'limit',
|
|
64
|
+
currentPage: 'page'
|
|
65
|
+
},
|
|
66
|
+
resProps: {
|
|
67
|
+
result: 'datas',
|
|
68
|
+
total: 'total'
|
|
69
|
+
},
|
|
70
|
+
notData: {
|
|
71
|
+
emptyUrl: '',
|
|
72
|
+
emptyText: '暂无记录',
|
|
73
|
+
resultUrl: '',
|
|
74
|
+
resultText: '暂无相关结果',
|
|
75
|
+
resultHint: '请检查输入是否正确'
|
|
76
|
+
}
|
|
77
|
+
},
|
|
59
78
|
notData: {
|
|
60
79
|
emptyUrl: '',
|
|
61
80
|
emptyText: '暂无记录'
|
|
@@ -137,24 +137,27 @@ export default {
|
|
|
137
137
|
this.inpVal = eqEmptyNull(value) ? '' : XEUtils.toFixed(XEUtils.toNumber(value), 2)
|
|
138
138
|
},
|
|
139
139
|
checkValue () {
|
|
140
|
-
// 如果是空值,则不处理
|
|
141
|
-
if (eqEmptyNull(this.inpVal) && eqEmptyNull(this.value)) {
|
|
142
|
-
return { status: false, value: this.inpVal }
|
|
143
|
-
}
|
|
144
140
|
const numVal = XEUtils.toNumber(this.inpVal)
|
|
145
141
|
if (this.minNum !== null && (numVal < this.minNum)) {
|
|
146
|
-
this.$emit('input', this.minNum)
|
|
147
142
|
this.updateModel = true
|
|
143
|
+
this.updateValue(this.minNum)
|
|
144
|
+
this.$emit('input', this.minNum)
|
|
148
145
|
return { status: false, value: this.minNum }
|
|
149
146
|
}
|
|
150
147
|
if (this.maxNum !== null && (numVal > this.maxNum)) {
|
|
151
|
-
this.$emit('input', this.maxNum)
|
|
152
148
|
this.updateModel = true
|
|
149
|
+
this.updateValue(this.maxNum)
|
|
150
|
+
this.$emit('input', this.maxNum)
|
|
153
151
|
return { status: false, value: this.maxNum }
|
|
154
152
|
}
|
|
153
|
+
// 如果是空值,则不处理
|
|
154
|
+
if (eqEmptyNull(this.inpVal) && eqEmptyNull(this.value)) {
|
|
155
|
+
return { status: false, value: this.inpVal }
|
|
156
|
+
}
|
|
155
157
|
const val = XEUtils.floor(numVal, 2)
|
|
156
158
|
if (`${val}` !== `${this.value}`) {
|
|
157
159
|
this.updateModel = true
|
|
160
|
+
this.updateValue(val)
|
|
158
161
|
this.$emit('input', val)
|
|
159
162
|
return { status: false, value: val }
|
|
160
163
|
}
|
|
@@ -126,34 +126,39 @@ export default {
|
|
|
126
126
|
this.inpVal = eqEmptyNull(value) ? '' : String(XEUtils.toNumber(value))
|
|
127
127
|
},
|
|
128
128
|
checkValue () {
|
|
129
|
-
// 如果是空值,则不处理
|
|
130
|
-
if (eqEmptyNull(this.inpVal) && eqEmptyNull(this.value)) {
|
|
131
|
-
return { status: true, value: this.inpVal }
|
|
132
|
-
}
|
|
133
129
|
const numVal = XEUtils.toNumber(XEUtils.toValueString(this.inpVal).slice(0, this.maxLength))
|
|
134
130
|
if (this.minNum !== null && (numVal < this.minNum)) {
|
|
135
131
|
this.updateModel = true
|
|
132
|
+
this.inpVal = this.minNum
|
|
136
133
|
this.$emit('input', this.minNum)
|
|
137
134
|
return { status: false, value: this.minNum }
|
|
138
135
|
}
|
|
139
136
|
if (this.maxNum !== null && (numVal > this.maxNum)) {
|
|
140
137
|
this.updateModel = true
|
|
138
|
+
this.inpVal = this.maxNum
|
|
141
139
|
this.$emit('input', this.maxNum)
|
|
142
140
|
return { status: false, value: this.maxNum }
|
|
143
141
|
}
|
|
142
|
+
// 如果是空值,则不处理
|
|
143
|
+
if (eqEmptyNull(this.inpVal) && eqEmptyNull(this.value)) {
|
|
144
|
+
return { status: true, value: this.inpVal }
|
|
145
|
+
}
|
|
144
146
|
if (this.type === 'integer' && !/^-?[0-9]+$/.test(numVal)) {
|
|
145
147
|
const value = XEUtils.toInteger(numVal)
|
|
146
148
|
this.updateModel = true
|
|
149
|
+
this.inpVal = value
|
|
147
150
|
this.$emit('input', value)
|
|
148
151
|
return { status: false, value: value }
|
|
149
152
|
}
|
|
150
153
|
if (`${numVal}` !== this.inpVal) {
|
|
151
154
|
this.updateModel = true
|
|
155
|
+
this.inpVal = numVal
|
|
152
156
|
this.$emit('input', numVal)
|
|
153
157
|
return { status: false, value: numVal }
|
|
154
158
|
}
|
|
155
159
|
if (`${numVal}` !== `${this.value}`) {
|
|
156
160
|
this.updateModel = true
|
|
161
|
+
this.inpVal = numVal
|
|
157
162
|
this.$emit('input', numVal)
|
|
158
163
|
return { status: false, value: numVal }
|
|
159
164
|
}
|
|
@@ -272,6 +277,7 @@ export default {
|
|
|
272
277
|
width: 80rpx;
|
|
273
278
|
border: 1px solid #e5e5e5;
|
|
274
279
|
font-size: 36rpx;
|
|
280
|
+
padding: 0 16rpx;
|
|
275
281
|
background: #F2F2F6;
|
|
276
282
|
}
|
|
277
283
|
.ml-number-input-minus-btn {
|
|
@@ -12,10 +12,22 @@
|
|
|
12
12
|
</slot>
|
|
13
13
|
</view>
|
|
14
14
|
<ml-fixed-footer>
|
|
15
|
-
<ml-button>上一页</ml-button>
|
|
16
|
-
<ml-button>{{ pageVO.currPage }}/{{ pageCount }}</ml-button>
|
|
17
|
-
<ml-button>下一页</ml-button>
|
|
15
|
+
<ml-button :disabled="pageVO.currPage <= 1" @click="prevPage()">上一页</ml-button>
|
|
16
|
+
<ml-button @click="openPageEvent">{{ pageVO.currPage }}/{{ pageCount }}</ml-button>
|
|
17
|
+
<ml-button :disabled="pageVO.currPage >= pageCount" @click="nextPage()">下一页</ml-button>
|
|
18
18
|
</ml-fixed-footer>
|
|
19
|
+
|
|
20
|
+
<ml-modal v-model="showPopup" title="跳往页码" height="200rpx" showConfirmButton showCancelButton @confirm="confirmEvent">
|
|
21
|
+
<view class="ml-pager-jump-popup-warpper">
|
|
22
|
+
<view class="ml-pager-jump-popup-left">
|
|
23
|
+
<ml-number-input v-model="tempCurrPage" :min="1" :max="pageCount" border />
|
|
24
|
+
</view>
|
|
25
|
+
<view class="ml-pager-jump-popup-content">/</view>
|
|
26
|
+
<view class="ml-pager-jump-popup-right">
|
|
27
|
+
<view class="ml-pager-jump-popup-count">{{ pageCount }}</view>
|
|
28
|
+
</view>
|
|
29
|
+
</view>
|
|
30
|
+
</ml-modal>
|
|
19
31
|
</view>
|
|
20
32
|
</template>
|
|
21
33
|
|
|
@@ -44,10 +56,12 @@ export default {
|
|
|
44
56
|
return {
|
|
45
57
|
loading: false,
|
|
46
58
|
pageVO: {
|
|
47
|
-
pageSize: globalStore.
|
|
59
|
+
pageSize: globalStore.pager.pageSize,
|
|
48
60
|
currPage: 1,
|
|
49
61
|
total: 0
|
|
50
62
|
},
|
|
63
|
+
tempCurrPage: 0,
|
|
64
|
+
showPopup: false,
|
|
51
65
|
emptyUrl: '',
|
|
52
66
|
emptyText: '',
|
|
53
67
|
emptyHint: ''
|
|
@@ -55,7 +69,10 @@ export default {
|
|
|
55
69
|
},
|
|
56
70
|
computed: {
|
|
57
71
|
pageCount () {
|
|
58
|
-
|
|
72
|
+
if (this.pageVO.total) {
|
|
73
|
+
return XEUtils.ceil(this.pageVO.total / this.pageVO.pageSize)
|
|
74
|
+
}
|
|
75
|
+
return 1
|
|
59
76
|
},
|
|
60
77
|
loadStatus () {
|
|
61
78
|
if (this.loading) {
|
|
@@ -67,7 +84,7 @@ export default {
|
|
|
67
84
|
return !this.value || !this.value.length
|
|
68
85
|
},
|
|
69
86
|
pagePropOpts () {
|
|
70
|
-
return { ...globalStore.
|
|
87
|
+
return { ...globalStore.pager.pageProp, ...this.pageProps }
|
|
71
88
|
},
|
|
72
89
|
hasFilters () {
|
|
73
90
|
const fields = this.emptyOpts.fields || []
|
|
@@ -107,15 +124,15 @@ export default {
|
|
|
107
124
|
this.requestMethod.call(this.currVM, this.getParams())
|
|
108
125
|
).then(res => {
|
|
109
126
|
let data = []
|
|
110
|
-
if (XEUtils.isFunction(globalStore.
|
|
111
|
-
data = globalStore.
|
|
127
|
+
if (XEUtils.isFunction(globalStore.pager.resProps.result)) {
|
|
128
|
+
data = globalStore.pager.resProps.result({ response: res }) || []
|
|
112
129
|
} else {
|
|
113
|
-
data = Array.isArray(res) ? res : XEUtils.get(res, globalStore.
|
|
130
|
+
data = Array.isArray(res) ? res : XEUtils.get(res, globalStore.pager.resProps.result || 'datas')
|
|
114
131
|
}
|
|
115
|
-
if (XEUtils.isFunction(globalStore.
|
|
116
|
-
this.pageVO.total = XEUtils.toNumber(globalStore.
|
|
132
|
+
if (XEUtils.isFunction(globalStore.pager.resProps.total)) {
|
|
133
|
+
this.pageVO.total = XEUtils.toNumber(globalStore.pager.resProps.total({ response: res }))
|
|
117
134
|
} else {
|
|
118
|
-
this.pageVO.total = XEUtils.toNumber(XEUtils.get(res, globalStore.
|
|
135
|
+
this.pageVO.total = XEUtils.toNumber(XEUtils.get(res, globalStore.pager.resProps.total || 'total'))
|
|
119
136
|
}
|
|
120
137
|
this.loading = false
|
|
121
138
|
return data
|
|
@@ -141,41 +158,50 @@ export default {
|
|
|
141
158
|
if (this.$loading) {
|
|
142
159
|
this.$loading.hide()
|
|
143
160
|
}
|
|
144
|
-
uni.stopPullDownRefresh()
|
|
145
161
|
this.$emit('input', data)
|
|
146
162
|
} catch (e) {
|
|
147
163
|
if (this.$loading) {
|
|
148
164
|
this.$loading.hide()
|
|
149
165
|
}
|
|
150
|
-
uni.stopPullDownRefresh()
|
|
151
166
|
console.error(e)
|
|
152
167
|
}
|
|
153
168
|
this.updateEmptyStatus()
|
|
154
169
|
},
|
|
155
|
-
async loadMore () {
|
|
156
|
-
if (this.showPage && !this.loading && this.loadStatus === 'more') {
|
|
157
|
-
try {
|
|
158
|
-
this.pageVO.currPage++
|
|
159
|
-
const data = await this.getList()
|
|
160
|
-
const moreList = (this.value || []).concat(data)
|
|
161
|
-
this.$emit('input', moreList)
|
|
162
|
-
} catch (e) {
|
|
163
|
-
console.error(e)
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
},
|
|
167
170
|
updateEmptyStatus () {
|
|
168
171
|
this.$nextTick(() => {
|
|
169
172
|
if (this.hasFilters) {
|
|
170
|
-
this.emptyUrl = this.emptyOpts.resultUrl || globalStore.
|
|
171
|
-
this.emptyText = XEUtils.template(this.emptyOpts.resultText || globalStore.
|
|
172
|
-
this.emptyHint = XEUtils.template(this.emptyOpts.resultHint || globalStore.
|
|
173
|
+
this.emptyUrl = this.emptyOpts.resultUrl || globalStore.pager.notData.resultUrl || ''
|
|
174
|
+
this.emptyText = XEUtils.template(this.emptyOpts.resultText || globalStore.pager.notData.resultText, this.filterForm) || ''
|
|
175
|
+
this.emptyHint = XEUtils.template(this.emptyOpts.resultHint || globalStore.pager.notData.resultHint, this.filterForm) || ''
|
|
173
176
|
} else {
|
|
174
|
-
this.emptyUrl = this.emptyOpts.emptyUrl || globalStore.
|
|
175
|
-
this.emptyText = this.emptyOpts.emptyText || globalStore.
|
|
176
|
-
this.emptyHint = this.emptyOpts.emptyHint || globalStore.
|
|
177
|
+
this.emptyUrl = this.emptyOpts.emptyUrl || globalStore.pager.notData.emptyUrl || ''
|
|
178
|
+
this.emptyText = this.emptyOpts.emptyText || globalStore.pager.notData.emptyText || ''
|
|
179
|
+
this.emptyHint = this.emptyOpts.emptyHint || globalStore.pager.notData.emptyHint || ''
|
|
177
180
|
}
|
|
178
181
|
})
|
|
182
|
+
},
|
|
183
|
+
openPageEvent () {
|
|
184
|
+
this.tempCurrPage = this.pageVO.currPage
|
|
185
|
+
this.showPopup = true
|
|
186
|
+
},
|
|
187
|
+
confirmEvent () {
|
|
188
|
+
this.showPopup = false
|
|
189
|
+
if (String(this.pageVO.currPage) !== String(this.tempCurrPage)) {
|
|
190
|
+
this.pageVO.currPage = XEUtils.toNumber(this.tempCurrPage)
|
|
191
|
+
this.load()
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
prevPage () {
|
|
195
|
+
if (this.pageVO.currPage > 1) {
|
|
196
|
+
this.pageVO.currPage--
|
|
197
|
+
this.load()
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
nextPage () {
|
|
201
|
+
if (this.pageVO.currPage < this.pageCount) {
|
|
202
|
+
this.pageVO.currPage++
|
|
203
|
+
this.load()
|
|
204
|
+
}
|
|
179
205
|
}
|
|
180
206
|
}
|
|
181
207
|
}
|
|
@@ -192,4 +218,27 @@ export default {
|
|
|
192
218
|
text-align: center;
|
|
193
219
|
}
|
|
194
220
|
}
|
|
221
|
+
.ml-pager-jump-popup-warpper {
|
|
222
|
+
display: flex;
|
|
223
|
+
flex-direction: row;
|
|
224
|
+
align-items: center;
|
|
225
|
+
padding: 0 40rpx;
|
|
226
|
+
.ml-pager-jump-popup-left,
|
|
227
|
+
.ml-pager-jump-popup-right {
|
|
228
|
+
flex-grow: 1;
|
|
229
|
+
width: 40%;
|
|
230
|
+
text-align: center;
|
|
231
|
+
}
|
|
232
|
+
.ml-pager-jump-popup-content {
|
|
233
|
+
flex-shrink: 0;
|
|
234
|
+
text-align: center;
|
|
235
|
+
width: 80rpx;
|
|
236
|
+
}
|
|
237
|
+
.ml-pager-jump-popup-count {
|
|
238
|
+
height: 70rpx;
|
|
239
|
+
line-height: 70rpx;
|
|
240
|
+
border-radius: $ml-border-radius;
|
|
241
|
+
background: #F2F2F6;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
195
244
|
</style>
|