-- 授课教师

This commit is contained in:
yuping
2022-12-23 15:07:10 +08:00
parent da9a7c86c1
commit 9baf321254
2 changed files with 56 additions and 48 deletions

View File

@@ -1,5 +1,5 @@
import {reactive, ref, toRefs, watch} from "vue";
import {getCookieForName} from "@/api/method";
import {getCookieForName, throttle} from "@/api/method";
import JSONBigInt from 'json-bigint';
const JSONBigIntStr = JSONBigInt({storeAsString: true});
@@ -21,11 +21,8 @@ export function useBoeApiPage(_url, params = {}, config = {
})
function fetch() {
console.log('params', params)
state.loading = true
return request(_url, params).then(r => {
console.log(2222222222222)
console.log(r)
state.data = config.result(r)
state.totalPage = config.totalPage(r)
state.total = config.total(r)
@@ -69,6 +66,41 @@ export function useBoeApi(_url, params = {}, config = {
};
}
export function useBoeUserListPage(_url, params = {}, init = true) {
const state = reactive({
data: [],
loading: false,
total: 0,
totalPage: 0,
page: 1,
...params
})
watch(() => params.keyWord, throttle(fetch, 600))
watch(() => params.page, fetch)
function fetch() {
state.loading = true
if (!params.keyWord) {
state.loading = false
return
}
return request(_url, params).then(r => {
state.data = params.page === 1 ? r.result.userInfoList : [...state.data, ...r.result.userInfoList]
state.totalPage = r.result.totalPage
state.total = r.result.totalElement
state.loading = false
})
}
init && fetch()
return {
...toRefs(state),
fetch,
};
}
export function usePage(_url, params = {}, init = true) {
const state = reactive({