提交 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) => {
...@@ -46,7 +77,7 @@ export default function PictureSignature({ ...@@ -46,7 +77,7 @@ export default function PictureSignature({
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,7 +88,8 @@ export default function PictureSignature({ ...@@ -57,7 +88,8 @@ 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)
.then(res => {
let image = new Image(); //新建一个img标签(还没嵌入DOM节点) let image = new Image(); //新建一个img标签(还没嵌入DOM节点)
image.src = basicUrl + res; image.src = basicUrl + res;
image.onload = () => { image.onload = () => {
...@@ -128,7 +160,8 @@ export default function PictureSignature({ ...@@ -128,7 +160,8 @@ export default function PictureSignature({
apiRequest('/ImageLibApi/merge', { apiRequest('/ImageLibApi/merge', {
background: fileInfo?.path, background: fileInfo?.path,
content, content,
}).then(res => { })
.then(res => {
if (form && saveSignConfigValue) { if (form && saveSignConfigValue) {
form.setFieldsValue({ form.setFieldsValue({
[saveSignConfigValue]: content, [saveSignConfigValue]: content,
...@@ -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),
...@@ -243,14 +276,17 @@ export default function PictureSignature({ ...@@ -243,14 +276,17 @@ export default function PictureSignature({
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 className={styles.draggableIcon} data-mes={g.key} draggable={true}> <div style={styleList.draggableIcon}
<Icon type="scissor" /> data-mes={g.key}
draggable={true}
>
<Icon type='scissor' />
</div> </div>
<ShowItem {...g} basicUrl={basicUrl} /> <ShowItem {...g} basicUrl={basicUrl} />
</div> </div>
...@@ -259,12 +295,14 @@ export default function PictureSignature({ ...@@ -259,12 +295,14 @@ export default function PictureSignature({
</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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论