feat: 解决冲突

pull/265/head
raoyongjun 1 year ago
parent e926d48f28
commit 73ce0b42c2

@ -4,18 +4,15 @@ import { Download as DownloadIcon, Upload as UploadIcon } from '@vicons/tabler'
import { Icon } from '@vicons/utils' import { Icon } from '@vicons/utils'
import { useInfiniteScroll } from '@vueuse/core' import { useInfiniteScroll } from '@vueuse/core'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import imagesloaded from 'imagesloaded'
// import imagesloaded from 'imagesloaded'
import { cloneDeep, debounce } from 'lodash-es' import { cloneDeep, debounce } from 'lodash-es'
import Masonry from 'masonry-layout'
// import Masonry from 'masonry-layout'
import { NIcon, useMessage } from 'naive-ui' import { NIcon, useMessage } from 'naive-ui'
import type { Component } from 'vue' import type { Component } from 'vue'
import { import {
computed, computed,
h, h,
nextTick, nextTick,
onBeforeMount,
onMounted, onMounted,
onUnmounted, onUnmounted,
onUpdated, onUpdated,
@ -57,9 +54,9 @@ const listData = ref<any[]>([])
const timer = ref() const timer = ref()
const showClose = ref(false) const showClose = ref(false)
const deviceHeight = ref(600) const deviceHeight = ref(600)
// let _masonry: null | Masonry = null let _masonry: null | Masonry = null
// let _imagesload: any let _imagesload: any
// const masonryRef = ref<ComponentRef>(null) const masonryRef = ref<ComponentRef>(null)
const el = ref<HTMLDivElement | null>(null) const el = ref<HTMLDivElement | null>(null)
const viewMode = ref('masonry') const viewMode = ref('masonry')
const pagination = reactive({ const pagination = reactive({
@ -104,36 +101,36 @@ const listStyle = computed(() => {
} }
}) })
// const layout = debounce(() => { const layout = debounce(() => {
// if (masonryRef.value == null || el.value == null) if (masonryRef.value == null || el.value == null)
// return return
// if (_masonry !== null) if (_masonry !== null)
// (_masonry as any).addItems() (_masonry as any).addItems()
// _masonry = new Masonry(masonryRef.value as any, { _masonry = new Masonry(masonryRef.value as any, {
// itemSelector: '.grid-item', itemSelector: '.grid-item',
// gutter: 17, gutter: 17,
// columnWidth: 182, columnWidth: 182,
// percentPosition: true, percentPosition: true,
// stagger: 10, stagger: 10,
// }) })
// loading.value = false loading.value = false
// // //
// _imagesload = imagesloaded('.grid-item') _imagesload = imagesloaded('.grid-item')
// _imagesload.on('done', (instance) => { _imagesload.on('done', (instance) => {
// (_masonry as any).layout() (_masonry as any).layout()
// if (!el.value) if (!el.value)
// return return
// loading.value = false loading.value = false
// }) })
// _imagesload.on('fail', (instance) => { _imagesload.on('fail', (instance) => {
// message.error('') message.error('图片错误')
// loading.value = false loading.value = false
// }) })
// }, 300) }, 300)
useInfiniteScroll( useInfiniteScroll(
el as any, el as any,
@ -143,25 +140,12 @@ useInfiniteScroll(
{ distance: 10, canLoadMore: () => canloadMore }, { distance: 10, canLoadMore: () => canloadMore },
) )
onBeforeMount(async () => {
const more = await featchList()
more.forEach((item) => {
item.calHeight = 182 * item.high / item.wide
})
listData.value = more
const tmore = await featchList()
tmore.forEach((item) => {
item.calHeight = 182 * item.high / item.wide
})
listData.value = listData.value.concat(tmore)
})
onUpdated(() => { onUpdated(() => {
// nextTick(() => { nextTick(() => {
// setTimeout(() => { setTimeout(() => {
// layout() layout()
// }, 50) }, 50)
// }) })
}) })
const timeRange = ref('') const timeRange = ref('')
@ -173,6 +157,14 @@ const timeLabel = computed(() => {
return item?.label return item?.label
}) })
const viewLabel = computed(() => {
const item = viewOptions.find((option) => {
return option.value === viewMode.value
})
return item?.label
})
const isAllowDownload = ref(true) const isAllowDownload = ref(true)
const calNum = ref(0) const calNum = ref(0)
const searchValue = ref('') const searchValue = ref('')
@ -262,48 +254,46 @@ async function featchList(userSearchId?: string) {
const list = data.map((item) => { const list = data.map((item) => {
return { return {
calHeight: 0,
imgUrl: item.imgurl, imgUrl: item.imgurl,
thumburl: item.serverThumbnailUrl, thumburl: item.serverThumbnailUrl || item.imgurl || bgLoadingImg,
upname: item.upname, upname: item.upname,
ocrPictureclass: item.ocrPictureclass, ocrPictureclass: item.ocrPictureclass,
uphead: item.uphead, uphead: item.uphead,
similar: item.similarityscore || -1, similar: item.similarityscore || -1,
imgName: item.imgname, imgName: item.imgname,
states: item.states, states: item.states,
wide: item.wide,
high: item.high,
loadOver: false, loadOver: false,
isRepeatHis: item.isRepeatHis,
} }
}) })
loading.value = false
return list return list
} }
catch (error) { catch (error) {
canloadMore = false canloadMore = false
loading.value = false
return [] return []
} }
} }
async function loadMore() { async function loadMore() {
console.log('loading.value加兹安', loading.value, el.value)
if (loading.value || el.value == null) if (loading.value || el.value == null)
return return
canloadMore = false
const more = await featchList() const more = await featchList()
more.forEach((item) => { // if(isInitSeaerch.value) {
item.calHeight = 182 * item.high / item.wide // listData.value = []
}) // isInitSeaerch.value = false
// listData.value.push(...more) // }
listData.value = listData.value.concat(more)
console.log('listData.value出来了', listData.value) console.log(more)
listData.value.push(...more)
console.log(listData.value)
} }
const gridHeight = computed(() => { const gridHeight = computed(() => {
let height = '' let height = ''
if (viewMode.value === 'masonry') if (viewMode.value === 'masonry')
height = 'auto' height = ''
else if (viewMode.value === 'horizontalVersion') else if (viewMode.value === 'horizontalVersion')
height = '145px' height = '145px'
else if (viewMode.value === 'verticalVersion') else if (viewMode.value === 'verticalVersion')
@ -491,13 +481,9 @@ function reset() {
canloadMore = true canloadMore = true
filterId = null filterId = null
// layout() layout()
} }
watch(listData.value, (newVal, oldVal) => {
console.log('最新的val', newVal)
})
async function refreshHandler(filtersearchId?: any) { async function refreshHandler(filtersearchId?: any) {
reset() reset()
@ -657,16 +643,6 @@ const dropdownOptions = ref([
}, },
]) ])
function finish() {
console.log('finish')
}
function scroll() {
}
const masonryRef = ref(null)
defineExpose({ defineExpose({
showLoginSuccessModal, showLoginSuccessModal,
closeLoginSuccessModal, closeLoginSuccessModal,
@ -739,30 +715,24 @@ defineExpose({
<span style="color: #507afd; font-weight: 500">{{ totalCount }}</span> </span> <span style="color: #507afd; font-weight: 500">{{ totalCount }}</span> </span>
</div> </div>
<!-- <n-spin :show="loading"> --> <n-spin :show="loading">
<div ref="el" class="scroll" :style="listStyle"> <div ref="el" class="scroll" :style="listStyle">
<waterfall :col="8" :data="listData" :gutter-width="10" @finish="finish"> <!-- <n-scrollbar :on-scroll="scrollHandler"> -->
<div ref="masonryRef" class="grid">
<div <div
v-for="(item, index) in listData" v-for="(item, index) in listData"
:key="item.calHeight" :key="index"
:style="{ height: gridHeight }" :style="{ height: gridHeight, minHeight: gridMinHeight }"
class="grid-item" class="grid-item"
> >
<img <!-- <div :style="{ 'background-color': randomColor(0.2) }" class="wrapper-content-item-img" /> -->
:key="item.thumburl" <!-- <img
v-lazy="item.thumburl" class="wrapper-content-item-img" :class="{ 'wrapper-content-item-img-fit': viewMode !== 'masonry' }"
:class="{ :src="item.imgUrl"
'img-fit': viewMode === 'horizontalVersion', > -->
'img-full': viewMode === '3:4' || viewMode === 'verticalVersion',
}"
:style="{ height: `${`${item.calHeight}px`}` }"
class="img"
alt="加载错误"
>
<n-image <n-image
ref="imageRef" ref="imageRef"
:key="item.imgUrl"
class="img" class="img"
:img-props="{ :img-props="{
onClick: ($event) => { onClick: ($event) => {
@ -778,9 +748,7 @@ defineExpose({
:src="item.thumburl" :src="item.thumburl"
:fallback-src="bgLoadingImg" :fallback-src="bgLoadingImg"
:style="{ backgroundImage: `url(${loading ? bgLoadingImg : 'none'})` }" :style="{ backgroundImage: `url(${loading ? bgLoadingImg : 'none'})` }"
style="display: none"
/> />
<img <img
v-if="item.states == 3" v-if="item.states == 3"
class="tag-status" class="tag-status"
@ -793,6 +761,29 @@ defineExpose({
src="@/assets/images/task/tag-not-pass.png" src="@/assets/images/task/tag-not-pass.png"
alt="" alt=""
> >
<img
v-if="(item.states != 3 && item.states != 5) && item.isRepeatHis"
class="tag-status"
src="@/assets/images/reset.png"
alt=""
>
<img
v-if="(item.states == 3 || item.states == 5) && item.isRepeatHis"
style="top:35px"
class="tag-status"
src="@/assets/images/reset.png"
alt=""
>
<!-- @load="loadImgOver(item)" -->
<!-- <n-image
class="img"
:class="{
'img-fit': viewMode === 'horizontalVersion',
'img-full': viewMode === '3:4' || viewMode === 'verticalVersion',
}"
:src="baseImg"
v-show="!item.loadOver"
/> -->
<div v-if="item.similar != -1" class="percent"> <div v-if="item.similar != -1" class="percent">
<SvgIcon size="42" :name="item.similar == 100 ? 'error_tag' : 'tag'" /> <SvgIcon size="42" :name="item.similar == 100 ? 'error_tag' : 'tag'" />
@ -845,11 +836,16 @@ defineExpose({
/> />
<span>{{ item.upname }}</span> <span>{{ item.upname }}</span>
</div> </div>
<!-- <div class="right">
<span :style="{ marginRight: '5px' }">分类</span>
<span>{{ item.ocrPictureclass?.classname }}</span>
</div> -->
</div> </div>
</div> </div>
</waterfall>
</div> </div>
<!-- </n-spin> --> <!-- </n-scrollbar> -->
</div>
</n-spin>
</div> </div>
<PackageSettingsModal ref="packageModalRef" @commit="commitHandler" /> <PackageSettingsModal ref="packageModalRef" @commit="commitHandler" />
<GeneratePackageModal ref="generateModalRef" /> <GeneratePackageModal ref="generateModalRef" />
@ -873,6 +869,7 @@ defineExpose({
flex-direction: column; flex-direction: column;
box-sizing: border-box; box-sizing: border-box;
margin-left: 16px; margin-left: 16px;
margin-right: 16px;
width: 100%; width: 100%;
&-header { &-header {
@ -919,26 +916,19 @@ defineExpose({
padding-bottom: 16px; padding-bottom: 16px;
} }
.grid{
display: block !important;
}
.img { .img {
width: 182px;
max-width: 182px;
border-radius: 7px; border-radius: 7px;
display: block; display: block;
opacity: 1 !important; height: calc(100% - 25px);
// height: calc(100% - 25px);
} }
.img-fit { .img-fit {
width: 182px; width: 100%;
overflow: hidden; overflow: hidden;
} }
.img-full { .img-full {
width: 182px; width: 100%;
overflow: hidden; overflow: hidden;
::v-deep(img) { ::v-deep(img) {

Loading…
Cancel
Save