king
2020-05-29 5ba94ec7b5ad34098ff9c5d21b4139b1b91c2865
src/tabviews/zshare/mutilform/index.jsx
@@ -27,6 +27,8 @@
    readin: null,
    fieldlen: null,
    formlist: [],
    encrypts: [],    // 加密字段
    intercepts: [],  // 截取字段
    record: {}
  }
@@ -53,6 +55,8 @@
    let readin = {}
    let fieldlen = {}
    let formlist = []
    let encrypts = []
    let intercepts = []
    if (action.groups.length > 0) {
      action.groups.forEach(group => {
@@ -75,6 +79,15 @@
    let _inputfields = formlist.filter(item => item.type === 'text' || item.type === 'number') // 用于过滤下拉菜单关联表单
    formlist = formlist.map(item => {
      if (item.type === 'title') return item
      if (item.type === 'textarea' && item.encryption === 'true') {
        encrypts.push(item.field)
      }
      if (item.interception === 'true') {
        intercepts.push(item.field)
      }
      let _readin = item.readin !== 'false'
      if (item.type === 'linkMain' || item.type === 'funcvar') {
        _readin = false
@@ -115,10 +128,23 @@
        }
      }
      let newval = '$$initval$$'
      if (item.type === 'linkMain' && BData && BData.hasOwnProperty(item.field)) {
        item.initval = BData[item.field]
        newval = BData[item.field]
      } else if (item.type !== 'linkMain' && _readin && !/^date/.test(item.type) && this.props.data && this.props.data.hasOwnProperty(item.field)) {
        item.initval = this.props.data[item.field]
        newval = this.props.data[item.field]
      }
      if (encrypts.includes(item.field) && newval !== '$$initval$$') {
        try {
          newval = window.decodeURIComponent(window.atob(newval))
        } catch (e) {
          console.warn(e)
        }
      }
      if (newval !== '$$initval$$') {
        item.initval = newval
      }
      if (item.supvalue) {
@@ -163,6 +189,8 @@
      datatype: datatype,
      readin: readin,
      fieldlen: fieldlen,
      encrypts: encrypts,
      intercepts: intercepts,
      formlist: formlist
    }, () => {
      if (action.setting && action.setting.focus) {
@@ -290,7 +318,6 @@
    formlist.forEach((item, index) => {
      // if ((!item.field && item.type !== 'title') || item.hidden === 'true') return
      // if (item.supField && !item.supvalue.includes(this.props.form.getFieldValue(item.supField))) return
      if (item.type === 'title') {
@@ -558,15 +585,7 @@
          </Col>
        )
      } else if (item.type === 'funcvar') {
        // fields.push(
        //   <Col span={24 / cols} key={index}>
        //     <Form.Item label={item.label}>
        //       {getFieldDecorator(item.field, {
        //         initialValue: item.linkfield,
        //       })(<Input placeholder="" autoComplete="off" disabled={item.readonly === 'true'} />)}
        //     </Form.Item>
        //   </Col>
        // )
        // 函数变量字段,默认不显示
      } else if (item.type === 'textarea') {
        let _max = item.fieldlength || 512
        let _labelcol = cols !== 3 ? 8 / cols : 3
@@ -601,7 +620,9 @@
  }
  handleConfirm = () => {
    const { record } = this.state
    const { record, encrypts, intercepts } = this.state
    let _encrypts = JSON.parse(JSON.stringify(encrypts))
    // 表单提交时检查输入值是否正确
    return new Promise((resolve, reject) => {
      this.props.form.validateFieldsAndScroll((err, values) => {
@@ -624,7 +645,9 @@
              let _val = item.initval
              if (record.hasOwnProperty(item.field)) {
                _val = record[item.field]
                _encrypts = _encrypts.filter(_field => _field !== item.field)
              }
              search.push({
                type: this.state.datatype[item.field],
                readonly: this.state.readtype[item.field],
@@ -640,7 +663,7 @@
                readin: this.state.readin[item.field],
                fieldlen: this.state.fieldlen[item.field],
                key: item.field,
                value: item.initVal
                value: item.initval
              })
            }
          })
@@ -679,9 +702,12 @@
              }
              _value = vals.join(',')
            } else if (this.state.datatype[key] === 'text') {
              _value = values[key].replace(/(^\s*|\s*$) | \t* | \v*/ig, '')
            } else if (this.state.datatype[key] === 'text' || this.state.datatype[key] === 'textarea') {
              _value = values[key].replace(/\t*|\v*/g, '') // 去除制表符
              if (intercepts.includes(key)) {              // 去除首尾空格
                _value = _value.replace(/(^\s*|\s*$)/g, '')
              }
            } else {
              _value = values[key]
              
@@ -697,6 +723,22 @@
            })
          })
          if (_encrypts && _encrypts.length > 0) {
            search = search.map(item => {
              let _value = item.value
              if (_encrypts.includes(item.key)) {
                try {
                  _value = window.btoa(window.encodeURIComponent(_value))
                } catch (e) {
                  console.warn(e)
                }
              }
              item.value = _value
              return item
            })
          }
          resolve(search)
        } else {
          reject(err)