From 6afdec0062dacbded57e166230eb22cc55ced0c1 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期六, 08 五月 2021 14:30:21 +0800 Subject: [PATCH] 2021-05-08 --- src/views/menudesign/printmenuform/index.jsx | 100 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 99 insertions(+), 1 deletions(-) diff --git a/src/views/menudesign/printmenuform/index.jsx b/src/views/menudesign/printmenuform/index.jsx index a6de29a..b9204e6 100644 --- a/src/views/menudesign/printmenuform/index.jsx +++ b/src/views/menudesign/printmenuform/index.jsx @@ -1,6 +1,6 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { Form, Row, Col, InputNumber, Select, Radio } from 'antd' +import { Form, Row, Col, InputNumber, Select, Radio, Tooltip, Icon } from 'antd' import './index.scss' @@ -25,6 +25,20 @@ this.props.updateConfig({...this.props.config, everyPCount: val}) } + changePrintWidth = (val) => { + if (typeof(val) !== 'number') { + val = '' + } + this.props.updateConfig({...this.props.config, printWidth: val}) + } + + changePrintHeight = (val) => { + if (typeof(val) !== 'number') { + val = '' + } + this.props.updateConfig({...this.props.config, printHeight: val}) + } + changeLastCount = (val) => { if (typeof(val) !== 'number') { val = '' @@ -34,14 +48,67 @@ pageSizeChange = (val) => { this.props.updateConfig({...this.props.config, pageSize: val}) + this.resetPage() } onLayoutChange = (val) => { this.props.updateConfig({...this.props.config, pageLayout: val}) + this.resetPage() } onPaddingChange = (val) => { this.props.updateConfig({...this.props.config, pagePadding: val}) + this.resetPage() + } + + onPrintCustomChange = (val) => { + this.props.updateConfig({...this.props.config, printCustom: val}) + this.resetPage() + } + + resetPage = () => { + this.setState({}, () => { + const { config } = this.props + + if (config.printCustom !== 'true') return + + let pageSize = config.pageSize || 'A4' + let pageLayout = config.pageLayout !== 'horizontal' ? 'vertical' : 'horizontal' + let pagePadding = config.pagePadding !== 'without' ? 'default' : 'without' + + let pageParam = { + A4: { + vertical: 980, + horizontal: 1200, + verticaldefault: 1.455, + verticalwithout: 1.411, + horizontaldefault: 0.679, + horizontalwithout: 0.701, + }, + A3: { + vertical: 1200, + horizontal: 1600, + verticaldefault: 1.441, + verticalwithout: 1.410, + horizontaldefault: 0.688, + horizontalwithout: 0.703, + }, + A5: { + vertical: 700, + horizontal: 1000, + verticaldefault: 1.478, + verticalwithout: 1.413, + horizontaldefault: 0.669, + horizontalwithout: 0.700, + } + } + + let width = pageParam[pageSize][pageLayout] + let height = Math.floor(width * pageParam[pageSize][pageLayout + pagePadding]) + + this.props.updateConfig({...config, printHeight: height, printWidth: width}) + this.props.form.setFieldsValue({printHeight: height, printWidth: width}) + }) } render() { @@ -149,6 +216,37 @@ })(<InputNumber min={1} max={1000} precision={0} onChange={this.changeLastCount}/>)} </Form.Item> </Col> + <Col span={24}> + <Form.Item label={ + <Tooltip placement="topLeft" title="閽堝涓嶈鍒欑焊寮狅紝鍙嚜瀹氫箟璁剧疆鎵撳嵃楂樺害鍜屽搴︼紝娉細鍚屾椂璁剧疆鎵撳嵃瀹藉害鍜岄珮搴﹀悗鏂瑰彲鐢熸晥銆�"> + <Icon type="question-circle" /> + 鑷畾涔� + </Tooltip> + }> + {getFieldDecorator('printCustom', { + initialValue: config.printCustom || 'false' + })( + <Radio.Group onChange={(e) => {this.onPrintCustomChange(e.target.value)}}> + <Radio value="false">涓嶅惎鐢�</Radio> + <Radio value="true">鍚敤</Radio> + </Radio.Group> + )} + </Form.Item> + </Col> + {config.printCustom === 'true' ? <Col span={24}> + <Form.Item label="鎵撳嵃瀹藉害"> + {getFieldDecorator('printWidth', { + initialValue: config.printWidth || '' + })(<InputNumber min={10} max={9999} precision={0} onChange={this.changePrintWidth}/>)} + </Form.Item> + </Col> : null} + {config.printCustom === 'true' ? <Col span={24}> + <Form.Item label="鎵撳嵃楂樺害"> + {getFieldDecorator('printHeight', { + initialValue: config.printHeight || '' + })(<InputNumber min={10} max={9999} precision={0} onChange={this.changePrintHeight}/>)} + </Form.Item> + </Col> : null} </Row> </Form> ) -- Gitblit v1.8.0