mali-applet-ui 0.0.55 → 0.0.58
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,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<button class="ml-button" :class="[className || '', `type-${type}`, status ? `status-${status}` : '', round ? 'is-round' : '']" @tap="tapEvent" @click="clickEvent">
|
|
2
|
+
<button class="ml-button" :class="[className || '', `type-${type}`, status ? `status-${status}` : '', round ? 'is-round' : '']" :style="styles" @tap="tapEvent" @click="clickEvent">
|
|
3
3
|
<slot>{{ content }}</slot>
|
|
4
4
|
</button>
|
|
5
5
|
</template>
|
|
@@ -18,10 +18,16 @@ export default {
|
|
|
18
18
|
type: String,
|
|
19
19
|
default: 'button'
|
|
20
20
|
},
|
|
21
|
+
width: String,
|
|
21
22
|
redirect: Boolean,
|
|
22
23
|
url: String,
|
|
23
24
|
className: String
|
|
24
25
|
},
|
|
26
|
+
computed: {
|
|
27
|
+
styles () {
|
|
28
|
+
return this.width ? `width:${this.width};` : ''
|
|
29
|
+
}
|
|
30
|
+
},
|
|
25
31
|
methods: {
|
|
26
32
|
tapEvent () {
|
|
27
33
|
if (this.url) {
|
|
@@ -4,21 +4,125 @@
|
|
|
4
4
|
<scroll-view scroll-y>
|
|
5
5
|
<slot></slot>
|
|
6
6
|
</scroll-view>
|
|
7
|
-
<uni-load-more v-if="
|
|
7
|
+
<uni-load-more v-if="showPage" :status="loadStatus"></uni-load-more>
|
|
8
8
|
</view>
|
|
9
9
|
</view>
|
|
10
10
|
</template>
|
|
11
11
|
|
|
12
12
|
<script>
|
|
13
|
+
import globalStore from '../../config/store'
|
|
14
|
+
import XEUtils from 'xe-utils'
|
|
15
|
+
|
|
13
16
|
export default {
|
|
14
17
|
name: 'MlListGroup',
|
|
15
18
|
options: {
|
|
16
19
|
virtualHost: true
|
|
17
20
|
},
|
|
18
21
|
props: {
|
|
22
|
+
value: Array,
|
|
23
|
+
showPage: Boolean,
|
|
24
|
+
autoload: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: true
|
|
27
|
+
},
|
|
28
|
+
pageProps: Object,
|
|
29
|
+
requestMethod: Function,
|
|
19
30
|
title: String,
|
|
20
|
-
loadMore: Boolean,
|
|
21
31
|
className: String
|
|
32
|
+
},
|
|
33
|
+
data () {
|
|
34
|
+
return {
|
|
35
|
+
loading: false,
|
|
36
|
+
pageVO: {
|
|
37
|
+
pageSize: globalStore.list.pageSize,
|
|
38
|
+
currPage: 1,
|
|
39
|
+
total: 0
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
computed: {
|
|
44
|
+
loadStatus () {
|
|
45
|
+
if (this.loading) {
|
|
46
|
+
return 'loading'
|
|
47
|
+
}
|
|
48
|
+
return this.pageVO.pageSize * this.pageVO.currPage < Number(this.pageVO.total) ? 'more' : 'noMore'
|
|
49
|
+
},
|
|
50
|
+
pagePropOpts () {
|
|
51
|
+
return { ...globalStore.list.pageProp, ...this.pageProps }
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
created () {
|
|
55
|
+
if (this.autoload && this.requestMethod) {
|
|
56
|
+
this.reload()
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
methods: {
|
|
60
|
+
getParams () {
|
|
61
|
+
return this.showPage ? {
|
|
62
|
+
pageObj: this.pageVO,
|
|
63
|
+
data: {
|
|
64
|
+
[this.pagePropOpts.currentPage || 'page']: this.pageVO.currPage,
|
|
65
|
+
[this.pagePropOpts.pageSize || 'limit']: this.pageVO.pageSize
|
|
66
|
+
}
|
|
67
|
+
} : {
|
|
68
|
+
data: {}
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
getList () {
|
|
72
|
+
this.loading = true
|
|
73
|
+
if (this.requestMethod) {
|
|
74
|
+
return Promise.resolve(
|
|
75
|
+
this.requestMethod(this.getParams())
|
|
76
|
+
).then(res => {
|
|
77
|
+
let data = []
|
|
78
|
+
if (XEUtils.isFunction(globalStore.list.resProps.result)) {
|
|
79
|
+
data = globalStore.list.resProps.result({ response: res }) || []
|
|
80
|
+
} else {
|
|
81
|
+
data = Array.isArray(res) ? res : XEUtils.get(res, globalStore.list.resProps.result || 'datas')
|
|
82
|
+
}
|
|
83
|
+
if (this.showPage) {
|
|
84
|
+
if (XEUtils.isFunction(globalStore.list.resProps.total)) {
|
|
85
|
+
this.pageVO.total = XEUtils.toNumber(globalStore.list.resProps.total({ response: res }))
|
|
86
|
+
} else {
|
|
87
|
+
this.pageVO.total = XEUtils.toNumber(XEUtils.get(res, globalStore.list.resProps.total || 'total'))
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
this.loading = false
|
|
91
|
+
return data
|
|
92
|
+
}).catch(() => {
|
|
93
|
+
this.loading = false
|
|
94
|
+
return []
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
return Promise.resolve([])
|
|
98
|
+
},
|
|
99
|
+
async reload() {
|
|
100
|
+
uni.showLoading({
|
|
101
|
+
title: '加载中'
|
|
102
|
+
})
|
|
103
|
+
try {
|
|
104
|
+
const data = await this.getList()
|
|
105
|
+
uni.stopPullDownRefresh()
|
|
106
|
+
uni.hideLoading()
|
|
107
|
+
this.$emit('input', data)
|
|
108
|
+
} catch (e) {
|
|
109
|
+
uni.stopPullDownRefresh()
|
|
110
|
+
uni.hideLoading()
|
|
111
|
+
console.error(e)
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
async loadMore() {
|
|
115
|
+
if (this.showPage && !this.loading && this.loadStatus === 'more') {
|
|
116
|
+
try {
|
|
117
|
+
this.pageVO.currPage++
|
|
118
|
+
const data = await this.getList()
|
|
119
|
+
const moreList = (this.value || []).concat(data)
|
|
120
|
+
this.$emit('input', moreList)
|
|
121
|
+
} catch (e) {
|
|
122
|
+
console.error(e)
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
22
126
|
}
|
|
23
127
|
}
|
|
24
128
|
</script>
|
package/config/store.js
CHANGED
|
@@ -28,9 +28,17 @@ const globalStore = {
|
|
|
28
28
|
optionMethod: null
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
|
-
//
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
// 列表组件
|
|
32
|
+
list: {
|
|
33
|
+
pageSize: 30,
|
|
34
|
+
pageProp: {
|
|
35
|
+
pageSize: 'limit',
|
|
36
|
+
currentPage: 'page'
|
|
37
|
+
},
|
|
38
|
+
resProps: {
|
|
39
|
+
result: 'datas',
|
|
40
|
+
total: 'total'
|
|
41
|
+
}
|
|
34
42
|
}
|
|
35
43
|
}
|
|
36
44
|
|