| | |
| | | readin: null, |
| | | fieldlen: null, |
| | | formlist: [], |
| | | encrypts: [], // 加密字段 |
| | | intercepts: [], // 截取字段 |
| | | record: {} |
| | | } |
| | | |
| | |
| | | let readin = {} |
| | | let fieldlen = {} |
| | | let formlist = [] |
| | | let encrypts = [] |
| | | let intercepts = [] |
| | | |
| | | if (action.groups.length > 0) { |
| | | action.groups.forEach(group => { |
| | |
| | | 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 |
| | |
| | | } |
| | | } |
| | | |
| | | 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) { |
| | |
| | | datatype: datatype, |
| | | readin: readin, |
| | | fieldlen: fieldlen, |
| | | encrypts: encrypts, |
| | | intercepts: intercepts, |
| | | formlist: formlist |
| | | }, () => { |
| | | if (action.setting && action.setting.focus) { |
| | |
| | | |
| | | 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') { |
| | |
| | | </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 |
| | |
| | | } |
| | | |
| | | 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) => { |
| | |
| | | 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], |
| | |
| | | readin: this.state.readin[item.field], |
| | | fieldlen: this.state.fieldlen[item.field], |
| | | key: item.field, |
| | | value: item.initVal |
| | | value: item.initval |
| | | }) |
| | | } |
| | | }) |
| | |
| | | } |
| | | |
| | | _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] |
| | | |
| | |
| | | }) |
| | | }) |
| | | |
| | | 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) |