fix: 预警记录大图添加od
This commit is contained in:
parent
9c96671e4e
commit
8b99b57dfa
@ -2,6 +2,7 @@ import React, { useImperativeHandle, useRef, useState, forwardRef } from 'react'
|
|||||||
import { Modal, ModalProps, Space, SpaceProps } from 'antd';
|
import { Modal, ModalProps, Space, SpaceProps } from 'antd';
|
||||||
import theme from 'antd/lib/theme';
|
import theme from 'antd/lib/theme';
|
||||||
import { DownloadOutlined } from '@ant-design/icons';
|
import { DownloadOutlined } from '@ant-design/icons';
|
||||||
|
import { CropperImage } from '@zhst/meta'
|
||||||
import './index.less'
|
import './index.less'
|
||||||
|
|
||||||
type ViewLargerImageModalParams = {
|
type ViewLargerImageModalParams = {
|
||||||
@ -10,6 +11,14 @@ type ViewLargerImageModalParams = {
|
|||||||
label?: string;
|
label?: string;
|
||||||
value?: string;
|
value?: string;
|
||||||
}[];
|
}[];
|
||||||
|
odRect?: {
|
||||||
|
id?: string;
|
||||||
|
x: number;
|
||||||
|
y: number;
|
||||||
|
w: number;
|
||||||
|
h: number;
|
||||||
|
selectAble?: boolean;
|
||||||
|
}[]
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface ViewLargerImageModalRef {
|
export interface ViewLargerImageModalRef {
|
||||||
@ -30,12 +39,17 @@ export const ViewLargerImageModal = forwardRef<ViewLargerImageModalRef, ViewLarg
|
|||||||
(props, ref) => {
|
(props, ref) => {
|
||||||
|
|
||||||
const componentName = `zhst-biz-view-warning-larger-image-modal`;
|
const componentName = `zhst-biz-view-warning-larger-image-modal`;
|
||||||
const { modalProps, downloadImg, imgStyle, title = '预警大图', downloadText = '下载大图', spaceProps } = props
|
const { modalProps, downloadImg, imgStyle, title = '预警大图', downloadText = '下载大图', spaceProps, } = props
|
||||||
const { useToken } = theme
|
const { useToken } = theme
|
||||||
const { token } = useToken()
|
const { token } = useToken()
|
||||||
const [open, setOpen] = useState<boolean>(false);
|
const [open, setOpen] = useState<boolean>(false);
|
||||||
const [imageKey, setimageKey] = useState<string>();
|
const [imageKey, setimageKey] = useState<string>();
|
||||||
|
const [odRect, setOdRect] = useState<ViewLargerImageModalParams['odRect']>();
|
||||||
const [warningData, setWarningData] = useState<ViewLargerImageModalParams['warningData']>();
|
const [warningData, setWarningData] = useState<ViewLargerImageModalParams['warningData']>();
|
||||||
|
const odRectDefault = odRect?.map(rect => ({
|
||||||
|
...rect,
|
||||||
|
selectAble: rect.hasOwnProperty('selectAble') ? rect.selectAble : false
|
||||||
|
}));
|
||||||
|
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
@ -47,6 +61,7 @@ export const ViewLargerImageModal = forwardRef<ViewLargerImageModalRef, ViewLarg
|
|||||||
setOpen(true);
|
setOpen(true);
|
||||||
setimageKey(_params?.imageKey)
|
setimageKey(_params?.imageKey)
|
||||||
setWarningData(_params?.warningData)
|
setWarningData(_params?.warningData)
|
||||||
|
setOdRect(_params?.odRect)
|
||||||
},
|
},
|
||||||
handleCancel
|
handleCancel
|
||||||
};
|
};
|
||||||
@ -65,7 +80,13 @@ export const ViewLargerImageModal = forwardRef<ViewLargerImageModalRef, ViewLarg
|
|||||||
>
|
>
|
||||||
<Space size={0} {...spaceProps}>
|
<Space size={0} {...spaceProps}>
|
||||||
<div className={`${componentName}-left-img`}>
|
<div className={`${componentName}-left-img`}>
|
||||||
<img alt={title} src={imageKey} style={{ ...imgStyle }} />
|
<div style={{ width: 789, height: 444, ...imgStyle }}>
|
||||||
|
<CropperImage
|
||||||
|
// editAble={true}
|
||||||
|
odList={odRectDefault}
|
||||||
|
url={imageKey}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className='right-context'>
|
<div className='right-context'>
|
||||||
{warningData?.map(({ label, value }) => (
|
{warningData?.map(({ label, value }) => (
|
||||||
|
@ -16,7 +16,7 @@ const backEndData = [
|
|||||||
// warningTime: "2023-03-01 ",
|
// warningTime: "2023-03-01 ",
|
||||||
warningTimestamp: Date.now(),
|
warningTimestamp: Date.now(),
|
||||||
// warningTimeFormat:"YYYY-MM-DD"
|
// warningTimeFormat:"YYYY-MM-DD"
|
||||||
odRect:[{
|
odRect: [{
|
||||||
// "id": "456",
|
// "id": "456",
|
||||||
"x": 0.6519352,
|
"x": 0.6519352,
|
||||||
"y": 0.2965385,
|
"y": 0.2965385,
|
||||||
@ -34,7 +34,7 @@ const backEndData = [
|
|||||||
// warningTime: "2023-03-01 ",
|
// warningTime: "2023-03-01 ",
|
||||||
warningTimestamp: Date.now(),
|
warningTimestamp: Date.now(),
|
||||||
// warningTimeFormat:"YYYY-MM-DD"
|
// warningTimeFormat:"YYYY-MM-DD"
|
||||||
odRect:[{
|
odRect: [{
|
||||||
// "id": "456",
|
// "id": "456",
|
||||||
"x": 0.1519352,
|
"x": 0.1519352,
|
||||||
"y": 0.2965385,
|
"y": 0.2965385,
|
||||||
@ -78,7 +78,7 @@ export default () => {
|
|||||||
|
|
||||||
const handleClick = (record?: IRecord) => {
|
const handleClick = (record?: IRecord) => {
|
||||||
// 点击的时候把数据 拿过来处理一下传给大图弹框
|
// 点击的时候把数据 拿过来处理一下传给大图弹框
|
||||||
const { imageKey, warningType, boxId, position, cabietId, warningTime, warningTimestamp, warningTimeFormat = 'YYYY-MM-DD HH:mm:ss' } = record || {}
|
const { imageKey, warningType, boxId, position, cabietId, warningTime, warningTimestamp, warningTimeFormat = 'YYYY-MM-DD HH:mm:ss', odRect } = record || {}
|
||||||
const formattedDate = warningTimestamp ? dayjs(warningTimestamp).format(warningTimeFormat) : '';
|
const formattedDate = warningTimestamp ? dayjs(warningTimestamp).format(warningTimeFormat) : '';
|
||||||
const warningTimeShow = warningTime ? warningTime : formattedDate
|
const warningTimeShow = warningTime ? warningTime : formattedDate
|
||||||
//用于渲染右侧的 信息
|
//用于渲染右侧的 信息
|
||||||
@ -90,8 +90,7 @@ export default () => {
|
|||||||
{ label: '柜子ID', value: cabietId },
|
{ label: '柜子ID', value: cabietId },
|
||||||
]
|
]
|
||||||
// 调用这个方法打开弹框
|
// 调用这个方法打开弹框
|
||||||
viewLargerImageModalRef?.current?.show({ imageKey: imageKey, warningData: warningData })
|
viewLargerImageModalRef?.current?.show({ imageKey: imageKey, warningData: warningData, odRect: odRect })
|
||||||
|
|
||||||
setSelectedRecordId(record?.id)
|
setSelectedRecordId(record?.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
.zhst-biz-view-warning-larger-image-modal {
|
.zhst-biz-view-warning-larger-image-modal {
|
||||||
font-family: MicrosoftYaHei;
|
font-family: MicrosoftYaHei;
|
||||||
|
|
||||||
&-left-img img{
|
|
||||||
width: 789px;
|
|
||||||
height: 444px;
|
|
||||||
display: 'block',
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-modal-content {
|
.ant-modal-content {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
height: 492px;
|
height: 492px;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Card, Space, Divider, CardProps } from 'antd';
|
import { Card, Space, Divider, CardProps } from 'antd';
|
||||||
import { theme } from 'antd/lib';
|
import { theme } from 'antd/lib';
|
||||||
import React, { useEffect, useRef } from 'react';
|
import React from 'react';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { CropperImage } from '@zhst/meta'
|
import { CropperImage } from '@zhst/meta'
|
||||||
import './index.less'
|
import './index.less'
|
||||||
@ -60,7 +60,7 @@ export interface IRecord {
|
|||||||
w: number;
|
w: number;
|
||||||
h: number;
|
h: number;
|
||||||
selectAble?: boolean;
|
selectAble?: boolean;
|
||||||
}[]
|
}[]
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ export interface WarningRecordCardProps {
|
|||||||
export const WarningRecordCard: React.FC<WarningRecordCardProps> = (props) => {
|
export const WarningRecordCard: React.FC<WarningRecordCardProps> = (props) => {
|
||||||
const componentName = `zhst-biz-warning-record-card`;
|
const componentName = `zhst-biz-warning-record-card`;
|
||||||
const { record, onRecordClick, style, cardProps, selectedRecordId, cardStyle, imgStyle } = props;
|
const { record, onRecordClick, style, cardProps, selectedRecordId, cardStyle, imgStyle } = props;
|
||||||
const { imageKey, id, warningType, warningInfo = [], cabietText, warningTime, warningTimestamp, warningTimeFormat = 'YYYY-MM-DD HH:mm:ss', odRect = []} = record || {}
|
const { imageKey, id, warningType, warningInfo = [], cabietText, warningTime, warningTimestamp, warningTimeFormat = 'YYYY-MM-DD HH:mm:ss', odRect = [] } = record || {}
|
||||||
const formattedDate = warningTimestamp ? dayjs(warningTimestamp).format(warningTimeFormat) : '';
|
const formattedDate = warningTimestamp ? dayjs(warningTimestamp).format(warningTimeFormat) : '';
|
||||||
const warningTimeShow = warningTime ? warningTime : formattedDate
|
const warningTimeShow = warningTime ? warningTime : formattedDate
|
||||||
const { useToken } = theme
|
const { useToken } = theme
|
||||||
@ -105,11 +105,10 @@ export const WarningRecordCard: React.FC<WarningRecordCardProps> = (props) => {
|
|||||||
<div className={componentName} key={id} onClick={handleClick} style={style}>
|
<div className={componentName} key={id} onClick={handleClick} style={style}>
|
||||||
<Card
|
<Card
|
||||||
cover={
|
cover={
|
||||||
<div style={{ width: 336, height: 203 ,...imgStyle}}>
|
<div style={{ width: 336, height: 203, ...imgStyle }}>
|
||||||
<CropperImage
|
<CropperImage
|
||||||
type='line'
|
|
||||||
// editAble={true}
|
// editAble={true}
|
||||||
odList={ odRectDefault }
|
odList={odRectDefault}
|
||||||
url={imageKey}
|
url={imageKey}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -15,7 +15,7 @@ const backEndData = [
|
|||||||
// warningTime: "2023-03-01 ",
|
// warningTime: "2023-03-01 ",
|
||||||
warningTimestamp: Date.now(),
|
warningTimestamp: Date.now(),
|
||||||
// warningTimeFormat:"YYYY-MM-DD"
|
// warningTimeFormat:"YYYY-MM-DD"
|
||||||
odRect:[{
|
odRect: [{
|
||||||
// "id": "123",
|
// "id": "123",
|
||||||
"x": 0.5519352,
|
"x": 0.5519352,
|
||||||
"y": 0.2965385,
|
"y": 0.2965385,
|
||||||
@ -33,7 +33,7 @@ const backEndData = [
|
|||||||
// warningTime: "2023-03-01 ",
|
// warningTime: "2023-03-01 ",
|
||||||
warningTimestamp: Date.now(),
|
warningTimestamp: Date.now(),
|
||||||
// warningTimeFormat:"YYYY-MM-DD"
|
// warningTimeFormat:"YYYY-MM-DD"
|
||||||
odRect:[{
|
odRect: [{
|
||||||
// "id": "456",
|
// "id": "456",
|
||||||
"x": 0.1519352,
|
"x": 0.1519352,
|
||||||
"y": 0.2965385,
|
"y": 0.2965385,
|
||||||
@ -62,9 +62,7 @@ export default () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Space size={[8, 16]} direction="vertical">
|
<Space size={[8, 16]} direction="vertical">
|
||||||
{
|
{dataSource?.map((record) => <WarningRecordCard key={record?.id} record={record} />)}
|
||||||
dataSource?.map((record) => <WarningRecordCard key={record?.id} record={record} />)
|
|
||||||
}
|
|
||||||
</Space>
|
</Space>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,10 @@
|
|||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ant-card-bordered {
|
||||||
|
border: 2px solid #f0f0f0;
|
||||||
|
}
|
||||||
|
|
||||||
&-cover-img img {
|
&-cover-img img {
|
||||||
width: 336px;
|
width: 336px;
|
||||||
height: 203px;
|
height: 203px;
|
||||||
|
Loading…
Reference in New Issue
Block a user