mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-10 11:26:45 +08:00
Merge remote-tracking branch 'origin/user-modify' into dev0731
This commit is contained in:
@@ -26,7 +26,7 @@ export const ASSESSMENT_DETAIL = (assessmentId)=>`/assessment/queryAssessmentDet
|
||||
|
||||
export const USER_LIST_PAGE = "/admin/thirdApi/user/list";
|
||||
//学员列表 没有分页数据 只能通过名称检索 速度较快
|
||||
export const USER_LIST = "/admin/thirdApi/user/searchList";
|
||||
export const USER_LIST = "/admin/thirdApi/user/list";
|
||||
export const ORG_LIST = "/admin/thirdApi/org/list";
|
||||
export const ORG_CHILD_LIST = "/admin/thirdApi/org/info";
|
||||
|
||||
|
||||
@@ -248,6 +248,58 @@ export function useRowsPage(_url, params, init = true) {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页只返回 total 无分页信息
|
||||
* @param _url
|
||||
* @param params
|
||||
* @param init
|
||||
* @param listing
|
||||
*/
|
||||
export function useTotalPage(_url, params, init = true,listing = false) {
|
||||
|
||||
const state = reactive({
|
||||
data: [],
|
||||
total: 1,
|
||||
current: 1,
|
||||
pages: 1,
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
loading: false
|
||||
});
|
||||
|
||||
if (isRef(params) && listing) {
|
||||
watch(params.value, () => {
|
||||
fetch();
|
||||
});
|
||||
}
|
||||
|
||||
if (isRef(_url)) {
|
||||
watchEffect(fetch);
|
||||
} else {
|
||||
init && fetch();
|
||||
}
|
||||
|
||||
function reset() {
|
||||
state.data = [];
|
||||
state.loading = false;
|
||||
}
|
||||
|
||||
function fetch() {
|
||||
state.loading = true;
|
||||
return request(unref(_url), unref(params)).then(r => {
|
||||
state.data = r.data.list;
|
||||
state.pages = r.data.total/state.pageSize || 1;
|
||||
state.total = r.data.total;
|
||||
state.loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
...toRefs(state),
|
||||
fetch,
|
||||
reset,
|
||||
};
|
||||
}
|
||||
export function usePage(_url, params, init = true,listing = false) {
|
||||
|
||||
const state = reactive({
|
||||
@@ -300,6 +352,7 @@ export function usePage(_url, params, init = true,listing = false) {
|
||||
total: 0,
|
||||
totalPage: 0,
|
||||
page: 1,
|
||||
pageNo: 1,
|
||||
...params
|
||||
});
|
||||
|
||||
@@ -313,8 +366,8 @@ export function usePage(_url, params, init = true,listing = false) {
|
||||
return;
|
||||
}
|
||||
return request(_url, params).then(r => {
|
||||
state.data = params.page === 1 ? r.data.records : [...state.data, ...r.data.records];
|
||||
state.totalPage = r.data.pages;
|
||||
state.data = params.pageNo === 1 ? r.data.list : [...state.data, ...r.data.list];
|
||||
state.totalPage = r.data.total/10 || 1;
|
||||
state.total = r.data.total;
|
||||
state.loading = false;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user