From 4a18149d7ca9a0ea3ad569297f34e928c59e2025 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期六, 21 三月 2020 20:30:08 +0800
Subject: [PATCH] 2020-03-21

---
 src/templates/zshare/verifycardprint/index.jsx |   73 +++++++++++++++++++++++++++++++-----
 1 files changed, 63 insertions(+), 10 deletions(-)

diff --git a/src/templates/zshare/verifycardprint/index.jsx b/src/templates/zshare/verifycardprint/index.jsx
index 6379135..5847ad1 100644
--- a/src/templates/zshare/verifycardprint/index.jsx
+++ b/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-鎵撳嵃鏁版嵁鍒楄〃锛宯otification-淇℃伅鎻愮ず鎺т欢',
     })
   }
 
@@ -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>

--
Gitblit v1.8.0