fix: 找回丢失代码 #96

Merged
lizijie merged 4 commits from fix/retrieveLostCode into test 1 year ago

@ -1,16 +1,18 @@
<script lang="ts" setup> <script lang="ts" setup>
import { debounce } from 'lodash-es' import { getAllfieldList, getfieldList } from "@/api/home/filter";
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, computed, defineEmits, defineOptions,
defineOptions,
inject, inject,
nextTick, nextTick,
onMounted, onMounted,
ref, ref,
unref, unref,
toRaw, watch
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,3 +1,10 @@
<!-- 使用示例 -->
<!--
<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 {
@ -21,8 +28,21 @@ 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[]>([]);
@ -65,12 +85,9 @@ 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[] = [];
@ -84,41 +101,44 @@ function reset() {
taskpagination.pageNo = 0; taskpagination.pageNo = 0;
taskpagination.pageSize = 20; taskpagination.pageSize = 20;
listData.value.length = 0; listData.value.length = 0;
loading.value = false; emit('toggle', false)
canloadMore = true; canLoadMore.value = 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, canLoadMore: () => canloadMore } { distance: 10, interval: 1500, canLoadMore: () => canLoadMore.value }
); );
} }
async function loadMore() { async function loadMore() {
if (loading.value || el.value == null) return; if (loading.value || el.value == null) return;
const more = await featchList(); const more = await fetchList();
listData.value.push(...more); listData.value.push(...more);
} }
async function featchList() { async function fetchList() {
loading.value = true; console.log(3333)
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 = pageCount >= taskpagination.pageNo && pageCount > 0; canLoadMore.value = pageCount >= taskpagination.pageNo && pageCount > 0;
return data; return data;
} catch (error) { } catch (error) {
canloadMore = false; canLoadMore.value = false;
return []; return [];
} }
} }
@ -130,12 +150,12 @@ const layout = debounce(() => {
_imagesload.on("done", (instance) => { _imagesload.on("done", (instance) => {
if (!el.value) return; if (!el.value) return;
loading.value = false; emit('toggle', false)
}); });
_imagesload.on("fail", (instance) => { _imagesload.on("fail", (instance) => {
message.error("图片错误"); message.error("图片错误");
loading.value = false; emit('toggle', false)
}); });
}, 300); }, 300);
@ -149,9 +169,7 @@ watch(
totalCount.value = 0; totalCount.value = 0;
return; return;
} }
reset(); refreshHandler()
const more = await featchList();
listData.value.push(...more);
} }
}, { deep: true, immediate: true } }, { deep: true, immediate: true }
); );

Loading…
Cancel
Save