feat: 修改bug

pull/129/head
raofuzi 1 year ago
parent 114d5e9527
commit 07c93b17fc

@ -20,10 +20,14 @@ const cardStyle = {
'--n-padding-left': '120px', '--n-padding-left': '120px',
} }
let startTime = 0;
let endTime = 0;
let startCalTime = false;
const message = useMessage() const message = useMessage()
const timeRange = ref('') const timeRange = ref('desc')
const similarRange = ref('') const similarRange = ref('desc')
const batch = ref(false) const batch = ref(false)
const imageRef = ref<ComponentElRef | null>();
let filterId = null; let filterId = null;
let sortObj: any = { let sortObj: any = {
orderByUptime: 'desc' orderByUptime: 'desc'
@ -64,6 +68,7 @@ const viewLabel = computed(() => {
const masonryRef = ref<ComponentRef>(null) const masonryRef = ref<ComponentRef>(null)
const el = ref<HTMLDivElement | null>(null) const el = ref<HTMLDivElement | null>(null)
const elwc = ref<HTMLDivElement | null>(null)
const listData = ref<any[]>([]) const listData = ref<any[]>([])
const pagination = reactive({ const pagination = reactive({
pageNo: 1, pageNo: 1,
@ -149,7 +154,18 @@ async function loadMore() {
} }
onUpdated(() => { onUpdated(() => {
console.log('onUpdated', onUpdated) if(startCalTime) {
endTime = new Date().getTime();
if(endTime - startTime > 1000) {
createDom()
}
}else {
removeDom()
}
console.log('onUpdated')
// if(elwc.value) {
// on(elwc.value!, 'click', showjjj)
// }
layout() layout()
}) })
@ -163,6 +179,9 @@ let selectionBox: HTMLDivElement | null
const selectIds = ref<string[]>([]) const selectIds = ref<string[]>([])
function downHandler(event: MouseEvent) { function downHandler(event: MouseEvent) {
console.log("downHandler-------------------", event);
startTime = new Date().getTime();
startCalTime = true;
if (!selectionBox) if (!selectionBox)
return return
@ -218,6 +237,14 @@ function isSelected(pictureId: number) {
} }
function moveHandler(e: MouseEvent) { function moveHandler(e: MouseEvent) {
if(startCalTime) {
endTime = new Date().getTime();
if(endTime - startTime > 1000) {
createDom()
}
}else {
removeDom()
}
if (!selectionBox || !start) if (!selectionBox || !start)
return return
@ -234,20 +261,52 @@ function moveHandler(e: MouseEvent) {
imUpdateSelectIds(x, y, w, h) imUpdateSelectIds(x, y, w, h)
} }
function createDom() {
let dom = document.createElement('div');
dom.className = "selection-box";
dom.style.width = "1px";
dom.style.border = "1px dotted black";
dom.style.position = "absolute";
dom.style.display = "block";
dom.style.zIndex = '9999';
document.body.appendChild(dom);
selectionBox = document.querySelector('.selection-box') as HTMLDivElement
}
function removeDom() {
let dom = document.getElementsByClassName("selection-box")[0];
if(dom) {
document.body.removeChild(dom);
}
}
function upHandler(event: MouseEvent) { function upHandler(event: MouseEvent) {
endTime = new Date().getTime();
startCalTime = false;
console.log("upHandle--------------------", startTime, endTime);
if(endTime - startTime > 1000) {
createDom()
}else {
removeDom()
}
if (!selectionBox) if (!selectionBox)
return return
selectionBox.style.display = 'none'
start = null
if(selectionBox.style.width == "0px") { if(selectionBox.style.width == "0px") {
removeDom()
if(event.target?.className.indexOf("n-checkbox-box__border") != -1 ) {
return
}
selectIds.value = [] selectIds.value = []
selectedApproveItems.value.forEach((item) => (item.checked = false)); selectedApproveItems.value.forEach((item) => (item.checked = false));
selectedApproveItems.value.length = 0; selectedApproveItems.value.length = 0;
console.log("11111111111111", event, selectionBox.style);
listData.value.map(item => { listData.value.map(item => {
item.checked = false; item.checked = false;
}); });
batch.value = false; batch.value = false;
} }
selectionBox.style.display = 'none'
start = null
} }
const gridHeight = computed(() => { const gridHeight = computed(() => {
@ -266,17 +325,19 @@ const gridHeight = computed(() => {
}) })
function addListeners() { function addListeners() {
selectionBox = document.querySelector('.selection-box') as HTMLDivElement
// selectionBox.style['z-index'] = '-1'
on(el.value!, 'mousedown', downHandler) on(el.value!, 'mousedown', downHandler)
on(el.value!, 'mousemove', moveHandler) on(el.value!, 'mousemove', moveHandler)
on(document, 'mouseup', upHandler) on(document, 'mouseup', upHandler)
// on(elwc.value!, 'mouseup', upHandler)
} }
function removeListeners() { function removeListeners() {
off(el.value!, 'mousedown', downHandler) off(el.value!, 'mousedown', downHandler)
on(el.value!, 'mousemove', moveHandler) on(el.value!, 'mousemove', moveHandler)
on(document, 'mouseup', upHandler) on(document, 'mouseup', upHandler)
// on(elwc.value!, 'mouseup', upHandler)
} }
function afterEnter() { function afterEnter() {
@ -289,6 +350,7 @@ function afterLeave() {
onMounted(() => { onMounted(() => {
show.value && addListeners() show.value && addListeners()
removeDom()
}) })
async function showModal() { async function showModal() {
@ -300,20 +362,30 @@ async function showModal() {
layout() layout()
} }
async function onChange(val) { async function onChange() {
if(timeRange.value == "desc") {
timeRange.value = "asc";
}else {
timeRange.value = "desc";
}
sortObj = { sortObj = {
// orderbyname: val, // orderbyname: val,
orderByUptime: val orderByUptime: timeRange.value
} }
pagination.pageNo = 1 pagination.pageNo = 1
const list = await featchList() const list = await featchList()
listData.value = list listData.value = list
} }
async function onChangeView(val) { async function onChangeView() {
if(similarRange.value == "desc") {
similarRange.value = "asc";
}else {
similarRange.value = "desc";
}
sortObj = { sortObj = {
// orderbyname: val, // orderbyname: val,
orderBySimilarity: val orderBySimilarity: similarRange.value
} }
pagination.pageNo = 1 pagination.pageNo = 1
const list = await featchList() const list = await featchList()
@ -368,6 +440,7 @@ const showActions = computed(() => {
function onCheckChange(checked: any, item: any) { function onCheckChange(checked: any, item: any) {
item.checked = checked item.checked = checked
const index = selectedApproveItems.value.indexOf(item); const index = selectedApproveItems.value.indexOf(item);
const picIndex = selectIds.value.indexOf(item.pictureId); const picIndex = selectIds.value.indexOf(item.pictureId);
@ -382,6 +455,12 @@ function onCheckChange(checked: any, item: any) {
} else { } else {
selectIds.value.splice(picIndex, 1); selectIds.value.splice(picIndex, 1);
} }
setTimeout(() => {
nextTick(() => {
batch.value = true
console.log("2222222222222222222");
})
}, 100)
} }
function rejectHandler() { function rejectHandler() {
@ -466,37 +545,48 @@ function reloadList() {
} }
async function refreshHandler(filtersearchId?: any) { async function refreshHandler(filtersearchId?: any) {
// rao start // rao start
// reset() reset()
// const list = await featchList() const list = await featchList()
// listData.value = list listData.value = list
// layout() layout()
// rao end // rao end
reset(); // reset();
if (filtersearchId) { // if (filtersearchId) {
filterId = filtersearchId; // filterId = filtersearchId;
} // }
nextTick(() => { // nextTick(() => {
setTimeout(() => { // setTimeout(() => {
useInfiniteScroll( // useInfiniteScroll(
el as any, // el as any,
() => { // () => {
loadMore(); // loadMore();
}, // },
{ distance: 10, canLoadMore: () => canloadMore } // { distance: 10, canLoadMore: () => canloadMore }
); // );
}, 300); // }, 300);
}); // });
}
function previewHandler(index: number, event: MouseEvent) {
console.log("imageRef.value?.[index]", imageRef.value?.[index]);
// event.stopImmediatePropagation();
// event.stopPropagation();
if (imageRef.value?.[index] && (imageRef.value[index] as any).src)
(imageRef.value?.[index] as any).click();
} }
function showjjj (e) {
console.log("showjjj------------------", e);
}
</script> </script>
<template> <template>
<div> <div>
<n-modal v-model:show="show" :mask-closable="false" style="position: relative;" transform-origin="center" <n-modal v-model:show="show" :mask-closable="false" style="position: relative;" transform-origin="center"
@after-enter="afterEnter" @after-leave="afterLeave"> @after-enter="afterEnter" @after-leave="afterLeave">
<n-card :style="cardStyle" class="card card-1" style="position: fixed;top:64px" :bordered="false" size="huge" <n-card ref="elwc" :style="cardStyle" class="card card-1" style="position: fixed;top:64px" :bordered="false" size="huge"
role="dialog" aria-modal="true"> role="dialog" aria-modal="true">
<div class="wrapper"> <div class="wrapper">
<div class="wrapper-m32"> <div class="wrapper-m32">
@ -510,7 +600,27 @@ async function refreshHandler(filtersearchId?: any) {
<div class="wrapper-content"> <div class="wrapper-content">
<div class="wrapper-content-form wrapper-m32"> <div class="wrapper-content-form wrapper-m32">
<div> <div>
<n-popselect v-model:value="timeRange" :options="timeOptions" trigger="click" @change="onChange"> <n-popselect v-model:value="viewMode" :options="viewOptions" trigger="click">
<div class="wrapper-form-dropdown">
<span>视图模式</span>
<SvgIcon class="wrapper-content-form-gap" name="arrow-botton" size="14" />
</div>
</n-popselect>
<div
style="margin-left: 15px; cursor: pointer; color: #323233"
@click="onChange()"
>
<span>时间排序</span>
<SvgIcon style="margin-left: 8px" name="sort" size="12" />
</div>
<div
style="margin-left: 15px; cursor: pointer; color: #323233"
@click="onChangeView()"
>
<span>相似度排序</span>
<SvgIcon style="margin-left: 8px" name="sort" size="12" />
</div>
<!-- <n-popselect v-model:value="timeRange" :options="timeOptions" trigger="click" @change="onChange">
<div class="wrapper-content-form-dropdown"> <div class="wrapper-content-form-dropdown">
<span>时间排序</span> <span>时间排序</span>
<SvgIcon class="wrapper-content-form-dropdown-gap" name="arrow-botton" size="14" /> <SvgIcon class="wrapper-content-form-dropdown-gap" name="arrow-botton" size="14" />
@ -521,13 +631,7 @@ async function refreshHandler(filtersearchId?: any) {
<span>相似度排序</span> <span>相似度排序</span>
<SvgIcon class="wrapper-content-form-dropdown-gap" name="arrow-botton" size="14" /> <SvgIcon class="wrapper-content-form-dropdown-gap" name="arrow-botton" size="14" />
</div> </div>
</n-popselect> </n-popselect> -->
<n-popselect v-model:value="viewMode" :options="viewOptions" trigger="click">
<div class="wrapper-form-dropdown">
<span>视图模式</span>
<SvgIcon class="wrapper-content-form-gap" name="arrow-botton" size="14" />
</div>
</n-popselect>
</div> </div>
<div> <div>
<div class="remove" @click="remove"> <div class="remove" @click="remove">
@ -562,14 +666,16 @@ async function refreshHandler(filtersearchId?: any) {
:class="{ 'grid-item-selected': isSelected(item.pictureId) }" :style="{ height: gridHeight }" :class="{ 'grid-item-selected': isSelected(item.pictureId) }" :style="{ height: gridHeight }"
class="grid-item"> class="grid-item">
<n-image <n-image
ref="imageRef"
:src="item.imgUrl" :src="item.imgUrl"
:preview-src="item.imgUrl"
class="img " class="img "
:class="{ :class="{
'img-fit': viewMode === 'horizontalVersion', 'img-fit': viewMode === 'horizontalVersion',
'img-full': viewMode === '3:4' || viewMode === 'verticalVersion' }" 'img-full': viewMode === '3:4' || viewMode === 'verticalVersion' }"
/> />
<n-checkbox v-if="batch && item.historyStates === 1" v-model:checked="item.checked" <n-checkbox v-if="batch && item.historyStates === 1" v-model:checked="item.checked"
style="position:absolute;left:20px;top:20px" @click.prevent style="position:absolute;left:20px;top:20px" @click.prevent.stop
@update:checked="onCheckChange($event, item)" /> @update:checked="onCheckChange($event, item)" />
<img v-if="item.historyStates === 2" class="tag-status" src="@/assets/images/task/tag-pass.png" alt=""> <img v-if="item.historyStates === 2" class="tag-status" src="@/assets/images/task/tag-pass.png" alt="">
<img v-if="item.historyStates === 3" class="tag-status" src="@/assets/images/task/tag-not-pass.png" <img v-if="item.historyStates === 3" class="tag-status" src="@/assets/images/task/tag-not-pass.png"

Loading…
Cancel
Save