| | |
| | | |
| | | class MainTab extends Component { |
| | | static propTpyes = { |
| | | tabs: PropTypes.array, // 类型 |
| | | type: PropTypes.string, // 类型 |
| | | dict: PropTypes.object, // 字典项 |
| | | formlist: PropTypes.any, // 表单 |
| | |
| | | } |
| | | |
| | | state = { |
| | | formlist: null // 表单 |
| | | formlist: null // 表单 |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | UNSAFE_componentWillMount () { |
| | | const { formlist } = this.props |
| | | |
| | | let type = formlist.filter(cell => cell.key === 'type')[0].initVal |
| | | console.log(type) |
| | | |
| | | let _initval = formlist.filter(cell => cell.key === 'linkTab')[0].initVal |
| | | |
| | | let _tabs = this.props.tabs.filter(tab => tab.type === type) |
| | | let initTab = _tabs.filter(tab => tab.uuid === _initval)[0] |
| | | console.log(_tabs) |
| | | this.setState({ |
| | | formlist: formlist |
| | | formlist: formlist.map(item => { |
| | | if (item.key === 'linkTab') { |
| | | item.options = [ |
| | | { |
| | | value: '', |
| | | text: '新建' |
| | | }, |
| | | ..._tabs |
| | | ] |
| | | if (!initTab) { |
| | | item.initVal = '' |
| | | } |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | }) |
| | | } |
| | | |
| | |
| | | * @description 标签页类型切换 |
| | | */ |
| | | openTypeChange = (key, value) => { |
| | | console.log(value) |
| | | // if (key === 'type') { |
| | | // console.log(value) |
| | | const { formlist } = this.state |
| | | |
| | | // this.setState({ |
| | | // formlist: this.state.formlist.map(form => { |
| | | // return form |
| | | // }) |
| | | // }, () => { |
| | | // this.setState({ |
| | | // formlist: this.state.formlist.map(form => { |
| | | // return form |
| | | // }) |
| | | // }) |
| | | // }) |
| | | // } |
| | | if (key === 'type') { |
| | | let _tabs = this.props.tabs.filter(tab => tab.type === value) |
| | | |
| | | this.setState({ |
| | | formlist: formlist.map(item => { |
| | | if (item.key === 'linkTab') { |
| | | item.options = [ |
| | | { |
| | | value: '', |
| | | text: '新建' |
| | | }, |
| | | ..._tabs |
| | | ] |
| | | item.initVal = '' |
| | | item.hidden = true |
| | | } |
| | | return item |
| | | }) |
| | | }, () => { |
| | | this.setState({ |
| | | formlist: this.state.formlist.map(item => { |
| | | if (item.key === 'linkTab') { |
| | | item.hidden = false |
| | | } |
| | | return item |
| | | }) |
| | | }) |
| | | }) |
| | | |
| | | console.log(value) |
| | | |
| | | this.setState({ |
| | | formlist: this.state.formlist.map(form => { |
| | | return form |
| | | }) |
| | | }, () => { |
| | | this.setState({ |
| | | formlist: this.state.formlist.map(form => { |
| | | return form |
| | | }) |
| | | }) |
| | | }) |
| | | } |
| | | } |
| | | |
| | | getFields() { |
| | |
| | | onChange={(value) => {this.openTypeChange(item.key, value)}} |
| | | > |
| | | {item.options.map((option, i) => |
| | | <Select.Option id={`${i}`} title={option.text} key={`${i}`} value={option.value}> |
| | | <Select.Option id={'mk' + i} title={option.text} key={'mk' + i} value={option.value}> |
| | | {item.key === 'icon' && i !== 0 ? <Icon type={option.text} /> : option.text} |
| | | </Select.Option> |
| | | )} |
| | |
| | | values.uuid = this.props.card.uuid |
| | | |
| | | if (!values.linkTab) { // 没有关联标签(新建时),创建新标签Id |
| | | values.linkId = Utils.getuuid() |
| | | values.linkTab = Utils.getuuid() |
| | | } |
| | | |
| | | resolve({ |