| | |
| | | fieldMap.set(key, supItem) |
| | | }) |
| | | |
| | | let reFieldsVal = null |
| | | |
| | | formlist = formlist.map(cell => { |
| | | if (cell.labelwidth) { |
| | | cell.labelCol = {style: {width: cell.labelwidth + '%'}} |
| | |
| | | } |
| | | if (!cell.field || !fieldMap.has(cell.field)) return cell |
| | | let item = fieldMap.get(cell.field) |
| | | |
| | | // 下级表单控制-字段写入 |
| | | if ((['select', 'radio', 'link'].includes(item.type) || (item.type === 'checkcard' && item.multiple !== 'true')) && item.linkSubField) { |
| | | item.subFields = [] |
| | | item.linkSubField.forEach(m => { |
| | | let n = fieldMap.get(m) |
| | | if (n && ['text', 'number', 'textarea'].includes(n.type)) { |
| | | item.subFields.push({ |
| | | uuid: n.uuid, |
| | | field: m |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | if (item.subFields.length === 0) { |
| | | item.subFields = null |
| | | } else if (item.oriOptions.length > 0) { |
| | | item.oriOptions = item.oriOptions.map(cell => { |
| | | item.subFields.forEach(m => { |
| | | cell[m.field] = cell[m.field] === undefined ? '' : cell[m.field] |
| | | }) |
| | | return cell |
| | | }) |
| | | |
| | | item.options = fromJS(item.oriOptions).toJS() |
| | | } |
| | | item.linkSubField = null |
| | | } |
| | | |
| | | // if (item.type === 'link') { |
| | | if (item.linkField) { |
| | |
| | | if (linkFields[item.field]) { |
| | | item.linkFields = linkFields[item.field] |
| | | } |
| | | |
| | | // 下级表单控制-字段写入 |
| | | if ((['select', 'radio', 'link'].includes(item.type) || (item.type === 'checkcard' && item.multiple !== 'true')) && item.linkSubField) { |
| | | item.subFields = [] |
| | | item.linkSubField.forEach(m => { |
| | | let n = fieldMap.get(m) |
| | | if (n && ['text', 'number', 'textarea'].includes(n.type)) { |
| | | item.subFields.push({ |
| | | uuid: n.uuid, |
| | | field: m |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | if (item.subFields.length === 0) { |
| | | item.subFields = null |
| | | } else if (item.options.length > 0) { |
| | | item.options = item.options.map(cell => { |
| | | item.subFields.forEach(m => { |
| | | cell[m.field] = cell[m.field] === undefined ? '' : cell[m.field] |
| | | }) |
| | | return cell |
| | | }) |
| | | |
| | | item.oriOptions = fromJS(item.options).toJS() |
| | | } |
| | | item.linkSubField = null |
| | | } |
| | | |
| | | |
| | | if (item.enter === 'tab' || item.enter === 'sub') { |
| | | if (fieldMap.has(item.tabField)) { |
| | | item.tabUuid = fieldMap.get(item.tabField).uuid |
| | |
| | | item.tabUuid = item.uuid |
| | | } |
| | | } |
| | | |
| | | if (item.subFields && item.options.length > 0) { |
| | | // eslint-disable-next-line |
| | | let option = item.options.filter(cell => item.initval == cell.value)[0] |
| | | |
| | | if (option) { |
| | | reFieldsVal = reFieldsVal || {} |
| | | item.subFields.forEach(n => { |
| | | reFieldsVal[n.field] = option[n.field] |
| | | }) |
| | | } |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | | if (reFieldsVal) { |
| | | formlist = formlist.map(cell => { |
| | | if (reFieldsVal[cell.field] === undefined) return cell |
| | | |
| | | cell.initval = reFieldsVal[cell.field] |
| | | record[cell.field] = reFieldsVal[cell.field] |
| | | |
| | | return cell |
| | | }) |
| | | } |
| | | |
| | | this.record = record |
| | | |
| | |
| | | } |
| | | |
| | | resetFormList = (result) => { |
| | | let reFieldsVal = null |
| | | let _formlist = fromJS(this.state.formlist).toJS().map(item => { |
| | | if (['select', 'link', 'radio', 'checkbox', 'checkcard', 'multiselect'].includes(item.type) && result[item.field] && result[item.field].length > 0) { |
| | | let options = [] |
| | |
| | | } else { |
| | | item.options = item.oriOptions |
| | | } |
| | | } |
| | | |
| | | if (['select', 'link', 'radio'].includes(item.type) && typeof(item.initval) === 'string' && item.initval.indexOf('$first') > -1) { // 选中第一项 |
| | | item.initval = item.options[0] ? item.options[0].value : '' |
| | | this.record[item.field] = item.initval |
| | | if (['select', 'link', 'radio'].includes(item.type) && typeof(item.initval) === 'string' && item.initval.indexOf('$first') > -1) { // 选中第一项 |
| | | item.initval = item.options[0] ? item.options[0].value : '' |
| | | this.record[item.field] = item.initval |
| | | } |
| | | |
| | | if (item.subFields && item.options.length > 0) { |
| | | // eslint-disable-next-line |
| | | let option = item.options.filter(cell => item.initval == cell.value)[0] |
| | | |
| | | if (option) { |
| | | reFieldsVal = reFieldsVal || {} |
| | | item.subFields.forEach(n => { |
| | | reFieldsVal[n.field] = option[n.field] |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | | if (reFieldsVal) { |
| | | _formlist = _formlist.map((cell, i) => { |
| | | if (reFieldsVal[cell.field] === undefined) return cell |
| | | |
| | | cell.initval = reFieldsVal[cell.field] |
| | | this.record[cell.field] = reFieldsVal[cell.field] |
| | | |
| | | setTimeout(() => { |
| | | MKEmitter.emit('mkFC', 'input', cell.uuid, reFieldsVal[cell.field]) |
| | | }, i * 5) |
| | | |
| | | return cell |
| | | }) |
| | | } |
| | | |
| | | this.setState({ |
| | | formlist: _formlist |
| | | }) |