king
2020-05-09 aaaf56d7ca060f7c681d6b8a67aac46aa89a4dbc
src/templates/sharecomponent/settingcomponent/settingform/customscript/index.jsx
@@ -12,7 +12,8 @@
class CustomForm extends Component {
  static propTpyes = {
    dict: PropTypes.object,         // 字典项
    tableName: PropTypes.string,    // 表名
    setting: PropTypes.object,      // 设置
    searches: PropTypes.array,      // 搜索条件
    systemScripts: PropTypes.array, // 系统脚本
    customScripts: PropTypes.array, // 自定义脚本
    scriptsChange: PropTypes.func   // 表单
@@ -20,7 +21,27 @@
  state = {
    editItem: null,
    loading: false
    loading: false,
    usefulFields: ''
  }
  UNSAFE_componentWillMount() {
    const { searches } = this.props
    let _usefulFields = searches.map(item => {
      if (item.type === 'group') {
        if (item.transfer === 'true') {
          return item.field + ', ' + item.datefield
        } else {
          return item.datefield
        }
      } else {
        return item.field
      }
    })
    this.setState({
      usefulFields: _usefulFields.join(', ')
    })
  }
  edit = (record) => {
@@ -35,6 +56,8 @@
  }
  handleConfirm = () => {
    const { searches, setting } = this.props
    // 表单提交时检查输入值是否正确
    this.props.form.validateFieldsAndScroll((err, values) => {
      if (!err) {
@@ -101,6 +124,34 @@
          LText: _initsql + values.sql + tail
        }
        let allSearch = Utils.initMainSearch(searches)
        allSearch = Utils.getAllSearchOptions(allSearch)
        let regoptions = allSearch.map(item => {
          return {
            reg: new RegExp('@' + item.key + '@', 'ig'),
            value: `'${item.value}'`
          }
        })
        regoptions.push({
          reg: new RegExp('@orderBy@', 'ig'),
          value: setting.order
        })
        if (setting.laypage !== 'false') {
          regoptions.push({
            reg: new RegExp('@pageSize@', 'ig'),
            value: 10
          }, {
            reg: new RegExp('@pageIndex@', 'ig'),
            value: 1
          })
        }
        regoptions.forEach(item => {
          param.LText = param.LText.replace(item.reg, item.value)
        })
        param.LText = Utils.formatOptions(param.LText)
        param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
        param.secretkey = Utils.encrypt(param.LText, param.timestamp)
@@ -149,8 +200,9 @@
  }
  render() {
    const { systemScripts, tableName } = this.props
    const { systemScripts, setting } = this.props
    const { getFieldDecorator } = this.props.form
    const { usefulFields } = this.state
    const formItemLayout = {
      labelCol: {
        xs: { span: 24 },
@@ -165,9 +217,9 @@
    return (
      <Form {...formItemLayout} className="modal-menu-setting-script">
        <Row gutter={24}>
          {tableName ? <Col span={8}>
          {setting.tableName ? <Col span={8}>
            <Form.Item label={'表名'} style={{whiteSpace: 'nowrap', margin: 0}}>
              {tableName}
              {setting.tableName}
            </Form.Item>
          </Col> : null}
          <Col span={16}>
@@ -177,7 +229,7 @@
          </Col>
          <Col span={24} className="sqlfield">
            <Form.Item label={'可用字段'}>
              id, bid, loginuid, sessionuid, userid, appkey
              id, bid, loginuid, sessionuid, userid, appkey{usefulFields ? ', ' + usefulFields : ''}
            </Form.Item>
          </Col>
          <Col span={8} style={{whiteSpace: 'nowrap'}}>