king
2023-08-27 da64ab0923bf8817fc8599a6e37b953ce38f64c8
src/templates/sharecomponent/actioncomponent/verifyexcelout/customscript/index.jsx
@@ -1,7 +1,8 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { Form, Row, Col, Button, notification, Tooltip, Select } from 'antd'
import { Form, Row, Col, Button, notification, Tooltip, Select, Switch, Radio } from 'antd'
import { QuestionCircleOutlined } from '@ant-design/icons'
import moment from 'moment'
import Api from '@/api'
@@ -21,6 +22,7 @@
    systemScripts: [],
    usefulfields: null,
    loading: false,
    skip: false
  }
  UNSAFE_componentWillMount () {
@@ -60,7 +62,7 @@
    _sParam.secretkey = Utils.encrypt(_sParam.LText, _sParam.timestamp)
    _sParam.open_key = Utils.encryptOpenKey(_sParam.secretkey, _sParam.timestamp) // 云端数据验证
    
    Api.getSystemConfig(_sParam).then(res => {
    Api.getCloudConfig(_sParam).then(res => {
      if (res.status) {
        let _scripts = res.data.map(item => {
          return {
@@ -114,11 +116,13 @@
    })
    this.props.form.setFieldsValue({
      sql: record.sql
      sql: record.sql,
      position: record.position || 'front'
    })
  }
  handleConfirm = () => {
    const { skip } = this.state
    // 表单提交时检查输入值是否正确
    this.props.form.validateFieldsAndScroll((err, values) => {
      if (!err) {
@@ -189,6 +193,7 @@
        this.props.scriptsChange(values, (status) => {
          if (status) {
            this.setState({
              skip: false,
              loading: false,
              editItem: null
            })
@@ -200,7 +205,7 @@
              loading: false
            })
          }
        })
        }, skip)
      }
    })
  }
@@ -211,25 +216,13 @@
    })
    
    this.props.form.setFieldsValue({
      sql: ' '
      sql: ' ',
      position: 'front'
    })
  }
  selectScript = (value, option) => {
    const { usefulfields, sheet } = this.props
    let _value = ''
    if (value === 'default') {
      let fields = usefulfields.filter(item => item.import !== 'false')
      fields = fields.map(col => col.Column).join(',')
      let _sheet = sheet.replace(/(.*)\.(.*)\.|@db@/ig, '')
      _value = `Select ${fields} From ${_sheet}`
    } else {
      _value = value
    }
    let _value = value
    let _sql = this.props.form.getFieldValue('sql')
    if (/^\s+$/.test(_sql)) {
      _sql = ''
@@ -253,7 +246,7 @@
  render() {
    const { sheet, linefields } = this.props
    const { usefulfields, systemScripts } = this.state
    const { usefulfields, systemScripts, skip } = this.state
    const { getFieldDecorator } = this.props.form
    const formItemLayout = {
      labelCol: {
@@ -276,7 +269,7 @@
          </Col>
          <Col span={10}>
            <Form.Item label="报错字段" style={{margin: 0, whiteSpace: 'nowrap'}}>
              ErrorCode(增加后缀NT表示数据不回滚,如ENT、NNT、FNT、NMNT), retmsg
              ErrorCode(增加后缀NT表示数据不回滚,如ENT、NNT、FNT、NMNT、CNT、-2NT), retmsg
            </Form.Item>
          </Col>
          <Col span={24} className="sqlfield">
@@ -287,6 +280,23 @@
              {linefields ? <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'表单及行变量,系统会定义变量并赋值。'}>,&nbsp;{linefields}</Tooltip> : null}
            </Form.Item>
          </Col>
          <Col span={8} style={{whiteSpace: 'nowrap'}}>
            <Form.Item style={{marginBottom: 0}} label={
              <Tooltip placement="bottomLeft" title={'自定义脚本与数据源位置关系。'}>
                <QuestionCircleOutlined className="mk-form-tip" />
                执行位置
              </Tooltip>
            }>
              {getFieldDecorator('position', {
                initialValue: 'front'
              })(
                <Radio.Group>
                  <Radio value="front">前置</Radio>
                  <Radio value="back">后置</Radio>
                </Radio.Group>
              )}
            </Form.Item>
          </Col>
          <Col span={8}>
            <Form.Item style={{marginBottom: 0}} label="快捷添加">
              <Select
@@ -295,9 +305,6 @@
                onSelect={this.selectScript}
                getPopupContainer={() => document.getElementById('verify-excelin-custom-scripts')}
              >
                <Select.Option key="default" value={'default'}>
                  默认sql
                </Select.Option>
                <Select.Option key="debugger" value={`z_debug: select @ErrorCode='E',@retmsg='测试断点' goto aaa`}>
                  测试断点
                </Select.Option>
@@ -309,7 +316,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>
@@ -317,6 +324,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', {