king
2020-11-10 5df578ff69f6b02e821d59a8883bc75d78695a62
src/templates/sharecomponent/actioncomponent/verifyprint/index.jsx
@@ -2,21 +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 from '@/templates/zshare/codemirror'
import EditTable from './editable'
import 'codemirror/lib/codemirror.css'
// import 'codemirror/theme/solarized.css'
import 'codemirror/theme/cobalt.css'
import './index.scss'
const { TabPane } = Tabs
let _printFunc = null // antd 无法获取 codemirror 内容,手动控制
class VerifyCard extends Component {
  static propTpyes = {
@@ -49,16 +43,14 @@
      printMode: _verify.printMode,
      printFunc: _verify.printFunc || '// Function(data, form, printer, notification) data-打印数据列表,form-表单信息(不存在时为{}),printer-打印设置,notification-信息提示控件'
    })
    _printFunc = _verify.printFunc || ''
  }
  componentDidMount() {
    let _sql = `select PrintTempNO,Images,PrintTempNO+PrintTempName as PN from sPrintTemplate 
    where appkey= @appkey@ and Deleted=0
    where appkey= @appkey@ and Deleted=0  and typechartwo=''
    union select ID,Images,a.PrintTempNO+PrintTempName as PN 
    from (select * from sPrintTemplate where appkey= '' and Deleted=0 ) a
    left join (select PrintTempNO from sPrintTemplate where appkey= @appkey@ and Deleted=0 ) b
    from (select * from sPrintTemplate where appkey= '' and Deleted=0  and typechartwo='') a
    left join (select PrintTempNO from sPrintTemplate where appkey= @appkey@  and Deleted=0 ) b
    on a.PrintTempNO=b.PrintTempNO 
    left join (select Srcid from sPrintTemplate_Log where appkey='' and apicode= @appkey@ and Deleted=0 ) c 
    on a.ID=c.Srcid where b.PrintTempNO is null and c.Srcid is null`
@@ -70,10 +62,10 @@
      arr_field: 'PN,PrintTempNO,Images'
    }
    param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
    param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
    param.secretkey = Utils.encrypt(param.LText, param.timestamp)
    param.open_key = Utils.encrypt(param.secretkey, param.timestamp, true) // 云端数据验证
    param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) // 云端数据验证
    Api.getSystemConfig(param).then(res => {
      if (res.status) {
@@ -170,7 +162,7 @@
    return new Promise((resolve, reject) => {
      this.props.form.validateFieldsAndScroll((err, values) => {
        if (!err) {
          let _verify = {...verify, ...values, printFunc: _printFunc}
          let _verify = {...verify, ...values}
          if (this.refs.editTable && this.refs.editTable.state) {
            let printTypes = this.refs.editTable.state.dataSource
@@ -309,19 +301,7 @@
                        }
                      ]
                    })(
                      <CodeMirror
                        className="code-mirror-area"
                        options={{
                          mode: 'text/javascript',
                          theme: 'cobalt',
                          lineNumbers: true,
                          lineWrapping: true
                        }}
                        onBeforeChange={() => {}}
                        onBlur={(editor) => {
                          _printFunc = editor.getValue()
                        }}
                      />
                      <CodeMirror mode="text/javascript"/>
                    )} 
                  </Form.Item>
                </Col> : null}
@@ -336,7 +316,7 @@
                        }
                      ]
                    })(
                      <Select onChange={this.changeTemplate}>
                      <Select dropdownClassName="print-template-setting" onChange={this.changeTemplate}>
                        {this.state.templates.map((option, key) =>
                          <Select.Option id={key} key={key} value={option.value}>
                            {option.text}
@@ -352,7 +332,12 @@
              </Row>
            </Form>
          </TabPane>
          <TabPane tab="打印类型" key="2">
          <TabPane tab={
            <span>
              打印类型
              {verify.printerTypeList.length ? <span className="count-tip">{verify.printerTypeList.length}</span> : null}
            </span>
          } key="2">
            <Form {...formItemLayout}>
              <Row gutter={24}>
                <Col span={24} className="print-tip">