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

签章组件 支持保存配置参数

上级 cd1cc81f
...@@ -11,12 +11,38 @@ let fakeFileInfo = { ...@@ -11,12 +11,38 @@ let fakeFileInfo = {
}; };
const getContent = (signConfig = [], ratioX) => {
let data = deepCopy(signConfig);
return JSON.stringify({
objs: data.map((g) => {
// 1200 的 x => 1500的 x
//
g.x = Math.ceil(g.x * ratioX, 10);
g.y = Math.ceil(g.y * ratioX, 10);
if (g.type === 'text') {
g.fontSize = Math.ceil(g.fontSize * ratioX);
g.y = g.y + 20;
// g.x = g.x + 20;
}
if(g.type === 'image'){
g.w = Math.ceil(g.w * ratioX);
g.h = Math.ceil(g.h * ratioX);
}
// console.log(g);
return g;
}),
});
};
export default function PictureSignature({ export default function PictureSignature({
json, json,
disabled, disabled,
basicUrl, basicUrl,
onChangeFile, onChangeFile,
imageIndex, imageIndex,
form,
// fileInfo, // fileInfo,
...others ...others
}) { }) {
...@@ -66,7 +92,7 @@ export default function PictureSignature({ ...@@ -66,7 +92,7 @@ export default function PictureSignature({
let func = new Function(json.otherProps); let func = new Function(json.otherProps);
let otherPropsX = func(); let otherPropsX = func();
setOtherProps(otherPropsX); setOtherProps(otherPropsX);
// console.log(otherPropsX); console.log(otherPropsX);
} catch (e) { } catch (e) {
console.log('签章组件 其余配置项出错,没有返回一个正确的值'); console.log('签章组件 其余配置项出错,没有返回一个正确的值');
return false; return false;
...@@ -74,7 +100,7 @@ export default function PictureSignature({ ...@@ -74,7 +100,7 @@ export default function PictureSignature({
} }
}, [json.otherProps]); }, [json.otherProps]);
const {ModalProps, signConfig, footerButtons, originButtons, backgroundImageWidth} = otherProps; const {ModalProps, signConfig, footerButtons, originButtons, backgroundImageWidth, saveSignConfigValue = ''} = otherProps;
const handleClickButton = (clickType) => { const handleClickButton = (clickType) => {
switch (clickType) { switch (clickType) {
...@@ -83,6 +109,7 @@ export default function PictureSignature({ ...@@ -83,6 +109,7 @@ export default function PictureSignature({
setOpenEdit(true); setOpenEdit(true);
break; break;
case 'confirm': // 确定 case 'confirm': // 确定
onChangeFile({...fileInfo}, imageIndex); onChangeFile({...fileInfo}, imageIndex);
changeShowModal(); changeShowModal();
break; break;
...@@ -91,30 +118,16 @@ export default function PictureSignature({ ...@@ -91,30 +118,16 @@ export default function PictureSignature({
// let ratioY = 1200 / backgroundImageWidth * imageInfo.height; // let ratioY = 1200 / backgroundImageWidth * imageInfo.height;
// console.log(ratioX); // console.log(ratioX);
// return ; // return ;
let signConfig = deepCopy(otherProps.signConfig); let content = getContent(otherProps.signConfig, ratioX);
apiRequest('/ImageLibApi/merge', { apiRequest('/ImageLibApi/merge', {
background: fileInfo?.path, background: fileInfo?.path,
content: JSON.stringify({ content,
objs: signConfig.map((g) => {
// 1200 的 x => 1500的 x
//
g.x = Math.ceil(g.x * ratioX, 10);
g.y = Math.ceil(g.y * ratioX, 10);
if (g.type === 'text') {
g.fontSize = Math.ceil(g.fontSize * ratioX);
g.y = g.y + 20;
// g.x = g.x + 20;
}
if(g.type === 'image'){
g.w = Math.ceil(g.w * ratioX);
g.h = Math.ceil(g.h * ratioX);
}
// console.log(g);
return g;
}),
}),
}).then((res) => { }).then((res) => {
if(form && saveSignConfigValue){
form.setFieldsValue({
[saveSignConfigValue]: content,
})
}
if (res && res.path) { if (res && res.path) {
message.success('操作成功'); message.success('操作成功');
let newPath = res.path; let newPath = res.path;
...@@ -259,7 +272,7 @@ export default function PictureSignature({ ...@@ -259,7 +272,7 @@ export default function PictureSignature({
} }
export function SignArray(props) { export function SignArray(props) {
const {value, onChange, basicUrl, json,} = props; const {value, onChange, basicUrl, json, form} = props;
// console.log(props); // console.log(props);
let files = value?.files || []; let files = value?.files || [];
const onChangeFile = (newFielInfo, imageIndex) => { const onChangeFile = (newFielInfo, imageIndex) => {
...@@ -276,6 +289,7 @@ export function SignArray(props) { ...@@ -276,6 +289,7 @@ export function SignArray(props) {
return <PictureSignature json={json} return <PictureSignature json={json}
basicUrl={basicUrl} basicUrl={basicUrl}
fileInfo={g} fileInfo={g}
form={form}
imageIndex={index} imageIndex={index}
onChangeFile={onChangeFile} onChangeFile={onChangeFile}
......
...@@ -2992,10 +2992,15 @@ export default class tableCom extends Component { ...@@ -2992,10 +2992,15 @@ export default class tableCom extends Component {
cm = getFieldDecorator(dataColumn.base52, { cm = getFieldDecorator(dataColumn.base52, {
initialValue: { files: filesPictureSignature }, initialValue: { files: filesPictureSignature },
rules:
json?.vlds && json?.vlds.length > 0
? json.vlds
: [{ required, message: '请进行签章' }],
})( })(
<SignArray json={json} <SignArray json={json}
disabled={disabled || isPreview} disabled={disabled || isPreview}
basicUrl={queryApiActionPath()} basicUrl={queryApiActionPath()}
form={this.props.form}
/>); />);
if ( if (
get === 'mobile' && get === 'mobile' &&
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论