Compare commits

..

No commits in common. 'cdd50c48f2c74b18d1e4bee1344bedbcc4592a41' and '5dfe0eefe0b5b5c25f5d3ceb179ac3cdc386147f' have entirely different histories.

@ -1,18 +1,16 @@
<script lang="ts" setup> <script lang="ts" setup>
import { getAllfieldList, getfieldList } from "@/api/home/filter"; import { debounce } from 'lodash-es'
import { useWindowSizeFn } from "@/hooks/event/useWindowSizeFn";
import { useUser } from "@/store/modules/user";
import { useWorkOrder } from "@/store/modules/workOrder";
import { getViewportOffset } from "@/utils/domUtils";
import { debounce } from 'lodash-es';
import { import {
computed, defineEmits, defineOptions, computed,
defineOptions,
inject, inject,
nextTick, nextTick,
onMounted, onMounted,
ref, ref,
unref, unref,
watch toRaw,
watch,
defineEmits
} from "vue"; } from "vue";
import CustomFieldModalVue from "../modal/CustomFieldModal.vue"; import CustomFieldModalVue from "../modal/CustomFieldModal.vue";
import WorkSheetList from "./WorkSheetList.vue"; import WorkSheetList from "./WorkSheetList.vue";

@ -1,10 +1,3 @@
<!-- 使用示例 -->
<!--
<n-spin :show="loading">
<div ref="el" class="scroll"></div>
<PictureWall :taskDetailInfo="taskDetailInfo" :loading="loading" :el="el" @toggle="toggleLoading"></PictureWall>
</n-spin>
-->
<script lang="ts" setup> <script lang="ts" setup>
import { audit } from '@/api/task/task'; import { audit } from '@/api/task/task';
import { import {
@ -28,21 +21,8 @@ const props = defineProps({
type: Object, type: Object,
default: () => ({}), default: () => ({}),
}, },
el: {
type: Object as () => HTMLDivElement | null,
default: () => (null),
},
loading: {
type: Boolean,
default: () => (false),
},
}); });
const { taskDetailInfo } = toRefs(props)
const emit = defineEmits<{
(e: 'toggle', loading: boolean)
}>()
const { taskDetailInfo, el, loading } = toRefs(props)
const batch = ref(false); // const batch = ref(false); //
const selectItems = ref<any[]>([]); const selectItems = ref<any[]>([]);
@ -85,9 +65,12 @@ const selectTask = ref<any>(null);
const overTask = ref<any>(null); const overTask = ref<any>(null);
const confrimModalRef = ref(null); const confrimModalRef = ref(null);
const listData = ref<any[]>([]); const listData = ref<any[]>([]);
const loading = ref(false);
const el = ref<HTMLDivElement | null>(null);
const selectedSortName = ref(''); const selectedSortName = ref('');
const notPassModalRef = ref(null) const notPassModalRef = ref(null)
const canLoadMore = ref(true);
let canloadMore = true;
let processItems: any[] = []; let processItems: any[] = [];
@ -101,44 +84,41 @@ function reset() {
taskpagination.pageNo = 0; taskpagination.pageNo = 0;
taskpagination.pageSize = 20; taskpagination.pageSize = 20;
listData.value.length = 0; listData.value.length = 0;
emit('toggle', false) loading.value = false;
canLoadMore.value = true; canloadMore = true;
} }
async function refreshHandler() { async function refreshHandler() {
reset(); reset();
console.log('refreshHandler')
useInfiniteScroll( useInfiniteScroll(
el as any, el as any,
() => { () => {
console.log(el)
console.log(11111111)
loadMore(); loadMore();
}, },
{ distance: 10, interval: 1500, canLoadMore: () => canLoadMore.value } { distance: 10, canLoadMore: () => canloadMore }
); );
} }
async function loadMore() { async function loadMore() {
if (loading.value || el.value == null) return; if (loading.value || el.value == null) return;
const more = await fetchList(); const more = await featchList();
listData.value.push(...more); listData.value.push(...more);
} }
async function fetchList() { async function featchList() {
console.log(3333) loading.value = true;
emit('toggle', true)
try { try {
taskpagination.pageNo += 1; taskpagination.pageNo += 1;
const { data, total, pageCount } = await getPictureSimilarityList( const { data, total, pageCount } = await getPictureSimilarityList(
{ ...taskpagination, ...sortBy, checkDuplicateId: workStore.activeId, pictureId: taskDetailInfo.value.id } { ...taskpagination, ...sortBy, checkDuplicateId: workStore.activeId, pictureId: taskDetailInfo.value.id }
); );
totalCount.value = total; totalCount.value = total;
canLoadMore.value = pageCount >= taskpagination.pageNo && pageCount > 0; canloadMore = pageCount >= taskpagination.pageNo && pageCount > 0;
return data; return data;
} catch (error) { } catch (error) {
canLoadMore.value = false; canloadMore = false;
return []; return [];
} }
} }
@ -150,12 +130,12 @@ const layout = debounce(() => {
_imagesload.on("done", (instance) => { _imagesload.on("done", (instance) => {
if (!el.value) return; if (!el.value) return;
emit('toggle', false) loading.value = false;
}); });
_imagesload.on("fail", (instance) => { _imagesload.on("fail", (instance) => {
message.error("图片错误"); message.error("图片错误");
emit('toggle', false) loading.value = false;
}); });
}, 300); }, 300);
@ -169,7 +149,9 @@ watch(
totalCount.value = 0; totalCount.value = 0;
return; return;
} }
refreshHandler() reset();
const more = await featchList();
listData.value.push(...more);
} }
}, { deep: true, immediate: true } }, { deep: true, immediate: true }
); );

Loading…
Cancel
Save