mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-12 12:26:47 +08:00
-- 授课教师
This commit is contained in:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user