| | |
| | | import PropTypes from 'prop-types' |
| | | import { Form, Tabs, Row, Col, Button, notification, Modal, message, InputNumber, Input, Select, Radio } from 'antd' |
| | | import moment from 'moment' |
| | | import {UnControlled as CodeMirror} from 'react-codemirror2' |
| | | import 'codemirror/mode/javascript/javascript' |
| | | |
| | | import Api from '@/api' |
| | | import Utils from '@/utils/utils.js' |
| | | |
| | | import 'codemirror/lib/codemirror.css' |
| | | // import 'codemirror/theme/solarized.css' |
| | | import 'codemirror/theme/cobalt.css' |
| | | |
| | | import './index.scss' |
| | | |
| | |
| | | verify: {}, |
| | | templates: [], |
| | | selectimg: '', |
| | | printMode: 'normal' |
| | | } |
| | | |
| | | UNSAFE_componentWillMount() { |
| | |
| | | ..._verify, |
| | | Template: _verify.Template || '' |
| | | }, |
| | | linkType: _verify.linkType || 'system' |
| | | linkType: _verify.linkType || 'system', |
| | | printMode: _verify.printMode || 'normal', |
| | | printFunc: _verify.printFunc || '// Function(data, notification) // data-打印数据列表,notification-信息提示控件', |
| | | }) |
| | | } |
| | | |
| | |
| | | }) |
| | | } |
| | | |
| | | changePrintMode = (e) => { |
| | | let value = e.target.value |
| | | |
| | | this.setState({ |
| | | printMode: value |
| | | }) |
| | | } |
| | | |
| | | changeLinkType = (e) => { |
| | | let value = e.target.value |
| | | |
| | |
| | | render() { |
| | | const { getFieldDecorator } = this.props.form |
| | | |
| | | const { verify, linkType } = this.state |
| | | const { verify, linkType, printMode, printFunc } = this.state |
| | | const formItemLayout = { |
| | | labelCol: { |
| | | xs: { span: 24 }, |
| | |
| | | <Form {...formItemLayout}> |
| | | <Row gutter={24}> |
| | | <Col span={8}> |
| | | <Form.Item label={'打印模式'}> |
| | | {getFieldDecorator('printMode', { |
| | | initialValue: printMode || 'normal' |
| | | })( |
| | | <Radio.Group onChange={this.changePrintMode}> |
| | | <Radio value="normal">标准</Radio> |
| | | <Radio value="custom">自定义</Radio> |
| | | </Radio.Group> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | {printMode === 'custom' ? <Col span={24}> |
| | | <Form.Item label={'处理函数'} className="printFunc"> |
| | | {getFieldDecorator('printFunc', { |
| | | initialValue: printFunc || '', |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: this.props.dict['form.required.input'] + '处理函数!' |
| | | } |
| | | ] |
| | | })( |
| | | <CodeMirror |
| | | className="code-mirror-area" |
| | | options={{ |
| | | mode: 'text/javascript', |
| | | theme: 'cobalt', |
| | | lineNumbers: true, |
| | | lineWrapping: true |
| | | }} |
| | | onBeforeChange={() => {}} |
| | | /> |
| | | )} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {printMode === 'normal' ? <Col span={8}> |
| | | <Form.Item label={'链接类型'}> |
| | | {getFieldDecorator('linkType', { |
| | | initialValue: linkType || 'system' |
| | |
| | | </Radio.Group> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={8}> |
| | | </Col> : null} |
| | | {printMode === 'normal' ? <Col span={8}> |
| | | <Form.Item label={'链接地址'}> |
| | | {getFieldDecorator('linkUrl', { |
| | | initialValue: verify.linkUrl || '127.0.0.1:13529', |
| | |
| | | ] |
| | | })(<Input placeholder="" autoComplete="off" disabled={linkType === 'system'} />)} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={8}> |
| | | </Col> : null } |
| | | {printMode === 'normal' ? <Col span={8}> |
| | | <Form.Item label={'打印模板'}> |
| | | {getFieldDecorator('Template', { |
| | | initialValue: verify.Template || '', |
| | |
| | | </Select> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={9}> |
| | | <img style={{width: '90%', marginBottom: '25px'}} src={this.state.selectimg} alt=""/> |
| | | </Col> |
| | | </Col> : null } |
| | | {printMode === 'normal' ? <Col span={8} offset={8}> |
| | | <img className="legend" src={this.state.selectimg} alt=""/> |
| | | </Col> : null } |
| | | </Row> |
| | | </Form> |
| | | </TabPane> |