| | |
| | | return !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | updateStyle = (style) => { |
| | | const { card } = this.state |
| | | |
| | | this.props.updateStyle({componentId: card.componentId, classId: card.classId, uuid: card.uuid, style}) |
| | | } |
| | | |
| | | /** |
| | | * @description 字体大小切换,超出范围忽略 |
| | | */ |
| | | changeFontSize = (val) => { |
| | | const { card } = this.state |
| | | let value = parseInt(val) |
| | | |
| | | if (isNaN(value) || value < 12 || value > 100) return |
| | | |
| | | this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {fontSize: `${value}px`}}) |
| | | this.updateStyle({fontSize: `${value}px`}) |
| | | } |
| | | |
| | | /** |
| | | * @description 修改行间距,超出范围忽略 |
| | | */ |
| | | changeLineHeight = (val) => { |
| | | const { card } = this.state |
| | | let value = parseFloat(val) |
| | | |
| | | if (isNaN(value) || value < 1 || value > 10) return |
| | | |
| | | this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {lineHeight: value}}) |
| | | this.updateStyle({lineHeight: value}) |
| | | } |
| | | |
| | | /** |
| | | * @description 字体间距修改,超出范围忽略 |
| | | */ |
| | | changeLetterSpacing = (val) => { |
| | | const { card } = this.state |
| | | let value = parseFloat(val) |
| | | |
| | | if (isNaN(value) || value < 0 || value > 100) return |
| | | |
| | | this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {letterSpacing: `${value}px`}}) |
| | | this.updateStyle({letterSpacing: `${value}px`}) |
| | | } |
| | | |
| | | /** |
| | | * @description 修改字体粗细 |
| | | */ |
| | | boldChange = (val) => { |
| | | const { card } = this.state |
| | | |
| | | this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {fontWeight: val}}) |
| | | this.updateStyle({fontWeight: val}) |
| | | } |
| | | |
| | | /** |
| | | * @description 修改字体颜色 ,颜色控件 |
| | | */ |
| | | changeFontColor = (val) => { |
| | | const { card } = this.state |
| | | |
| | | this.setState({ |
| | | fontColor: val |
| | | }) |
| | | this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {color: val}}) |
| | | this.updateStyle({color: val}) |
| | | } |
| | | |
| | | /** |
| | |
| | | * @description 字体对齐 |
| | | */ |
| | | changeTextAlign = (e) => { |
| | | const { card } = this.state |
| | | |
| | | this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {textAlign: e.target.value}}) |
| | | this.updateStyle({textAlign: e.target.value}) |
| | | } |
| | | |
| | | /** |
| | | * @description 字体样式,倾斜 |
| | | */ |
| | | changeFontStyle = (e) => { |
| | | const { card } = this.state |
| | | |
| | | this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {fontStyle: e.target.value}}) |
| | | this.updateStyle({fontStyle: e.target.value}) |
| | | } |
| | | |
| | | /** |
| | | * @description 字体装饰,下划线、贯穿线、上划线 |
| | | */ |
| | | changeTextDecoration = (e) => { |
| | | const { card } = this.state |
| | | |
| | | this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {textDecoration: e.target.value}}) |
| | | this.updateStyle({textDecoration: e.target.value}) |
| | | } |
| | | |
| | | /** |
| | | * @description 修改背景颜色 ,颜色控件 |
| | | */ |
| | | changeBackgroundColor = (val) => { |
| | | const { card } = this.state |
| | | |
| | | this.setState({ |
| | | backgroundColor: val |
| | | }) |
| | | this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {backgroundColor: val}}) |
| | | this.updateStyle({backgroundColor: val}) |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | imgChange = (list) => { |
| | | const { card } = this.state |
| | | |
| | | if (list[0] && list[0].response) { |
| | | this.setState({ |
| | | bgimages: [], |
| | | backgroundImage: list[0].response |
| | | }) |
| | | this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {backgroundImage: `url(${list[0].response})`}}) |
| | | this.updateStyle({backgroundImage: `url(${list[0].response})`}) |
| | | } else { |
| | | this.setState({bgimages: list}) |
| | | } |
| | |
| | | } |
| | | |
| | | submitBackgroundImage = (e) => { |
| | | const { card } = this.state |
| | | let val = e.target.value |
| | | val = val.replace(/^\s*|\s*$/ig, '') |
| | | |
| | |
| | | val = `linear-gradient(${val})` |
| | | } |
| | | |
| | | this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {backgroundImage: val}}) |
| | | this.updateStyle({backgroundImage: val}) |
| | | } |
| | | |
| | | submitBorder = (val, type) => { |
| | | const { card } = this.state |
| | | |
| | | this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {[type]: val}}) |
| | | this.updateStyle({[type]: val}) |
| | | } |
| | | |
| | | changeBorderRadius = (val) => { |
| | | const { card } = this.state |
| | | let value = parseFloat(val) |
| | | |
| | | if (isNaN(value) || value < 0 || value > 500) return |
| | | |
| | | this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {borderRadius: `${value}px`}}) |
| | | this.updateStyle({borderRadius: `${value}px`}) |
| | | } |
| | | |
| | | changeMarginTop = (e) => { |
| | |
| | | } |
| | | |
| | | submitMarginTop = (val) => { |
| | | const { card } = this.state |
| | | |
| | | this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {marginTop: val}}) |
| | | this.setState({ |
| | | marginTop: val |
| | | }) |
| | | this.updateStyle({marginTop: val}) |
| | | } |
| | | |
| | | changeMarginBottom = (e) => { |
| | |
| | | } |
| | | |
| | | submitMarginBottom = (val) => { |
| | | const { card } = this.state |
| | | |
| | | this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {marginBottom: val}}) |
| | | this.setState({ |
| | | marginBottom: val |
| | | }) |
| | | this.updateStyle({marginBottom: val}) |
| | | } |
| | | |
| | | render () { |
| | | const { card, fontColor, backgroundColor, backgroundImage, bgimages, marginTop, marginTopVal, marginBottom, marginBottomVal } = this.state |
| | | const { card, backgroundImage, bgimages, marginTop, marginTopVal, marginBottom, marginBottomVal } = this.state |
| | | const formItemLayout = { |
| | | labelCol: { |
| | | xs: { span: 24 }, |
| | |
| | | label={<Icon title="字体颜色" type="font-colors" />} |
| | | labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } |
| | | > |
| | | <ColorSketch color={card.color || '#000000'} changeColor={this.changeFontColor} /> |
| | | <Input value={fontColor} onChange={this.changeFontColorInput} /> |
| | | <ColorSketch value={card.color || '#000000'} onChange={this.changeFontColor} /> |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={24}> |
| | |
| | | label={<Icon title="背景颜色" type="bg-colors" />} |
| | | labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } |
| | | > |
| | | <ColorSketch color={card.backgroundColor || '#ffffff'} changeColor={this.changeBackgroundColor} /> |
| | | <Input value={backgroundColor} onChange={this.changeBackgroundColorInput} /> |
| | | <ColorSketch value={card.backgroundColor || '#ffffff'} onChange={this.changeBackgroundColor} /> |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={24}> |
| | |
| | | label={<Icon title="背景图片" type="picture" />} |
| | | labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } |
| | | > |
| | | <FileUpload value={bgimages} maxFile={2} fileType="text" onChange={this.imgChange}/> |
| | | <FileUpload accept=".jpg,.png,.gif,.svg" value={bgimages} maxFile={2} fileType="text" onChange={this.imgChange}/> |
| | | <Input placeholder="" value={backgroundImage} autoComplete="off" onBlur={this.submitBackgroundImage} onPressEnter={this.submitBackgroundImage} onChange={this.changeBackgroundImageInput} /> |
| | | </Form.Item> |
| | | </Col> |