|
@@ -1,12 +1,13 @@
|
|
-import { Input, Modal, Transfer } from 'antd'
|
|
|
|
|
|
+import { Input, Modal } from 'antd'
|
|
import { useEffect, useMemo, useRef, useState } from 'react'
|
|
import { useEffect, useMemo, useRef, useState } from 'react'
|
|
import AMapLoader from '@amap/amap-jsapi-loader';
|
|
import AMapLoader from '@amap/amap-jsapi-loader';
|
|
import style from './style.module.scss'
|
|
import style from './style.module.scss'
|
|
import { SceneType, SceneTypeDomain, SceneTypePaths } from 'constant';
|
|
import { SceneType, SceneTypeDomain, SceneTypePaths } from 'constant';
|
|
-import { base64ToBlob, getHref } from 'utils';
|
|
|
|
|
|
+import { base64ToBlob, getHref, drawImage } from 'utils';
|
|
import { asyncLoading } from 'components/loading';
|
|
import { asyncLoading } from 'components/loading';
|
|
import { RedoOutlined } from '@ant-design/icons';
|
|
import { RedoOutlined } from '@ant-design/icons';
|
|
import { fetchTaggings } from 'api'
|
|
import { fetchTaggings } from 'api'
|
|
|
|
+import { SortTransfer } from './sort-transfer'
|
|
|
|
|
|
import type { Tagging } from 'api'
|
|
import type { Tagging } from 'api'
|
|
|
|
|
|
@@ -148,7 +149,7 @@ const getFuseImage = async (iframe: HTMLIFrameElement) => {
|
|
const fuseCnavas = targetWindow.document.querySelector('.scene-canvas > canvas') as HTMLElement
|
|
const fuseCnavas = targetWindow.document.querySelector('.scene-canvas > canvas') as HTMLElement
|
|
|
|
|
|
if (fuseCnavas) {
|
|
if (fuseCnavas) {
|
|
- const dataURL = await targetWindow.sdk.screenshot(540, 390)
|
|
|
|
|
|
+ const dataURL = await targetWindow.sdk.screenshot(targetIframe.offsetWidth, targetIframe.offsetHeight)
|
|
const res = await fetch(dataURL)
|
|
const res = await fetch(dataURL)
|
|
const blob = await res.blob()
|
|
const blob = await res.blob()
|
|
return { type: ImageType.FUSE, blob }
|
|
return { type: ImageType.FUSE, blob }
|
|
@@ -173,7 +174,6 @@ const getFuseImage = async (iframe: HTMLIFrameElement) => {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
export const SelectFuse = (props: SelectImageProps & { caseId: number }) => {
|
|
export const SelectFuse = (props: SelectImageProps & { caseId: number }) => {
|
|
const [open, setOpen] = useState(true)
|
|
const [open, setOpen] = useState(true)
|
|
const [blob, setBlob] = useState<Blob | null>(null)
|
|
const [blob, setBlob] = useState<Blob | null>(null)
|
|
@@ -224,10 +224,11 @@ export const SelectFuse = (props: SelectImageProps & { caseId: number }) => {
|
|
const hotItems = Array.from(contentDoc.querySelectorAll('.hot-item')) as HTMLDivElement[]
|
|
const hotItems = Array.from(contentDoc.querySelectorAll('.hot-item')) as HTMLDivElement[]
|
|
hotItems.forEach(hot => {
|
|
hotItems.forEach(hot => {
|
|
const hotTitle = (hot.querySelector('.tip') as HTMLDivElement).innerText
|
|
const hotTitle = (hot.querySelector('.tip') as HTMLDivElement).innerText
|
|
- const index = addTags.findIndex(tag => tag.tagTitle === hotTitle)
|
|
|
|
|
|
+ const index = addTags.findIndex(tag => tag.tagTitle.trim() === hotTitle.trim())
|
|
if (index !== -1) {
|
|
if (index !== -1) {
|
|
const bound = hot.getBoundingClientRect()
|
|
const bound = hot.getBoundingClientRect()
|
|
- const size = 32
|
|
|
|
|
|
+ const size = (img.width / 540) * 32
|
|
|
|
+
|
|
const left = bound.left + size / 2
|
|
const left = bound.left + size / 2
|
|
const top = bound.top + size / 2
|
|
const top = bound.top + size / 2
|
|
ctx.save()
|
|
ctx.save()
|
|
@@ -247,15 +248,30 @@ export const SelectFuse = (props: SelectImageProps & { caseId: number }) => {
|
|
ctx.restore()
|
|
ctx.restore()
|
|
}
|
|
}
|
|
})
|
|
})
|
|
-
|
|
|
|
- const blob = await new Promise<Blob | null>(resolve => $canvas.toBlob(resolve, 'png'))
|
|
|
|
|
|
+
|
|
|
|
+ const $ccanvas = document.createElement('canvas')
|
|
|
|
+ $ccanvas.width = 540
|
|
|
|
+ $ccanvas.height = 390
|
|
|
|
+ const cctx = $ccanvas.getContext('2d')!
|
|
|
|
+ drawImage(
|
|
|
|
+ cctx,
|
|
|
|
+ $ccanvas.width,
|
|
|
|
+ $ccanvas.height,
|
|
|
|
+ $canvas,
|
|
|
|
+ img.width,
|
|
|
|
+ img.height,
|
|
|
|
+ 0, 0
|
|
|
|
+ )
|
|
|
|
+
|
|
|
|
+ const blob = await new Promise<Blob | null>(resolve => $ccanvas.toBlob(resolve, 'png'))
|
|
setBlob(blob)
|
|
setBlob(blob)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
return (
|
|
return (
|
|
<Modal
|
|
<Modal
|
|
- width="1000px"
|
|
|
|
|
|
+ width="1500px"
|
|
title="选择户型图"
|
|
title="选择户型图"
|
|
open={open}
|
|
open={open}
|
|
onCancel={() => setOpen(false)}
|
|
onCancel={() => setOpen(false)}
|
|
@@ -272,14 +288,14 @@ export const SelectFuse = (props: SelectImageProps & { caseId: number }) => {
|
|
<div className={style['house-tags']}>
|
|
<div className={style['house-tags']}>
|
|
<h4>请选择要同步到现场图的标注:</h4>
|
|
<h4>请选择要同步到现场图的标注:</h4>
|
|
<div className={style['tagging-transfer']}>
|
|
<div className={style['tagging-transfer']}>
|
|
- <Transfer
|
|
|
|
|
|
+ <SortTransfer
|
|
dataSource={mockData}
|
|
dataSource={mockData}
|
|
titles={['所有', '需要']}
|
|
titles={['所有', '需要']}
|
|
targetKeys={addTagIds}
|
|
targetKeys={addTagIds}
|
|
selectedKeys={selectTags}
|
|
selectedKeys={selectTags}
|
|
onChange={setAddTagIds}
|
|
onChange={setAddTagIds}
|
|
onSelectChange={(sKeys, tKeys) => setSelectTags([...sKeys, ...tKeys])}
|
|
onSelectChange={(sKeys, tKeys) => setSelectTags([...sKeys, ...tKeys])}
|
|
- render={(item) => item.data.tagTitle}
|
|
|
|
|
|
+ onChangeSort={tags => setAddTagIds(tags.map(tag => tag.data.tagId.toString()))}
|
|
/>
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|