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

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

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