| | |
| | | |
| | | class ReplaceField extends Component { |
| | | static propTpyes = { |
| | | type: PropTypes.string, |
| | | config: PropTypes.object, |
| | | updateConfig: PropTypes.func |
| | | } |
| | |
| | | |
| | | // 依据原字段替换为新字段 |
| | | exec = (map) => { |
| | | const { type } = this.props |
| | | let config = fromJS(this.props.config).toJS() |
| | | |
| | | if (type === 'custom') { |
| | | let _replace = (components) => { |
| | | return components.map(item => { |
| | | if (item.type === 'tabs') { |
| | |
| | | } |
| | | |
| | | config.components = _replace(config.components) |
| | | // } else if (type === 'table') { |
| | | // config.columns = config.columns.map(col => { |
| | | // if (col.field && map[col.field.toLowerCase()]) { |
| | | // col.field = map[col.field.toLowerCase()].FieldName |
| | | // } |
| | | // return col |
| | | // }) |
| | | |
| | | // config.search = config.search.map(col => { |
| | | // if (col.field && map[col.field.toLowerCase()]) { |
| | | // col.field = map[col.field.toLowerCase()].FieldName |
| | | // } |
| | | // if (col.datefield && map[col.datefield.toLowerCase()]) { |
| | | // col.datefield = map[col.datefield.toLowerCase()].FieldName |
| | | // } |
| | | // return col |
| | | // }) |
| | | |
| | | // config.action = config.action.map(m => { |
| | | // if (m.verify && m.verify.columns) { |
| | | // m.verify.columns = m.verify.columns.map(col => { |
| | | // if (col.Column && map[col.Column.toLowerCase()]) { |
| | | // col.Column = map[col.Column.toLowerCase()].FieldName |
| | | // } |
| | | // return col |
| | | // }) |
| | | // } |
| | | // return m |
| | | // }) |
| | | } else if (type === 'form') { |
| | | config.fields = config.fields.map(col => { |
| | | if (col.field && map[col.field.toLowerCase()]) { |
| | | col.field = map[col.field.toLowerCase()].FieldName |
| | | config.interfaces && config.interfaces.forEach(item => { |
| | | if (item.columns) { |
| | | item.columns = item.columns.map(col => { |
| | | let cell = map[col.field.toLowerCase()] |
| | | if (cell) { |
| | | col.field = cell.FieldName |
| | | if (cell.datatype) { |
| | | col.datatype = cell.datatype |
| | | } |
| | | } |
| | | return col |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | this.setState({ |
| | | confirming: false, |
| | |
| | | |
| | | // 依据字段替换名称 |
| | | execLabel = (map) => { |
| | | const { type } = this.props |
| | | let config = fromJS(this.props.config).toJS() |
| | | |
| | | if (type === 'custom') { |
| | | let _replace = (components) => { |
| | | return components.map(item => { |
| | | if (item.type === 'tabs') { |
| | |
| | | } |
| | | |
| | | config.components = _replace(config.components) |
| | | // } else if (type === 'table') { |
| | | // config.columns = config.columns.map(col => { |
| | | // if (col.field && map[col.field.toLowerCase()]) { |
| | | // col.label = map[col.field.toLowerCase()].FieldDec |
| | | // } |
| | | // return col |
| | | // }) |
| | | |
| | | // config.search = config.search.map(col => { |
| | | // if (col.field && map[col.field.toLowerCase()]) { |
| | | // col.label = map[col.field.toLowerCase()].FieldDec |
| | | // } |
| | | // return col |
| | | // }) |
| | | |
| | | // config.action = config.action.map(m => { |
| | | // if (m.verify && m.verify.columns) { |
| | | // m.verify.columns = m.verify.columns.map(col => { |
| | | // if (col.Column && map[col.Column.toLowerCase()]) { |
| | | // col.Text = map[col.Column.toLowerCase()].FieldDec |
| | | // } |
| | | // return col |
| | | // }) |
| | | // } |
| | | // return m |
| | | // }) |
| | | } else if (type === 'form') { |
| | | config.fields = config.fields.map(col => { |
| | | config.interfaces && config.interfaces.forEach(item => { |
| | | if (item.columns) { |
| | | item.columns = item.columns.map(col => { |
| | | if (col.field && map[col.field.toLowerCase()]) { |
| | | col.label = map[col.field.toLowerCase()].FieldDec |
| | | } |
| | | return col |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | this.setState({ |
| | | confirming: false, |