king
2020-03-21 4a18149d7ca9a0ea3ad569297f34e928c59e2025
src/templates/zshare/verifycardprint/index.jsx
@@ -2,9 +2,15 @@
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'
@@ -24,6 +30,7 @@
    verify: {},
    templates: [],
    selectimg: '',
    printMode: 'normal'
  }
  UNSAFE_componentWillMount() {
@@ -34,7 +41,9 @@
        ..._verify,
        Template: _verify.Template || ''
      },
      linkType: _verify.linkType || 'system'
      linkType: _verify.linkType || 'system',
      printMode: _verify.printMode || 'normal',
      printFunc: _verify.printFunc || '// Function(data, notification) // data-打印数据列表,notification-信息提示控件',
    })
  }
@@ -167,6 +176,14 @@
    })
  }
  changePrintMode = (e) => {
    let value = e.target.value
    this.setState({
      printMode: value
    })
  }
  changeLinkType = (e) => {
    let value = e.target.value
@@ -184,7 +201,7 @@
  render() {
    const { getFieldDecorator } = this.props.form
    const { verify, linkType } = this.state
    const { verify, linkType, printMode, printFunc } = this.state
    const formItemLayout = {
      labelCol: {
        xs: { span: 24 },
@@ -203,6 +220,42 @@
            <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'
@@ -213,8 +266,8 @@
                      </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',
@@ -226,8 +279,8 @@
                      ]
                    })(<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 || '',
@@ -247,10 +300,10 @@
                      </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>