提交 a79c3360 authored 作者: 钟是志's avatar 钟是志

查看代码

上级 f859edb2
...@@ -5,12 +5,43 @@ import ShowItem, { dragEventList, zipImage } from './ShowItem'; ...@@ -5,12 +5,43 @@ import ShowItem, { dragEventList, zipImage } from './ShowItem';
import { apiRequest } from '../../utils/request'; import { apiRequest } from '../../utils/request';
import { deepCopy } from '@/webPublic/one_stop_public/utils/myutils'; import { deepCopy } from '@/webPublic/one_stop_public/utils/myutils';
import { getModal } from '@/webPublic/one_stop_public/utils/utils'; import { getModal } from '@/webPublic/one_stop_public/utils/utils';
const Modal = getModal();
let fakeFileInfo = { const Modal = getModal();
path: '/u/202112/25143111x0ki.jpg', // 超大的图片 const styleList = {
name: '摇摇后摇.jpg', modalParentDiv: {
display: 'grid',
placeItems: 'center',
width: '100%',
height: '100%',
},
modalDiv: {
display: 'grid',
position: 'relative',
overflow: 'auto',
backgroundRepeat: 'no-repeat',
backgroundPosition: 'center',
backgroundSize: 'cover',
},
oneSetItem: {
position: 'absolute',
border: '1px solid red',
},
oneSetItemP: {
marginBottom: 0,
userSelect: 'none',
},
draggableIcon:{
position: 'absolute',
left: '10',
top: '10',
color: 'red',
zIndex: '10000',
},
readOnlyImage: {
width: '100%',
display: 'grid',
placeItems: 'center',
},
}; };
const getContent = (signConfig = [], ratioX) => { const getContent = (signConfig = [], ratioX) => {
...@@ -38,15 +69,15 @@ const getContent = (signConfig = [], ratioX) => { ...@@ -38,15 +69,15 @@ const getContent = (signConfig = [], ratioX) => {
}; };
export default function PictureSignature({ export default function PictureSignature({
json, json,
disabled, disabled,
basicUrl, basicUrl,
onChangeFile, onChangeFile,
imageIndex, imageIndex,
form, form,
// fileInfo, // fileInfo,
...others ...others
}) { }) {
let imageRef = useRef(); let imageRef = useRef();
const [fileInfo, setFileInfo] = useState({ ...others?.fileInfo }); const [fileInfo, setFileInfo] = useState({ ...others?.fileInfo });
// const [fileInfo, setFileInfo] = useState(fakeFileInfo); // const [fileInfo, setFileInfo] = useState(fakeFileInfo);
...@@ -57,22 +88,23 @@ export default function PictureSignature({ ...@@ -57,22 +88,23 @@ export default function PictureSignature({
const changeShowModal = () => { const changeShowModal = () => {
if (!showModal) { if (!showModal) {
if (!imageInfo && !disabled) { if (!imageInfo && !disabled) {
zipImage(fileInfo.path, fileInfo.name, otherProps?.backgroundImageWidth).then(res => { zipImage(fileInfo.path, fileInfo.name, otherProps?.backgroundImageWidth)
let image = new Image(); //新建一个img标签(还没嵌入DOM节点) .then(res => {
image.src = basicUrl + res; let image = new Image(); //新建一个img标签(还没嵌入DOM节点)
image.onload = () => { image.src = basicUrl + res;
// alert(image.width); image.onload = () => {
setImageInfo({ // alert(image.width);
width: image.width, setImageInfo({
height: image.height, width: image.width,
height: image.height,
});
};
setFileInfo({
path: res,
name: fileInfo.name,
originPath: res,
}); });
};
setFileInfo({
path: res,
name: fileInfo.name,
originPath: res,
}); });
});
} }
} }
setShowModal(!showModal); setShowModal(!showModal);
...@@ -128,21 +160,22 @@ export default function PictureSignature({ ...@@ -128,21 +160,22 @@ export default function PictureSignature({
apiRequest('/ImageLibApi/merge', { apiRequest('/ImageLibApi/merge', {
background: fileInfo?.path, background: fileInfo?.path,
content, content,
}).then(res => { })
if (form && saveSignConfigValue) { .then(res => {
form.setFieldsValue({ if (form && saveSignConfigValue) {
[saveSignConfigValue]: content, form.setFieldsValue({
}); [saveSignConfigValue]: content,
} });
if (res && res.path) { }
message.success('操作成功'); if (res && res.path) {
let newPath = res.path; message.success('操作成功');
fileInfo.originPath = fileInfo.path; let newPath = res.path;
fileInfo.path = newPath; fileInfo.originPath = fileInfo.path;
setFileInfo({ ...fileInfo }); fileInfo.path = newPath;
setOpenEdit(false); setFileInfo({ ...fileInfo });
} setOpenEdit(false);
}); }
});
break; break;
case 'restore': // 还原图片 case 'restore': // 还原图片
if (fileInfo.originPath) { if (fileInfo.originPath) {
...@@ -223,11 +256,11 @@ export default function PictureSignature({ ...@@ -223,11 +256,11 @@ export default function PictureSignature({
}} }}
{...ModalProps} {...ModalProps}
> >
<div className={styles.modalParentDiv}> <div style={styleList.modalParentDiv}>
{openEdit && ( // 开启签章功能 {openEdit && ( // 开启签章功能
<div <div
className={styles.modalDiv}
style={{ style={{
...styleList.modalDiv,
backgroundImage: `url(${basicUrl + fileInfo?.path})`, backgroundImage: `url(${basicUrl + fileInfo?.path})`,
width: showImageWidth, width: showImageWidth,
height: imageInfo.height / (imageInfo.width / showImageWidth), height: imageInfo.height / (imageInfo.width / showImageWidth),
...@@ -237,34 +270,39 @@ export default function PictureSignature({ ...@@ -237,34 +270,39 @@ export default function PictureSignature({
id={'dropZone'} id={'dropZone'}
> >
{Array.isArray(signConfig) && {Array.isArray(signConfig) &&
signConfig.map(g => { signConfig.map(g => {
return ( return (
<div <div
key={g.key} key={g.key}
data-mes={g.key} data-mes={g.key}
draggable={false} draggable={false}
className={styles.oneSetItem} style={{
style={{ ...styleList.oneSetItem,
top: g.y, top: g.y,
left: g.x, left: g.x,
}} }}
>
<div style={styleList.draggableIcon}
data-mes={g.key}
draggable={true}
> >
<div className={styles.draggableIcon} data-mes={g.key} draggable={true}> <Icon type='scissor' />
<Icon type="scissor" />
</div>
<ShowItem {...g} basicUrl={basicUrl} />
</div> </div>
); <ShowItem {...g} basicUrl={basicUrl} />
})} </div>
);
})}
</div> </div>
)} )}
{!openEdit && ( // 不开启签章功能 只是预览图片 {!openEdit && ( // 不开启签章功能 只是预览图片
<div className={styles.readOnlyImage}> <div style={styleList.readOnlyImage}
>
<img <img
src={basicUrl + fileInfo?.path + `?v=${Math.random()}`} src={basicUrl + fileInfo?.path + `?v=${Math.random()}`}
alt={fileInfo.name} alt={fileInfo.name}
style={{ style={{
width: `${showImageWidth}px`, width: `${showImageWidth}px`,
height: 'auto',
}} }}
/> />
</div> </div>
...@@ -277,7 +315,13 @@ export default function PictureSignature({ ...@@ -277,7 +315,13 @@ export default function PictureSignature({
} }
export function SignArray(props) { export function SignArray(props) {
const { value, onChange, basicUrl, json, form } = props; const {
value,
onChange,
basicUrl,
json,
form,
} = props;
let files = value?.files || []; let files = value?.files || [];
const onChangeFile = (newFielInfo, imageIndex) => { const onChangeFile = (newFielInfo, imageIndex) => {
if (newFielInfo && newFielInfo.path) { if (newFielInfo && newFielInfo.path) {
......
import React from "react"; import React from "react";
import {queryApiActionPath} from "@/webPublic/one_stop_public/utils/queryConfig"; import {queryApiActionPath} from "@/webPublic/one_stop_public/utils/queryConfig";
import {apiRequest} from "@/webPublic/one_stop_public/utils/request";
import {getToken} from "@/webPublic/one_stop_public/utils/token"; import {getToken} from "@/webPublic/one_stop_public/utils/token";
const oneSetItemP = {
marginBottom: 0,
userSelect: 'none',
};
const ShowItem = ({ basicUrl, type, x, y, ...otherInfo }) => { const ShowItem = ({ basicUrl, type, x, y, ...otherInfo }) => {
switch (type) { switch (type) {
case 'image': case 'image':
...@@ -27,6 +31,7 @@ const ShowItem = ({ basicUrl, type, x, y, ...otherInfo }) => { ...@@ -27,6 +31,7 @@ const ShowItem = ({ basicUrl, type, x, y, ...otherInfo }) => {
key={otherInfo.key} key={otherInfo.key}
style={{ style={{
// border: '1px solid red', // border: '1px solid red',
...oneSetItemP,
cursor: 'pointer', cursor: 'pointer',
fontSize: otherInfo?.fontSize ? otherInfo.fontSize + 'px' : undefined, fontSize: otherInfo?.fontSize ? otherInfo.fontSize + 'px' : undefined,
fontFamily: otherInfo?.fontFamily ? otherInfo.fontFamily : undefined, fontFamily: otherInfo?.fontFamily ? otherInfo.fontFamily : undefined,
......
...@@ -10,32 +10,23 @@ ...@@ -10,32 +10,23 @@
.modalDiv{ .modalDiv{
display: grid; display: grid;
//width: 1200px;
//grid-template-columns: 100px 1fr;
//grid-template-rows;
position: relative; position: relative;
overflow: auto; overflow: auto;
background-repeat: no-repeat; background-repeat: no-repeat;
background-position: center; background-position: center;
background-size: cover; background-size: cover;
.rightSide{
overflow: auto;
}
} }
.readOnlyImage{ .readOnlyImage{
width: 100%; width: 100%;
display: grid; display: grid;
place-items: center; place-items: center;
//min-height: 800px;
img{ img{
//width: 1200px;
height: auto; height: auto;
} }
} }
.oneSetItem{ .oneSetItem{
position: absolute; position: absolute;
//margin-top: 20px;
border: 1px solid red; border: 1px solid red;
p{ p{
margin-bottom: 0; margin-bottom: 0;
...@@ -60,7 +51,6 @@ ...@@ -60,7 +51,6 @@
position: absolute; position: absolute;
left: 10; left: 10;
top: 10; top: 10;
//border: 1px solid #f2f2f2;
color: red; color: red;
z-index: 10000; z-index: 10000;
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论