You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
1.8 KiB
Vue
101 lines
1.8 KiB
Vue
<template>
|
|
<view class="myTable">
|
|
<wd-toast />
|
|
<kevyloading v-if="loading" type="bsm-loader" color="#618af8" transparent></kevyloading>
|
|
<scroll-view scroll-y="true" class="scroll-Y" @scrolltolower="lower">
|
|
<slot :list="list"></slot>
|
|
|
|
<view v-if="list.length == 0">
|
|
<wd-status-tip image="search" tip="当前查询无结果" />
|
|
</view>
|
|
</scroll-view>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { ref } from 'vue'
|
|
import kevyloading from "@/components/kevy-loading/kevy-loading";
|
|
import { useToast } from '@/uni_modules/wot-design-uni'
|
|
const toast = useToast()
|
|
const props = defineProps({
|
|
apiObj: {
|
|
type: Function,
|
|
default: () => (() => { })
|
|
},
|
|
params: {
|
|
type: Object,
|
|
default: () => ({})
|
|
}
|
|
})
|
|
|
|
const query = ref({
|
|
page: 1,
|
|
pageSize: 20
|
|
})
|
|
|
|
const loading = ref(false)
|
|
const total = ref(0)
|
|
const list = ref([])
|
|
|
|
const getData = async () => {
|
|
console.log(getData);
|
|
|
|
loading.value = true
|
|
const res = await props.apiObj({
|
|
...query.value,
|
|
...props.params
|
|
})
|
|
|
|
if (res.data.rows.length) {
|
|
query.value.pageSize = res.data.pageSize
|
|
total.value = res.data.total
|
|
list.value = [...list.value, ...res.data.rows]
|
|
} else {
|
|
toast.success('全部加载完了')
|
|
}
|
|
|
|
loading.value = false
|
|
}
|
|
|
|
getData()
|
|
|
|
const upData = async (upParams = {}) => {
|
|
loading.value = true
|
|
query.value.page = 1
|
|
query.value.pageSize = 20
|
|
|
|
const res = await props.apiObj({
|
|
...query.value,
|
|
...props.params,
|
|
...upParams
|
|
})
|
|
|
|
console.log({
|
|
...query.value,
|
|
...props.params,
|
|
...upParams
|
|
});
|
|
|
|
query.value.pageSize = res.data.pageSize
|
|
total.value = res.data.total
|
|
list.value = res.data.rows
|
|
|
|
loading.value = false
|
|
}
|
|
|
|
const lower = e => {
|
|
query.value.page++
|
|
getData()
|
|
}
|
|
|
|
defineExpose({
|
|
upData
|
|
})
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
.scroll-Y {
|
|
height: calc(100vh - 120px);
|
|
}
|
|
</style>
|