king
2023-08-02 574ea3b532b625456c09f14fc11073aad6b61db7
src/templates/zshare/verifycard/callbackcustomscript/index.jsx
@@ -1,6 +1,6 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { Form, Row, Col, Button, notification, Modal, Tooltip, Radio, Select } from 'antd'
import { Form, Row, Col, Button, notification, Modal, Tooltip, Radio, Select, Switch } from 'antd'
import { QuestionCircleOutlined } from '@ant-design/icons'
import moment from 'moment'
@@ -21,7 +21,8 @@
  state = {
    editItem: null,
    loading: false
    loading: false,
    skip: false
  }
  edit = (record) => {
@@ -36,7 +37,7 @@
  }
  handleConfirm = () => {
    const { editItem } = this.state
    const { editItem, skip } = this.state
    // 表单提交时检查输入值是否正确
    this.props.form.validateFieldsAndScroll((err, values) => {
      if (!err) {
@@ -161,26 +162,38 @@
        param.LText = Utils.formatOptions(param.LText)
        param.secretkey = Utils.encrypt('', param.timestamp)
        
        this.setState({loading: true})
        Api.genericInterface(param).then(res => {
          if (res.status) {
            this.setState({
              loading: false,
              editItem: null
            }, () => {
              this.props.scriptsChange(values)
            })
            this.props.form.setFieldsValue({
              sql: ' '
            })
          } else {
            this.setState({loading: false})
            Modal.error({
              title: res.message
            })
          }
        })
        if (skip) {
          this.setState({
            skip: false,
            editItem: null
          }, () => {
            this.props.scriptsChange(values)
          })
          this.props.form.setFieldsValue({
            sql: ' '
          })
        } else {
          this.setState({loading: true})
          Api.genericInterface(param).then(res => {
            if (res.status) {
              this.setState({
                loading: false,
                editItem: null
              }, () => {
                this.props.scriptsChange(values)
              })
              this.props.form.setFieldsValue({
                sql: ' '
              })
            } else {
              this.setState({loading: false})
              Modal.error({
                title: res.message
              })
            }
          })
        }
      }
    })
  }
@@ -198,6 +211,9 @@
  selectScript = (value, option) => {
    if (!value || !option) return
    let _sql = this.props.form.getFieldValue('sql')
    if (/^\s+$/.test(_sql)) {
      _sql = ''
    }
    if (_sql) {
      _sql = _sql + ` 
@@ -218,6 +234,7 @@
  render() {
    const { usefulfields, systemScripts, btn } = this.props
    const { getFieldDecorator } = this.props.form
    const { skip } = this.state
    const formItemLayout = {
      labelCol: {
        xs: { span: 24 },
@@ -269,7 +286,7 @@
              )}
            </Form.Item>
          </Col>
          <Col span={10}>
          <Col span={8}>
            <Form.Item label={'快捷添加'} style={{marginBottom: 0}}>
              <Select
                allowClear
@@ -285,7 +302,7 @@
              </Select>
            </Form.Item>
          </Col>
          <Col span={6} className="add">
          <Col span={5} className="add" style={{whiteSpace: 'nowrap'}}>
            <Button onClick={this.handleConfirm} loading={this.state.loading} className="mk-green" style={{marginBottom: 15, marginLeft: 40}}>
              保存
            </Button>
@@ -293,6 +310,10 @@
              取消
            </Button>
          </Col>
          <Col span={3} style={{paddingTop: '15px', fontSize: '12px', whiteSpace: 'nowrap'}}>
            强制保存:
            <Switch checked={skip} size="small" onChange={() => this.setState({skip: !skip})}/>
          </Col>
          <Col span={24} className="sql">
            <Form.Item label="sql">
              {getFieldDecorator('sql', {