/* * Author: 黎永顺 * name: 水印设置-弹框 * Description: * Date: 2023/6/13 */ import React, { Component } from "react"; import { WeaError, WeaFormItem, WeaInputNumber, WeaLocaleProvider, WeaSearchGroup, WeaSelect, WeaSlideModal } from "ecCom"; import { Button } from "antd"; import ImageUploadList from "../../../components/upload"; import WmContentSetModal from "./wmContentSetModal"; import "./index.less"; const getLabel = WeaLocaleProvider.getLabel; class WaterMarkSetModal extends Component { constructor(props) { super(props); this.state = { wmClassify: "text", wmNoTransparent: 0, wmRotate: 0, wmImg: null, wmcontSet: { visible: false, textSet: {} } }; } componentWillReceiveProps(nextProps, nextContext) { if (nextProps.visible !== this.props.visible && nextProps.visible) { const { watermarkSetting } = nextProps; const { wmClassify = "text", wmNoTransparent = 0, wmRotate = 0, wmImg, wmOriginText, wmHeight, wmWidth, pureWmText, wmSelectedFieldIds, wmText } = watermarkSetting; if (wmClassify === "text") { this.setState({ wmClassify, wmNoTransparent, wmRotate, wmcontSet: { ...this.state.wmcontSet, textSet: wmOriginText ? { wmOriginText, wmHeight, wmWidth, pureWmText, wmSelectedFieldIds, wmText } : {} } }); } else { this.setState({ wmClassify, wmNoTransparent, wmRotate, wmImg }); } } } handleCustomSave = () => { const { wmClassify, wmImg, wmRotate, wmNoTransparent, wmcontSet } = this.state; if ((wmClassify === "text" && _.isEmpty(wmcontSet.textSet)) || (wmClassify !== "text" && !wmImg)) { this.refs.watermarkContError.showError(); return; } if (wmClassify === "text") { this.props.onChange({ wmSetting: { wmClassify, ...wmcontSet.textSet, wmNoTransparent, wmRotate } }); } else { this.props.onChange({ wmSetting: { wmClassify, wmImg, wmNoTransparent, wmRotate } }); } this.props.onClose(); }; render() { const { wmClassify, wmNoTransparent, wmRotate, wmImg, wmcontSet } = this.state; return ( {getLabel(111, "水印设置")}} direction="right" top={0} width={800} height={100} measureT="%" measureX="px" measureY="%" content={ this.setState({ wmClassify })} /> { wmClassify === "text" ?
this.setState({ wmcontSet: { ...wmcontSet, visible: true } })}/> { _.isEmpty(wmcontSet.textSet) ? : { window.open(`${window.location.origin}/spa/hrmSalary/static/index.html#/main/hrmSalary/payroll/watermark/preview`, "_blank"); }}/> 预览 }
:
this.setState({ wmImg }, () => { window.localStorage.setItem("wmSetting", JSON.stringify({ wmSetting: { wmClassify, wmRotate, wmNoTransparent, ...this.state.wmImg } })); })} wmImg={wmImg}/> { !wmImg ? : { window.open(`${window.location.origin}/spa/hrmSalary/static/index.html#/main/hrmSalary/payroll/watermark/preview`, "_blank"); }}>预览 }
}
this.setState({ wmNoTransparent })} /> this.setState({ wmRotate })} />
{/* 水印内容设置弹框*/} this.setState({ wmcontSet: { ...wmcontSet, visible: false, textSet } }, () => { window.localStorage.setItem("wmSetting", JSON.stringify({ wmSetting: { wmClassify, wmRotate, wmNoTransparent, ...this.state.wmcontSet.textSet } })); })} />
} /> ); } } export default WaterMarkSetModal;