mali-applet-ui 1.0.76 → 1.0.77
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 +19 -0
- package/lib/components/ml-pager/ml-pager.vue +24 -29
- package/package.json +1 -1
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: '暂无记录'
|
|
@@ -13,9 +13,14 @@
|
|
|
13
13
|
</view>
|
|
14
14
|
<ml-fixed-footer>
|
|
15
15
|
<ml-button>上一页</ml-button>
|
|
16
|
-
<ml-button>{{ pageVO.currPage }}/{{ pageCount }}</ml-button>
|
|
16
|
+
<ml-button @click="openPageEvent">{{ pageVO.currPage }}/{{ pageCount }}</ml-button>
|
|
17
17
|
<ml-button>下一页</ml-button>
|
|
18
18
|
</ml-fixed-footer>
|
|
19
|
+
|
|
20
|
+
<ml-modal v-model="showPopup" title="跳往页码" showConfirmButton showCancelButton>
|
|
21
|
+
<view>自定义内容</view>
|
|
22
|
+
<ml-number-input v-model="val3" border controls />
|
|
23
|
+
</ml-modal>
|
|
19
24
|
</view>
|
|
20
25
|
</template>
|
|
21
26
|
|
|
@@ -44,10 +49,11 @@ export default {
|
|
|
44
49
|
return {
|
|
45
50
|
loading: false,
|
|
46
51
|
pageVO: {
|
|
47
|
-
pageSize: globalStore.
|
|
52
|
+
pageSize: globalStore.pager.pageSize,
|
|
48
53
|
currPage: 1,
|
|
49
54
|
total: 0
|
|
50
55
|
},
|
|
56
|
+
showPopup: false,
|
|
51
57
|
emptyUrl: '',
|
|
52
58
|
emptyText: '',
|
|
53
59
|
emptyHint: ''
|
|
@@ -67,7 +73,7 @@ export default {
|
|
|
67
73
|
return !this.value || !this.value.length
|
|
68
74
|
},
|
|
69
75
|
pagePropOpts () {
|
|
70
|
-
return { ...globalStore.
|
|
76
|
+
return { ...globalStore.pager.pageProp, ...this.pageProps }
|
|
71
77
|
},
|
|
72
78
|
hasFilters () {
|
|
73
79
|
const fields = this.emptyOpts.fields || []
|
|
@@ -107,15 +113,15 @@ export default {
|
|
|
107
113
|
this.requestMethod.call(this.currVM, this.getParams())
|
|
108
114
|
).then(res => {
|
|
109
115
|
let data = []
|
|
110
|
-
if (XEUtils.isFunction(globalStore.
|
|
111
|
-
data = globalStore.
|
|
116
|
+
if (XEUtils.isFunction(globalStore.pager.resProps.result)) {
|
|
117
|
+
data = globalStore.pager.resProps.result({ response: res }) || []
|
|
112
118
|
} else {
|
|
113
|
-
data = Array.isArray(res) ? res : XEUtils.get(res, globalStore.
|
|
119
|
+
data = Array.isArray(res) ? res : XEUtils.get(res, globalStore.pager.resProps.result || 'datas')
|
|
114
120
|
}
|
|
115
|
-
if (XEUtils.isFunction(globalStore.
|
|
116
|
-
this.pageVO.total = XEUtils.toNumber(globalStore.
|
|
121
|
+
if (XEUtils.isFunction(globalStore.pager.resProps.total)) {
|
|
122
|
+
this.pageVO.total = XEUtils.toNumber(globalStore.pager.resProps.total({ response: res }))
|
|
117
123
|
} else {
|
|
118
|
-
this.pageVO.total = XEUtils.toNumber(XEUtils.get(res, globalStore.
|
|
124
|
+
this.pageVO.total = XEUtils.toNumber(XEUtils.get(res, globalStore.pager.resProps.total || 'total'))
|
|
119
125
|
}
|
|
120
126
|
this.loading = false
|
|
121
127
|
return data
|
|
@@ -141,41 +147,30 @@ export default {
|
|
|
141
147
|
if (this.$loading) {
|
|
142
148
|
this.$loading.hide()
|
|
143
149
|
}
|
|
144
|
-
uni.stopPullDownRefresh()
|
|
145
150
|
this.$emit('input', data)
|
|
146
151
|
} catch (e) {
|
|
147
152
|
if (this.$loading) {
|
|
148
153
|
this.$loading.hide()
|
|
149
154
|
}
|
|
150
|
-
uni.stopPullDownRefresh()
|
|
151
155
|
console.error(e)
|
|
152
156
|
}
|
|
153
157
|
this.updateEmptyStatus()
|
|
154
158
|
},
|
|
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
159
|
updateEmptyStatus () {
|
|
168
160
|
this.$nextTick(() => {
|
|
169
161
|
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.
|
|
162
|
+
this.emptyUrl = this.emptyOpts.resultUrl || globalStore.pager.notData.resultUrl || ''
|
|
163
|
+
this.emptyText = XEUtils.template(this.emptyOpts.resultText || globalStore.pager.notData.resultText, this.filterForm) || ''
|
|
164
|
+
this.emptyHint = XEUtils.template(this.emptyOpts.resultHint || globalStore.pager.notData.resultHint, this.filterForm) || ''
|
|
173
165
|
} else {
|
|
174
|
-
this.emptyUrl = this.emptyOpts.emptyUrl || globalStore.
|
|
175
|
-
this.emptyText = this.emptyOpts.emptyText || globalStore.
|
|
176
|
-
this.emptyHint = this.emptyOpts.emptyHint || globalStore.
|
|
166
|
+
this.emptyUrl = this.emptyOpts.emptyUrl || globalStore.pager.notData.emptyUrl || ''
|
|
167
|
+
this.emptyText = this.emptyOpts.emptyText || globalStore.pager.notData.emptyText || ''
|
|
168
|
+
this.emptyHint = this.emptyOpts.emptyHint || globalStore.pager.notData.emptyHint || ''
|
|
177
169
|
}
|
|
178
170
|
})
|
|
171
|
+
},
|
|
172
|
+
openPageEvent () {
|
|
173
|
+
|
|
179
174
|
}
|
|
180
175
|
}
|
|
181
176
|
}
|