mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-11 20:06:47 +08:00
Merge branch 'develop' of ssh://gitlab.dongwu-inc.com:10022/BOE/fe-manage into develop
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import {reactive, ref, toRefs, watch} from "vue";
|
import {reactive, ref, toRefs, watch} from "vue";
|
||||||
import {getCookieForName} from "@/api/method";
|
import {getCookieForName, throttle} from "@/api/method";
|
||||||
import JSONBigInt from 'json-bigint';
|
import JSONBigInt from 'json-bigint';
|
||||||
|
|
||||||
const JSONBigIntStr = JSONBigInt({storeAsString: true});
|
const JSONBigIntStr = JSONBigInt({storeAsString: true});
|
||||||
@@ -21,11 +21,8 @@ export function useBoeApiPage(_url, params = {}, config = {
|
|||||||
})
|
})
|
||||||
|
|
||||||
function fetch() {
|
function fetch() {
|
||||||
console.log('params', params)
|
|
||||||
state.loading = true
|
state.loading = true
|
||||||
return request(_url, params).then(r => {
|
return request(_url, params).then(r => {
|
||||||
console.log(2222222222222)
|
|
||||||
console.log(r)
|
|
||||||
state.data = config.result(r)
|
state.data = config.result(r)
|
||||||
state.totalPage = config.totalPage(r)
|
state.totalPage = config.totalPage(r)
|
||||||
state.total = config.total(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) {
|
export function usePage(_url, params = {}, init = true) {
|
||||||
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
|
|||||||
@@ -28,8 +28,8 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import {computed, defineEmits, defineProps, onMounted, ref, watch} from "vue";
|
import {computed, defineEmits, defineProps, onMounted, ref, watch} from "vue";
|
||||||
import {scrollLoad, throttle} from "@/api/method";
|
import {useBoeUserListPage} from "@/api/request";
|
||||||
import * as api1 from "@/api/index1";
|
import {USER_LIST} from "@/api/ThirdApi";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
value: {
|
value: {
|
||||||
@@ -48,8 +48,6 @@ const props = defineProps({
|
|||||||
mode: String
|
mode: String
|
||||||
})
|
})
|
||||||
|
|
||||||
const options = ref([])
|
|
||||||
|
|
||||||
const selectOptions = ref([])
|
const selectOptions = ref([])
|
||||||
|
|
||||||
const managerArray = computed(() => props.mode === 'select' ? props.value : (props.value ? props.value.split(',') : []))
|
const managerArray = computed(() => props.mode === 'select' ? props.value : (props.value ? props.value.split(',') : []))
|
||||||
@@ -58,11 +56,17 @@ const emit = defineEmits({})
|
|||||||
|
|
||||||
const isOpen = ref(false)
|
const isOpen = ref(false)
|
||||||
|
|
||||||
const memberParam = ref({keyWord: '', pageNo: 1, pageSize: 10})
|
const memberParam = ref({keyWord: '', page: 1, pageSize: 20})
|
||||||
const loading = ref(false)
|
|
||||||
|
|
||||||
|
const {data: userList, loading} = useBoeUserListPage(USER_LIST, memberParam.value, false)
|
||||||
|
|
||||||
|
const options = computed(() => userList.value.filter(e => !(props.value + '').includes(e.id)).map(e => ({
|
||||||
|
label: e.realName + e.userNo,
|
||||||
|
value: e.id,
|
||||||
|
...e,
|
||||||
|
audienceList: null
|
||||||
|
})))
|
||||||
|
|
||||||
watch(() => memberParam.value, throttle(getMemberData, 1000))
|
|
||||||
watch(props, init)
|
watch(props, init)
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
@@ -78,59 +82,32 @@ onMounted(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
function getMemberData() {
|
const memberScroll = ({target: {scrollHeight, scrollTop, clientHeight}}) => {
|
||||||
if (!memberParam.value.keyWord) {
|
scrollHeight === (clientHeight + scrollTop) && memberParam.value.page++
|
||||||
return
|
|
||||||
}
|
|
||||||
if (memberParam.value.pageNo !== 1) {
|
|
||||||
options.value && options.value.length && (options.value = [])
|
|
||||||
}
|
|
||||||
isOpen.value = true
|
|
||||||
loading.value = true
|
|
||||||
api1.getMemberInfo(memberParam.value).then((res) => {
|
|
||||||
if (!res.data.data.rows || !res.data.data.rows.length) {
|
|
||||||
isOpen.value = false
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
console.log(1111111111111)
|
|
||||||
console.log(props.value)
|
|
||||||
const list = res.data.data.rows.filter(e => !(props.value + '').includes(e.id)).map(e => ({
|
|
||||||
label: e.realName + e.userNo,
|
|
||||||
value: e.id,
|
|
||||||
deptId: e.departId,
|
|
||||||
departName: e.departName,
|
|
||||||
userNo: e.userNo,
|
|
||||||
name: e.realName
|
|
||||||
}));
|
|
||||||
memberParam.value.pageNo === 1 && props.value ? (options.value = list) : options.value.push(...list)
|
|
||||||
loading.value = false
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const memberScroll = (e) => {
|
|
||||||
let num = scrollLoad(e);
|
|
||||||
if (num === 2) {
|
|
||||||
memberParam.value.pageNo++;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//搜索学员
|
//搜索学员
|
||||||
const searchMember = (keyWord) => {
|
const searchMember = (keyWord) => {
|
||||||
console.log('searchMember', keyWord)
|
console.log('searchMember', keyWord)
|
||||||
loading.value = true
|
loading.value = true
|
||||||
options.value = []
|
|
||||||
isOpen.value = true
|
isOpen.value = true
|
||||||
keyWord && (memberParam.value = {keyWord, pageNo: 1, pageSize: 10});
|
userList.value = []
|
||||||
|
memberParam.value.page = 1
|
||||||
|
memberParam.value.keyWord = keyWord
|
||||||
};
|
};
|
||||||
|
|
||||||
function blur() {
|
function blur() {
|
||||||
isOpen.value = false
|
isOpen.value = false
|
||||||
|
memberParam.value.keyWord = ''
|
||||||
|
memberParam.value.page = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
function change(e, l) {
|
function change(e, l) {
|
||||||
|
memberParam.value.keyWord = ''
|
||||||
|
memberParam.value.page = 1
|
||||||
isOpen.value = false
|
isOpen.value = false
|
||||||
Array.isArray(l) && (selectOptions.value = l)
|
Array.isArray(l) && (selectOptions.value = l)
|
||||||
Array.isArray(selectOptions.value) && emit('onChange', e, l, selectOptions.value.find(e => e.deptId)?.deptId, selectOptions.value.find(e => e.deptId)?.departName)
|
Array.isArray(selectOptions.value) && emit('onChange', e, l, selectOptions.value.find(e => e.departId)?.departId, selectOptions.value.find(e => e.departId)?.departName)
|
||||||
if (Array.isArray(l)) {
|
if (Array.isArray(l)) {
|
||||||
emit('update:name', l.map(t => t.label).join(','))
|
emit('update:name', l.map(t => t.label).join(','))
|
||||||
emit('update:value', l.map(t => t.value).join(','))
|
emit('update:value', l.map(t => t.value).join(','))
|
||||||
|
|||||||
Reference in New Issue
Block a user