Merge remote-tracking branch 'origin/user-modify' into dev0731

This commit is contained in:
yujicun
2023-08-04 11:36:39 +08:00
4 changed files with 63 additions and 18 deletions

View File

@@ -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";

View File

@@ -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;
});

View File

@@ -56,7 +56,7 @@ const emit = defineEmits({})
const isOpen = ref(false)
const memberParam = ref({keyword: '', page: 1, pageSize: 20})
const memberParam = ref({keyword: '', pageNo:1, pageSize: 20})
const {data: userList, loading} = useThrottlePage(USER_LIST, memberParam.value, false)
@@ -83,7 +83,7 @@ onMounted(() => {
const memberScroll = ({target: {scrollHeight, scrollTop, clientHeight}}) => {
scrollHeight === (clientHeight + scrollTop) && memberParam.value.page++
scrollHeight === (clientHeight + scrollTop) && memberParam.value.pageNo++
};
//搜索学员
@@ -92,7 +92,7 @@ const searchMember = (keyword) => {
loading.value = true
isOpen.value = true
userList.value = []
memberParam.value.page = 1
memberParam.value.pageNo = 1
memberParam.value.keyword = keyword
console.log('searchMember', memberParam.value)
};
@@ -100,12 +100,12 @@ const searchMember = (keyword) => {
function blur() {
isOpen.value = false
memberParam.value.keyword = ''
memberParam.value.page = 1
memberParam.value.pageNo = 1
}
function change(e, l) {
memberParam.value.keyword = ''
memberParam.value.page = 1
memberParam.value.pageNo = 1
isOpen.value = false
Array.isArray(l) && (selectOptions.value = l)
Array.isArray(selectOptions.value) && emit('onChange', e, l, selectOptions.value.find(e => e.departId)?.departId, selectOptions.value.find(e => e.departId)?.departName, selectOptions.value.find(e => e.departId)?.orgName)

View File

@@ -132,7 +132,7 @@
</div>
<div class="tableBox tabb">
<BaseTable ref="auditTableRef" :columns="audiColums" :url="AUDIENCE_LIST" page-key="pageNo"
v-model:params="audienceName"
v-model:params="audienceName" :request="useTotalPage"
v-model:selectedRows="auditSelectRows" v-model:selectedRowKeys="auditSelectRowKeys"
type="checkbox"></BaseTable>
</div>
@@ -296,7 +296,7 @@
<script setup>
import {message} from "ant-design-vue";
import {computed, defineEmits, defineProps, ref, watch} from "vue";
import { useNewRowsPageNoInit, request, useRequest} from "@/api/request";
import {useNewRowsPageNoInit, request, useRequest, useTotalPage} from "@/api/request";
import {
saveStu,
} from "@/api/index1";
@@ -507,14 +507,6 @@ const audiColums = ref([
align: "center",
className: "h",
},
{
title: "类型",
dataIndex: "audienceType",
key: "audienceType",
width: 40,
align: "center",
className: "h",
},
]);
const orgSelectKeys = ref([]);
const auditTableRef = ref();